MCPcopy Create free account
hub / github.com/NetHack/NetHack / parse_brdcst

Function parse_brdcst

sys/vms/vmsmail.c:119–303  ·  view source on GitHub ↗

try to decipher and categorize broadcast message text */

Source from the content-addressed store, hash-verified

117/* try to decipher and categorize broadcast message text
118*/
119static struct mail_info *
120parse_brdcst(char *buf) /* called by parse_next_broadcast() */
121 /* input: filtered broadcast text */
122{
123 int typ;
124 char *txt;
125 const char *nam, *cmd;
126#ifdef SHELL /* only parse if spawned commands are enabled */
127 char *p, *q;
128 boolean is_jnet_send;
129 char user[127 + 1], node[127 + 1], sentinel;
130
131 /* Check these first; otherwise, their arbitrary text would enable
132 easy spoofing of some other message patterns. Unfortunately,
133 any home-grown broadcast delivery program poses a similar risk. */
134 if (!strncmpi(buf, "reply received", 14))
135 goto other;
136 is_jnet_send = (sscanf(buf, "(%[^)])%s -%c", node, user, &sentinel) == 3);
137 if (is_jnet_send)
138 goto jnet_send;
139
140 /* scan the text more or less by brute force */
141 if ((q = strstri(buf, " mail")) != 0 || /* all known mail broadcasts */
142 !strncmpi(q = buf, "mail ", 5)) { /* unexpected alternative */
143 typ = MSG_MAIL;
144 p = strstri(q, " from");
145 txt = p ? strcat(strcpy(txt_buf, "Mail for you"), p) : (char *) 0;
146
147 if (!strncmpi(buf, "new mail", 8)) {
148 /*
149 * New mail [on node FOO] from [SPAM::]BAR
150 * [\"personal_name\"] [\(HH:MM:SS\)]
151 */
152 nam = "VMSmail"; /* assume VMSmail */
153 cmd = "MAIL";
154 if (txt && (p = strrchr(txt, '(')) > txt && /* discard time */
155 (--p, strspn(p, "0123456789( :.)") == strlen(p)))
156 *p = '\0';
157 } else if (!strncmpi(buf, "new all-in-1", 12)) {
158 int i;
159 /*
160 * New ALL-IN-1 MAIL message [on node FOO] from Personal Name
161 * \(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
162 */
163 nam = "A1mail";
164 cmd = "A1M";
165 if (txt && (p = strrchr(txt, '(')) > txt
166 && /* discard date+time */
167 sscanf(p - 1, " (%*d-%*[^-]-%*d %*d:%*d:%d) %c", &i,
168 &sentinel) == 1)
169 *--p = '\0';
170 } else if (!strncmpi(buf, "software tools", 14)) {
171 /*
172 * Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
173 */
174 nam = "STmail";
175 cmd = "MSG";
176 if (txt && (p = strstri(p, " in ")) != 0) /* specific folder */

Callers 1

parse_next_broadcastFunction · 0.85

Calls 4

strstriFunction · 0.85
strrchrFunction · 0.85
eosFunction · 0.85
strncmpiFunction · 0.50

Tested by

no test coverage detected