152
size_t MessageFetchSize(int number)
154
MessageReferenceCheck(number);
155
if (mail_list[number].m_pMessage)
157
return mail_list[number].m_nMessage;
148
165
// This function returns a reference to the message and the the
149
166
// reference count is increased to reflect that.
151
168
static int MessageAdd(char *pMessage)
160
172
bool bFound = false;
161
173
for (i = 0; i < mudstate.mail_db_top; i++)
163
175
pm = &mail_list[i];
164
if (pm->m_pMessage == NULL)
176
if (NULL == pm->m_pMessage)
173
186
mail_db_grow(i + 1);
176
189
pm = &mail_list[i];
177
pm->m_pMessage = StringClone(pMessage);
190
pm->m_nMessage = strlen(pMessage);
191
pm->m_pMessage = StringCloneLen(pMessage, pm->m_nMessage);
178
192
MessageReferenceInc(i);
450
468
char *aPattern = alloc_lbuf("get_folder_num_pat");
451
469
char *q = aPattern;
470
safe_chr(':', aPattern, &q);
456
*q++ = mux_toupper(*p);
474
safe_chr(mux_toupper(*p), aPattern, &q);
477
safe_chr(':', aPattern, &q);
461
479
size_t nPattern = q - aPattern;
463
int i = BMH_StringSearch(nPattern, aPattern, nFolders, aFolders);
482
bool bSucceeded = BMH_StringSearch(&i, nPattern, aPattern, nFolders, aFolders);
464
483
free_lbuf(aPattern);
467
486
p = aFolders + i + nPattern;
1396
buff[LBUF_SIZE-1] = '\0';
1397
strncpy(buff, MessageFetch(mp->number), LBUF_SIZE);
1398
if (buff[LBUF_SIZE-1] != '\0')
1400
STARTLOG(LOG_BUGS, "BUG", "MAIL");
1401
log_text(tprintf("do_mail_read: %s: Mail message %d truncated.", Name(player), mp->number));
1403
buff[LBUF_SIZE-1] = '\0';
1436
safe_str(MessageFetch(mp->number), buff, &bp);
1405
1439
notify(player, DASH_LINE);
1406
1440
status = status_string(mp);
1407
1441
names = make_namelist(player, mp->tolist);
1443
char szFromName[MBUF_SIZE];
1444
GetFromField(mp->from, szFromName);
1408
1446
char szSubjectBuffer[MBUF_SIZE];
1409
int iRealVisibleWidth;
1447
size_t iRealVisibleWidth;
1410
1448
ANSI_TruncateToField(mp->subject, sizeof(szSubjectBuffer),
1411
1449
szSubjectBuffer, 65, &iRealVisibleWidth, ANSI_ENDGOAL_NORMAL);
1412
notify(player, tprintf("%-3d From: %-*s At: %-25s %s\r\nFldr : %-2d Status: %s\r\nTo : %-65s\r\nSubject: %s",
1413
i, PLAYER_NAME_LIMIT - 6, Name(mp->from),
1451
notify(player, tprintf("%-3d From: %s At: %-25s %s\r\nFldr : %-2d Status: %s\r\nTo : %-65s\r\nSubject: %s",
1415
1454
(Connected(mp->from) &&
1416
1455
(!Hidden(mp->from) || See_Hidden(player))) ?
1472
1511
struct mail *mp;
1473
1512
struct mail_selector ms;
1474
1513
int i = 0, j = 0;
1475
int iRealVisibleWidth;
1514
size_t iRealVisibleWidth;
1476
1515
char szSubjectBuffer[MBUF_SIZE];
1481
notify(player, tprintf("-------------------- MAIL: %-25s ------------------", Name(target)));
1520
notify(player, tprintf("-------------------- MAIL: %-25s ------------------", Moniker(target)));
1482
1521
MailList ml(target);
1483
1522
for (mp = ml.FirstItem(); !ml.IsEnd(); mp = ml.NextItem())
1485
1524
if (mp->from == player)
1528
char szFromName[MBUF_SIZE];
1529
GetFromField(mp->from, szFromName);
1488
1531
ANSI_TruncateToField(mp->subject, sizeof(szSubjectBuffer),
1489
1532
szSubjectBuffer, 25, &iRealVisibleWidth, ANSI_ENDGOAL_NORMAL);
1490
size_t nSize = strlen(MessageFetch(mp->number));
1491
const char *pFromName = Name(mp->from);
1492
notify(player, tprintf("[%s] %-3d (%4d) From: %-*s Sub: %s",
1533
size_t nSize = MessageFetchSize(mp->number);
1534
notify(player, tprintf("[%s] %-3d (%4d) From: %s Sub: %s",
1493
1535
status_chars(mp),
1495
PLAYER_NAME_LIMIT - 6, pFromName,
1496
1538
szSubjectBuffer));
1516
1558
char *status = status_string(mp);
1517
1559
const char *str = MessageFetch(mp->number);
1561
char szFromName[MBUF_SIZE];
1562
GetFromField(mp->from, szFromName);
1518
1564
ANSI_TruncateToField(mp->subject, sizeof(szSubjectBuffer),
1519
1565
szSubjectBuffer, 65, &iRealVisibleWidth, ANSI_ENDGOAL_NORMAL);
1520
1567
notify(player, DASH_LINE);
1521
notify(player, tprintf("%-3d From: %-*s At: %-25s %s\r\nFldr : %-2d Status: %s\r\nSubject: %s",
1522
i, PLAYER_NAME_LIMIT - 6, Name(mp->from),
1568
notify(player, tprintf("%-3d From: %s At: %-25s %s\r\nFldr : %-2d Status: %s\r\nSubject: %s",
1524
1571
(Connected(mp->from) &&
1525
1572
(!Hidden(mp->from) || See_Hidden(player))) ?
1612
1659
if (mail_match(mp, ms, i))
1614
1661
time = mail_list_time(mp->time);
1615
size_t nSize = strlen(MessageFetch(mp->number));
1616
const char *pFromName = Name(mp->from);
1662
size_t nSize = MessageFetchSize(mp->number);
1664
char szFromName[MBUF_SIZE];
1665
GetFromField(mp->from, szFromName);
1619
1669
ANSI_TruncateToField(mp->subject, sizeof(szSubjectBuffer),
1620
1670
szSubjectBuffer, 25, &iRealVisibleWidth, ANSI_ENDGOAL_NORMAL);
1622
notify(player, tprintf("[%s] %-3d (%4d) From: %-*s Sub: %s",
1623
status_chars(mp), i, nSize, PLAYER_NAME_LIMIT - 6, pFromName, szSubjectBuffer));
1672
notify(player, tprintf("[%s] %-3d (%4d) From: %s Sub: %s",
1673
status_chars(mp), i, nSize, szFromName, szSubjectBuffer));
1627
notify(player, tprintf("[%s] %-3d (%4d) From: %-*s At: %s %s",
1628
status_chars(mp), i, nSize, PLAYER_NAME_LIMIT - 6, pFromName, time,
1677
notify(player, tprintf("[%s] %-3d (%4d) From: %s At: %s %s",
1678
status_chars(mp), i, nSize, szFromName, time,
1629
1679
((Connected(mp->from) && (!Hidden(mp->from) || See_Hidden(player))) ? "Conn" : " ")));
1631
1681
free_lbuf(time);
2209
notify(player, tprintf("MAIL: You sent your message to %s.", Name(target)));
2273
notify(player, tprintf("MAIL: You sent your message to %s.", Moniker(target)));
2212
notify(target, tprintf("MAIL: You have a new message from %s.", Name(player)));
2213
did_it(player, target, A_MAIL, NULL, 0, NULL, A_AMAIL, NULL, NOTHING);
2276
notify(target, tprintf("MAIL: You have a new message from %s.", Moniker(player)));
2277
did_it(player, target, A_MAIL, NULL, 0, NULL, A_AMAIL, 0, NULL, NOTHING);
2216
2280
static void do_mail_nuke(dbref player)
2259
2323
if (Wizard(target))
2261
notify(player, tprintf("Let %s clear their own @mail.", Name(target)));
2325
notify(player, tprintf("Let %s clear their own @mail.", Moniker(target)));
2264
2328
do_mail_clear(target, NULL);
2265
2329
do_mail_purge(target);
2266
notify(player, tprintf("Mail cleared for %s(#%d).", Name(target), target));
2330
notify(player, tprintf("Mail cleared for %s(#%d).", Moniker(target), target));
2269
2333
else if (string_prefix("sanity", action))
2271
int *ai = (int *)MEMALLOC(mudstate.mail_db_top * sizeof(int));
2338
ai = new int[mudstate.mail_db_top];
2347
notify(player, "Out of memory.");
2273
2351
memset(ai, 0, mudstate.mail_db_top * sizeof(int));
2275
2353
DO_WHOLE_DB(thing)
2304
2382
if (bGoodReference)
2306
2384
notify(player, tprintf("%s(#%d) has mail, but is not a player.",
2307
Name(mp->to), mp->to));
2385
Moniker(mp->to), mp->to));
2311
2389
notify(player, tprintf("%s(#%d) is not a player, but has mail which refers to a non-existent mailbag item.",
2312
Name(mp->to), mp->to));
2390
Moniker(mp->to), mp->to));
2315
2393
else if (!bGoodReference)
2317
notify(player, tprintf("%s(#%d) has mail which refers to a non-existent mailbag item.", Name(mp->to), mp->to));
2395
notify(player, tprintf("%s(#%d) has mail which refers to a non-existent mailbag item.", Moniker(mp->to), mp->to));
2430
2524
static void do_mail_stats(dbref player, char *name, int full)
2432
2526
dbref target, thing;
2433
int fc, fr, fu, tc, tr, tu, fchars, tchars, cchars, count;
2434
fc = fr = fu = tc = tr = tu = fchars = tchars = cchars = count = 0;
2527
int fc, fr, fu, tc, tr, tu, count;
2531
fc = fr = fu = tc = tr = tu = count = 0;
2436
2533
// Find player.
2908
static void load_mail_V6(FILE *fp)
2910
int mail_top = getref(fp);
2911
mail_db_grow(mail_top + 1);
2917
char *p = fgets(nbuf1, sizeof(nbuf1), fp);
2919
&& strncmp(nbuf1, "***", 3) != 0)
2921
struct mail *mp = NULL;
2924
mp = new struct mail;
2933
STARTLOG(LOG_BUGS, "BUG", "MAIL");
2934
log_text("Out of memory.");
2939
mp->to = mux_atol(nbuf1);
2940
mp->from = getref(fp);
2942
mp->number = getref(fp);
2943
MessageReferenceInc(mp->number);
2945
pBuffer = getstring_noalloc(fp, true, &nBuffer);
2946
pBuffer = (char *)convert_color((UTF8 *)pBuffer);
2947
pBuffer = ConvertToLatin((UTF8 *)pBuffer);
2948
nBuffer = strlen(pBuffer);
2949
mp->tolist = StringCloneLen(pBuffer, nBuffer);
2951
pBuffer = getstring_noalloc(fp, true, &nBuffer);
2952
pBuffer = (char *)convert_color((UTF8 *)pBuffer);
2953
pBuffer = ConvertToLatin((UTF8 *)pBuffer);
2954
nBuffer = strlen(pBuffer);
2955
mp->time = StringCloneLen(pBuffer, nBuffer);
2957
pBuffer = getstring_noalloc(fp, true, &nBuffer);
2958
pBuffer = (char *)convert_color((UTF8 *)pBuffer);
2959
pBuffer = ConvertToLatin((UTF8 *)pBuffer);
2960
nBuffer = strlen(pBuffer);
2961
mp->subject = StringCloneLen(pBuffer, nBuffer);
2963
mp->read = getref(fp);
2965
MailList ml(mp->to);
2968
p = fgets(nbuf1, sizeof(nbuf1), fp);
2971
p = fgets(nbuf1, sizeof(nbuf1), fp);
2973
&& strncmp(nbuf1, "+++", 3))
2975
int number = mux_atol(nbuf1);
2976
pBuffer = getstring_noalloc(fp, true, &nBuffer);
2977
pBuffer = (char *)convert_color((UTF8 *)pBuffer);
2978
pBuffer = ConvertToLatin((UTF8 *)pBuffer);
2979
nBuffer = strlen(pBuffer);
2980
new_mail_message(pBuffer, number);
2981
p = fgets(nbuf1, sizeof(nbuf1), fp);
2811
2985
static void load_mail_V5(FILE *fp)
2813
2987
int mail_top = getref(fp);
2814
2988
mail_db_grow(mail_top + 1);
2817
2993
char *p = fgets(nbuf1, sizeof(nbuf1), fp);
2818
while (p && strncmp(nbuf1, "***", 3) != 0)
2995
&& strncmp(nbuf1, "***", 3) != 0)
2820
struct mail *mp = (struct mail *)MEMALLOC(sizeof(struct mail));
2997
struct mail *mp = NULL;
3000
mp = new struct mail;
3009
STARTLOG(LOG_BUGS, "BUG", "MAIL");
3010
log_text("Out of memory.");
2823
3015
mp->to = mux_atol(nbuf1);
2824
3016
mp->from = getref(fp);
2826
3018
mp->number = getref(fp);
2827
3019
MessageReferenceInc(mp->number);
2828
mp->tolist = StringClone(getstring_noalloc(fp, true));
2830
mp->time = StringClone(getstring_noalloc(fp, true));
2831
mp->subject = StringClone(getstring_noalloc(fp, true));
3020
pBuffer = getstring_noalloc(fp, true, &nBuffer);
3021
mp->tolist = StringCloneLen(pBuffer, nBuffer);
3022
pBuffer = getstring_noalloc(fp, true, &nBuffer);
3023
mp->time = StringCloneLen(pBuffer, nBuffer);
3024
pBuffer = getstring_noalloc(fp, true, &nBuffer);
3025
mp->subject = StringCloneLen(pBuffer, nBuffer);
2832
3026
mp->read = getref(fp);
2834
3028
MailList ml(mp->to);
3427
malias_t *pt = NULL;
3439
notify(player, "MAIL: Out of memory.");
3174
3446
ma_size = MA_INC;
3175
malias = (struct malias **)MEMALLOC(sizeof(struct malias *) * ma_size);
3176
ISOUTOFMEMORY(malias);
3450
malias = new malias_t *[ma_size];
3459
notify(player, "MAIL: Out of memory.");
3178
3464
else if (ma_top >= ma_size)
3180
3466
ma_size += MA_INC;
3181
nm = (struct malias **)MEMALLOC(sizeof(struct malias *) * (ma_size));
3470
nm = new malias_t *[ma_size];
3479
notify(player, "MAIL: Out of memory.");
3184
3484
for (i = 0; i < ma_top; i++)
3186
3486
nm[i] = malias[i];
3191
malias[ma_top] = (struct malias *)MEMALLOC(sizeof(struct malias));
3192
ISOUTOFMEMORY(malias[ma_top]);
3493
malias[ma_top] = pt;
3195
3495
// Parse the player list.
3666
char *mailmsg = atr_get(player, A_MAILMSG, &aowner, &aflags);
3667
if (*mailmsg == '\0')
3966
char *pMailMsg = atr_get(player, A_MAILMSG, &aowner, &aflags);
3967
if (*pMailMsg == '\0')
3669
3969
notify(player, "MAIL: The body of this message is empty. Use - to add to the message.");
3673
3974
char *mailsub = atr_get(player, A_MAILSUB, &aowner, &aflags);
3674
3975
char *mailflags = atr_get(player, A_MAILFLAGS, &aowner, &aflags);
3675
mail_to_list(player, tolist, mailsub, mailmsg, flags | mux_atol(mailflags), false);
3976
mail_to_list(player, tolist, mailsub, pMailMsg, flags | mux_atol(mailflags), false);
3676
3977
free_lbuf(mailflags);
3677
3978
free_lbuf(mailsub);
3679
3980
Flags2(player) &= ~PLAYER_MAILS;
3982
free_lbuf(pMailMsg);
3843
char *mailto = atr_get(player, A_MAILTO, &aowner, &aflags);
3844
char *mailmsg = atr_get(player, A_MAILMSG, &aowner, &aflags);
3845
char *names = make_namelist(player, mailto);
4144
char *mailto = atr_get(player, A_MAILTO, &aowner, &aflags);
4145
char *pMailMsg = atr_get(player, A_MAILMSG, &aowner, &aflags);
4146
char *names = make_namelist(player, mailto);
3847
int iRealVisibleWidth;
4148
size_t iRealVisibleWidth;
3848
4149
char szSubjectBuffer[MBUF_SIZE];
3849
4150
ANSI_TruncateToField(atr_get_raw(player, A_MAILSUB),
3850
4151
sizeof(szSubjectBuffer), szSubjectBuffer, 35,
3851
4152
&iRealVisibleWidth, ANSI_ENDGOAL_NORMAL);
3853
notify(player, DASH_LINE);
3854
notify(player, tprintf("From: %-*s Subject: %s\nTo: %s",
3855
PLAYER_NAME_LIMIT - 6, Name(player), szSubjectBuffer, names));
3856
notify(player, DASH_LINE);
3857
notify(player, mailmsg);
3858
notify(player, DASH_LINE);
4154
char szFromName[MBUF_SIZE];
4155
GetFromField(player, szFromName);
4157
notify(player, DASH_LINE);
4158
notify(player, tprintf("From: %s Subject: %s\nTo: %s",
4159
szFromName, szSubjectBuffer, names));
4160
notify(player, DASH_LINE);
4161
notify(player, pMailMsg);
4162
notify(player, DASH_LINE);
4163
free_lbuf(pMailMsg);
3860
4164
free_lbuf(names);
3861
4165
free_lbuf(mailto);
3993
4297
m->list[m->numrecep] = thing;
3994
4298
m->numrecep = m->numrecep + 1;
3995
notify(player, tprintf("MAIL: %s added to %s", Name(thing), m->name));
4299
notify(player, tprintf("MAIL: %s added to %s", Moniker(thing), m->name));
3998
4302
static void do_malias_remove(dbref player, char *alias, char *person)
4001
struct malias *m = get_malias(player, alias, &nResult);
4305
malias_t *m = get_malias(player, alias, &nResult);
4002
4306
if (nResult == GMA_NOTFOUND)
4004
4308
notify(player, tprintf("MAIL: Alias '%s' not found.", alias));
4049
4353
notify(player, tprintf("MAIL: %s removed from alias %s.",
4050
Name(thing), alias));
4354
Moniker(thing), alias));
4054
4358
notify(player, tprintf("MAIL: %s is not a member of alias %s.",
4055
Name(thing), alias));
4359
Moniker(thing), alias));
4059
4363
static void do_malias_rename(dbref player, char *alias, char *newname)
4062
struct malias *m = get_malias(player, newname, &nResult);
4366
malias_t *m = get_malias(player, newname, &nResult);
4063
4367
if (nResult == GMA_FOUND)
4065
4369
notify(player, "MAIL: That name already exists!");