mux/src/mail.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include <sys/types.h>
#include "attrs.h"
#include "command.h"
#include "powers.h"
#include "mail.h"

Include dependency graph for mail.cpp:

Go to the source code of this file.

Data Structures

struct  malias
struct  tag_mailstatusentry

Defines

#define SIZEOF_MALIAS   13
#define WIDTHOF_MALIASDESC   40
#define SIZEOF_MALIASDESC   (WIDTHOF_MALIASDESC*2)
#define MAX_MALIAS_MEMBERSHIP   100
#define MAIL_FUDGE   1
#define MAIL_INVALID_RANGE   0
#define MAIL_INVALID_NUMBER   1
#define MAIL_INVALID_AGE   2
#define MAIL_INVALID_DBREF   3
#define MAIL_INVALID_PLAYER   4
#define MAIL_INVALID_SPEC   5
#define MAIL_INVALID_PLAYER_OR_USING_MALIAS   6
#define GMA_NOTFOUND   1
#define GMA_FOUND   2
#define GMA_INVALIDFORM   3
#define NUM_MAILSTATUSTABLE   7

Functions

static void mail_db_grow (int newtop)
static DCL_INLINE void MessageReferenceInc (int number)
static void MessageReferenceCheck (int number)
static void MessageReferenceDec (int number)
static const char * MessageFetch (int number)
static int MessageAdd (char *pMessage)
static int add_mail_message (dbref player, char *message)
static bool MessageAddWithNumber (int i, char *pMessage)
static void new_mail_message (char *message, int number)
static void set_player_folder (dbref player, int fnum)
static void add_folder_name (dbref player, int fld, char *name)
static char * get_folder_name (dbref player, int fld)
static int get_folder_number (dbref player, char *name)
static int parse_folder (dbref player, char *folder_string)
static bool parse_msglist (char *msglist, struct mail_selector *ms, dbref player)
static int player_folder (dbref player)
static void do_mail_change_folder (dbref player, char *fld, char *newname)
static int sign (int x)
static bool mail_match (struct mail *mp, struct mail_selector ms, int num)
static void do_mail_flags (dbref player, char *msglist, mail_flag flag, bool negate)
static void do_mail_tag (dbref player, char *msglist)
static void do_mail_safe (dbref player, char *msglist)
void do_mail_clear (dbref player, char *msglist)
static void do_mail_untag (dbref player, char *msglist)
static void do_mail_unclear (dbref player, char *msglist)
static void do_mail_file (dbref player, char *msglist, char *folder)
static char * MakeCanonicalMailAlias (char *pMailAlias, int *pnValidMailAlias, bool *pbValidMailAlias)
static struct maliasget_malias (dbref player, char *alias, int *pnResult)
static char * make_namelist (dbref player, char *arg)
static char * status_string (struct mail *mp)
static void do_mail_read (dbref player, char *msglist)
static char * status_chars (struct mail *mp)
static void do_mail_review (dbref player, char *name, char *msglist)
static char * mail_list_time (const char *the_time)
static void do_mail_list (dbref player, char *msglist, bool sub)
void do_mail_purge (dbref player)
static char * make_numlist (dbref player, char *arg, bool bBlind)
static void do_expmail_start (dbref player, char *arg, char *subject)
static void do_mail_fwd (dbref player, char *msg, char *tolist)
static void do_mail_reply (dbref player, char *msg, bool all, int key)
mailmail_fetch (dbref player, int num)
const char * mail_fetch_message (dbref player, int num)
int mail_fetch_from (dbref player, int num)
void count_mail (dbref player, int folder, int *rcount, int *ucount, int *ccount)
static void urgent_mail (dbref player, int folder, int *ucount)
static void mail_return (dbref player, dbref target)
static bool mail_check (dbref player, dbref target)
static void send_mail (dbref player, dbref target, const char *tolist, const char *subject, int number, mail_flag flags, bool silent)
static void do_mail_nuke (dbref player)
static void do_mail_debug (dbref player, char *action, char *victim)
static void do_mail_stats (dbref player, char *name, int full)
static void do_mail_stub (dbref player, char *arg1, char *arg2)
static void malias_write (FILE *fp)
static void save_malias (FILE *fp)
int dump_mail (FILE *fp)
static void load_mail_V5 (FILE *fp)
static char * MakeCanonicalMailAliasDesc (char *pMailAliasDesc, int *pnValidMailAliasDesc, bool *pbValidMailAliasDesc, int *pnVisualWidth)
static void malias_read (FILE *fp)
static void load_malias (FILE *fp)
void load_mail (FILE *fp)
void check_mail_expiration (void)
void check_mail (dbref player, int folder, bool silent)
static void do_malias_send (dbref player, char *tolist, char *listto, char *subject, int number, mail_flag flags, bool silent)
static void do_malias_create (dbref player, char *alias, char *tolist)
static void do_malias_list (dbref player, char *alias)
static char * Spaces (unsigned int n)
static void do_malias_list_all (dbref player)
static void do_malias_switch (dbref player, char *a1, char *a2)
static void do_mail_cc (dbref player, char *arg, bool bBlind)
static void mail_to_list (dbref player, char *list, char *subject, char *message, int flags, bool silent)
static void do_mail_quick (dbref player, char *arg1, char *arg2)
static void do_expmail_stop (dbref player, int flags)
static void do_expmail_abort (dbref player)
void do_prepend (dbref executor, dbref caller, dbref enactor, int key, char *text)
void do_postpend (dbref executor, dbref caller, dbref enactor, int key, char *text)
static void do_edit_msg (dbref player, char *from, char *to)
static void do_mail_proof (dbref player)
static void do_malias_desc (dbref player, char *alias, char *desc)
static void do_malias_chown (dbref player, char *alias, char *owner)
static void do_malias_add (dbref player, char *alias, char *person)
static void do_malias_remove (dbref player, char *alias, char *person)
static void do_malias_rename (dbref player, char *alias, char *newname)
static void do_malias_delete (dbref player, char *alias)
static void do_malias_adminlist (dbref player)
static void do_malias_status (dbref player)
static void malias_cleanup1 (struct malias *m, dbref target)
void malias_cleanup (dbref player)
static void do_mail_retract1 (dbref player, char *name, char *msglist)
static void do_mail_retract (dbref player, char *name, char *msglist)
void do_malias (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *arg1, char *arg2)
void do_mail (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *arg1, char *arg2)

