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. 139b50d902SRodney W. Grimes * 4. 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 479ce73e90SMike Heffner extern const struct cmd cmdtab[]; 489ce73e90SMike Heffner 499b50d902SRodney W. Grimes /* 509b50d902SRodney W. Grimes * Print the current active headings. 519b50d902SRodney W. Grimes * Don't change dot if invoker didn't give an argument. 529b50d902SRodney W. Grimes */ 539b50d902SRodney W. Grimes 549b50d902SRodney W. Grimes static int screen; 559b50d902SRodney W. Grimes 569b50d902SRodney W. Grimes int 57*640e31deSPhilippe Charnier headers(int *msgvec) 589b50d902SRodney W. Grimes { 599ce73e90SMike Heffner int n, mesg, flag, size; 609ce73e90SMike Heffner struct message *mp; 619b50d902SRodney W. Grimes 629b50d902SRodney W. Grimes size = screensize(); 639b50d902SRodney W. Grimes n = msgvec[0]; 649b50d902SRodney W. Grimes if (n != 0) 659b50d902SRodney W. Grimes screen = (n-1)/size; 669b50d902SRodney W. Grimes if (screen < 0) 679b50d902SRodney W. Grimes screen = 0; 689b50d902SRodney W. Grimes mp = &message[screen * size]; 699b50d902SRodney W. Grimes if (mp >= &message[msgCount]) 709b50d902SRodney W. Grimes mp = &message[msgCount - size]; 719b50d902SRodney W. Grimes if (mp < &message[0]) 729b50d902SRodney W. Grimes mp = &message[0]; 739b50d902SRodney W. Grimes flag = 0; 749b50d902SRodney W. Grimes mesg = mp - &message[0]; 759b50d902SRodney W. Grimes if (dot != &message[n-1]) 769b50d902SRodney W. Grimes dot = mp; 779b50d902SRodney W. Grimes for (; mp < &message[msgCount]; mp++) { 789b50d902SRodney W. Grimes mesg++; 799b50d902SRodney W. Grimes if (mp->m_flag & MDELETED) 809b50d902SRodney W. Grimes continue; 819b50d902SRodney W. Grimes if (flag++ >= size) 829b50d902SRodney W. Grimes break; 839b50d902SRodney W. Grimes printhead(mesg); 849b50d902SRodney W. Grimes } 859b50d902SRodney W. Grimes if (flag == 0) { 869b50d902SRodney W. Grimes printf("No more mail.\n"); 879b50d902SRodney W. Grimes return (1); 889b50d902SRodney W. Grimes } 899b50d902SRodney W. Grimes return (0); 909b50d902SRodney W. Grimes } 919b50d902SRodney W. Grimes 929b50d902SRodney W. Grimes /* 939b50d902SRodney W. Grimes * Scroll to the next/previous screen 949b50d902SRodney W. Grimes */ 959b50d902SRodney W. Grimes int 96*640e31deSPhilippe Charnier scroll(char arg[]) 979b50d902SRodney W. Grimes { 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 134*640e31deSPhilippe 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 149*640e31deSPhilippe Charnier from(int *msgvec) 1509b50d902SRodney W. Grimes { 1519ce73e90SMike Heffner int *ip; 1529b50d902SRodney W. Grimes 153d030d2d2SPoul-Henning Kamp for (ip = msgvec; *ip != 0; ip++) 1549b50d902SRodney W. Grimes printhead(*ip); 1559b50d902SRodney W. Grimes if (--ip >= msgvec) 1569b50d902SRodney W. Grimes dot = &message[*ip - 1]; 1579b50d902SRodney W. Grimes return (0); 1589b50d902SRodney W. Grimes } 1599b50d902SRodney W. Grimes 1609b50d902SRodney W. Grimes /* 1619b50d902SRodney W. Grimes * Print out the header of a specific message. 1629b50d902SRodney W. Grimes * This is a slight improvement to the standard one. 1639b50d902SRodney W. Grimes */ 1649b50d902SRodney W. Grimes void 165*640e31deSPhilippe Charnier printhead(int mesg) 1669b50d902SRodney W. Grimes { 1679b50d902SRodney W. Grimes struct message *mp; 1689b50d902SRodney W. Grimes char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; 1699b50d902SRodney W. Grimes char pbuf[BUFSIZ]; 1709b50d902SRodney W. Grimes struct headline hl; 1719b50d902SRodney W. Grimes int subjlen; 1729b50d902SRodney W. Grimes char *name; 1739b50d902SRodney W. Grimes 1749b50d902SRodney W. Grimes mp = &message[mesg-1]; 1759b50d902SRodney W. Grimes (void)readline(setinput(mp), headline, LINESIZE); 1769ce73e90SMike Heffner if ((subjline = hfield("subject", mp)) == NULL) 1779b50d902SRodney W. Grimes subjline = hfield("subj", mp); 1789b50d902SRodney W. Grimes /* 1799b50d902SRodney W. Grimes * Bletch! 1809b50d902SRodney W. Grimes */ 1819b50d902SRodney W. Grimes curind = dot == mp ? '>' : ' '; 1829b50d902SRodney W. Grimes dispc = ' '; 1839b50d902SRodney W. Grimes if (mp->m_flag & MSAVED) 1849b50d902SRodney W. Grimes dispc = '*'; 1859b50d902SRodney W. Grimes if (mp->m_flag & MPRESERVE) 1869b50d902SRodney W. Grimes dispc = 'P'; 1879b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == MNEW) 1889b50d902SRodney W. Grimes dispc = 'N'; 1899b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == 0) 1909b50d902SRodney W. Grimes dispc = 'U'; 1919b50d902SRodney W. Grimes if (mp->m_flag & MBOX) 1929b50d902SRodney W. Grimes dispc = 'M'; 1939b50d902SRodney W. Grimes parse(headline, &hl, pbuf); 19422694ebaSBruce Evans sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); 1959b50d902SRodney W. Grimes subjlen = screenwidth - 50 - strlen(wcount); 1969ce73e90SMike Heffner name = value("show-rcpt") != NULL ? 1979b50d902SRodney W. Grimes skin(hfield("to", mp)) : nameof(mp, 0); 1989ce73e90SMike Heffner if (subjline == NULL || subjlen < 0) /* pretty pathetic */ 1999b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s\n", 2009b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount); 2019b50d902SRodney W. Grimes else 2029b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n", 2039b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount, 2049b50d902SRodney W. Grimes subjlen, subjline); 2059b50d902SRodney W. Grimes } 2069b50d902SRodney W. Grimes 2079b50d902SRodney W. Grimes /* 2089b50d902SRodney W. Grimes * Print out the value of dot. 2099b50d902SRodney W. Grimes */ 2109b50d902SRodney W. Grimes int 211*640e31deSPhilippe Charnier pdot(void) 2129b50d902SRodney W. Grimes { 2139b50d902SRodney W. Grimes printf("%d\n", dot - &message[0] + 1); 2149b50d902SRodney W. Grimes return (0); 2159b50d902SRodney W. Grimes } 2169b50d902SRodney W. Grimes 2179b50d902SRodney W. Grimes /* 2189b50d902SRodney W. Grimes * Print out all the possible commands. 2199b50d902SRodney W. Grimes */ 2209b50d902SRodney W. Grimes int 221*640e31deSPhilippe Charnier pcmdlist(void) 2229b50d902SRodney W. Grimes { 2239ce73e90SMike Heffner const struct cmd *cp; 2249ce73e90SMike Heffner int cc; 2259b50d902SRodney W. Grimes 2269b50d902SRodney W. Grimes printf("Commands are:\n"); 2279b50d902SRodney W. Grimes for (cc = 0, cp = cmdtab; cp->c_name != NULL; cp++) { 2289b50d902SRodney W. Grimes cc += strlen(cp->c_name) + 2; 2299b50d902SRodney W. Grimes if (cc > 72) { 2309b50d902SRodney W. Grimes printf("\n"); 2319b50d902SRodney W. Grimes cc = strlen(cp->c_name) + 2; 2329b50d902SRodney W. Grimes } 2339ce73e90SMike Heffner if ((cp+1)->c_name != NULL) 2349b50d902SRodney W. Grimes printf("%s, ", cp->c_name); 2359b50d902SRodney W. Grimes else 2369b50d902SRodney W. Grimes printf("%s\n", cp->c_name); 2379b50d902SRodney W. Grimes } 2389b50d902SRodney W. Grimes return (0); 2399b50d902SRodney W. Grimes } 2409b50d902SRodney W. Grimes 2419b50d902SRodney W. Grimes /* 2429b50d902SRodney W. Grimes * Paginate messages, honor ignored fields. 2439b50d902SRodney W. Grimes */ 2449b50d902SRodney W. Grimes int 245*640e31deSPhilippe Charnier more(int *msgvec) 2469b50d902SRodney W. Grimes { 2479ce73e90SMike Heffner 2489b50d902SRodney W. Grimes return (type1(msgvec, 1, 1)); 2499b50d902SRodney W. Grimes } 2509b50d902SRodney W. Grimes 2519b50d902SRodney W. Grimes /* 2529b50d902SRodney W. Grimes * Paginate messages, even printing ignored fields. 2539b50d902SRodney W. Grimes */ 2549b50d902SRodney W. Grimes int 255*640e31deSPhilippe Charnier More(int *msgvec) 2569b50d902SRodney W. Grimes { 2579b50d902SRodney W. Grimes 2589b50d902SRodney W. Grimes return (type1(msgvec, 0, 1)); 2599b50d902SRodney W. Grimes } 2609b50d902SRodney W. Grimes 2619b50d902SRodney W. Grimes /* 2629b50d902SRodney W. Grimes * Type out messages, honor ignored fields. 2639b50d902SRodney W. Grimes */ 2649b50d902SRodney W. Grimes int 265*640e31deSPhilippe Charnier type(int *msgvec) 2669b50d902SRodney W. Grimes { 2679b50d902SRodney W. Grimes 2689b50d902SRodney W. Grimes return (type1(msgvec, 1, 0)); 2699b50d902SRodney W. Grimes } 2709b50d902SRodney W. Grimes 2719b50d902SRodney W. Grimes /* 2729b50d902SRodney W. Grimes * Type out messages, even printing ignored fields. 2739b50d902SRodney W. Grimes */ 2749b50d902SRodney W. Grimes int 275*640e31deSPhilippe Charnier Type(int *msgvec) 2769b50d902SRodney W. Grimes { 2779b50d902SRodney W. Grimes 2789b50d902SRodney W. Grimes return (type1(msgvec, 0, 0)); 2799b50d902SRodney W. Grimes } 2809b50d902SRodney W. Grimes 2819b50d902SRodney W. Grimes /* 2829b50d902SRodney W. Grimes * Type out the messages requested. 2839b50d902SRodney W. Grimes */ 284e7d53813SDiomidis Spinellis static jmp_buf pipestop; 2859b50d902SRodney W. Grimes int 286*640e31deSPhilippe Charnier type1(int *msgvec, int doign, int page) 2879b50d902SRodney W. Grimes { 2889ce73e90SMike Heffner int nlines, *ip; 2899ce73e90SMike Heffner struct message *mp; 2909ce73e90SMike Heffner char *cp; 2919b50d902SRodney W. Grimes FILE *obuf; 2929b50d902SRodney W. Grimes 2939b50d902SRodney W. Grimes obuf = stdout; 2949b50d902SRodney W. Grimes if (setjmp(pipestop)) 2959b50d902SRodney W. Grimes goto close_pipe; 2969ce73e90SMike Heffner if (value("interactive") != NULL && 2979ce73e90SMike Heffner (page || (cp = value("crt")) != NULL)) { 2989b50d902SRodney W. Grimes nlines = 0; 2999b50d902SRodney W. Grimes if (!page) { 3009b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) 3019b50d902SRodney W. Grimes nlines += message[*ip - 1].m_lines; 3029b50d902SRodney W. Grimes } 3039b50d902SRodney W. Grimes if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) { 3049b50d902SRodney W. Grimes cp = value("PAGER"); 3059b50d902SRodney W. Grimes if (cp == NULL || *cp == '\0') 3069b50d902SRodney W. Grimes cp = _PATH_MORE; 3079b50d902SRodney W. Grimes obuf = Popen(cp, "w"); 3089b50d902SRodney W. Grimes if (obuf == NULL) { 3090c3a8314SMike Heffner warnx("%s", cp); 3109b50d902SRodney W. Grimes obuf = stdout; 3119b50d902SRodney W. Grimes } else 3129ce73e90SMike Heffner (void)signal(SIGPIPE, brokpipe); 3139b50d902SRodney W. Grimes } 3149b50d902SRodney W. Grimes } 3159ce73e90SMike Heffner 3169ce73e90SMike Heffner /* 3179ce73e90SMike Heffner * Send messages to the output. 3189ce73e90SMike Heffner * 3199ce73e90SMike Heffner */ 3209b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { 3219b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3229b50d902SRodney W. Grimes touch(mp); 3239b50d902SRodney W. Grimes dot = mp; 3249ce73e90SMike Heffner if (value("quiet") == NULL) 3259b50d902SRodney W. Grimes fprintf(obuf, "Message %d:\n", *ip); 3269ce73e90SMike Heffner (void)sendmessage(mp, obuf, doign ? ignore : 0, NULL); 3279b50d902SRodney W. Grimes } 3289ce73e90SMike Heffner 3299b50d902SRodney W. Grimes close_pipe: 3309b50d902SRodney W. Grimes if (obuf != stdout) { 3319b50d902SRodney W. Grimes /* 3329b50d902SRodney W. Grimes * Ignore SIGPIPE so it can't cause a duplicate close. 3339b50d902SRodney W. Grimes */ 3349ce73e90SMike Heffner (void)signal(SIGPIPE, SIG_IGN); 3359ce73e90SMike Heffner (void)Pclose(obuf); 3369ce73e90SMike Heffner (void)signal(SIGPIPE, SIG_DFL); 3379b50d902SRodney W. Grimes } 3389b50d902SRodney W. Grimes return (0); 3399b50d902SRodney W. Grimes } 3409b50d902SRodney W. Grimes 3419b50d902SRodney W. Grimes /* 3429b50d902SRodney W. Grimes * Respond to a broken pipe signal -- 3439b50d902SRodney W. Grimes * probably caused by quitting more. 3449b50d902SRodney W. Grimes */ 3459ce73e90SMike Heffner /*ARGSUSED*/ 3469b50d902SRodney W. Grimes void 347*640e31deSPhilippe Charnier brokpipe(int signo __unused) 3489b50d902SRodney W. Grimes { 3499b50d902SRodney W. Grimes longjmp(pipestop, 1); 3509b50d902SRodney W. Grimes } 3519b50d902SRodney W. Grimes 3529b50d902SRodney W. Grimes /* 3539b50d902SRodney W. Grimes * Print the top so many lines of each desired message. 3549b50d902SRodney W. Grimes * The number of lines is taken from the variable "toplines" 3559b50d902SRodney W. Grimes * and defaults to 5. 3569b50d902SRodney W. Grimes */ 3579b50d902SRodney W. Grimes int 358*640e31deSPhilippe Charnier top(int *msgvec) 3599b50d902SRodney W. Grimes { 3609ce73e90SMike Heffner int *ip; 3619ce73e90SMike Heffner struct message *mp; 3629b50d902SRodney W. Grimes int c, topl, lines, lineb; 3639b50d902SRodney W. Grimes char *valtop, linebuf[LINESIZE]; 3649b50d902SRodney W. Grimes FILE *ibuf; 3659b50d902SRodney W. Grimes 3669b50d902SRodney W. Grimes topl = 5; 3679b50d902SRodney W. Grimes valtop = value("toplines"); 3689ce73e90SMike Heffner if (valtop != NULL) { 3699b50d902SRodney W. Grimes topl = atoi(valtop); 3709b50d902SRodney W. Grimes if (topl < 0 || topl > 10000) 3719b50d902SRodney W. Grimes topl = 5; 3729b50d902SRodney W. Grimes } 3739b50d902SRodney W. Grimes lineb = 1; 3749b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) { 3759b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3769b50d902SRodney W. Grimes touch(mp); 3779b50d902SRodney W. Grimes dot = mp; 3789ce73e90SMike Heffner if (value("quiet") == NULL) 3799b50d902SRodney W. Grimes printf("Message %d:\n", *ip); 3809b50d902SRodney W. Grimes ibuf = setinput(mp); 3819b50d902SRodney W. Grimes c = mp->m_lines; 3829b50d902SRodney W. Grimes if (!lineb) 3839b50d902SRodney W. Grimes printf("\n"); 3849b50d902SRodney W. Grimes for (lines = 0; lines < c && lines <= topl; lines++) { 3850c3a8314SMike Heffner if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) 3869b50d902SRodney W. Grimes break; 3879b50d902SRodney W. Grimes puts(linebuf); 3880c3a8314SMike Heffner lineb = strspn(linebuf, " \t") == strlen(linebuf); 3899b50d902SRodney W. Grimes } 3909b50d902SRodney W. Grimes } 3919b50d902SRodney W. Grimes return (0); 3929b50d902SRodney W. Grimes } 3939b50d902SRodney W. Grimes 3949b50d902SRodney W. Grimes /* 3959b50d902SRodney W. Grimes * Touch all the given messages so that they will 3969b50d902SRodney W. Grimes * get mboxed. 3979b50d902SRodney W. Grimes */ 3989b50d902SRodney W. Grimes int 399*640e31deSPhilippe Charnier stouch(int msgvec[]) 4009b50d902SRodney W. Grimes { 4019ce73e90SMike Heffner int *ip; 4029b50d902SRodney W. Grimes 4039b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4049b50d902SRodney W. Grimes dot = &message[*ip-1]; 4059b50d902SRodney W. Grimes dot->m_flag |= MTOUCH; 4069b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4079b50d902SRodney W. Grimes } 4089b50d902SRodney W. Grimes return (0); 4099b50d902SRodney W. Grimes } 4109b50d902SRodney W. Grimes 4119b50d902SRodney W. Grimes /* 4129b50d902SRodney W. Grimes * Make sure all passed messages get mboxed. 4139b50d902SRodney W. Grimes */ 4149b50d902SRodney W. Grimes int 415*640e31deSPhilippe Charnier mboxit(int msgvec[]) 4169b50d902SRodney W. Grimes { 4179ce73e90SMike Heffner int *ip; 4189b50d902SRodney W. Grimes 4199b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4209b50d902SRodney W. Grimes dot = &message[*ip-1]; 4219b50d902SRodney W. Grimes dot->m_flag |= MTOUCH|MBOX; 4229b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4239b50d902SRodney W. Grimes } 4249b50d902SRodney W. Grimes return (0); 4259b50d902SRodney W. Grimes } 4269b50d902SRodney W. Grimes 4279b50d902SRodney W. Grimes /* 4289b50d902SRodney W. Grimes * List the folders the user currently has. 4299b50d902SRodney W. Grimes */ 4309b50d902SRodney W. Grimes int 431*640e31deSPhilippe Charnier folders(void) 4329b50d902SRodney W. Grimes { 4330c3a8314SMike Heffner char dirname[PATHSIZE]; 4349b50d902SRodney W. Grimes char *cmd; 4359b50d902SRodney W. Grimes 4360c3a8314SMike Heffner if (getfold(dirname, sizeof(dirname)) < 0) { 4379b50d902SRodney W. Grimes printf("No value set for \"folder\"\n"); 4389ce73e90SMike Heffner return (1); 4399b50d902SRodney W. Grimes } 4409ce73e90SMike Heffner if ((cmd = value("LISTER")) == NULL) 4419b50d902SRodney W. Grimes cmd = "ls"; 4429ce73e90SMike Heffner (void)run_command(cmd, 0, -1, -1, dirname, NULL, NULL); 4439ce73e90SMike Heffner return (0); 4449b50d902SRodney W. Grimes } 445856f23edSMike Heffner 446856f23edSMike Heffner /* 447856f23edSMike Heffner * Update the mail file with any new messages that have 448856f23edSMike Heffner * come in since we started reading mail. 449856f23edSMike Heffner */ 450856f23edSMike Heffner int 451*640e31deSPhilippe Charnier inc(void *v __unused) 452856f23edSMike Heffner { 453856f23edSMike Heffner int nmsg, mdot; 454856f23edSMike Heffner 455856f23edSMike Heffner nmsg = incfile(); 456856f23edSMike Heffner 457856f23edSMike Heffner if (nmsg == 0) 458856f23edSMike Heffner printf("No new mail.\n"); 459856f23edSMike Heffner else if (nmsg > 0) { 460856f23edSMike Heffner mdot = newfileinfo(msgCount - nmsg); 461856f23edSMike Heffner dot = &message[mdot - 1]; 462856f23edSMike Heffner } else 463856f23edSMike Heffner printf("\"inc\" command failed...\n"); 464856f23edSMike Heffner 465856f23edSMike Heffner return (0); 466856f23edSMike Heffner } 467