MCPcopy Index your code
hub / github.com/NetHack/NetHack / readmail

Function readmail

src/mail.c:486–541  ·  view source on GitHub ↗

ARGSUSED*/

Source from the content-addressed store, hash-verified

484
485/*ARGSUSED*/
486void
487readmail(struct obj *otmp UNUSED)
488{
489 int i;
490 enum delivery_types delivery = normal_delivery;
491 const char *recipient = 0;
492 static const char *const junk_templates[] = {
493 "%sReport bugs to <%s>.%s", /*** must be first entry ***/
494 "Please disregard previous letter.",
495 "Welcome to NetHack.",
496#ifdef AMIGA
497 "Only Amiga makes it possible.",
498 "CATS have all the answers.",
499#endif
500 "This mail complies with the Yendorian Anti-Spam Act (YASA)",
501 "Please find enclosed a small token to represent your Owlbear",
502 "**FR33 P0T10N 0F FULL H34L1NG**",
503 "Please return to sender (Asmodeus)",
504 /* when enclosed by "It reads: \"...\"", this is too long
505 for an ordinary 80-column display so wraps to a second line
506 (suboptimal but works correctly);
507 dollar sign and fractional zorkmids are inappropriate within
508 nethack but are suitable for typical dysfunctional spam mail */
509 ("Buy a potion of gain level for only $19.99! "
510 " Guaranteed to be blessed!"),
511 /* DEVTEAM_URL will be substituted for 2nd "%s";
512 terminating punctuation (formerly "!") has deliberately been
513 omitted so that it can't be mistaken for part of the URL
514 (unfortunately that is still followed by a closing quote--in
515 the pline below, not the data here) */
516 "%sInvitation: Visit the NetHack web site at %s%s"
517 };
518 const char *const it_reads = "It reads: \"";
519
520 i = rn2(SIZE(junk_templates));
521 if (strchr(junk_templates[i], '%')) {
522 if (i == 0) {
523 recipient = DEVTEAM_EMAIL;
524 delivery = subst_delivery;
525 } else if (strstri(junk_templates[i], "web site")) {
526 recipient = DEVTEAM_URL;
527 delivery = subst_delivery;
528 } else {
529 impossible("fake mail #%d has undefined substitution", i);
530 delivery = faulty_delivery;
531 }
532 }
533 if (Blind) {
534 pline("Unfortunately you cannot see what it says.");
535 } else {
536 if (delivery == subst_delivery)
537 pline(junk_templates[i], it_reads, recipient, "\"");
538 else if (delivery == normal_delivery)
539 pline("%s%s\"", it_reads, junk_templates[i]);
540 }
541}
542
543RESTORE_WARNING_FORMAT_NONLITERAL

Callers 1

seffect_mailFunction · 0.85

Calls 12

rn2Function · 0.85
strstriFunction · 0.85
read_simplemailFunction · 0.85
childFunction · 0.85
getmailstatusFunction · 0.85
getlinFunction · 0.85
eosFunction · 0.85
vms_doshellFunction · 0.85
impossibleFunction · 0.70
plineFunction · 0.70
nh_getenvFunction · 0.70
nh_terminateFunction · 0.70

Tested by

no test coverage detected