Variables

static int ma_size = 0
static int ma_top = 0
static struct malias ** malias = NULL
static MAILBODYmail_list = NULL
static char * mailmsg []
static struct tag_mailstatusentry aMailStatusTable [NUM_MAILSTATUSTABLE]


Define Documentation

#define GMA_FOUND   2

Definition at line 1203 of file mail.cpp.

Referenced by do_mail_retract(), do_malias_add(), do_malias_chown(), do_malias_create(), do_malias_delete(), do_malias_desc(), do_malias_list(), do_malias_remove(), do_malias_rename(), and get_malias().

#define GMA_INVALIDFORM   3

Definition at line 1204 of file mail.cpp.

Referenced by do_malias_create(), do_malias_send(), get_malias(), and make_numlist().

#define GMA_NOTFOUND   1

Definition at line 1202 of file mail.cpp.

Referenced by do_mail_retract(), do_malias_add(), do_malias_chown(), do_malias_delete(), do_malias_desc(), do_malias_list(), do_malias_remove(), do_malias_rename(), do_malias_send(), get_malias(), and make_numlist().

#define MAIL_FUDGE   1

Definition at line 50 of file mail.cpp.

Referenced by mail_db_grow().

#define MAIL_INVALID_AGE   2

Definition at line 514 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_DBREF   3

Definition at line 515 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_NUMBER   1

Definition at line 513 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_PLAYER   4

Definition at line 516 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_PLAYER_OR_USING_MALIAS   6

Definition at line 518 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_RANGE   0

Definition at line 512 of file mail.cpp.

Referenced by parse_msglist().

#define MAIL_INVALID_SPEC   5

Definition at line 517 of file mail.cpp.

Referenced by parse_msglist().

#define MAX_MALIAS_MEMBERSHIP   100

Definition at line 26 of file mail.cpp.

Referenced by do_malias_create(), and malias_read().

#define NUM_MAILSTATUSTABLE   7

Definition at line 1325 of file mail.cpp.

Referenced by status_string().

#define SIZEOF_MALIAS   13

Definition at line 22 of file mail.cpp.

Referenced by MakeCanonicalMailAlias().

#define SIZEOF_MALIASDESC   (WIDTHOF_MALIASDESC*2)

Definition at line 24 of file mail.cpp.

Referenced by MakeCanonicalMailAliasDesc().

