-/* NetHack 3.6 vmsmail.c $NHDT-Date: 1432512789 2015/05/25 00:13:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
-/* Copyright (c) Robert Patrick Rankin, 1991. */
+/* NetHack 3.6 vmsmail.c $NHDT-Date: 1449801741 2015/12/11 02:42:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
+/* Copyright (c) Robert Patrick Rankin, 1991. */
/* NetHack may be freely redistributed. See license for details. */
#include "config.h"
#endif /*__GNUC__*/
#include <signal.h>
/* #include <string.h> */
-#define vms_ok(sts) ((sts) &1)
+#define vms_ok(sts) ((sts) & 1)
static struct mail_info *FDECL(parse_brdcst, (char *));
static void FDECL(filter_brdcst, (char *));
/*
* Mail (et al) overview:
*
- * When a broadcast is asynchronously captured, a volatile counter
+ * When a broadcast is asynchronously captured, a volatile counter
* ('broadcasts') is incremented. Each player turn, ckmailstatus() polls
* the counter and calls parse_next_broadcast() if it's positive; this
* returns some display text, object name, and response command, which is
* If SHELL is undefined, then all broadcasts are treated as 'other'; since
* no subproceses are allowed, there'd be no way to respond to the scroll.
*
- * When a scroll of mail is read by the character, readmail() extracts
+ * When a scroll of mail is read by the character, readmail() extracts
* the command string and uses it for the default when prompting the
* player for a system command to spawn. The player may enter any command
* he or she chooses, or just <return> to accept the default or <escape> to
*
* Broadcast parsing:
*
- * The following broadcast messages are [attempted to be] recognized:
- * text fragment name for scroll default command
- * New mail VMSmail MAIL
- * New ALL-IN-1 MAIL A1mail A1M
- * Software Tools mail STmail MSG [+folder]
- * MM mail MMmail MM
- * WPmail: New mail WPmail OFFICE/MAIL
- * **M400 mail M400mail M400
- * " mail", ^"mail " unknown mail SPAWN
- * " phoning" Phone call PHONE ANSWER
- * talk-daemon...by...foo Talk request TALK[/OLD] foo@bar
- * (node)user - Bitnet noise XYZZY user@node
+ * The following broadcast messages are [attempted to be] recognized:
+ * text fragment name for scroll default command
+ * New mail VMSmail MAIL
+ * New ALL-IN-1 MAIL A1mail A1M
+ * Software Tools mail STmail MSG [+folder]
+ * MM mail MMmail MM
+ * WPmail: New mail WPmail OFFICE/MAIL
+ * **M400 mail M400mail M400
+ * " mail", ^"mail " unknown mail SPAWN
+ * " phoning" Phone call PHONE ANSWER
+ * talk-daemon...by...foo Talk request TALK[/OLD] foo@bar
+ * (node)user - Bitnet noise XYZZY user@node
* Anything else results in just the message text being passed along, no
* scroll of mail so consequently no command to execute when scroll read.
* The user can set up ``$ XYZZY :== SEND'' prior to invoking NetHack if
* vanilla JNET responses to Bitnet messages are prefered.
*
- * Static return buffers are used because only one broadcast gets
+ * Static return buffers are used because only one broadcast gets
* processed at a time, and the essential information in each one is
* either displayed and discarded or copied into a scroll-of-mail object.
*
- * The test driver code below can be used to check out potential new
+ * The test driver code below can be used to check out potential new
* entries without rebuilding NetHack itself. CC/DEFINE="TEST_DRIVER"
* Link it with hacklib.obj or nethack.olb/incl=hacklib (not nethack/lib).
*/
-static struct mail_info msg; /* parse_*()'s return buffer */
-static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
- cmd_buf[99], /* arbitrary */
- txt_buf[255 + 1]; /* same size as used for message buf[] */
+static struct mail_info msg; /* parse_*()'s return buffer */
+static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
+ cmd_buf[99], /* arbitrary */
+ txt_buf[255 + 1]; /* same size as used for message buf[] */
/* try to decipher and categorize broadcast message text
*/
if (!strncmpi(buf, "new mail", 8)) {
/*
- New mail [on node FOO] from [SPAM::]BAR [\"personal_name\"]
- [\(HH:MM:SS\)]
- */
+ * New mail [on node FOO] from [SPAM::]BAR
+ * [\"personal_name\"] [\(HH:MM:SS\)]
+ */
nam = "VMSmail"; /* assume VMSmail */
cmd = "MAIL";
if (txt && (p = strrchr(txt, '(')) > txt && /* discard time */
} else if (!strncmpi(buf, "new all-in-1", 12)) {
int i;
/*
- New ALL-IN-1 MAIL message [on node FOO] from Personal Name
- \(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
- */
+ * New ALL-IN-1 MAIL message [on node FOO] from Personal Name
+ * \(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
+ */
nam = "A1mail";
cmd = "A1M";
if (txt && (p = strrchr(txt, '(')) > txt
*--p = '\0';
} else if (!strncmpi(buf, "software tools", 14)) {
/*
- Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
- */
+ * Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
+ */
nam = "STmail";
cmd = "MSG";
if (txt && (p = strstri(p, " in ")) != 0) /* specific folder */
cmd = strcat(strcpy(cmd_buf, "MSG +"), p + 4);
} else if (q - 2 >= buf && !strncmpi(q - 2, "mm", 2)) {
/*
- {MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n
- [Subject: subject_text] (PMDF only)
- */
+ * {MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n
+ * [Subject: subject_text] (PMDF only)
+ */
nam = "MMmail"; /* MultiNet's version of MM */
cmd = "MM"; /*{ perhaps "MM READ"? }*/
} else if (!strncmpi(buf, "wpmail:", 7)) {
/*
- WPmail: New mail from BAR. subject_text
- */
+ * WPmail: New mail from BAR. subject_text
+ */
nam = "WPmail"; /* WordPerfect [sic] Office */
cmd = "OFFICE/MAIL";
} else if (!strncmpi(buf, "**m400 mail", 7)) {
/*
- **M400 mail waiting**
- */
+ * **M400 mail waiting**
+ */
nam = "M400mail"; /* Messenger 400 [not seen] */
cmd = "M400";
} else {
if (!txt)
txt = strcat(strcpy(txt_buf, "Mail for you: "), buf);
- /*
- : end of mail recognition; now check for call-type
- interruptions...
- */
+
+ /*
+ * end of mail recognition; now check for call-type interruptions...
+ */
} else if ((q = strstri(buf, " phoning")) != 0) {
/*
- BAR is phoning you [on FOO] \(HH:MM:SS\)
- */
+ * BAR is phoning you [on FOO] \(HH:MM:SS\)
+ */
typ = MSG_CALL;
nam = "Phone call";
cmd = "PHONE ANSWER";
} else if ((q = strstri(buf, " talk-daemon")) != 0
|| (q = strstri(buf, " talk_daemon")) != 0) {
/*
- Message from TALK-DAEMON@FOO at HH:MM:SS\n
- Connection request by BAR@SPAM\n
- \[Respond with: TALK[/OLD] BAR@SPAM\]
- */
+ * Message from TALK-DAEMON@FOO at HH:MM:SS\n
+ * Connection request by BAR@SPAM\n
+ * \[Respond with: TALK[/OLD] BAR@SPAM\]
+ */
typ = MSG_CALL;
nam = "Talk request"; /* MultiNet's TALK and/or TALK/OLD */
cmd = "TALK";
} else if (is_jnet_send) { /* sscanf(,"(%[^)])%s -%c",,,)==3 */
jnet_send:
/*
- \(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM)
- */
+ * \(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM)
+ */
typ = MSG_CALL;
nam = "Bitnet noise"; /* RSCS/NJE message received via JNET */
Sprintf(cmd_buf, "XYZZY %s@%s", user, node);
cmd = cmd_buf;
/*{ perhaps just vanilla SEND instead of XYZZY? }*/
Sprintf(txt_buf, "Message from %s@%s:%s", user, node,
- &buf[1 + strlen(node) + 1 + strlen(user) + 2
- - 1]); /* "(node)user -" */
+ /* "(node)user -" */
+ &buf[1 + strlen(node) + 1 + strlen(user) + 2 - 1]);
txt = txt_buf;
- /*
- : end of call recognition; anything else is none-of-the-above...
- */
+
+ /*
+ * end of call recognition; anything else is none-of-the-above...
+ */
} else {
other:
#endif /* SHELL */
- /* arbitrary broadcast: batch job completed, system shutdown imminent,
- * &c */
+ /* arbitrary broadcast: batch job completed, system shutdown
+ * imminent, &c
+ */
typ = MSG_OTHER;
nam = (char *) 0; /*"captured broadcast message"*/
cmd = (char *) 0;
/* filter the text; restrict consecutive spaces or dots to just two */
for (p = buf_p = buf; *buf_p; buf_p++) {
c = *buf_p & '\177';
- if (c == ' ' || c == '\t' || c == '\n')
+ if (c == ' ' || c == '\t' || c == '\n') {
if (p == buf || /* ignore leading whitespace */
(p >= buf + 2 && *(p - 1) == ' ' && *(p - 2) == ' '))
continue;
else
c = ' ';
- else if (c == '.' || c < ' ' || c == '\177')
+ } else if (c == '.' || c < ' ' || c == '\177') {
if (p == buf || /* skip leading beeps & such */
(p >= buf + 2 && *(p - 1) == '.' && *(p - 2) == '.'))
continue;
else
c = '.';
- else if (c == '%' && /* trim %%% OPCOM verbosity %%% */
- p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%')
+ } else if (c == '%' && /* trim %%% OPCOM verbosity %%% */
+ p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%') {
continue;
+ }
*p++ = c;
}
*p = '\0'; /* terminate, then strip trailing junk */
static char empty_string[] = "";
/* fetch the text of a captured broadcast, then mangle and decipher it
-*/
+ */
struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
{
short length, msg_type;
}
/* spit out any pending broadcast messages whenever we leave
-*/
+ */
static void flush_broadcasts() /* called from disable_broadcast_trapping() */
{
if (broadcasts > 0) {
}
}
-/* AST routine called when the terminal's associated mailbox receives a
- * message
-*/
+/* AST routine called when terminal's associated mailbox receives a message
+ */
/*ARGSUSED*/
static void
broadcast_ast(dummy) /* called asynchronously by terminal driver */
-int dummy; /* not used */
+int dummy UNUSED;
{
broadcasts++;
}
/* initialize the broadcast manipulation code; SMG makes this easy
*/
-unsigned long init_broadcast_trapping() /* called by setftty() [once only] */
+unsigned long
+init_broadcast_trapping() /* called by setftty() [once only] */
{
unsigned long sts, preserve_screen_flag = 1;
- /* we need a pasteboard to pass to the broadcast setup/teardown routines
- */
- sts =
- smg$create_pasteboard(&pasteboard_id, 0, 0, 0, &preserve_screen_flag);
+ /* we need a pasteboard to pass to the broadcast setup/teardown routines */
+ sts = smg$create_pasteboard(&pasteboard_id, 0, 0, 0,
+ &preserve_screen_flag);
if (!vms_ok(sts)) {
errno = EVMSERR, vaxc$errno = sts;
raw_print("");
}
/* set up the terminal driver to deliver $brkthru data to a mailbox device
-*/
-unsigned long enable_broadcast_trapping() /* called by setftty() */
+ */
+unsigned long
+enable_broadcast_trapping() /* called by setftty() */
{
unsigned long sts = 1;
}
/* return to 'normal'; $brkthru data goes straight to the terminal
-*/
-unsigned long disable_broadcast_trapping() /* called by settty() */
+ */
+unsigned long
+disable_broadcast_trapping() /* called by settty() */
{
unsigned long sts = 1;
}
return sts;
}
+
#else /* MAIL */
+
/* simple stubs for non-mail configuration */
unsigned long
init_broadcast_trapping()
{
return 0;
}
+
#endif /* MAIL */
/*----------------------------------------------------------------------*/
wait_synch()
{
char dummy[BUFSIZ];
+
printf("\nPress <return> to continue: ");
fflush(stdout);
(void) gets(dummy);