9 date 95.12.06.21.04.11; author jromine; state Exp;
14 date 92.12.15.00.20.22; author jromine; state Exp;
19 date 92.11.04.00.49.51; author jromine; state Exp;
24 date 92.10.26.16.49.12; author jromine; state Exp;
29 date 92.10.16.21.37.03; author jromine; state Exp;
34 date 92.02.03.17.57.22; author jromine; state Exp;
39 date 92.02.03.16.36.04; author jromine; state Exp;
44 date 92.01.31.22.17.18; author jromine; state Exp;
49 date 92.01.31.16.33.10; author jromine; state Exp;
54 date 90.04.05.14.56.36; author sources; state Exp;
59 date 90.03.20.16.20.08; author sources; state Exp;
64 date 90.02.06.13.22.19; author sources; state Exp;
69 date 90.02.05.15.01.55; author sources; state Exp;
74 date 90.02.05.14.25.08; author sources; state Exp;
79 date 89.11.17.15.57.55; author sources; state Exp;
84 date 89.09.22.13.48.47; author sources; state Exp;
89 date 89.05.07.12.46.13; author sources; state Exp;
94 date 89.05.07.12.35.52; author sources; state Exp;
99 date 89.05.05.19.41.21; author sources; state Exp;
110 @remove MAXFOLDER limit
113 @/* msh.c - The MH shell (sigh) */
115 static char ident[] = "@@(#)$Id: msh.c,v 2.13 1992/12/15 00:20:22 jromine Exp jromine $";
119 Keep more status information in maildrop map
123 #include "../h/dropsbr.h"
124 #include "../h/formatsbr.h"
125 #include "../h/scansbr.h"
126 #include "../zotnet/tws.h"
128 #include "../zotnet/mts.h"
130 #include <sys/types.h>
131 #include <sys/stat.h>
137 #include <sys/ioctl.h>
138 #endif /* NOIOCTLH */
143 #include "../h/mshsbr.h"
144 #include "../h/vmhsbr.h"
150 #define MIMEminc(a) (a)
152 #define MIMEminc(a) 0
155 #define QUOTE '\\' /* sigh */
160 static struct swit switches[] = {
162 "idstart number", -7, /* interface from bbc */
164 "idstop number", -6, /* .. */
166 "idquit number", -6, /* .. */
168 "idname BBoard", -6, /* .. */
201 char *fmsh = NULL; /* folder instead of file */
202 int modified; /* command modified folder */
203 struct msgs *mp; /* used a lot */
204 static int nMsgs = 0;
205 struct Msg *Msgs = NULL; /* Msgs[0] not used */
206 static FILE *fp; /* input file */
207 static FILE *yp = NULL; /* temporary file */
208 static int mode; /* mode of file */
209 static int numfds = 0; /* number of files cached */
210 static int maxfds = 0; /* number of files cached to be cached */
211 static time_t mtime = (time_t) 0;/* mtime of file */
215 #define ALARM ((unsigned int) 10)
216 #define ttyN(c) ttyNaux ((c), NULLCP)
220 static int vmhpid = OK;
225 static int vmhtty = NOTOK;
232 static int topcur = 0;
234 static int numwins = 0;
235 static int windows[NWIN + 1];
237 static jmp_buf peerenv;
239 void padios (), padvise ();
240 static TYPESIG alrmser ();
246 int pmsh = 0; /* BPOP enabled */
248 extern char response[];
253 static int pfd = NOTOK; /* fd parent is reading from */
254 static int ppid = 0; /* pid of parent */
258 int interactive; /* running from a /dev/tty */
259 int redirected; /* re-directing output */
260 FILE *sp = NULL; /* original stdout */
262 char *cmd_name; /* command being run */
264 char myfilter[BUFSIZ]; /* path to mhl.forward */
266 static char *myprompt = "(%s) ";/* prompting string */
270 static int gap; /* gap in BBoard-ID:s */
272 static char *myname = NULL; /* BBoard name */
274 char *BBoard_ID = "BBoard-ID";/* BBoard-ID constant */
277 TYPESIG (*istat) (); /* original SIGINT */
278 static TYPESIG (*pstat) (); /* current SIGPIPE */
279 TYPESIG (*qstat) (); /* original SIGQUIT */
281 static TYPESIG (*tstat) (); /* original SIGTSTP */
283 int interrupted; /* SIGINT detected */
284 int broken_pipe; /* SIGPIPE detected */
285 int told_to_quit; /* SIGQUIT detected */
288 int should_intr; /* signal handler should interrupt call */
289 jmp_buf sigenv; /* the environment pointer */
292 static TYPESIG intrser (), pipeser (), quitser ();
297 struct passwd *getpwnam ();
301 static int read_map(), read_file(), check_folder(), getargs(), parse();
302 static int getcmds(), init_io(), initaux_io(), finaux_io(), peerwait();
303 static int pINI(), pQRY(), pQRY1(), pQRY2(), pCMD(), pFIN();
304 static int ttyR(), ttyNaux(), winN(), winR(), winX();
305 static msh(), m_gMsgs(), scanrange(), scanstring(), quit();
306 static fin_io(), m_init();
308 static int read_pop();
335 setlocale(LC_ALL, "");
337 invo_name = r1bindex (argv[0], '/');
338 mts_init (invo_name);
339 if ((cp = m_find (invo_name)) != NULL) {
340 ap = brkstring (cp = getcpy (cp), " ", "\n");
341 ap = copyip (ap, arguments);
345 (void) copyip (argv + 1, ap);
350 while (cp = *argp++) {
352 switch (smatch (++cp, switches)) {
354 ambigsw (cp, switches);
357 adios (NULLCP, "-%s unknown", cp);
359 (void) sprintf (buf, "%s [switches] file", invo_name);
360 help (buf, switches);
364 if (!(cp = *argp++) || *cp == '-')
365 adios (NULLCP, "missing argument to %s", argp[-2]);
366 if ((id = atoi (cp)) < 1)
367 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
370 if (!(cp = *argp++) || *cp == '-')
371 adios (NULLCP, "missing argument to %s", argp[-2]);
372 if ((pfd = atoi (cp)) <= 1)
373 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
376 if (!(cp = *argp++) || *cp == '-')
377 adios (NULLCP, "missing argument to %s", argp[-2]);
378 if ((ppid = atoi (cp)) <= 1)
379 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
382 if (!(myname = *argp++) || *myname == '-')
383 adios (NULLCP, "missing argument to %s", argp[-2]);
394 if (!(myprompt = *argp++) || *myprompt == '-')
395 adios (NULLCP, "missing argument to %s", argp[-2]);
399 if (!(cp = *argp++) || *cp == '-')
400 adios (NULLCP, "missing argument to %s", argp[-2]);
401 if ((vmh1 = atoi (cp)) < 1)
402 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
405 if (!(cp = *argp++) || *cp == '-')
406 adios (NULLCP, "missing argument to %s", argp[-2]);
407 if ((vmh2 = atoi (cp)) < 1)
408 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
412 if (!(cp = *argp++) || *cp == '-')
413 adios (NULLCP, "missing argument to %s", argp[-2]);
415 if ((pmsh1 = atoi (cp)) < 1)
416 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
420 if (!(cp = *argp++) || *cp == '-')
421 adios (NULLCP, "missing argument to %s", argp[-2]);
423 if ((pmsh2 = atoi (cp)) < 1)
424 adios (NULLCP, "bad argument %s %s", argp[-2], cp);
435 if (*cp == '+' || *cp == '@@') {
437 adios (NULLCP, "only one folder at a time!");
439 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
443 adios (NULLCP, "only one file at a time!");
450 if (!file && !folder)
453 adios (NULLCP, "use a file or a folder, not both");
454 (void) strcpy (myfilter, libpath (mhlforward));
457 (void) ioctl (pfd, FIOCLEX, NULLCP);
463 setsigx (istat, SIGINT, intrser);
464 setsigx (qstat, SIGQUIT, quitser);
466 (void) sc_width (); /* MAGIC... */
468 if (vmh = vmh1 && vmh2) {
469 (void) rcinit (vmh1, vmh2);
471 (void) signal (SIGINT, SIG_IGN);
472 (void) signal (SIGQUIT, SIG_IGN);
474 tstat = signal (SIGTSTP, SIG_IGN);
479 if (pmsh = pmsh1 && pmsh2) {
480 cp = getenv ("MHPOPDEBUG");
482 if (pop_set (pmsh1, pmsh2, cp && *cp, myname) == NOTOK)
484 if (pop_set (pmsh1, pmsh2, cp && *cp) == NOTOK)
486 padios (NULLCP, "%s", response);
488 file = folder, folder = NULL;
497 display_info (id > 0 ? scansw : 0);
499 msh (id > 0 ? scansw : 0);
508 static struct swit mshcmds[] = {
580 register struct Cmd *cmdp;
581 static int once_only = ADVCMD;
583 (void) sprintf (prompt, myprompt, invo_name);
592 if ((i = getcmds (mshcmds, cmdp, scansw)) == EOF) {
598 (void) check_folder (scansw);
599 if ((i = getargs (prompt, mshcmds, cmdp)) == EOF) {
600 (void) putchar ('\n');
604 cmd_name = mshcmds[i].sw;
612 if (once_only == ADVCMD)
613 once_only = i = SHOWCMD;
615 i = mp -> curmsg != mp -> hghmsg ? NEXTCMD : EXITCMD;
616 cmd_name = mshcmds[i].sw;
622 case FORWCMD: /* sigh */
632 if ((cp = m_find (cmd_name)) != NULL) {
633 ap = brkstring (cp = getcpy (cp), " ", "\n");
634 ap = copyip (ap, vec);
645 (void) copyip (cmdp -> args + 1, ap);
649 if (!vmh && init_io (cmdp, vmh) == NOTOK) {
655 redirected = vmh || cmdp -> direction != STDIO;
666 if (!vmh || ttyN (cmdp) != NOTOK)
667 forkcmd (vec, cmd_name);
671 if (!vmh || ttyN (cmdp) != NOTOK)
676 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
682 || (filehak (vec) == OK ? ttyN (cmdp)
683 : winN (cmdp, DISPLAY, 1)) != NOTOK)
688 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
693 if (!vmh || ttyN (cmdp) != NOTOK)
698 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
704 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
710 if (!vmh || ttyN (cmdp) != NOTOK)
718 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
724 || (packhak (vec) == OK ? ttyN (cmdp)
725 : winN (cmdp, DISPLAY, 1)) != NOTOK)
730 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
735 if (!vmh || ttyN (cmdp) != NOTOK)
740 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
745 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
750 if (!vmh || winN (cmdp, DISPLAY, 1) != NOTOK)
755 padios (NULLCP, "no dispatch for %s", cmd_name);
784 maildir = m_maildir (folder);
785 if (chdir (maildir) == NOTOK)
786 padios (maildir, "unable to change directory to");
787 if (!(mp = m_gmsg (folder)))
788 padios (NULLCP, "unable to read folder %s", folder);
789 if (mp -> hghmsg == 0)
790 padios (NULLCP, "no messages in %s", folder);
793 mtime = stat (mp -> foldpath, &st) != NOTOK ? st.st_mtime : 0;
795 m_gMsgs (mp -> hghmsg);
797 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++) {
798 Msgs[msgnum].m_bboard_id = 0;
799 Msgs[msgnum].m_top = NOTOK;
800 Msgs[msgnum].m_start = Msgs[msgnum].m_stop = 0L;
801 Msgs[msgnum].m_scanl = NULL;
806 fmsh = getcpy (folder);
811 maxfds = getdtablesize () / 2;
813 if ((maxfds -= 2) < 1)
831 (void) strcpy (tmpfil, m_tmpfil (invo_name));
832 if ((fp = fopen (tmpfil, "w+")) == NULL)
833 padios (tmpfil, "unable to create");
834 (void) unlink (tmpfil);
838 if ((fp = fopen (file, "r")) == NULL)
839 padios (file, "unable to read");
841 (void) ioctl (fileno (fp), FIOCLEX, NULLCP);
843 if (fstat (fileno (fp), &st) != NOTOK) {
844 mode = (int) (st.st_mode & 0777), mtime = st.st_mtime;
845 msgp = read_map (file, (long) st.st_size);
848 mode = m_gmprot (), mtime = 0;
852 if ((msgp = read_file (msgp ? Msgs[msgp].m_stop : 0L, msgp + 1)) < 1)
853 padios (NULLCP, "no messages in %s", myname ? myname : file);
855 mp = (struct msgs *) calloc ((unsigned) 1, MHSIZE (mp, 1, msgp + 1));
857 padios (NULLCP, "unable to allocate folder storage");
864 mp -> foldpath = getcpy (myname ? myname : file);
868 mp -> msgflags |= READONLY;
871 (void) stat (file, &st);
872 if (st.st_uid != getuid () || access (file, 02) == NOTOK)
873 mp -> msgflags |= READONLY;
878 mp -> hghoff = mp -> hghmsg + 1;
881 mp -> msgstats = (short *)
882 calloc ((unsigned) 1, MHSIZEX (mp, mp -> lowmsg, mp -> hghmsg));
883 if (mp -> msgstats == NULL)
884 padios (NULLCP, "unable to allocate messages storage");
885 mp -> msgstats = (mp -> msgbase = mp -> msgstats) - mp -> lowoff;
886 if (mp -> msgstats < (short *)0)
887 padios (NULLCP, "setup() botch -- you lose big");
892 for (i = mp -> lowmsg; i <= mp -> hghmsg; i++) {
894 mp -> msgstats[i] = EXISTS | VIRTUAL;
897 for (i = mp -> lowmsg; i <= mp -> hghmsg; i++) {
898 if (Msgs[i].m_top) /* set in read_pop() */
899 mp -> msgstats[i] = EXISTS | VIRTUAL;
905 for (i = mp -> lowmsg; i <= mp -> hghmsg; i++)
906 mp -> msgstats[i] = EXISTS;
909 mp -> msgattrs[0] = getcpy ("unseen");
910 mp -> msgattrs[1] = NULL;
912 m_unknown (fp); /* the MAGIC invocation */
921 static int read_map (file, size)
927 register struct drop *dp,
936 if ((i = map_read (file, size, &rp, 1)) == 0)
942 for (dp = rp + 1; i-- > 0; msgp++, dp++) {
943 mp = &Msgs[msgp].m_drop;
944 mp -> d_id = dp -> d_id;
945 mp -> d_size = dp -> d_size;
946 mp -> d_start = dp -> d_start;
947 mp -> d_stop = dp -> d_stop;
948 Msgs[msgp].m_scanl = NULL;
957 static int read_file (pos, msgp)
962 register struct drop *dp,
971 if ((i = mbx_read (fp, pos, &rp, 1)) <= 0)
974 m_gMsgs ((msgp - 1) + i);
976 for (dp = rp; i-- > 0; msgp++, dp++) {
977 mp = &Msgs[msgp].m_drop;
979 mp -> d_size = dp -> d_size;
980 mp -> d_start = dp -> d_start;
981 mp -> d_stop = dp -> d_stop;
982 Msgs[msgp].m_scanl = NULL;
993 static int pop_base = 0;
995 static int pop_statmsg (s)
1000 n = (i = atoi (s)) - pop_base; /* s="nnn header-line..." */
1001 Msgs[n].m_top = Msgs[n].m_bboard_id = i;
1005 static int read_pop () {
1009 if (pop_stat (&nmsgs, &nbytes) == NOTOK)
1010 padios (NULLCP, "%s", response);
1014 #ifdef NNTP /* this makes read_pop() do some real work... */
1015 pop_base = nbytes - 1; /* nmsgs=last-first+1, nbytes=first */
1016 pop_exists (pop_statmsg);
1022 static int pop_action (s)
1025 fprintf (yp, "%s\n", s);
1037 nMsgs = n + MAXFOLDER / 2;
1038 Msgs = (struct Msg *) calloc ((unsigned) (nMsgs + 2), sizeof *Msgs);
1040 padios (NULLCP, "unable to allocate Msgs structure");
1047 nmsgs = nMsgs + n + MAXFOLDER / 2;
1048 Msgs = (struct Msg *) realloc ((char *) Msgs,
1049 (unsigned) (nmsgs + 2) * sizeof *Msgs);
1051 padios (NULLCP, "unable to reallocate Msgs structure");
1052 bzero ((char *) (Msgs + nMsgs + 2),
1053 (unsigned) ((nmsgs - nMsgs) * sizeof *Msgs));
1060 FILE *msh_ready (msgnum, full)
1061 register int msgnum;
1077 if ((fd = Msgs[msgnum].m_top) == NOTOK) {
1078 if (numfds >= maxfds)
1079 for (msgp = mp -> lowmsg; msgp <= mp -> hghmsg; msgp++)
1080 if (Msgs[msgp].m_top != NOTOK) {
1081 (void) close (Msgs[msgp].m_top);
1082 Msgs[msgp].m_top = NOTOK;
1087 if ((fd = open (cp = m_name (msgnum), 0)) == NOTOK)
1088 padios (cp, "unable to open message");
1089 Msgs[msgnum].m_top = fd;
1093 if ((fd = dup (fd)) == NOTOK)
1094 padios ("cached message", "unable to dup");
1095 if ((yp = fdopen (fd, "r")) == NULL)
1096 padios (NULLCP, "unable to fdopen cached message");
1097 (void) fseek (yp, 0L, 0);
1102 if (pmsh && (mp -> msgstats[msgnum] & VIRTUAL)) {
1103 if (Msgs[msgnum].m_top == 0)
1104 padios (NULLCP, "msh_ready (%d, %d) botch", msgnum, full);
1106 (void) strcpy (tmpfil, m_tmpfil (invo_name));
1107 if ((yp = fopen (tmpfil, "w+")) == NULL)
1108 padios (tmpfil, "unable to create");
1109 (void) unlink (tmpfil);
1111 if (pop_top (Msgs[msgnum].m_top, 4, pop_action) == NOTOK)
1112 padios (NULLCP, "%s", response);
1114 m_eomsbr ((int (*)()) 0); /* XXX */
1115 msg_style = MS_DEFAULT; /* .. */
1116 (void) fseek (yp, 0L, 0);
1120 (void) fseek (fp, 0L, 2);
1121 (void) fwrite (mmdlm1, 1, strlen (mmdlm1), fp);
1123 padios ("temporary file", "write error on");
1124 (void) fseek (fp, 0L, 2);
1128 if (pop_retr (Msgs[msgnum].m_top, pop_action) == NOTOK)
1129 padios (NULLCP, "%s", response);
1132 (void) fseek (fp, 0L, 2);
1134 (void) fwrite (mmdlm2, 1, strlen (mmdlm2), fp);
1136 padios ("temporary file", "write error on");
1138 Msgs[msgnum].m_start = pos1;
1139 Msgs[msgnum].m_stop = pos2;
1141 mp -> msgstats[msgnum] &= ~VIRTUAL;
1145 m_eomsbr ((int (*)()) 0); /* XXX */
1146 (void) fseek (fp, Msgs[msgnum].m_start, 0);
1152 static int check_folder (scansw)
1168 if (stat (mp -> foldpath, &st) == NOTOK)
1169 padios (mp -> foldpath, "unable to stat");
1170 if (mtime == st.st_mtime)
1172 mtime = st.st_mtime;
1174 low = mp -> hghmsg + 1;
1177 if (!(mp = m_gmsg (fmsh)))
1178 padios (NULLCP, "unable to re-read folder %s", fmsh);
1182 for (msgp = mp -> lowmsg; msgp <= mp -> hghmsg; msgp++) {
1183 if (Msgs[msgp].m_top != NOTOK) {
1184 (void) close (Msgs[msgp].m_top);
1185 Msgs[msgp].m_top = NOTOK;
1188 if (Msgs[msgp].m_scanl) {
1189 free (Msgs[msgp].m_scanl);
1190 Msgs[msgp].m_scanl = NULL;
1196 if (modified || low > hgh)
1200 if (fstat (fileno (fp), &st) == NOTOK)
1201 padios (mp -> foldpath, "unable to fstat");
1202 if (mtime == st.st_mtime)
1204 mode = (int) (st.st_mode & 0777);
1205 mtime = st.st_mtime;
1207 if ((msgp = read_file (Msgs[mp -> hghmsg].m_stop, mp -> hghmsg + 1)) < 1)
1208 padios (NULLCP, "no messages in %s", mp -> foldpath); /* XXX */
1209 if (msgp <= mp -> hghmsg)
1212 if ((mp = m_remsg (mp, 0, msgp)) == NULL)
1213 padios (NULLCP, "unable to allocate folder storage");
1215 low = mp -> hghmsg + 1, hgh = msgp;
1216 flags = scansw ? m_seqflag (mp, "unseen") : 0;
1217 for (i = mp -> hghmsg + 1; i <= msgp; i++) {
1218 mp -> msgstats[i] = EXISTS | flags;
1221 mp -> hghmsg = msgp;
1228 advise (NULLCP, "new messages have arrived!\007");
1230 scanrange (low, hgh);
1237 static scanrange (low, hgh)
1241 char buffer[BUFSIZ];
1243 (void) sprintf (buffer, "%d-%d", low, hgh);
1244 scanstring (buffer);
1248 static scanstring (arg)
1255 if ((cp = m_find (cmd_name = "scan")) != NULL) {
1256 ap = brkstring (cp = getcpy (cp), " ", "\n");
1257 ap = copyip (ap, vec);
1279 if (mp -> curmsg == 0)
1280 m_setcur (mp, mp -> lowmsg);
1281 if (id <= 0 || (flags = m_seqflag (mp, "unseen")) == 0)
1284 for (msgnum = mp -> hghmsg; msgnum >= mp -> lowmsg; msgnum--)
1285 mp -> msgstats[msgnum] |= flags;
1290 for (msgnum = mp -> hghmsg; msgnum >= mp -> lowmsg; msgnum--)
1291 if (mp -> msgstats[msgnum] & EXISTS) /* FIX */
1292 if ((i = readid (msgnum)) > 0 && i < id) {
1294 mp -> msgstats[msgnum] &= ~flags;
1297 for (i = mp -> lowmsg; i < msgnum; i++)
1298 mp -> msgstats[i] &= ~flags;
1300 if (cur > mp -> hghmsg)
1306 if ((gap = 1 < id && id < (i = readid (mp -> lowmsg)) ? id : 0) && !vmh)
1307 advise (NULLCP, "gap in ID:s, last seen %d, lowest present %d\n",
1328 if (Msgs[msgnum].m_bboard_id)
1329 return Msgs[msgnum].m_bboard_id;
1332 if (Msgs[msgnum].m_top == 0)
1333 padios (NULLCP, "readid (%d) botch", msgnum);
1334 if (pop_list (Msgs[msgnum].m_top, (int *) 0, &arg1, &arg2, &arg3) == OK
1336 return (Msgs[msgnum].m_bboard_id = arg3);
1340 zp = msh_ready (msgnum, 0);
1342 switch (state = m_getfld (state, name, buf, sizeof buf, zp)) {
1346 if (uleq (name, BBoard_ID)) {
1348 while (state == FLDPLUS) {
1349 state = m_getfld (state, name, buf, sizeof buf, zp);
1355 return (Msgs[msgnum].m_bboard_id = i);
1359 while (state == FLDPLUS)
1360 state = m_getfld (state, name, buf, sizeof buf, zp);
1361 if (state != FLDEOF)
1371 display_info (scansw)
1377 interactive = isatty (fileno (stdout));
1379 if ((sd = dup (fileno (stdout))) == NOTOK)
1380 padios ("standard output", "unable to dup");
1381 #ifndef BSD42 /* XXX */
1383 (void) ioctl (sd, FIOCLEX, NULL);
1384 #endif /* FIOCLEX */
1385 #endif /* not BSD42 */
1386 if ((sp = fdopen (sd, "w")) == NULL)
1387 padios ("standard output", "unable to fdopen");
1390 (void) m_putenv ("mhfolder", mp -> foldpath);
1395 printf ("Reading ");
1396 if (SOprintf ("%s", myname))
1397 printf ("%s", myname);
1398 printf (", currently at message %d of %d\n",
1399 mp -> curmsg, mp -> hghmsg);
1402 printf ("Reading ");
1404 printf ("+%s", fmsh);
1406 printf ("%s", mp -> foldpath);
1407 printf (", currently at message %d of %d\n",
1408 mp -> curmsg, mp -> hghmsg);
1411 if ((flags = m_seqflag (mp, "unseen"))
1413 && (mp -> msgstats[mp -> hghmsg] & flags))
1414 scanstring ("unseen");
1419 static write_ids () {
1428 if (flags = m_seqflag (mp, "unseen"))
1429 for (msgnum = mp -> hghmsg; msgnum >= mp -> lowmsg; msgnum--)
1430 if (!(mp -> msgstats[msgnum] & flags)) {
1431 if (Msgs[msgnum].m_bboard_id == 0)
1432 (void) readid (msgnum);
1433 if ((i = Msgs[msgnum].m_bboard_id) > 0)
1437 (void) sprintf (buffer, "%d %d\n", i, Msgs[mp -> hghmsg].m_bboard_id);
1438 (void) write (pfd, buffer, sizeof buffer);
1456 if (!(mp -> msgflags & MODIFIED) || mp -> msgflags & READONLY || fmsh) {
1458 (void) rc2peer (RC_FIN, 0, NULLCP);
1463 (void) ttyNaux (NULLCMD, "FAST");
1465 if ((dp = lkfopen (mp -> foldpath, "r")) == NULL) {
1466 advise (mp -> foldpath, "unable to lock");
1468 (void) ttyR (NULLCMD);
1473 if (fstat (fileno (dp), &st) == NOTOK) {
1474 advise (mp -> foldpath, "unable to stat");
1477 if (mtime != st.st_mtime) {
1478 advise (NULLCP, "new messages have arrived, no update");
1481 mode = (int) (st.st_mode & 0777);
1483 if (mp -> nummsg == 0) {
1484 cp = concat ("Zero file \"", mp -> foldpath, "\"? ", NULLCP);
1485 if (getanswer (cp)) {
1486 if ((i = creat (mp -> foldpath, mode)) != NOTOK)
1489 advise (mp -> foldpath, "error zero'ing");
1490 (void) unlink (map_name (mp -> foldpath));/* XXX */
1495 cp = concat ("Update file \"", mp -> foldpath, "\"? ", NULLCP);
1496 if (!getanswer (cp))
1498 (void) strcpy (tmpfil, m_backup (mp -> foldpath));
1499 if ((md = mbx_open (tmpfil, st.st_uid, st.st_gid, mode)) == NOTOK) {
1500 advise (tmpfil, "unable to open");
1504 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
1505 if (mp -> msgstats[msgnum] & EXISTS
1506 && pack (tmpfil, md, msgnum) == NOTOK) {
1507 (void) mbx_close (tmpfil, md);
1508 (void) unlink (tmpfil);
1509 (void) unlink (map_name (tmpfil));
1512 (void) mbx_close (tmpfil, md);
1514 if (rename (tmpfil, mp -> foldpath) == NOTOK)
1515 admonish (mp -> foldpath, "unable to rename %s to", tmpfil);
1517 (void) strcpy (map1, map_name (tmpfil));
1518 (void) strcpy (map2, map_name (mp -> foldpath));
1520 if (rename (map1, map2) == NOTOK) {
1521 admonish (map2, "unable to rename %s to", map1);
1522 (void) unlink (map1);
1523 (void) unlink (map2);
1530 (void) lkfclose (dp, mp -> foldpath);
1532 (void) ttyR (NULLCMD);
1539 static int getargs (prompt, sw, cmdp)
1546 static char buffer[BUFSIZ];
1552 switch (setjmp (sigenv)) {
1559 if (interrupted && !told_to_quit) {
1560 (void) putchar ('\n');
1564 (void) kill (ppid, SIGEMT);
1569 printf ("%s", prompt);
1570 (void) fflush (stdout);
1572 for (cp = buffer; (i = getchar ()) != '\n';) {
1574 if (interrupted && !told_to_quit) {
1576 (void) putchar ('\n');
1579 if (told_to_quit || i == EOF) {
1581 (void) kill (ppid, SIGEMT);
1586 longjmp (sigenv, DONE);
1588 if (cp < &buffer[sizeof buffer - 2])
1595 if (buffer[0] == '?') {
1596 printf ("commands:\n");
1597 printsw (ALL, sw, "");
1598 printf ("type CTRL-D or use ``quit'' to leave %s\n",
1603 if (parse (buffer, cmdp) == NOTOK)
1606 switch (i = smatch (cmdp -> args[0], sw)) {
1608 ambigsw (cmdp -> args[0], sw);
1611 printf ("say what: ``%s'' -- type ? (or help) for help\n",
1625 static int getcmds (sw, cmdp, scansw)
1637 switch (peer2rc (rc)) {
1639 (void) pQRY (rc -> rc_data, scansw);
1643 if ((i = pCMD (rc -> rc_data, sw, cmdp)) != NOTOK)
1649 (void) kill (ppid, SIGEMT);
1653 padios (NULLCP, "%s", rc -> rc_data);
1656 (void) fmt2peer (RC_ERR, "pLOOP protocol screw-up");
1663 static int parse (buffer, cmdp)
1672 cmdp -> line[0] = 0;
1673 pp = cmdp -> args[argp++] = cmdp -> line;
1674 cmdp -> redirect = NULL;
1675 cmdp -> direction = STDIO;
1676 cmdp -> stream = NULL;
1678 for (cp = buffer; c = *cp; cp++)
1683 (void) fmt2peer (RC_EOF, "null command");
1694 cmdp -> args[argp++] = pp;
1701 switch (c = *cp++) {
1703 padvise (NULLCP, "unmatched \"");
1708 if ((c = *cp++) == 0)
1719 if ((c = *cp++) == 0) {
1721 padvise (NULLCP, "the newline character can not be quoted");
1731 if (pp == cmdp -> line) {
1732 padvise (NULLCP, "invalid null command");
1735 if (*cmdp -> args[argp - 1] == 0)
1737 cmdp -> direction = c == '>' ? CRTIO : PIPIO;
1738 if (cmdp -> direction == CRTIO && (c = *cp) == '>') {
1739 cmdp -> direction = APPIO;
1742 cmdp -> redirect = pp + 1;/* sigh */
1743 for (; c = *cp; cp++)
1747 padvise (NULLCP, cmdp -> direction != PIPIO
1748 ? "missing name for redirect"
1749 : "invalid null command");
1752 (void) strcpy (cmdp -> redirect, cp);
1753 if (cmdp -> direction != PIPIO) {
1755 if (isspace (*cp)) {
1756 padvise (NULLCP, "bad name for redirect");
1759 if (expand (cmdp -> redirect) == NOTOK)
1768 cmdp -> args[argp] = NULL;
1775 int expand (redirect)
1783 if (*redirect != '~')
1786 if (cp = index (pp = redirect + 1, '/'))
1791 if (pw = getpwnam (pp))
1794 padvise (NULLCP, "unknown user: %s", pp);
1798 (void) sprintf (path, "%s/%s", pp, cp ? cp : "");
1799 (void) strcpy (redirect, path);
1805 static int init_io (cmdp, vio)
1806 register struct Cmd *cmdp;
1815 result = initaux_io (cmdp);
1822 static int initaux_io (cmdp)
1823 register struct Cmd *cmdp;
1827 switch (cmdp -> direction) {
1833 mode = cmdp -> direction == CRTIO ? "write" : "append";
1834 if ((cmdp -> stream = fopen (cmdp -> redirect, mode)) == NULL) {
1835 padvise (cmdp -> redirect, "unable to %s ", mode);
1836 cmdp -> direction = STDIO;
1842 if ((cmdp -> stream = popen (cmdp -> redirect, "w")) == NULL) {
1843 padvise (cmdp -> redirect, "unable to pipe");
1844 cmdp -> direction = STDIO;
1847 (void) signal (SIGPIPE, pipeser);
1852 padios (NULLCP, "unknown redirection for command");
1855 (void) fflush (stdout);
1856 if (dup2 (fileno (cmdp -> stream), fileno (stdout)) == NOTOK)
1857 padios ("standard output", "unable to dup2");
1865 static fin_io (cmdp, vio)
1866 register struct Cmd *cmdp;
1879 static int finaux_io (cmdp)
1880 register struct Cmd *cmdp;
1882 switch (cmdp -> direction) {
1888 (void) fflush (stdout);
1889 (void) close (fileno (stdout));
1890 if (ferror (stdout))
1891 padvise (NULLCP, "problems writing %s", cmdp -> redirect);
1892 (void) fclose (cmdp -> stream);
1896 (void) fflush (stdout);
1897 (void) close (fileno (stdout));
1898 (void) pclose (cmdp -> stream);
1899 (void) signal (SIGPIPE, SIG_DFL);
1903 padios (NULLCP, "unknown redirection for command");
1906 if (dup2 (fileno (sp), fileno (stdout)) == NOTOK)
1907 padios ("standard output", "unable to dup2");
1910 cmdp -> direction = STDIO;
1918 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
1919 mp -> msgstats[msgnum] &= ~SELECTED;
1920 mp -> lowsel = mp -> hghsel = mp -> numsel = 0;
1938 void m_setcur (mp, msgnum)
1939 register struct msgs *mp;
1940 register int msgnum;
1942 if (mp -> curmsg == msgnum)
1945 if (mp -> curmsg && Msgs[mp -> curmsg].m_scanl) {
1946 free (Msgs[mp -> curmsg].m_scanl);
1947 Msgs[mp -> curmsg].m_scanl = NULL;
1949 if (Msgs[msgnum].m_scanl) {
1950 free (Msgs[msgnum].m_scanl);
1951 Msgs[msgnum].m_scanl = NULL;
1954 mp -> curmsg = msgnum;
1961 static TYPESIG intrser (i)
1965 (void) signal (SIGINT, intrser);
1966 #endif /* not BSD42 */
1973 longjmp (sigenv, NOTOK);
1980 static TYPESIG pipeser (i)
1984 (void) signal (SIGPIPE, pipeser);
1985 #endif /* not BSD42 */
1987 if (broken_pipe++ == 0)
1988 fprintf (stderr, "broken pipe\n");
1993 longjmp (sigenv, NOTOK);
2000 static TYPESIG quitser (i)
2004 (void) signal (SIGQUIT, quitser);
2011 longjmp (sigenv, NOTOK);
2017 static int pINI () {
2026 switch (peer2rc (rc)) {
2029 while (isspace (*bp))
2031 if (sscanf (bp, "%d", &vrsn) != 1) {
2033 (void) fmt2peer (RC_ERR, "bad init \"%s\"", rc -> rc_data);
2036 if (vrsn != RC_VRSN) {
2037 (void) fmt2peer (RC_ERR, "version %d unsupported", vrsn);
2041 while (*bp && !isspace (*bp))
2043 while (isspace (*bp))
2045 if (sscanf (bp, "%d", &numwins) != 1 || numwins <= 0)
2050 for (i = 1; i <= numwins; i++) {
2051 while (*bp && !isspace (*bp))
2053 while (isspace (*bp))
2055 if (sscanf (bp, "%d", &windows[i]) != 1 || windows[i] <= 0)
2058 (void) rc2peer (RC_ACK, 0, NULLCP);
2062 padios (NULLCP, "%s", rc -> rc_data);
2065 (void) fmt2peer (RC_ERR, "pINI protocol screw-up");
2066 done (1); /* NOTREACHED */
2074 static int pQRY (str, scansw)
2078 if (pQRY1 (scansw) == NOTOK || pQRY2 () == NOTOK)
2081 (void) rc2peer (RC_EOF, 0, NULLCP);
2087 static int pQRY1 (scansw)
2091 static int lastlow = 0,
2096 oldhgh = mp -> hghmsg;
2097 if (check_folder (scansw) && oldhgh < mp -> hghmsg) {
2098 switch (winX (STATUS)) {
2103 printf ("new messages have arrived!");
2104 (void) fflush (stdout);
2105 (void) fflush (stderr);
2106 _exit (0); /* NOTREACHED */
2109 lastlow = lastcur = lasthgh = lastnum = 0;
2113 switch (winX (DISPLAY)) {
2118 scanrange (oldhgh + 1, mp -> hghmsg);
2119 (void) fflush (stdout);
2120 (void) fflush (stderr);
2121 _exit (0); /* NOTREACHED */
2130 switch (winX (STATUS)) {
2135 printf ("%s: gap in ID:s, last seen %d, lowest present %d\n",
2136 myname ? myname : fmsh ? fmsh : mp -> foldpath, gap - 1,
2137 readid (mp -> lowmsg));
2138 (void) fflush (stdout);
2139 (void) fflush (stderr);
2140 _exit (0); /* NOTREACHED */
2147 if (mp -> lowmsg != lastlow
2148 || mp -> curmsg != lastcur
2149 || mp -> hghmsg != lasthgh
2150 || mp -> nummsg != lastnum)
2151 switch (winX (STATUS)) {
2157 (void) fflush (stdout);
2158 (void) fflush (stderr);
2159 _exit (0); /* NOTREACHED */
2162 lastlow = mp -> lowmsg;
2163 lastcur = mp -> curmsg;
2164 lasthgh = mp -> hghmsg;
2165 lastnum = mp -> nummsg;
2174 static int pQRY2 () {
2185 if (mp -> nummsg == 0 && mp -> nummsg != num)
2186 switch (winX (SCAN)) {
2192 (void) fflush (stdout);
2193 (void) fflush (stderr);
2194 _exit (0); /* NOTREACHED */
2203 j = (k = windows[SCAN]) / 2;
2204 for (msgnum = mp -> curmsg; msgnum <= mp -> hghmsg; msgnum++)
2205 if (mp -> msgstats[msgnum] & EXISTS)
2209 k = i >= k ? 1 : k - i;
2215 for (msgnum = mp -> curmsg; msgnum >= mp -> lowmsg; msgnum--)
2216 if (mp -> msgstats[msgnum] & EXISTS) {
2223 for (msgnum = mp -> curmsg + 1; msgnum <= mp -> hghmsg; msgnum++)
2224 if (mp -> msgstats[msgnum] & EXISTS) {
2228 if (n++ >= windows[SCAN])
2234 && mp -> msgstats[lo] & EXISTS
2235 && mp -> msgstats[hi] & EXISTS
2236 && (lo < mp -> curmsg
2237 || (lo == mp -> curmsg && lo == mp -> lowmsg))
2238 && (mp -> curmsg < hi
2239 || (hi == mp -> curmsg && hi == mp -> hghmsg))
2240 && hi - lo == j - i)
2243 if (mp -> curmsg != cur || modified)
2244 switch (winN (NULLCMD, SCAN, 0)) {
2252 scanrange (lo = i, hi = j);
2254 (void) winR (NULLCMD);
2263 static int pCMD (str, sw, cmdp)
2271 switch (winX (DISPLAY)) {
2276 printf ("commands:\n");
2277 printsw (ALL, sw, "");
2278 printf ("type ``quit'' to leave %s\n", invo_name);
2279 (void) fflush (stdout);
2280 (void) fflush (stderr);
2281 _exit (0); /* NOTREACHED */
2284 (void) rc2peer (RC_EOF, 0, NULLCP);
2288 if (parse (str, cmdp) == NOTOK)
2291 switch (i = smatch (cmdp -> args[0], sw)) {
2293 switch (winX (DISPLAY)) {
2298 ambigsw (cmdp -> args[0], sw);
2299 (void) fflush (stdout);
2300 (void) fflush (stderr);
2301 _exit (0); /* NOTREACHED */
2304 (void) rc2peer (RC_EOF, 0, NULLCP);
2309 (void) fmt2peer (RC_ERR,
2310 "say what: ``%s'' -- type ? (or help) for help",
2321 static int pFIN () {
2324 switch (setjmp (peerenv)) {
2326 (void) signal (SIGALRM, alrmser);
2327 (void) alarm (ALARM);
2329 status = peerwait ();
2340 static int peerwait () {
2346 switch (peer2rc (rc)) {
2349 (void) rc2peer (RC_FIN, 0, NULLCP);
2353 advise (NULLCP, "%s", rc -> rc_data);
2357 (void) fmt2peer (RC_FIN, "pLOOP protocol screw-up");
2365 static TYPESIG alrmser (i)
2368 longjmp (peerenv, DONE);
2373 static int ttyNaux (cmdp, s)
2374 register struct Cmd *cmdp;
2382 if (cmdp && init_io (cmdp, vmh) == NOTOK)
2386 (void) fseek (fp, 0L, 0);/* XXX: fseek() too tricky for our own good */
2389 switch (rc2rc (RC_TTY, s ? strlen (s) : 0, s, rc)) {
2391 vmhtty = OK; /* fall */
2396 padios (NULLCP, "%s", rc -> rc_data);/* NOTREACHED */
2399 (void) fmt2peer (RC_ERR, "pTTY protocol screw-up");
2400 done (1); /* NOTREACHED */
2404 (void) signal (SIGTSTP, tstat);
2405 #endif /* SIGTSTP */
2411 static int ttyR (cmdp)
2412 register struct Cmd *cmdp;
2418 (void) signal (SIGTSTP, SIG_IGN);
2419 #endif /* SIGTSTP */
2430 switch (rc2rc (RC_EOF, 0, NULLCP, rc)) {
2432 (void) rc2peer (RC_EOF, 0, NULLCP);
2436 padios (NULLCP, "%s", rc -> rc_data);/* NOTREACHED */
2439 (void) fmt2peer (RC_ERR, "pTTY protocol screw-up");
2440 done (1); /* NOTREACHED */
2446 static int winN (cmdp, n, eof)
2447 register struct Cmd *cmdp;
2453 char buffer[BUFSIZ];
2457 if (vmhpid == NOTOK)
2463 (void) fseek (fp, 0L, 0);/* XXX: fseek() too tricky for our own good */
2467 (void) sprintf (buffer, "%d", n);
2468 switch (str2rc (RC_WIN, buffer, rc)) {
2476 padios (NULLCP, "%s", rc -> rc_data);
2479 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2483 if (pipe (pd) == NOTOK) {
2484 (void) err2peer (RC_ERR, "pipe", "unable to");
2488 switch (vmhpid = fork ()) {
2490 (void) err2peer (RC_ERR, "fork", "unable to");
2491 (void) close (pd[0]);
2492 (void) close (pd[1]);
2496 (void) close (pd[1]);
2497 (void) signal (SIGPIPE, SIG_IGN);
2498 while ((i = read (pd[0], buffer, sizeof buffer)) > 0)
2499 switch (rc2rc (RC_DATA, i, buffer, rc)) {
2507 advise (NULLCP, "%s", rc -> rc_data);
2511 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2515 switch (rc2rc (RC_EOF, 0, NULLCP, rc)) {
2518 (void) rc2peer (RC_EOF, 0, NULLCP);
2523 advise (NULLCP, "%s", rc -> rc_data);
2528 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2533 (void) err2peer (RC_ERR, "pipe", "error reading from");
2534 (void) close (pd[0]);
2535 _exit (i != NOTOK ? i : 1);
2538 if ((vmhfd0 = dup (fileno (stdin))) == NOTOK)
2539 padios ("standard input", "unable to dup");
2540 if ((vmhfd1 = dup (fileno (stdout))) == NOTOK)
2541 padios ("standard output", "unable to dup");
2542 if ((vmhfd2 = dup (fileno (stderr))) == NOTOK)
2543 padios ("diagnostic output", "unable to dup");
2546 if ((i = open ("/dev/null", 0)) != NOTOK && i != fileno (stdin)) {
2547 (void) dup2 (i, fileno (stdin));
2551 (void) fflush (stdout);
2552 if (dup2 (pd[1], fileno (stdout)) == NOTOK)
2553 padios ("standard output", "unable to dup2");
2556 (void) fflush (stderr);
2557 if (dup2 (pd[1], fileno (stderr)) == NOTOK)
2558 padios ("diagnostic output", "unable to dup2");
2561 if (cmdp && init_io (cmdp, 0) == NOTOK)
2563 pstat = signal (SIGPIPE, pipeser);
2566 (void) close (pd[0]);
2567 (void) close (pd[1]);
2575 static int winR (cmdp)
2576 register struct Cmd *cmdp;
2586 if (dup2 (vmhfd0, fileno (stdin)) == NOTOK)
2587 padios ("standard input", "unable to dup2");
2589 (void) close (vmhfd0);
2591 (void) fflush (stdout);
2592 if (dup2 (vmhfd1, fileno (stdout)) == NOTOK)
2593 padios ("standard output", "unable to dup2");
2595 (void) close (vmhfd1);
2597 (void) fflush (stderr);
2598 if (dup2 (vmhfd2, fileno (stderr)) == NOTOK)
2599 padios ("diagnostic output", "unable to dup2");
2601 (void) close (vmhfd2);
2603 (void) signal (SIGPIPE, pstat);
2605 if ((status = pidwait (vmhpid, OK)) == 2)
2609 return (status == 0 ? OK : NOTOK);
2620 char buffer[BUFSIZ];
2627 (void) fseek (fp, 0L, 0);/* XXX: fseek() too tricky for our own good */
2629 (void) sprintf (buffer, "%d", n);
2630 switch (str2rc (RC_WIN, buffer, rc)) {
2638 padios (NULLCP, "%s", rc -> rc_data);
2641 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2645 if (pipe (pd) == NOTOK) {
2646 (void) err2peer (RC_ERR, "pipe", "unable to");
2650 switch (pid = fork ()) {
2652 (void) err2peer (RC_ERR, "fork", "unable to");
2653 (void) close (pd[0]);
2654 (void) close (pd[1]);
2658 (void) close (fileno (stdin));
2659 if ((i = open ("/dev/null", 0)) != NOTOK && i != fileno (stdin)) {
2660 (void) dup2 (i, fileno (stdin));
2663 (void) dup2 (pd[1], fileno (stdout));
2664 (void) dup2 (pd[1], fileno (stderr));
2665 (void) close (pd[0]);
2666 (void) close (pd[1]);
2671 (void) close (pd[1]);
2672 while ((i = read (pd[0], buffer, sizeof buffer)) > 0)
2673 switch (rc2rc (RC_DATA, i, buffer, rc)) {
2678 (void) close (pd[0]);
2679 (void) pidwait (pid, OK);
2683 padios (NULLCP, "%s", rc -> rc_data);
2686 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2690 switch (rc2rc (RC_EOF, 0, NULLCP, rc)) {
2695 padios (NULLCP, "%s", rc -> rc_data);
2698 (void) fmt2peer (RC_ERR, "pWIN protocol screw-up");
2702 (void) err2peer (RC_ERR, "pipe", "error reading from");
2704 (void) close (pd[0]);
2705 (void) pidwait (pid, OK);
2706 return (i != NOTOK ? pid : NOTOK);
2714 void padios (what, fmt, a, b, c, d, e, f)
2725 (void) err2peer (RC_FIN, what, fmt, a, b, c, d, e, f);
2729 advise (what, fmt, a, b, c, d, e, f);
2737 void padvise (what, fmt, a, b, c, d, e, f)
2748 (void) err2peer (RC_ERR, what, fmt, a, b, c, d, e, f);
2750 advise (what, fmt, a, b, c, d, e, f);
2762 static char ident[] = "@@(#)$Id: msh.c,v 2.12 1992/11/04 00:49:51 jromine Exp jromine $";
2764 if (msgp >= MAXFOLDER)
2765 padios (NULLCP, "more than %d messages in %s", MAXFOLDER,
2779 static char ident[] = "@@(#)$Id: msh.c,v 2.11 1992/10/26 16:49:12 jromine Exp jromine $";
2937 static char ident[] = "@@(#)$Id: msh.c,v 2.10 1992/10/16 21:37:03 jromine Exp jromine $";
2941 static int alrmser ();
2944 static int intrser (), pipeser (), quitser ();
2948 (void) putenv ("mhfolder", mp -> foldpath);
2951 static int intrser (i)
2954 static int pipeser (i)
2957 static int quitser (i)
2960 static int alrmser (i)
2971 static char ident[] = "@@(#)$Id: msh.c,v 2.9 1992/02/03 17:57:22 jromine Exp jromine $";
2974 static int pmsh = 0; /* BPOP enabled */
2985 static char ident[] = "@@(#)$Id: msh.c,v 2.8 1992/02/03 16:36:04 jromine Exp jromine $";
3043 static char ident[] = "@@(#)$Id: msh.c,v 2.7 1992/01/31 22:17:18 jromine Exp jromine $";
3058 static char ident[] = "@@(#)$Id: msh.c,v 2.6 1992/01/31 16:33:10 jromine Exp jromine $";
3061 mp = (struct msgs *) calloc ((unsigned) 1, MSIZE (mp, 1, msgp + 1));
3064 calloc ((unsigned) 1, MSIZEX (mp, mp -> lowmsg, mp -> hghmsg));
3075 static char ident[] = "@@(#)$Id: msh.c,v 2.5 90/04/05 14:56:36 sources Exp $";
3084 mp -> msgflags = NULL;
3090 if (buffer[0] == NULL)
3093 cmdp -> line[0] = NULL;
3111 if ((c = *cp++) == NULL)
3114 if ((c = *cp++) == NULL) {
3117 if (*cmdp -> args[argp - 1] == NULL)
3138 static char ident[] = "@@(#)$Id:$";
3142 nMsgs = n + MAXFOLDER / 2;
3145 (unsigned) (nMsgs + 2) * sizeof *Msgs);
3167 if (mp -> msgstats < 0)
3173 @*** empty log message ***
3181 int intrser (), pipeser (), quitser ();
3198 @changes for SUN40 shared libraries and NNTP under bbc
3203 int (*istat) (); /* original SIGINT */
3204 static int (*pstat) (); /* current SIGPIPE */
3205 int (*qstat) (); /* original SIGQUIT */
3208 static int (*tstat) (); /* original SIGTSTP */
3214 @*** empty log message ***
3229 /* the "myname" argument is an incredible hack for the NNTP stuff */
3236 @a working NNTP version
3245 static int read_pop ()
3263 if (pop_set (pmsh1, pmsh2, cp && *cp) == NOTOK)
3269 static int read_pop () {