#define WIDTHOF_MALIASDESC   40

Definition at line 23 of file mail.cpp.

Referenced by MakeCanonicalMailAliasDesc().


Function Documentation

static void add_folder_name ( dbref  player,
int  fld,
char *  name 
) [static]

Definition at line 286 of file mail.cpp.

References A_MAILFOLDERS, AF_LOCK, AF_MDARK, AF_NOPROG, AF_WIZARD, alloc_lbuf, atr_add(), atr_get_str_LEN(), BMH_Execute(), BMH_Prepare(), free_lbuf, LBUF_SIZE, mux_isspace, mux_ltoa(), and mux_toupper.

Referenced by do_mail_change_folder().

00287 {
00288     // Fetch current list of folders
00289     //
00290     int aflags;
00291     size_t nFolders;
00292     dbref aowner;
00293     char *aFolders = alloc_lbuf("add_folder_name.str");
00294     atr_get_str_LEN(aFolders, player, A_MAILFOLDERS, &aowner, &aflags,
00295         &nFolders);
00296 
00297     // Build new record ("%d:%s:%d", fld, uppercase(name), fld);
00298     //
00299     char *aNew = alloc_lbuf("add_folder_name.new");
00300     char *q = aNew;
00301     q += mux_ltoa(fld, q);
00302     *q++ = ':';
00303     char *p = name;
00304     while (*p)
00305     {
00306         *q++ = mux_toupper(*p);
00307         p++;
00308     }
00309     *q++ = ':';
00310     q += mux_ltoa(fld, q);
00311     *q = '\0';
00312     size_t nNew = q - aNew;
00313 
00314     if (nFolders != 0)
00315     {
00316         // Build pattern ("%d:", fld)
00317         //
00318         char *aPattern = alloc_lbuf("add_folder_name.pat");
00319         q = aPattern;
00320         q += mux_ltoa(fld, q);
00321         *q++ = ':';
00322         *q = '\0';
00323         size_t nPattern = q - aPattern;
00324 
00325         BMH_State bmhs;
00326         BMH_Prepare(&bmhs, nPattern, aPattern);
00327         for (;;)
00328         {
00329             int i = BMH_Execute(&bmhs, nPattern, aPattern, nFolders, aFolders);
00330             if (i < 0)
00331             {
00332                 break;
00333             }
00334 
00335             // Remove old record.
00336             //
00337             q = aFolders + i;
00338             p = q + nPattern;
00339 
00340             // Eat leading spaces.
00341             //
00342             while (  aFolders < q
00343                   && mux_isspace(q[-1]))
00344             {
00345                 q--;
00346             }
00347 
00348             // Skip past old record and trailing spaces.
00349             //
00350             while (  *p
00351                   && *p != ':')
00352             {
00353                 p++;
00354             }
00355             while (  *p
00356                   && !mux_isspace(*p))
00357             {
00358                 p++;
00359             }
00360             while (mux_isspace(*p))
00361             {
00362                 p++;
00363             }
00364 
00365             if (q != aFolders)
00366             {
00367                 *q++ = ' ';
00368             }
00369             while (*p)
00370             {
00371                 *q++ = *p++;
00372             }
00373             *q = '\0';
00374             nFolders = q - aFolders;
00375         }
00376         free_lbuf(aPattern);
00377     }
00378     if (nFolders + 1 + nNew < LBUF_SIZE)
00379     {
00380         // It will fit. Append new record.
00381         //
00382         q = aFolders + nFolders;
00383         if (nFolders)
00384         {
00385             *q++ = ' ';
00386         }
00387         memcpy(q, aNew, nNew);
00388         q += nNew;
00389         *q = '\0';
00390 
00391         atr_add(player, A_MAILFOLDERS, aFolders, player,
00392             AF_MDARK | AF_WIZARD | AF_NOPROG | AF_LOCK);
00393     }
00394     free_lbuf(aFolders);
00395     free_lbuf(aNew);
00396 }

static int add_mail_message ( dbref  player,
char *  message 
) [static]

Definition at line 188 of file mail.cpp.

References A_SIGNATURE, alloc_lbuf, atr_get, EV_EVAL, EV_FCHECK, EV_STRIP_CURLY, free_lbuf, MessageAdd(), mux_exec(), mux_stricmp(), NOTHING, notify, and tprintf().

Referenced by do_malias_send(), and mail_to_list().

