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 * 3. All advertising materials mentioning features or use of this software 149b50d902SRodney W. Grimes * must display the following acknowledgement: 159b50d902SRodney W. Grimes * This product includes software developed by the University of 169b50d902SRodney W. Grimes * California, Berkeley and its contributors. 179b50d902SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 189b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 199b50d902SRodney W. Grimes * without specific prior written permission. 209b50d902SRodney W. Grimes * 219b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 229b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 239b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 249b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 259b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 269b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 279b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 289b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 299b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 309b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 319b50d902SRodney W. Grimes * SUCH DAMAGE. 329b50d902SRodney W. Grimes */ 339b50d902SRodney W. Grimes 349b50d902SRodney W. Grimes #ifndef lint 350c3a8314SMike Heffner #if 0 369b50d902SRodney W. Grimes static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93"; 370c3a8314SMike Heffner #endif 380c3a8314SMike Heffner static const char rcsid[] = 390c3a8314SMike Heffner "$FreeBSD$"; 409b50d902SRodney W. Grimes #endif /* not lint */ 419b50d902SRodney W. Grimes 429b50d902SRodney W. Grimes #include "rcv.h" 439b50d902SRodney W. Grimes #include "extern.h" 449b50d902SRodney W. Grimes 459b50d902SRodney W. Grimes /* 469b50d902SRodney W. Grimes * Mail -- a mail program 479b50d902SRodney W. Grimes * 489b50d902SRodney W. Grimes * User commands. 499b50d902SRodney W. Grimes */ 509b50d902SRodney W. Grimes 519b50d902SRodney W. Grimes /* 529b50d902SRodney W. Grimes * Print the current active headings. 539b50d902SRodney W. Grimes * Don't change dot if invoker didn't give an argument. 549b50d902SRodney W. Grimes */ 559b50d902SRodney W. Grimes 569b50d902SRodney W. Grimes static int screen; 579b50d902SRodney W. Grimes 589b50d902SRodney W. Grimes int 599b50d902SRodney W. Grimes headers(msgvec) 609b50d902SRodney W. Grimes int *msgvec; 619b50d902SRodney W. Grimes { 629b50d902SRodney W. Grimes register int n, mesg, flag; 639b50d902SRodney W. Grimes register struct message *mp; 649b50d902SRodney W. Grimes int size; 659b50d902SRodney W. Grimes 669b50d902SRodney W. Grimes size = screensize(); 679b50d902SRodney W. Grimes n = msgvec[0]; 689b50d902SRodney W. Grimes if (n != 0) 699b50d902SRodney W. Grimes screen = (n-1)/size; 709b50d902SRodney W. Grimes if (screen < 0) 719b50d902SRodney W. Grimes screen = 0; 729b50d902SRodney W. Grimes mp = &message[screen * size]; 739b50d902SRodney W. Grimes if (mp >= &message[msgCount]) 749b50d902SRodney W. Grimes mp = &message[msgCount - size]; 759b50d902SRodney W. Grimes if (mp < &message[0]) 769b50d902SRodney W. Grimes mp = &message[0]; 779b50d902SRodney W. Grimes flag = 0; 789b50d902SRodney W. Grimes mesg = mp - &message[0]; 799b50d902SRodney W. Grimes if (dot != &message[n-1]) 809b50d902SRodney W. Grimes dot = mp; 819b50d902SRodney W. Grimes for (; mp < &message[msgCount]; mp++) { 829b50d902SRodney W. Grimes mesg++; 839b50d902SRodney W. Grimes if (mp->m_flag & MDELETED) 849b50d902SRodney W. Grimes continue; 859b50d902SRodney W. Grimes if (flag++ >= size) 869b50d902SRodney W. Grimes break; 879b50d902SRodney W. Grimes printhead(mesg); 889b50d902SRodney W. Grimes } 899b50d902SRodney W. Grimes if (flag == 0) { 909b50d902SRodney W. Grimes printf("No more mail.\n"); 919b50d902SRodney W. Grimes return(1); 929b50d902SRodney W. Grimes } 939b50d902SRodney W. Grimes return(0); 949b50d902SRodney W. Grimes } 959b50d902SRodney W. Grimes 969b50d902SRodney W. Grimes /* 979b50d902SRodney W. Grimes * Scroll to the next/previous screen 989b50d902SRodney W. Grimes */ 999b50d902SRodney W. Grimes int 1009b50d902SRodney W. Grimes scroll(arg) 1019b50d902SRodney W. Grimes char arg[]; 1029b50d902SRodney W. Grimes { 1039b50d902SRodney W. Grimes register int s, size; 1049b50d902SRodney W. Grimes int cur[1]; 1059b50d902SRodney W. Grimes 1069b50d902SRodney W. Grimes cur[0] = 0; 1079b50d902SRodney W. Grimes size = screensize(); 1089b50d902SRodney W. Grimes s = screen; 1099b50d902SRodney W. Grimes switch (*arg) { 1109b50d902SRodney W. Grimes case 0: 1119b50d902SRodney W. Grimes case '+': 1129b50d902SRodney W. Grimes s++; 1139b50d902SRodney W. Grimes if (s * size > msgCount) { 1149b50d902SRodney W. Grimes printf("On last screenful of messages\n"); 1159b50d902SRodney W. Grimes return(0); 1169b50d902SRodney W. Grimes } 1179b50d902SRodney W. Grimes screen = s; 1189b50d902SRodney W. Grimes break; 1199b50d902SRodney W. Grimes 1209b50d902SRodney W. Grimes case '-': 1219b50d902SRodney W. Grimes if (--s < 0) { 1229b50d902SRodney W. Grimes printf("On first screenful of messages\n"); 1239b50d902SRodney W. Grimes return(0); 1249b50d902SRodney W. Grimes } 1259b50d902SRodney W. Grimes screen = s; 1269b50d902SRodney W. Grimes break; 1279b50d902SRodney W. Grimes 1289b50d902SRodney W. Grimes default: 1299b50d902SRodney W. Grimes printf("Unrecognized scrolling command \"%s\"\n", arg); 1309b50d902SRodney W. Grimes return(1); 1319b50d902SRodney W. Grimes } 1329b50d902SRodney W. Grimes return(headers(cur)); 1339b50d902SRodney W. Grimes } 1349b50d902SRodney W. Grimes 1359b50d902SRodney W. Grimes /* 1369b50d902SRodney W. Grimes * Compute screen size. 1379b50d902SRodney W. Grimes */ 1389b50d902SRodney W. Grimes int 1399b50d902SRodney W. Grimes screensize() 1409b50d902SRodney W. Grimes { 1419b50d902SRodney W. Grimes int s; 1429b50d902SRodney W. Grimes char *cp; 1439b50d902SRodney W. Grimes 1449b50d902SRodney W. Grimes if ((cp = value("screen")) != NOSTR && (s = atoi(cp)) > 0) 1459b50d902SRodney W. Grimes return s; 1469b50d902SRodney W. Grimes return screenheight - 4; 1479b50d902SRodney W. Grimes } 1489b50d902SRodney W. Grimes 1499b50d902SRodney W. Grimes /* 1509b50d902SRodney W. Grimes * Print out the headlines for each message 1519b50d902SRodney W. Grimes * in the passed message list. 1529b50d902SRodney W. Grimes */ 1539b50d902SRodney W. Grimes int 1549b50d902SRodney W. Grimes from(msgvec) 1559b50d902SRodney W. Grimes int *msgvec; 1569b50d902SRodney W. Grimes { 1579b50d902SRodney W. Grimes register int *ip; 1589b50d902SRodney W. Grimes 159d030d2d2SPoul-Henning Kamp for (ip = msgvec; *ip != 0; ip++) 1609b50d902SRodney W. Grimes printhead(*ip); 1619b50d902SRodney W. Grimes if (--ip >= msgvec) 1629b50d902SRodney W. Grimes dot = &message[*ip - 1]; 1639b50d902SRodney W. Grimes return(0); 1649b50d902SRodney W. Grimes } 1659b50d902SRodney W. Grimes 1669b50d902SRodney W. Grimes /* 1679b50d902SRodney W. Grimes * Print out the header of a specific message. 1689b50d902SRodney W. Grimes * This is a slight improvement to the standard one. 1699b50d902SRodney W. Grimes */ 1709b50d902SRodney W. Grimes void 1719b50d902SRodney W. Grimes printhead(mesg) 1729b50d902SRodney W. Grimes int mesg; 1739b50d902SRodney W. Grimes { 1749b50d902SRodney W. Grimes struct message *mp; 1759b50d902SRodney W. Grimes char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; 1769b50d902SRodney W. Grimes char pbuf[BUFSIZ]; 1779b50d902SRodney W. Grimes struct headline hl; 1789b50d902SRodney W. Grimes int subjlen; 1799b50d902SRodney W. Grimes char *name; 1809b50d902SRodney W. Grimes 1819b50d902SRodney W. Grimes mp = &message[mesg-1]; 1829b50d902SRodney W. Grimes (void) readline(setinput(mp), headline, LINESIZE); 1839b50d902SRodney W. Grimes if ((subjline = hfield("subject", mp)) == NOSTR) 1849b50d902SRodney W. Grimes subjline = hfield("subj", mp); 1859b50d902SRodney W. Grimes /* 1869b50d902SRodney W. Grimes * Bletch! 1879b50d902SRodney W. Grimes */ 1889b50d902SRodney W. Grimes curind = dot == mp ? '>' : ' '; 1899b50d902SRodney W. Grimes dispc = ' '; 1909b50d902SRodney W. Grimes if (mp->m_flag & MSAVED) 1919b50d902SRodney W. Grimes dispc = '*'; 1929b50d902SRodney W. Grimes if (mp->m_flag & MPRESERVE) 1939b50d902SRodney W. Grimes dispc = 'P'; 1949b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == MNEW) 1959b50d902SRodney W. Grimes dispc = 'N'; 1969b50d902SRodney W. Grimes if ((mp->m_flag & (MREAD|MNEW)) == 0) 1979b50d902SRodney W. Grimes dispc = 'U'; 1989b50d902SRodney W. Grimes if (mp->m_flag & MBOX) 1999b50d902SRodney W. Grimes dispc = 'M'; 2009b50d902SRodney W. Grimes parse(headline, &hl, pbuf); 20122694ebaSBruce Evans sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); 2029b50d902SRodney W. Grimes subjlen = screenwidth - 50 - strlen(wcount); 2039b50d902SRodney W. Grimes name = value("show-rcpt") != NOSTR ? 2049b50d902SRodney W. Grimes skin(hfield("to", mp)) : nameof(mp, 0); 2059b50d902SRodney W. Grimes if (subjline == NOSTR || subjlen < 0) /* pretty pathetic */ 2069b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s\n", 2079b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount); 2089b50d902SRodney W. Grimes else 2099b50d902SRodney W. Grimes printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n", 2109b50d902SRodney W. Grimes curind, dispc, mesg, name, hl.l_date, wcount, 2119b50d902SRodney W. Grimes subjlen, subjline); 2129b50d902SRodney W. Grimes } 2139b50d902SRodney W. Grimes 2149b50d902SRodney W. Grimes /* 2159b50d902SRodney W. Grimes * Print out the value of dot. 2169b50d902SRodney W. Grimes */ 2179b50d902SRodney W. Grimes int 2189b50d902SRodney W. Grimes pdot() 2199b50d902SRodney W. Grimes { 2209b50d902SRodney W. Grimes printf("%d\n", dot - &message[0] + 1); 2219b50d902SRodney W. Grimes return(0); 2229b50d902SRodney W. Grimes } 2239b50d902SRodney W. Grimes 2249b50d902SRodney W. Grimes /* 2259b50d902SRodney W. Grimes * Print out all the possible commands. 2269b50d902SRodney W. Grimes */ 2279b50d902SRodney W. Grimes int 2289b50d902SRodney W. Grimes pcmdlist() 2299b50d902SRodney W. Grimes { 2309b50d902SRodney W. Grimes register struct cmd *cp; 2319b50d902SRodney W. Grimes register int cc; 2329b50d902SRodney W. Grimes extern struct cmd cmdtab[]; 2339b50d902SRodney W. Grimes 2349b50d902SRodney W. Grimes printf("Commands are:\n"); 2359b50d902SRodney W. Grimes for (cc = 0, cp = cmdtab; cp->c_name != NULL; cp++) { 2369b50d902SRodney W. Grimes cc += strlen(cp->c_name) + 2; 2379b50d902SRodney W. Grimes if (cc > 72) { 2389b50d902SRodney W. Grimes printf("\n"); 2399b50d902SRodney W. Grimes cc = strlen(cp->c_name) + 2; 2409b50d902SRodney W. Grimes } 2419b50d902SRodney W. Grimes if ((cp+1)->c_name != NOSTR) 2429b50d902SRodney W. Grimes printf("%s, ", cp->c_name); 2439b50d902SRodney W. Grimes else 2449b50d902SRodney W. Grimes printf("%s\n", cp->c_name); 2459b50d902SRodney W. Grimes } 2469b50d902SRodney W. Grimes return(0); 2479b50d902SRodney W. Grimes } 2489b50d902SRodney W. Grimes 2499b50d902SRodney W. Grimes /* 2509b50d902SRodney W. Grimes * Paginate messages, honor ignored fields. 2519b50d902SRodney W. Grimes */ 2529b50d902SRodney W. Grimes int 2539b50d902SRodney W. Grimes more(msgvec) 2549b50d902SRodney W. Grimes int *msgvec; 2559b50d902SRodney W. Grimes { 2569b50d902SRodney W. Grimes return (type1(msgvec, 1, 1)); 2579b50d902SRodney W. Grimes } 2589b50d902SRodney W. Grimes 2599b50d902SRodney W. Grimes /* 2609b50d902SRodney W. Grimes * Paginate messages, even printing ignored fields. 2619b50d902SRodney W. Grimes */ 2629b50d902SRodney W. Grimes int 2639b50d902SRodney W. Grimes More(msgvec) 2649b50d902SRodney W. Grimes int *msgvec; 2659b50d902SRodney W. Grimes { 2669b50d902SRodney W. Grimes 2679b50d902SRodney W. Grimes return (type1(msgvec, 0, 1)); 2689b50d902SRodney W. Grimes } 2699b50d902SRodney W. Grimes 2709b50d902SRodney W. Grimes /* 2719b50d902SRodney W. Grimes * Type out messages, honor ignored fields. 2729b50d902SRodney W. Grimes */ 2739b50d902SRodney W. Grimes int 2749b50d902SRodney W. Grimes type(msgvec) 2759b50d902SRodney W. Grimes int *msgvec; 2769b50d902SRodney W. Grimes { 2779b50d902SRodney W. Grimes 2789b50d902SRodney W. Grimes return(type1(msgvec, 1, 0)); 2799b50d902SRodney W. Grimes } 2809b50d902SRodney W. Grimes 2819b50d902SRodney W. Grimes /* 2829b50d902SRodney W. Grimes * Type out messages, even printing ignored fields. 2839b50d902SRodney W. Grimes */ 2849b50d902SRodney W. Grimes int 2859b50d902SRodney W. Grimes Type(msgvec) 2869b50d902SRodney W. Grimes int *msgvec; 2879b50d902SRodney W. Grimes { 2889b50d902SRodney W. Grimes 2899b50d902SRodney W. Grimes return(type1(msgvec, 0, 0)); 2909b50d902SRodney W. Grimes } 2919b50d902SRodney W. Grimes 2929b50d902SRodney W. Grimes /* 2939b50d902SRodney W. Grimes * Type out the messages requested. 2949b50d902SRodney W. Grimes */ 2959b50d902SRodney W. Grimes jmp_buf pipestop; 2969b50d902SRodney W. Grimes int 2979b50d902SRodney W. Grimes type1(msgvec, doign, page) 2989b50d902SRodney W. Grimes int *msgvec; 2999b50d902SRodney W. Grimes int doign, page; 3009b50d902SRodney W. Grimes { 3019b50d902SRodney W. Grimes register *ip; 3029b50d902SRodney W. Grimes register struct message *mp; 3039b50d902SRodney W. Grimes register char *cp; 3049b50d902SRodney W. Grimes int nlines; 3059b50d902SRodney W. Grimes FILE *obuf; 3069b50d902SRodney W. Grimes 3079b50d902SRodney W. Grimes obuf = stdout; 3089b50d902SRodney W. Grimes if (setjmp(pipestop)) 3099b50d902SRodney W. Grimes goto close_pipe; 3109b50d902SRodney W. Grimes if (value("interactive") != NOSTR && 3119b50d902SRodney W. Grimes (page || (cp = value("crt")) != NOSTR)) { 3129b50d902SRodney W. Grimes nlines = 0; 3139b50d902SRodney W. Grimes if (!page) { 3149b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) 3159b50d902SRodney W. Grimes nlines += message[*ip - 1].m_lines; 3169b50d902SRodney W. Grimes } 3179b50d902SRodney W. Grimes if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) { 3189b50d902SRodney W. Grimes cp = value("PAGER"); 3199b50d902SRodney W. Grimes if (cp == NULL || *cp == '\0') 3209b50d902SRodney W. Grimes cp = _PATH_MORE; 3219b50d902SRodney W. Grimes obuf = Popen(cp, "w"); 3229b50d902SRodney W. Grimes if (obuf == NULL) { 3230c3a8314SMike Heffner warnx("%s", cp); 3249b50d902SRodney W. Grimes obuf = stdout; 3259b50d902SRodney W. Grimes } else 3269b50d902SRodney W. Grimes signal(SIGPIPE, brokpipe); 3279b50d902SRodney W. Grimes } 3289b50d902SRodney W. Grimes } 3299b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { 3309b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3319b50d902SRodney W. Grimes touch(mp); 3329b50d902SRodney W. Grimes dot = mp; 3339b50d902SRodney W. Grimes if (value("quiet") == NOSTR) 3349b50d902SRodney W. Grimes fprintf(obuf, "Message %d:\n", *ip); 3350c3a8314SMike Heffner (void) sendmessage(mp, obuf, doign ? ignore : 0, NOSTR); 3369b50d902SRodney W. Grimes } 3379b50d902SRodney W. Grimes close_pipe: 3389b50d902SRodney W. Grimes if (obuf != stdout) { 3399b50d902SRodney W. Grimes /* 3409b50d902SRodney W. Grimes * Ignore SIGPIPE so it can't cause a duplicate close. 3419b50d902SRodney W. Grimes */ 3429b50d902SRodney W. Grimes signal(SIGPIPE, SIG_IGN); 3439b50d902SRodney W. Grimes Pclose(obuf); 3449b50d902SRodney W. Grimes signal(SIGPIPE, SIG_DFL); 3459b50d902SRodney W. Grimes } 3469b50d902SRodney W. Grimes return(0); 3479b50d902SRodney W. Grimes } 3489b50d902SRodney W. Grimes 3499b50d902SRodney W. Grimes /* 3509b50d902SRodney W. Grimes * Respond to a broken pipe signal -- 3519b50d902SRodney W. Grimes * probably caused by quitting more. 3529b50d902SRodney W. Grimes */ 3539b50d902SRodney W. Grimes void 3549b50d902SRodney W. Grimes brokpipe(signo) 3559b50d902SRodney W. Grimes int signo; 3569b50d902SRodney W. Grimes { 3579b50d902SRodney W. Grimes longjmp(pipestop, 1); 3589b50d902SRodney W. Grimes } 3599b50d902SRodney W. Grimes 3609b50d902SRodney W. Grimes /* 3619b50d902SRodney W. Grimes * Print the top so many lines of each desired message. 3629b50d902SRodney W. Grimes * The number of lines is taken from the variable "toplines" 3639b50d902SRodney W. Grimes * and defaults to 5. 3649b50d902SRodney W. Grimes */ 3659b50d902SRodney W. Grimes int 3669b50d902SRodney W. Grimes top(msgvec) 3679b50d902SRodney W. Grimes int *msgvec; 3689b50d902SRodney W. Grimes { 3699b50d902SRodney W. Grimes register int *ip; 3709b50d902SRodney W. Grimes register struct message *mp; 3719b50d902SRodney W. Grimes int c, topl, lines, lineb; 3729b50d902SRodney W. Grimes char *valtop, linebuf[LINESIZE]; 3739b50d902SRodney W. Grimes FILE *ibuf; 3749b50d902SRodney W. Grimes 3759b50d902SRodney W. Grimes topl = 5; 3769b50d902SRodney W. Grimes valtop = value("toplines"); 3779b50d902SRodney W. Grimes if (valtop != NOSTR) { 3789b50d902SRodney W. Grimes topl = atoi(valtop); 3799b50d902SRodney W. Grimes if (topl < 0 || topl > 10000) 3809b50d902SRodney W. Grimes topl = 5; 3819b50d902SRodney W. Grimes } 3829b50d902SRodney W. Grimes lineb = 1; 3839b50d902SRodney W. Grimes for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) { 3849b50d902SRodney W. Grimes mp = &message[*ip - 1]; 3859b50d902SRodney W. Grimes touch(mp); 3869b50d902SRodney W. Grimes dot = mp; 3879b50d902SRodney W. Grimes if (value("quiet") == NOSTR) 3889b50d902SRodney W. Grimes printf("Message %d:\n", *ip); 3899b50d902SRodney W. Grimes ibuf = setinput(mp); 3909b50d902SRodney W. Grimes c = mp->m_lines; 3919b50d902SRodney W. Grimes if (!lineb) 3929b50d902SRodney W. Grimes printf("\n"); 3939b50d902SRodney W. Grimes for (lines = 0; lines < c && lines <= topl; lines++) { 3940c3a8314SMike Heffner if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) 3959b50d902SRodney W. Grimes break; 3969b50d902SRodney W. Grimes puts(linebuf); 3970c3a8314SMike Heffner lineb = strspn(linebuf, " \t") == strlen(linebuf); 3989b50d902SRodney W. Grimes } 3999b50d902SRodney W. Grimes } 4009b50d902SRodney W. Grimes return(0); 4019b50d902SRodney W. Grimes } 4029b50d902SRodney W. Grimes 4039b50d902SRodney W. Grimes /* 4049b50d902SRodney W. Grimes * Touch all the given messages so that they will 4059b50d902SRodney W. Grimes * get mboxed. 4069b50d902SRodney W. Grimes */ 4079b50d902SRodney W. Grimes int 4089b50d902SRodney W. Grimes stouch(msgvec) 4099b50d902SRodney W. Grimes int msgvec[]; 4109b50d902SRodney W. Grimes { 4119b50d902SRodney W. Grimes register int *ip; 4129b50d902SRodney W. Grimes 4139b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4149b50d902SRodney W. Grimes dot = &message[*ip-1]; 4159b50d902SRodney W. Grimes dot->m_flag |= MTOUCH; 4169b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4179b50d902SRodney W. Grimes } 4189b50d902SRodney W. Grimes return(0); 4199b50d902SRodney W. Grimes } 4209b50d902SRodney W. Grimes 4219b50d902SRodney W. Grimes /* 4229b50d902SRodney W. Grimes * Make sure all passed messages get mboxed. 4239b50d902SRodney W. Grimes */ 4249b50d902SRodney W. Grimes int 4259b50d902SRodney W. Grimes mboxit(msgvec) 4269b50d902SRodney W. Grimes int msgvec[]; 4279b50d902SRodney W. Grimes { 4289b50d902SRodney W. Grimes register int *ip; 4299b50d902SRodney W. Grimes 4309b50d902SRodney W. Grimes for (ip = msgvec; *ip != 0; ip++) { 4319b50d902SRodney W. Grimes dot = &message[*ip-1]; 4329b50d902SRodney W. Grimes dot->m_flag |= MTOUCH|MBOX; 4339b50d902SRodney W. Grimes dot->m_flag &= ~MPRESERVE; 4349b50d902SRodney W. Grimes } 4359b50d902SRodney W. Grimes return(0); 4369b50d902SRodney W. Grimes } 4379b50d902SRodney W. Grimes 4389b50d902SRodney W. Grimes /* 4399b50d902SRodney W. Grimes * List the folders the user currently has. 4409b50d902SRodney W. Grimes */ 4419b50d902SRodney W. Grimes int 4429b50d902SRodney W. Grimes folders() 4439b50d902SRodney W. Grimes { 4440c3a8314SMike Heffner char dirname[PATHSIZE]; 4459b50d902SRodney W. Grimes char *cmd; 4469b50d902SRodney W. Grimes 4470c3a8314SMike Heffner if (getfold(dirname, sizeof(dirname)) < 0) { 4489b50d902SRodney W. Grimes printf("No value set for \"folder\"\n"); 4499b50d902SRodney W. Grimes return 1; 4509b50d902SRodney W. Grimes } 4519b50d902SRodney W. Grimes if ((cmd = value("LISTER")) == NOSTR) 4529b50d902SRodney W. Grimes cmd = "ls"; 4539b50d902SRodney W. Grimes (void) run_command(cmd, 0, -1, -1, dirname, NOSTR, NOSTR); 4549b50d902SRodney W. Grimes return 0; 4559b50d902SRodney W. Grimes } 456