19b50d902SRodney W. Grimes /*- 29b50d902SRodney W. Grimes * Copyright (c) 1980, 1993 39b50d902SRodney W. Grimes * The Regents of the University of California. All rights reserved. 49b50d902SRodney W. Grimes * 59b50d902SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 69b50d902SRodney W. Grimes * modification, are permitted provided that the following conditions 79b50d902SRodney W. Grimes * are met: 89b50d902SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 99b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 109b50d902SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 119b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 129b50d902SRodney W. Grimes * documentation and/or other materials provided with the distribution. 13*fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 149b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 159b50d902SRodney W. Grimes * without specific prior written permission. 169b50d902SRodney W. Grimes * 179b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 189b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 199b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 209b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 219b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 229b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 239b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 249b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 259b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 269b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 279b50d902SRodney W. Grimes * SUCH DAMAGE. 289b50d902SRodney W. Grimes */ 299b50d902SRodney W. Grimes 309b50d902SRodney W. Grimes #ifndef lint 310c3a8314SMike Heffner #if 0 32856f23edSMike Heffner static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95"; 330c3a8314SMike Heffner #endif 349b50d902SRodney W. Grimes #endif /* not lint */ 35e026a48cSDavid E. O'Brien #include <sys/cdefs.h> 36e026a48cSDavid E. O'Brien __FBSDID("$FreeBSD$"); 379b50d902SRodney W. Grimes 389b50d902SRodney W. Grimes #include "rcv.h" 399b50d902SRodney W. Grimes #include "extern.h" 409b50d902SRodney W. Grimes 419b50d902SRodney W. Grimes /* 429b50d902SRodney W. Grimes * Mail -- a mail program 439b50d902SRodney W. Grimes * 449b50d902SRodney W. Grimes * User commands. 459b50d902SRodney W. Grimes */ 469b50d902SRodney W. Grimes 479b50d902SRodney W. Grimes /* 489b50d902SRodney W. Grimes * Print the current active headings. 499b50d902SRodney W. Grimes * Don't change dot if invoker didn't give an argument. 509b50d902SRodney W. Grimes */ 519b50d902SRodney W. Grimes 529b50d902SRodney W. Grimes static int screen; 539b50d902SRodney W. Grimes 549b50d902SRodney W. Grimes int 55b948550dSPedro F. Giffuni headers(void *v) 569b50d902SRodney W. Grimes { 57b948550dSPedro F. Giffuni int *msgvec = v; 589ce73e90SMike Heffner int n, mesg, flag, size; 599ce73e90SMike Heffner struct message *mp; 609b50d902SRodney W. Grimes 619b50d902SRodney W. Grimes size = screensize(); 629b50d902SRodney W. Grimes n = msgvec[0]; 639b50d902SRodney W. Grimes if (n != 0) 649b50d902SRodney W. Grimes screen = (n-1)/size; 659b50d902SRodney W. Grimes if (screen < 0) 669b50d902SRodney W. Grimes screen = 0; 679b50d902SRodney W. Grimes mp = &message[screen * size]; 689b50d902SRodney W. Grimes if (mp >= &message[msgCount]) 699b50d902SRodney W. Grimes mp = &message[msgCount - size]; 709b50d902SRodney W. Grimes if (mp < &message[0]) 719b50d902SRodney W. Grimes mp = &message[0]; 729b50d902SRodney W. Grimes flag = 0; 739b50d902SRodney W. Grimes mesg = mp - &message[0]; 749b50d902SRodney W. Grimes if (dot != &message[n-1]) 759b50d902SRodney W. Grimes dot = mp; 769b50d902SRodney W. Grimes for (; mp < &message[msgCount]; mp++) { 779b50d902SRodney W. Grimes mesg++; 789b50d902SRodney W. Grimes if (mp->m_flag & MDELETED) 799b50d902SRodney W. Grimes continue; 809b50d902SRodney W. Grimes if (flag++ >= size) 819b50d902SRodney W. Grimes break; 829b50d902SRodney W. Grimes printhead(mesg); 839b50d902SRodney W. Grimes } 849b50d902SRodney W. Grimes if (flag == 0) { 859b50d902SRodney W. Grimes printf("No more mail.\n"); 869b50d902SRodney W. Grimes return (1); 879b50d902SRodney W. Grimes } 889b50d902SRodney W. Grimes return (0); 899b50d902SRodney W. Grimes } 909b50d902SRodney W. Grimes 919b50d902SRodney W. Grimes /* 929b50d902SRodney W. Grimes * Scroll to the next/previous screen 939b50d902SRodney W. Grimes */ 949b50d902SRodney W. Grimes int 95b948550dSPedro F. Giffuni scroll(void *v) 969b50d902SRodney W. Grimes { 97b948550dSPedro F. Giffuni char *arg = v; 989ce73e90SMike Heffner int s, size; 999b50d902SRodney W. Grimes int cur[1]; 1009b50d902SRodney W. Grimes 1019b50d902SRodney W. Grimes cur[0] = 0; 1029b50d902SRodney W. Grimes size = screensize(); 1039b50d902SRodney W. Grimes s = screen; 1049b50d902SRodney W. Grimes switch (*arg) { 1059b50d902SRodney W. Grimes case 0: 1069b50d902SRodney W. Grimes case '+': 1079b50d902SRodney W. Grimes s++; 108856f23edSMike Heffner if (s * size >= msgCount) { 1099b50d902SRodney W. Grimes printf("On last screenful of messages\n"); 1109b50d902SRodney W. Grimes return (0); 1119b50d902SRodney W. Grimes } 1129b50d902SRodney W. Grimes screen = s; 1139b50d902SRodney W. Grimes break; 1149b50d902SRodney W. Grimes 1159b50d902SRodney W. Grimes case '-': 1169b50d902SRodney W. Grimes if (--s < 0) { 1179b50d902SRodney W. Grimes printf("On first screenful of messages\n"); 1189b50d902SRodney W. Grimes return (0); 1199b50d902SRodney W. Grimes } 1209b50d902SRodney W. Grimes screen = s; 1219b50d902SRodney W. Grimes break; 1229b50d902SRodney W. Grimes 1239b50d902SRodney W. Grimes default: 1249b50d902SRodney W. Grimes printf("Unrecognized scrolling command \"%s\"\n", arg); 1259b50d902SRodney W. Grimes return (1); 1269b50d902SRodney W. Grimes } 1279b50d902SRodney W. Grimes return (headers(cur)); 1289b50d902SRodney W. Grimes } 1299b50d902SRodney W. Grimes 1309b50d902SRodney W. Grimes /* 1319b50d902SRodney W. Grimes * Compute screen size. 1329b50d902SRodney W. Grimes */ 1339b50d902SRodney W. Grimes int 134640e31deSPhilippe Charnier screensize(void) 1359b50d902SRodney W. Grimes { 1369b50d902SRodney W. Grimes int s; 1379b50d902SRodney W. Grimes char *cp; 1389b50d902SRodney W. Grimes 1399ce73e90SMike Heffner if ((cp = value("screen")) != NULL && (s = atoi(cp)) > 0) 1409ce73e90SMike Heffner return (s); 1419ce73e90SMike Heffner return (screenheight - 4); 1429b50d902SRodney W. Grimes } 1439b50d902SRodney W. Grimes 1449b50d902SRodney W. Grimes /* 1459b50d902SRodney W. Grimes * Print out the headlines for each message 1469b50d902SRodney W. Grimes * in the passed message list. 1479b50d902SRodney W. Grimes */ 1489b50d902SRodney W. Grimes int 149b948550dSPedro F. Giffuni from(void *v) 1509b50d902SRodney W. Grimes { 151b948550dSPedro F. Giffuni int *msgvec = v; 1529ce73e90SMike Heffner int *ip; 1539b50d902SRodney W. Grimes 154d030d2d2SPoul-Henning Kamp for (ip = msgvec; *ip != 0; ip++) 1559b50d902SRodney W. Grimes printhead(*ip); 1569b50d902SRodney W. Grimes if (--ip >= msgvec) 1579b50d902SRodney W. Grimes dot = &message[*ip - 1]; 1589b50d902SRodney W. Grimes return (0); 1599b50d902SRodney W. Grimes } 1609b50d902SRodney W. Grimes 1619b50d902SRodney W. Grimes /* 1629b50d902SRodney W. Grimes * Print out the header of a specific message. 1639b50d902SRodney W. Grimes * This is a slight improvement to the standard one. 1649b50d902SRodney W. Grimes */ 1659b50d902SRodney W. Grimes void 166640e31deSPhilippe Charnier printhead(int mesg) 1679b50d902SRodney W. Grimes { 1689b50d902SRodney W. Grimes struct message *mp; 1699b50d902SRodney W. Grimes char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; 1709b50d902SRodney W. Grimes char pbuf[BUFSIZ]; 1719b50d902SRodney W. Grimes struct headline hl; 1729b50d902SRodney W. Grimes int subjlen; 1739b50d902SRodney W. Grimes char *name; 1749b50d902SRodney W. Grimes 1759b50d902SRodney W. Grimes mp = &message[mesg-1]; 1769b50d902SRodney W. Grimes (void)readline(setinput(mp), headline, LINESIZE); 1779ce73e90SMike Heffner if ((subjline = hfield("subject", mp)) == NULL) 1789b50d902SRodney W. Grimes subjline = hfield("subj", mp); 1799b50d902SRodney W. Grimes /* 1809b50d902SRodney W. Grimes * Bletch! 1819b50d902SRodney W. Grimes */ 1829b50d902SRodney W. Grimes curind = dot == mp ? '>' : ' '; 1839b50d902SRodney W. Grimes dispc = ' '; 1849b50d902SRodney W. Grimes if (mp->m_flag & MSAVED) 1859b50d902SRodney W. Grimes dispc = '*'; 1869b50d902SRodney W. Grimes if (mp->m_flag & MPRESERVE) 1879b50d902SRodney W. Grimes dispc = 'P'; 1889b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == MNEW) 1899b50d902SRodney W. Grimes dispc = 'N'; 1909b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == 0) 1919b50d902SRodney W. Grimes dispc = 'U'; 1929b50d902SRodney W. Grimes if (mp->m_flag & MBOX) 1939b50d902SRodney W. Grimes dispc = 'M'; 1949b50d902SRodney W. Grimes parse(headline, &hl, pbuf); 19522694ebaSBruce Evans sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); 1969b50d902SRodney W. Grimes subjlen = screenwidth - 50 - strlen(wcount); 1979ce73e90SMike Heffner name = value("show-rcpt") != NULL ? 1989b50d902SRodney W. Grimes skin(hfield("to", mp)) : nameof(mp, 0); 1999ce73e90SMike Heffner if (subjline == NULL || subjlen < 0) /* pretty pathetic */ 2009b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s\n", 2019b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount); 2029b50d902SRodney W. Grimes else 2039b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n", 2049b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount, 2059b50d902SRodney W. Grimes subjlen, subjline); 2069b50d902SRodney W. Grimes } 2079b50d902SRodney W. Grimes 2089b50d902SRodney W. Grimes /* 2099b50d902SRodney W. Grimes * Print out the value of dot. 2109b50d902SRodney W. Grimes */ 2119b50d902SRodney W. Grimes int 212640e31deSPhilippe Charnier pdot(void) 2139b50d902SRodney W. Grimes { 214081aa516SDimitry Andric printf("%td\n", dot - &message[0] + 1); 2159b50d902SRodney W. Grimes return (0); 2169b50d902SRodney W. Grimes } 2179b50d902SRodney W. Grimes 2189b50d902SRodney W. Grimes /* 2199b50d902SRodney W. Grimes * Print out all the possible commands. 2209b50d902SRodney W. Grimes */ 2219b50d902SRodney W. Grimes int 222640e31deSPhilippe Charnier pcmdlist(void) 2239b50d902SRodney W. Grimes { 224b948550dSPedro F. Giffuni extern const struct cmd cmdtab[]; 2259ce73e90SMike Heffner const struct cmd *cp; 2269ce73e90SMike Heffner int cc; 2279b50d902SRodney W. Grimes 2289b50d902SRodney W. Grimes printf("Commands are:\n"); 2299b50d902SRodney W. Grimes for (cc = 0, cp = cmdtab; cp->c_name != NULL; cp++) { 2309b50d902SRodney W. Grimes cc += strlen(cp->c_name) + 2; 2319b50d902SRodney W. Grimes if (cc > 72) { 2329b50d902SRodney W. Grimes printf("\n"); 2339b50d902SRodney W. Grimes cc = strlen(cp->c_name) + 2; 2349b50d902SRodney W. Grimes } 2359ce73e90SMike Heffner if ((cp+1)->c_name != NULL) 2369b50d902SRodney W. Grimes printf("%s, ", cp->c_name); 2379b50d902SRodney W. Grimes else 2389b50d902SRodney W. Grimes printf("%s\n", cp->c_name); 2399b50d902SRodney W. Grimes } 2409b50d902SRodney W. Grimes return (0); 2419b50d902SRodney W. Grimes } 2429b50d902SRodney W. Grimes 2439b50d902SRodney W. Grimes /* 2449b50d902SRodney W. Grimes * Paginate messages, honor ignored fields. 2459b50d902SRodney W. Grimes */ 2469b50d902SRodney W. Grimes int 247b948550dSPedro F. Giffuni more(void *v) 2489b50d902SRodney W. Grimes { 249b948550dSPedro F. Giffuni int *msgvec = v; 2509ce73e90SMike Heffner 2519b50d902SRodney W. Grimes return (type1(msgvec, 1, 1)); 2529b50d902SRodney W. Grimes } 2539b50d902SRodney W. Grimes 2549b50d902SRodney W. Grimes /* 2559b50d902SRodney W. Grimes * Paginate messages, even printing ignored fields. 2569b50d902SRodney W. Grimes */ 2579b50d902SRodney W. Grimes int 258b948550dSPedro F. Giffuni More(void *v) 2599b50d902SRodney W. Grimes { 260b948550dSPedro F. Giffuni int *msgvec = v; 2619b50d902SRodney W. Grimes 2629b50d902SRodney W. Grimes return (type1(msgvec, 0, 1)); 2639b50d902SRodney W. Grimes } 2649b50d902SRodney W. Grimes 2659b50d902SRodney W. Grimes /* 2669b50d902SRodney W. Grimes * Type out messages, honor ignored fields. 2679b50d902SRodney W. Grimes */ 2689b50d902SRodney W. Grimes int 269b948550dSPedro F. Giffuni type(void *v) 2709b50d902SRodney W. Grimes { 271b948550dSPedro F. Giffuni int *msgvec = v; 2729b50d902SRodney W. Grimes 2739b50d902SRodney W. Grimes return (type1(msgvec, 1, 0)); 2749b50d902SRodney W. Grimes } 2759b50d902SRodney W. Grimes 2769b50d902SRodney W. Grimes /* 2779b50d902SRodney W. Grimes * Type out messages, even printing ignored fields. 2789b50d902SRodney W. Grimes */ 2799b50d902SRodney W. Grimes int 280b948550dSPedro F. Giffuni Type(void *v) 2819b50d902SRodney W. Grimes { 282b948550dSPedro F. Giffuni int *msgvec = v; 2839b50d902SRodney W. Grimes 2849b50d902SRodney W. Grimes return (type1(msgvec, 0, 0)); 2859b50d902SRodney W. Grimes } 2869b50d902SRodney W. Grimes 2879b50d902SRodney W. Grimes /* 2889b50d902SRodney W. Grimes * Type out the messages requested. 2899b50d902SRodney W. Grimes */ 290e7d53813SDiomidis Spinellis static jmp_buf pipestop; 2919b50d902SRodney W. Grimes int 292640e31deSPhilippe Charnier type1(int *msgvec, int doign, int page) 2939b50d902SRodney W. Grimes { 2949ce73e90SMike Heffner int nlines, *ip; 2959ce73e90SMike Heffner struct message *mp; 2969ce73e90SMike Heffner char *cp; 2979b50d902SRodney W. Grimes FILE *obuf; 2989b50d902SRodney W. Grimes 2999b50d902SRodney W. Grimes obuf = stdout; 3009b50d902SRodney W. Grimes if (setjmp(pipestop)) 3019b50d902SRodney W. Grimes goto close_pipe; 3029ce73e90SMike Heffner if (value("interactive") != NULL && 3039ce73e90SMike Heffner (page || (cp = value("crt")) != NULL)) { 3049b50d902SRodney W. Grimes nlines = 0; 3059b50d902SRodney W. Grimes if (!page) { 3069b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) 3079b50d902SRodney W. Grimes nlines += message[*ip - 1].m_lines; 3089b50d902SRodney W. Grimes } 3099b50d902SRodney W. Grimes if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) { 3109b50d902SRodney W. Grimes cp = value("PAGER"); 3119b50d902SRodney W. Grimes if (cp == NULL || *cp == '\0') 3129b50d902SRodney W. Grimes cp = _PATH_MORE; 3139b50d902SRodney W. Grimes obuf = Popen(cp, "w"); 3149b50d902SRodney W. Grimes if (obuf == NULL) { 3150c3a8314SMike Heffner warnx("%s", cp); 3169b50d902SRodney W. Grimes obuf = stdout; 3179b50d902SRodney W. Grimes } else 3189ce73e90SMike Heffner (void)signal(SIGPIPE, brokpipe); 3199b50d902SRodney W. Grimes } 3209b50d902SRodney W. Grimes } 3219ce73e90SMike Heffner 3229ce73e90SMike Heffner /* 3239ce73e90SMike Heffner * Send messages to the output. 3249ce73e90SMike Heffner * 3259ce73e90SMike Heffner */ 3269b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { 3279b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3289b50d902SRodney W. Grimes touch(mp); 3299b50d902SRodney W. Grimes dot = mp; 3309ce73e90SMike Heffner if (value("quiet") == NULL) 3319b50d902SRodney W. Grimes fprintf(obuf, "Message %d:\n", *ip); 3329ce73e90SMike Heffner (void)sendmessage(mp, obuf, doign ? ignore : 0, NULL); 3339b50d902SRodney W. Grimes } 3349ce73e90SMike Heffner 3359b50d902SRodney W. Grimes close_pipe: 3369b50d902SRodney W. Grimes if (obuf != stdout) { 3379b50d902SRodney W. Grimes /* 3389b50d902SRodney W. Grimes * Ignore SIGPIPE so it can't cause a duplicate close. 3399b50d902SRodney W. Grimes */ 3409ce73e90SMike Heffner (void)signal(SIGPIPE, SIG_IGN); 3419ce73e90SMike Heffner (void)Pclose(obuf); 3429ce73e90SMike Heffner (void)signal(SIGPIPE, SIG_DFL); 3439b50d902SRodney W. Grimes } 3449b50d902SRodney W. Grimes return (0); 3459b50d902SRodney W. Grimes } 3469b50d902SRodney W. Grimes 3479b50d902SRodney W. Grimes /* 3489b50d902SRodney W. Grimes * Respond to a broken pipe signal -- 3499b50d902SRodney W. Grimes * probably caused by quitting more. 3509b50d902SRodney W. Grimes */ 3519ce73e90SMike Heffner /*ARGSUSED*/ 3529b50d902SRodney W. Grimes void 353640e31deSPhilippe Charnier brokpipe(int signo __unused) 3549b50d902SRodney W. Grimes { 3559b50d902SRodney W. Grimes longjmp(pipestop, 1); 3569b50d902SRodney W. Grimes } 3579b50d902SRodney W. Grimes 3589b50d902SRodney W. Grimes /* 3599b50d902SRodney W. Grimes * Print the top so many lines of each desired message. 3609b50d902SRodney W. Grimes * The number of lines is taken from the variable "toplines" 3619b50d902SRodney W. Grimes * and defaults to 5. 3629b50d902SRodney W. Grimes */ 3639b50d902SRodney W. Grimes int 364b948550dSPedro F. Giffuni top(void *v) 3659b50d902SRodney W. Grimes { 366b948550dSPedro F. Giffuni int *msgvec = v; 3679ce73e90SMike Heffner int *ip; 3689ce73e90SMike Heffner struct message *mp; 3699b50d902SRodney W. Grimes int c, topl, lines, lineb; 3709b50d902SRodney W. Grimes char *valtop, linebuf[LINESIZE]; 3719b50d902SRodney W. Grimes FILE *ibuf; 3729b50d902SRodney W. Grimes 3739b50d902SRodney W. Grimes topl = 5; 3749b50d902SRodney W. Grimes valtop = value("toplines"); 3759ce73e90SMike Heffner if (valtop != NULL) { 3769b50d902SRodney W. Grimes topl = atoi(valtop); 3779b50d902SRodney W. Grimes if (topl < 0 || topl > 10000) 3789b50d902SRodney W. Grimes topl = 5; 3799b50d902SRodney W. Grimes } 3809b50d902SRodney W. Grimes lineb = 1; 3819b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) { 3829b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3839b50d902SRodney W. Grimes touch(mp); 3849b50d902SRodney W. Grimes dot = mp; 3859ce73e90SMike Heffner if (value("quiet") == NULL) 3869b50d902SRodney W. Grimes printf("Message %d:\n", *ip); 3879b50d902SRodney W. Grimes ibuf = setinput(mp); 3889b50d902SRodney W. Grimes c = mp->m_lines; 3899b50d902SRodney W. Grimes if (!lineb) 3909b50d902SRodney W. Grimes printf("\n"); 3919b50d902SRodney W. Grimes for (lines = 0; lines < c && lines <= topl; lines++) { 3920c3a8314SMike Heffner if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) 3939b50d902SRodney W. Grimes break; 3949b50d902SRodney W. Grimes puts(linebuf); 3950c3a8314SMike Heffner lineb = strspn(linebuf, " \t") == strlen(linebuf); 3969b50d902SRodney W. Grimes } 3979b50d902SRodney W. Grimes } 3989b50d902SRodney W. Grimes return (0); 3999b50d902SRodney W. Grimes } 4009b50d902SRodney W. Grimes 4019b50d902SRodney W. Grimes /* 4029b50d902SRodney W. Grimes * Touch all the given messages so that they will 4039b50d902SRodney W. Grimes * get mboxed. 4049b50d902SRodney W. Grimes */ 4059b50d902SRodney W. Grimes int 406b948550dSPedro F. Giffuni stouch(void *v) 4079b50d902SRodney W. Grimes { 408b948550dSPedro F. Giffuni int *msgvec = v; 4099ce73e90SMike Heffner int *ip; 4109b50d902SRodney W. Grimes 4119b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4129b50d902SRodney W. Grimes dot = &message[*ip-1]; 4139b50d902SRodney W. Grimes dot->m_flag |= MTOUCH; 4149b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4159b50d902SRodney W. Grimes } 4169b50d902SRodney W. Grimes return (0); 4179b50d902SRodney W. Grimes } 4189b50d902SRodney W. Grimes 4199b50d902SRodney W. Grimes /* 4209b50d902SRodney W. Grimes * Make sure all passed messages get mboxed. 4219b50d902SRodney W. Grimes */ 4229b50d902SRodney W. Grimes int 423b948550dSPedro F. Giffuni mboxit(void *v) 4249b50d902SRodney W. Grimes { 425b948550dSPedro F. Giffuni int *msgvec = v; 4269ce73e90SMike Heffner int *ip; 4279b50d902SRodney W. Grimes 4289b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4299b50d902SRodney W. Grimes dot = &message[*ip-1]; 4309b50d902SRodney W. Grimes dot->m_flag |= MTOUCH|MBOX; 4319b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4329b50d902SRodney W. Grimes } 4339b50d902SRodney W. Grimes return (0); 4349b50d902SRodney W. Grimes } 4359b50d902SRodney W. Grimes 4369b50d902SRodney W. Grimes /* 4379b50d902SRodney W. Grimes * List the folders the user currently has. 4389b50d902SRodney W. Grimes */ 4399b50d902SRodney W. Grimes int 440640e31deSPhilippe Charnier folders(void) 4419b50d902SRodney W. Grimes { 4420c3a8314SMike Heffner char dirname[PATHSIZE]; 4439b50d902SRodney W. Grimes char *cmd; 4449b50d902SRodney W. Grimes 4450c3a8314SMike Heffner if (getfold(dirname, sizeof(dirname)) < 0) { 4469b50d902SRodney W. Grimes printf("No value set for \"folder\"\n"); 4479ce73e90SMike Heffner return (1); 4489b50d902SRodney W. Grimes } 4499ce73e90SMike Heffner if ((cmd = value("LISTER")) == NULL) 4509b50d902SRodney W. Grimes cmd = "ls"; 451b22a8699SPedro F. Giffuni (void)run_command(cmd, 0, -1, -1, dirname, NULL); 4529ce73e90SMike Heffner return (0); 4539b50d902SRodney W. Grimes } 454856f23edSMike Heffner 455856f23edSMike Heffner /* 456856f23edSMike Heffner * Update the mail file with any new messages that have 457856f23edSMike Heffner * come in since we started reading mail. 458856f23edSMike Heffner */ 459856f23edSMike Heffner int 460640e31deSPhilippe Charnier inc(void *v __unused) 461856f23edSMike Heffner { 462856f23edSMike Heffner int nmsg, mdot; 463856f23edSMike Heffner 464856f23edSMike Heffner nmsg = incfile(); 465856f23edSMike Heffner 466856f23edSMike Heffner if (nmsg == 0) 467856f23edSMike Heffner printf("No new mail.\n"); 468856f23edSMike Heffner else if (nmsg > 0) { 469856f23edSMike Heffner mdot = newfileinfo(msgCount - nmsg); 470856f23edSMike Heffner dot = &message[mdot - 1]; 471856f23edSMike Heffner } else 472856f23edSMike Heffner printf("\"inc\" command failed...\n"); 473856f23edSMike Heffner 474856f23edSMike Heffner return (0); 475856f23edSMike Heffner } 476