00189 {
00190     if (!mux_stricmp(message, "clear"))
00191     {
00192         notify(player, "MAIL: You probably did not intend to send a @mail saying 'clear'.");
00193         return NOTHING;
00194     }
00195 
00196     // Evaluate signature.
00197     //
00198     int   aflags;
00199     dbref aowner;
00200     char *bp = alloc_lbuf("add_mail_message");
00201     char *atrstr = atr_get(player, A_SIGNATURE, &aowner, &aflags);
00202     char *execstr = bp;
00203     char *str = atrstr;
00204     mux_exec(execstr, &bp, player, player, player,
00205              EV_STRIP_CURLY | EV_FCHECK | EV_EVAL, &str, (char **)NULL, 0);
00206     *bp = '\0';
00207 
00208     // Save message body and return a reference to it.
00209     //
00210     int number = MessageAdd(tprintf("%s %s", message, execstr));
00211     free_lbuf(atrstr);
00212     free_lbuf(execstr);
00213     return number;
00214 }

void check_mail ( dbref  player,
int  folder,
bool  silent 
)

Definition at line 3070 of file mail.cpp.

References count_mail(), get_folder_name(), notify, tprintf(), and urgent_mail().

Referenced by announce_connect(), and do_mail_change_folder().

03071 {
03072     // Check for new @mail
03073     //
03074     int rc;     // Read messages.
03075     int uc;     // Unread messages.
03076     int cc;     // Cleared messages.
03077     int gc;     // urgent messages.
03078 
03079     // Just count messages
03080     //
03081     count_mail(player, folder, &rc, &uc, &cc);
03082     urgent_mail(player, folder, &gc);
03083 #ifdef MAIL_ALL_FOLDERS
03084     notify(player,
03085            tprintf("MAIL: %d messages in folder %d [%s] (%d unread, %d cleared).\r\n",
03086                rc + uc, folder, get_folder_name(player, folder), uc, cc));
03087 #else // MAIL_ALL_FOLDERS
03088     if (rc + uc > 0)
03089     {
03090         notify(player, tprintf("MAIL: %d messages in folder %d [%s] (%d unread, %d cleared).", rc + uc, folder, get_folder_name(player, folder), uc, cc));
03091     }
03092     else if (!silent)
03093     {
03094         notify(player, tprintf("\r\nMAIL: You have no mail.\r\n"));
03095     }
03096     if (gc > 0)
03097     {
03098         notify(player, tprintf("URGENT MAIL: You have %d urgent messages in folder %d [%s].", gc, folder, get_folder_name(player, folder)));
03099     }
03100 #endif // MAIL_ALL_FOLDERS
03101 }

void check_mail_expiration ( void   ) 

Definition at line 3024 of file mail.cpp.

References DO_WHOLE_DB, MailList::FirstItem(), CLinearTimeAbsolute::GetLocal(), MailList::IsEnd(), M_Safe, confdata::mail_expiration, mudconf, MailList::NextItem(), MailList::RemoveItem(), CLinearTimeDelta::ReturnSeconds(), and CLinearTimeAbsolute::SetString().

Referenced by fork_and_dump().

03025 {
03026     // Negative values for expirations never expire.
03027     //
03028     if (0 > mudconf.mail_expiration)
03029     {
03030         return;
03031     }
03032 
03033     dbref thing;
03034     int expire_secs = mudconf.mail_expiration * 86400;
03035 
03036     CLinearTimeAbsolute ltaNow;
03037     ltaNow.GetLocal();
03038 
03039     CLinearTimeAbsolute ltaMail;
03040     DO_WHOLE_DB(thing)
03041     {
03042         MailList ml(thing);
03043         struct mail *mp;
03044         for (mp = ml.FirstItem(); !ml.IsEnd(); mp = ml.NextItem())
03045         {
03046             if (M_Safe(mp))
03047             {
03048                 continue;
03049             }
03050 
03051             const char *pMailTimeStr = mp->time;
03052             if (!ltaMail.SetString(pMailTimeStr))
03053             {
03054                 continue;
03055             }
03056 
03057             CLinearTimeDelta ltd(ltaMail, ltaNow);
03058             if (ltd.ReturnSeconds() <= expire_secs)
03059             {
03060                 continue;
03061             }
03062 
03063             // Delete this one.
03064             //
03065             ml.RemoveItem();
03066         }
03067     }
03068 }

void count_mail ( dbref  player,
int  folder,
int *  rcount,
int *  ucount,
int *  ccount 
)

Definition at line 2017 of file mail.cpp.

References Cleared, MailList::FirstItem(), Folder, MailList::IsEnd(), MailList::NextItem(), and Read.

Referenced by check_mail(), and FUNCTION().

02018 {
02019     int rc = 0;
02020     int uc = 0;
02021     int cc = 0;
02022 
02023     MailList ml(player);
02024     struct mail *mp;
02025     for (mp = ml.FirstItem(); !ml.IsEnd(); mp = ml.NextItem())
02026     {
02027         if (Folder(mp) == folder)
02028         {
02029             if (Read(mp))
02030             {
02031                 rc++;
02032             }
02033             else
02034             {
02035                 uc++;
02036             }
02037 
02038             if (Cleared(mp))
02039             {
02040                 cc++;
02041             }
02042         }
02043     }
02044     *rcount = rc;
02045     *ucount = uc;
02046     *ccount = cc;
02047 }

static void do_edit_msg ( dbref  player,
char *  from,
char *  to 
) [static]

Definition at line 3814 of file mail.cpp.

References A_MAILMSG, atr_add(), atr_get, Flags2, free_lbuf, msg, notify, PLAYER_MAILS, and replace_string().

Referenced by do_mail().

03815 {
03816     if (Flags2(player) & PLAYER_MAILS)
03817     {
03818         dbref aowner;
03819         int aflags;
03820         char *msg = atr_get(player, A_MAILMSG, &aowner, &aflags);
03821         char *result = replace_string(from, to, msg);
03822         atr_add(player, A_MAILMSG, result, aowner, aflags);
03823         notify(player, "Text edited.");
03824         free_lbuf(result);
03825         free_lbuf(msg);
03826     }
03827     else
03828     {
03829         notify(player, "MAIL: No message in progress.");
03830     }
03831 }

static void do_expmail_abort ( dbref  player  )  [static]

Definition at line 3686 of file mail.cpp.

References Flags2, notify, and PLAYER_MAILS.

Referenced by do_mail().

03687 {
03688     Flags2(player) &= ~PLAYER_MAILS;
03689     notify(player, "MAIL: Message aborted.");
03690 }

static void do_expmail_start ( dbref  player,
char *  arg,
char *  subject 
) [static]

Definition at line 1776 of file mail.cpp.

References A_MAILFLAGS, A_MAILMSG, A_MAILSUB, A_MAILTO, atr_add_raw(), atr_clr(), Flags2, free_lbuf, make_namelist(), make_numlist(), notify, PLAYER_MAILS, ThrottleMail(), tprintf(), and Wizard.

Referenced by do_mail_fwd(), do_mail_reply(), and do_mail_stub().

01777 {
01778     if (!arg || !*arg)
01779     {
01780         notify(player, "MAIL: I do not know whom you want to mail.");
01781         return;
01782     }
01783     if (!subject || !*subject)
01784     {
01785         notify(player, "MAIL: No subject.");
01786         return;
01787     }
01788     if (Flags2(player) & PLAYER_MAILS)
01789     {
01790         notify(player, "MAIL: Mail message already in progress.");
01791         return;
01792     }
01793     if (  !Wizard(player)
01794        && ThrottleMail(player))
01795     {
01796         notify(player, "MAIL: Too much @mail sent recently.");
01797         return;
01798     }
01799     char *tolist = make_numlist(player, arg, false);
01800     if (!tolist)
01801     {
01802         return;
01803     }
01804 
01805     atr_add_raw(player, A_MAILTO, tolist);
01806     atr_add_raw(player, A_MAILSUB, subject);
01807     atr_add_raw(player, A_MAILFLAGS, "0");
01808     atr_clr(player, A_MAILMSG);
01809     Flags2(player) |= PLAYER_MAILS;
01810     char *names = make_namelist(player, tolist);
01811     notify(player, tprintf("MAIL: You are sending mail to '%s'.", names));
01812     free_lbuf(names);
01813     free_lbuf(tolist);
01814 }

static void do_expmail_stop ( dbref  player,
int  flags 
) [static]

Definition at line 3648 of file mail.cpp.

References A_MAILFLAGS, A_MAILMSG, A_MAILSUB, A_MAILTO, atr_get, Flags2, free_lbuf, mail_to_list(), mux_atol(), notify, and PLAYER_MAILS.

Referenced by do_mail(), and do_postpend().

03649 {
03650     if ((Flags2(player) & PLAYER_MAILS) != PLAYER_MAILS)
03651     {
03652         notify(player, "MAIL: No message started.");
03653         return;
03654     }
03655 
03656     dbref aowner;
03657     dbref aflags;
03658     char *tolist = atr_get(player, A_MAILTO, & aowner, &aflags);
03659     if (*tolist == '\0')
03660     {
03661         notify(player, "MAIL: No recipients.");
03662         free_lbuf(tolist);
03663     }
03664     else
03665     {
03666         char *mailmsg = atr_get(player, A_MAILMSG, &aowner, &aflags);
03667         if (*mailmsg == '\0')
03668         {
03669             notify(player, "MAIL: The body of this message is empty.  Use - to add to the message.");
03670             free_lbuf(tolist);
03671         }
03672         else
03673         {
03674             char *mailsub   = atr_get(player, A_MAILSUB, &aowner, &aflags);
03675             char *mailflags = atr_get(player, A_MAILFLAGS, &aowner, &aflags);
03676             mail_to_list(player, tolist, mailsub, mailmsg, flags | mux_atol(mailflags), false);
03677             free_lbuf(mailflags);
03678             free_lbuf(mailsub);
03679 
03680             Flags2(player) &= ~PLAYER_MAILS;
03681         }
03682         free_lbuf(mailmsg);
03683     }
03684 }

void do_mail ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  arg1,
char *  arg2 
)

Definition at line 4344 of file mail.cpp.

References do_edit_msg(), do_expmail_abort(), do_expmail_stop(), do_mail_cc(), do_mail_change_folder(), do_mail_clear(), do_mail_debug(), do_mail_file(), do_mail_fwd(), do_mail_list(), do_mail_nuke(), do_mail_proof(), do_mail_purge(), do_mail_quick(), do_mail_read(), do_mail_reply(), do_mail_retract(), do_mail_review(), do_mail_safe(), do_mail_stats(), do_mail_stub(), do_mail_tag(), do_mail_unclear(), do_mail_untag(), do_malias_create(), do_malias_list_all(), confdata::have_mailer, isPlayer, M_URGENT, MAIL_ABORT, MAIL_ALIAS, MAIL_ALIST, MAIL_BCC, MAIL_CC, MAIL_CLEAR, MAIL_DEBUG, MAIL_DSTATS, MAIL_EDIT, MAIL_FILE, MAIL_FOLDER, MAIL_FORWARD, MAIL_FSTATS, MAIL_LIST, MAIL_NUKE, MAIL_PROOF, MAIL_PURGE, MAIL_QUICK, MAIL_QUOTE, MAIL_READ, MAIL_REPLY, MAIL_REPLYALL, MAIL_RETRACT, MAIL_REVIEW, MAIL_SAFE, MAIL_SEND, MAIL_STATS, MAIL_TAG, MAIL_UNCLEAR, MAIL_UNTAG, MAIL_URGENT, mudconf, notify, and UNUSED_PARAMETER.

04353 {
04354     UNUSED_PARAMETER(caller);
04355     UNUSED_PARAMETER(enactor);
04356     UNUSED_PARAMETER(nargs);
04357 
04358     if (!mudconf.have_mailer)
04359     {
04360         notify(executor, "Mailer is disabled.");
04361         return;
04362     }
04363 
04364     // HACK: Fix to allow @mail/quick from objects.
04365     //
04366     if (  (key & ~MAIL_QUOTE) != MAIL_QUICK
04367        && !isPlayer(executor))
04368     {
04369         return;
04370     }
04371 
04372     switch (key & ~MAIL_QUOTE)
04373     {
04374     case 0:
04375         do_mail_stub(executor, arg1, arg2);
04376         break;
04377     case MAIL_STATS:
04378         do_mail_stats(executor, arg1, 0);
04379         break;
04380     case MAIL_DSTATS:
04381         do_mail_stats(executor, arg1, 1);
04382         break;
04383     case MAIL_FSTATS:
04384         do_mail_stats(executor, arg1, 2);
04385         break;
04386     case MAIL_DEBUG:
04387         do_mail_debug(executor, arg1, arg2);
04388         break;
04389     case MAIL_NUKE:
04390         do_mail_nuke(executor);
04391         break;
04392     case MAIL_FOLDER:
04393         do_mail_change_folder(executor, arg1, arg2);
04394         break;
04395     case MAIL_LIST:
04396         do_mail_list(executor, arg1, false);
04397         break;
04398     case MAIL_READ:
04399         do_mail_read(executor, arg1);
04400         break;
04401     case MAIL_CLEAR:
04402         do_mail_clear(executor, arg1);
04403         break;
04404     case MAIL_UNCLEAR:
04405         do_mail_unclear(executor, arg1);
04406         break;
04407     case MAIL_PURGE:
04408         do_mail_purge(executor);
04409         break;
04410     case MAIL_FILE:
04411         do_mail_file(executor, arg1, arg2);
04412         break;
04413     case MAIL_TAG:
04414         do_mail_tag(executor, arg1);
04415         break;
04416     case MAIL_UNTAG:
04417         do_mail_untag(executor, arg1);
04418         break;
04419     case MAIL_FORWARD:
04420         do_mail_fwd(executor, arg1, arg2);
04421         break;
04422     case MAIL_REPLY:
04423         do_mail_reply(executor, arg1, false, key);
04424         break;
04425     case MAIL_REPLYALL:
04426         do_mail_reply(executor, arg1, true, key);
04427         break;
04428     case MAIL_SEND:
04429         do_expmail_stop(executor, 0);
04430         break;
04431     case MAIL_EDIT:
04432         do_edit_msg(executor, arg1, arg2);
04433         break;
04434     case MAIL_URGENT:
04435         do_expmail_stop(executor, M_URGENT);
04436         break;
04437     case MAIL_ALIAS:
04438         do_malias_create(executor, arg1, arg2);
04439         break;
04440     case MAIL_ALIST:
04441         do_malias_list_all(executor);
04442         break;
04443     case MAIL_PROOF:
04444         do_mail_proof(executor);
04445         break;
04446     case MAIL_ABORT:
04447         do_expmail_abort(executor);
04448         break;
04449     case MAIL_QUICK:
04450         do_mail_quick(executor, arg1, arg2);
04451         break;
04452     case MAIL_REVIEW:
04453         do_mail_review(executor, arg1, arg2);
04454         break;
04455     case MAIL_RETRACT:
04456         do_mail_retract(executor, arg1, arg2);
04457         break;
04458     case MAIL_CC:
04459         do_mail_cc(executor, arg1, false);
04460         break;
04461     case MAIL_SAFE:
04462         do_mail_safe(executor, arg1);
04463         break;
04464     case MAIL_BCC:
04465         do_mail_cc(executor, arg1, true);
04466         break;
04467     }
04468 }

static void do_mail_cc ( dbref  player,
char *  arg,
bool  bBlind 
) [static]

Definition at line 3426 of file mail.cpp.

References A_MAILTO, alloc_lbuf, atr_add_raw(), atr_get_raw(), Flags2, free_lbuf, make_namelist(), make_numlist(), notify, PLAYER_MAILS, safe_chr, safe_str, and tprintf().

Referenced by do_mail().

03427 {
03428     if (!(Flags2(player) & PLAYER_MAILS))
03429     {
03430         notify(player, "MAIL: No mail message in progress.");
03431         return;
03432     }
03433     if (!arg || !*arg)
03434     {
03435         notify(player, "MAIL: I do not know whom you want to mail.");
03436         return;
03437     }
03438 
03439     char *tolist = make_numlist(player, arg, bBlind);
03440     if (!tolist)
03441     {
03442         return;
03443     }
03444     char *fulllist = alloc_lbuf("do_mail_cc");
03445     char *bp = fulllist;
03446 
03447     safe_str(tolist, fulllist, &bp);
03448     const char *pPlayerMailTo = atr_get_raw(player, A_MAILTO);
03449     if (pPlayerMailTo)
03450     {
03451         safe_chr(' ', fulllist, &bp);
03452         safe_str(pPlayerMailTo, fulllist, &bp);
03453     }
03454     *bp = '\0';
03455 
03456     atr_add_raw(player, A_MAILTO, fulllist);
03457     char *names = make_namelist(player, fulllist);
03458     notify(player, tprintf("MAIL: You are sending mail to '%s'.", names));
03459     free_lbuf(names);
03460     free_lbuf(tolist);
03461     free_lbuf(fulllist);
03462 }

static void do_mail_change_folder ( dbref  player,
char *  fld,
char *  newname