Annotation of src/usr.bin/mail/list.c, Revision 1.5
1.5 ! millert 1: /* $OpenBSD: list.c,v 1.4 1997/05/30 08:51:42 deraadt Exp $ */
! 2: /* $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $ */
1.2 deraadt 3:
1.1 deraadt 4: /*
5: * Copyright (c) 1980, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: */
36:
37: #ifndef lint
1.2 deraadt 38: #if 0
1.5 ! millert 39: static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95";
1.2 deraadt 40: #else
1.5 ! millert 41: static char rcsid[] = "$OpenBSD: list.c,v 1.4 1997/05/30 08:51:42 deraadt Exp $";
1.2 deraadt 42: #endif
1.1 deraadt 43: #endif /* not lint */
44:
45: #include "rcv.h"
46: #include <ctype.h>
47: #include "extern.h"
48:
49: /*
50: * Mail -- a mail program
51: *
52: * Message list handling.
53: */
54:
55: /*
56: * Convert the user string of message numbers and
57: * store the numbers into vector.
58: *
59: * Returns the count of messages picked up or -1 on error.
60: */
61: int
62: getmsglist(buf, vector, flags)
63: char *buf;
64: int *vector, flags;
65: {
66: register int *ip;
67: register struct message *mp;
68:
69: if (msgCount == 0) {
70: *vector = 0;
1.5 ! millert 71: return(0);
1.1 deraadt 72: }
73: if (markall(buf, flags) < 0)
74: return(-1);
75: ip = vector;
76: for (mp = &message[0]; mp < &message[msgCount]; mp++)
77: if (mp->m_flag & MMARK)
78: *ip++ = mp - &message[0] + 1;
79: *ip = 0;
80: return(ip - vector);
81: }
82:
83: /*
84: * Mark all messages that the user wanted from the command
85: * line in the message structure. Return 0 on success, -1
86: * on error.
87: */
88:
89: /*
90: * Bit values for colon modifiers.
91: */
92:
93: #define CMNEW 01 /* New messages */
94: #define CMOLD 02 /* Old messages */
95: #define CMUNREAD 04 /* Unread messages */
96: #define CMDELETED 010 /* Deleted messages */
97: #define CMREAD 020 /* Read messages */
98:
99: /*
100: * The following table describes the letters which can follow
101: * the colon and gives the corresponding modifier bit.
102: */
103:
104: struct coltab {
105: char co_char; /* What to find past : */
106: int co_bit; /* Associated modifier bit */
107: int co_mask; /* m_status bits to mask */
108: int co_equal; /* ... must equal this */
109: } coltab[] = {
1.2 deraadt 110: { 'n', CMNEW, MNEW, MNEW },
111: { 'o', CMOLD, MNEW, 0 },
112: { 'u', CMUNREAD, MREAD, 0 },
113: { 'd', CMDELETED, MDELETED, MDELETED },
114: { 'r', CMREAD, MREAD, MREAD },
115: { 0, 0, 0, 0 }
1.1 deraadt 116: };
117:
118: static int lastcolmod;
119:
120: int
121: markall(buf, f)
122: char buf[];
123: int f;
124: {
125: register char **np;
126: register int i;
127: register struct message *mp;
128: char *namelist[NMLSIZE], *bufp;
129: int tok, beg, mc, star, other, valdot, colmod, colresult;
130:
131: valdot = dot - &message[0] + 1;
132: colmod = 0;
133: for (i = 1; i <= msgCount; i++)
134: unmark(i);
135: bufp = buf;
136: mc = 0;
137: np = &namelist[0];
138: scaninit();
139: tok = scan(&bufp);
140: star = 0;
141: other = 0;
142: beg = 0;
143: while (tok != TEOL) {
144: switch (tok) {
145: case TNUMBER:
146: number:
147: if (star) {
1.5 ! millert 148: puts("No numbers mixed with *");
1.1 deraadt 149: return(-1);
150: }
151: mc++;
152: other++;
153: if (beg != 0) {
154: if (check(lexnumber, f))
155: return(-1);
156: for (i = beg; i <= lexnumber; i++)
157: if (f == MDELETED || (message[i - 1].m_flag & MDELETED) == 0)
158: mark(i);
159: beg = 0;
160: break;
161: }
162: beg = lexnumber;
163: if (check(beg, f))
164: return(-1);
165: tok = scan(&bufp);
166: regret(tok);
167: if (tok != TDASH) {
168: mark(beg);
169: beg = 0;
170: }
171: break;
172:
173: case TPLUS:
174: if (beg != 0) {
1.5 ! millert 175: puts("Non-numeric second argument");
1.1 deraadt 176: return(-1);
177: }
178: i = valdot;
179: do {
180: i++;
181: if (i > msgCount) {
1.5 ! millert 182: puts("Referencing beyond EOF");
1.1 deraadt 183: return(-1);
184: }
185: } while ((message[i - 1].m_flag & MDELETED) != f);
186: mark(i);
187: break;
188:
189: case TDASH:
190: if (beg == 0) {
191: i = valdot;
192: do {
193: i--;
194: if (i <= 0) {
1.5 ! millert 195: puts("Referencing before 1");
1.1 deraadt 196: return(-1);
197: }
198: } while ((message[i - 1].m_flag & MDELETED) != f);
199: mark(i);
200: }
201: break;
202:
203: case TSTRING:
204: if (beg != 0) {
1.5 ! millert 205: puts("Non-numeric second argument");
1.1 deraadt 206: return(-1);
207: }
208: other++;
209: if (lexstring[0] == ':') {
210: colresult = evalcol(lexstring[1]);
211: if (colresult == 0) {
212: printf("Unknown colon modifier \"%s\"\n",
213: lexstring);
214: return(-1);
215: }
216: colmod |= colresult;
217: }
218: else
219: *np++ = savestr(lexstring);
220: break;
221:
222: case TDOLLAR:
223: case TUP:
224: case TDOT:
225: lexnumber = metamess(lexstring[0], f);
226: if (lexnumber == -1)
227: return(-1);
228: goto number;
229:
230: case TSTAR:
231: if (other) {
1.5 ! millert 232: puts("Can't mix \"*\" with anything");
1.1 deraadt 233: return(-1);
234: }
235: star++;
236: break;
237:
238: case TERROR:
1.5 ! millert 239: return(-1);
1.1 deraadt 240: }
241: tok = scan(&bufp);
242: }
243: lastcolmod = colmod;
244: *np = NOSTR;
245: mc = 0;
246: if (star) {
247: for (i = 0; i < msgCount; i++)
248: if ((message[i].m_flag & MDELETED) == f) {
249: mark(i+1);
250: mc++;
251: }
252: if (mc == 0) {
1.5 ! millert 253: puts("No applicable messages.");
1.1 deraadt 254: return(-1);
255: }
256: return(0);
257: }
258:
259: /*
260: * If no numbers were given, mark all of the messages,
261: * so that we can unmark any whose sender was not selected
262: * if any user names were given.
263: */
264:
265: if ((np > namelist || colmod != 0) && mc == 0)
266: for (i = 1; i <= msgCount; i++)
267: if ((message[i-1].m_flag & MDELETED) == f)
268: mark(i);
269:
270: /*
271: * If any names were given, go through and eliminate any
272: * messages whose senders were not requested.
273: */
274:
275: if (np > namelist) {
276: for (i = 1; i <= msgCount; i++) {
277: for (mc = 0, np = &namelist[0]; *np != NOSTR; np++)
278: if (**np == '/') {
279: if (matchsubj(*np, i)) {
280: mc++;
281: break;
282: }
283: }
284: else {
285: if (matchsender(*np, i)) {
286: mc++;
287: break;
288: }
289: }
290: if (mc == 0)
291: unmark(i);
292: }
293:
294: /*
295: * Make sure we got some decent messages.
296: */
297:
298: mc = 0;
299: for (i = 1; i <= msgCount; i++)
300: if (message[i-1].m_flag & MMARK) {
301: mc++;
302: break;
303: }
304: if (mc == 0) {
305: printf("No applicable messages from {%s",
306: namelist[0]);
307: for (np = &namelist[1]; *np != NOSTR; np++)
308: printf(", %s", *np);
1.5 ! millert 309: puts("}");
1.1 deraadt 310: return(-1);
311: }
312: }
313:
314: /*
315: * If any colon modifiers were given, go through and
316: * unmark any messages which do not satisfy the modifiers.
317: */
318:
319: if (colmod != 0) {
320: for (i = 1; i <= msgCount; i++) {
321: register struct coltab *colp;
322:
323: mp = &message[i - 1];
324: for (colp = &coltab[0]; colp->co_char; colp++)
325: if (colp->co_bit & colmod)
326: if ((mp->m_flag & colp->co_mask)
327: != colp->co_equal)
328: unmark(i);
329:
330: }
331: for (mp = &message[0]; mp < &message[msgCount]; mp++)
332: if (mp->m_flag & MMARK)
333: break;
334: if (mp >= &message[msgCount]) {
335: register struct coltab *colp;
336:
1.5 ! millert 337: fputs("No messages satisfy", stdout);
1.1 deraadt 338: for (colp = &coltab[0]; colp->co_char; colp++)
339: if (colp->co_bit & colmod)
340: printf(" :%c", colp->co_char);
1.5 ! millert 341: putchar('\n');
1.1 deraadt 342: return(-1);
343: }
344: }
345: return(0);
346: }
347:
348: /*
349: * Turn the character after a colon modifier into a bit
350: * value.
351: */
352: int
353: evalcol(col)
354: int col;
355: {
356: register struct coltab *colp;
357:
358: if (col == 0)
359: return(lastcolmod);
360: for (colp = &coltab[0]; colp->co_char; colp++)
361: if (colp->co_char == col)
362: return(colp->co_bit);
363: return(0);
364: }
365:
366: /*
367: * Check the passed message number for legality and proper flags.
368: * If f is MDELETED, then either kind will do. Otherwise, the message
369: * has to be undeleted.
370: */
371: int
372: check(mesg, f)
373: int mesg, f;
374: {
375: register struct message *mp;
376:
377: if (mesg < 1 || mesg > msgCount) {
378: printf("%d: Invalid message number\n", mesg);
379: return(-1);
380: }
381: mp = &message[mesg-1];
382: if (f != MDELETED && (mp->m_flag & MDELETED) != 0) {
383: printf("%d: Inappropriate message\n", mesg);
384: return(-1);
385: }
386: return(0);
387: }
388:
389: /*
390: * Scan out the list of string arguments, shell style
391: * for a RAWLIST.
392: */
393: int
394: getrawlist(line, argv, argc)
395: char line[];
396: char **argv;
397: int argc;
398: {
399: register char c, *cp, *cp2, quotec;
400: int argn;
401: char linebuf[BUFSIZ];
402:
403: argn = 0;
404: cp = line;
405: for (;;) {
406: for (; *cp == ' ' || *cp == '\t'; cp++)
407: ;
408: if (*cp == '\0')
409: break;
410: if (argn >= argc - 1) {
1.5 ! millert 411: puts("Too many elements in the list; excess discarded.");
1.1 deraadt 412: break;
413: }
414: cp2 = linebuf;
415: quotec = '\0';
416: while ((c = *cp) != '\0') {
417: cp++;
418: if (quotec != '\0') {
419: if (c == quotec)
420: quotec = '\0';
421: else if (c == '\\')
422: switch (c = *cp++) {
423: case '\0':
424: *cp2++ = '\\';
425: cp--;
426: break;
427: case '0': case '1': case '2': case '3':
428: case '4': case '5': case '6': case '7':
429: c -= '0';
430: if (*cp >= '0' && *cp <= '7')
431: c = c * 8 + *cp++ - '0';
432: if (*cp >= '0' && *cp <= '7')
433: c = c * 8 + *cp++ - '0';
434: *cp2++ = c;
435: break;
436: case 'b':
437: *cp2++ = '\b';
438: break;
439: case 'f':
440: *cp2++ = '\f';
441: break;
442: case 'n':
443: *cp2++ = '\n';
444: break;
445: case 'r':
446: *cp2++ = '\r';
447: break;
448: case 't':
449: *cp2++ = '\t';
450: break;
451: case 'v':
452: *cp2++ = '\v';
453: break;
454: default:
455: *cp2++ = c;
456: }
457: else if (c == '^') {
458: c = *cp++;
459: if (c == '?')
460: *cp2++ = '\177';
461: /* null doesn't show up anyway */
1.2 deraadt 462: else if ((c >= 'A' && c <= '_') ||
463: (c >= 'a' && c <= 'z'))
1.1 deraadt 464: *cp2++ = c & 037;
465: else {
466: *cp2++ = '^';
467: cp--;
468: }
469: } else
470: *cp2++ = c;
471: } else if (c == '"' || c == '\'')
472: quotec = c;
473: else if (c == ' ' || c == '\t')
474: break;
475: else
476: *cp2++ = c;
477: }
478: *cp2 = '\0';
479: argv[argn++] = savestr(linebuf);
480: }
481: argv[argn] = NOSTR;
1.5 ! millert 482: return(argn);
1.1 deraadt 483: }
484:
485: /*
486: * scan out a single lexical item and return its token number,
487: * updating the string pointer passed **p. Also, store the value
488: * of the number or string scanned in lexnumber or lexstring as
489: * appropriate. In any event, store the scanned `thing' in lexstring.
490: */
491:
492: struct lex {
493: char l_char;
494: char l_token;
495: } singles[] = {
1.2 deraadt 496: { '$', TDOLLAR },
497: { '.', TDOT },
498: { '^', TUP },
499: { '*', TSTAR },
500: { '-', TDASH },
501: { '+', TPLUS },
502: { '(', TOPEN },
503: { ')', TCLOSE },
504: { 0, 0 }
1.1 deraadt 505: };
506:
507: int
508: scan(sp)
509: char **sp;
510: {
511: register char *cp, *cp2;
512: register int c;
513: register struct lex *lp;
514: int quotec;
515:
516: if (regretp >= 0) {
517: strcpy(lexstring, string_stack[regretp]);
518: lexnumber = numberstack[regretp];
519: return(regretstack[regretp--]);
520: }
521: cp = *sp;
522: cp2 = lexstring;
523: c = *cp++;
524:
525: /*
526: * strip away leading white space.
527: */
528:
529: while (c == ' ' || c == '\t')
530: c = *cp++;
531:
532: /*
533: * If no characters remain, we are at end of line,
534: * so report that.
535: */
536:
537: if (c == '\0') {
538: *sp = --cp;
539: return(TEOL);
540: }
541:
542: /*
543: * If the leading character is a digit, scan
544: * the number and convert it on the fly.
545: * Return TNUMBER when done.
546: */
547:
548: if (isdigit(c)) {
549: lexnumber = 0;
550: while (isdigit(c)) {
551: lexnumber = lexnumber*10 + c - '0';
552: *cp2++ = c;
553: c = *cp++;
554: }
555: *cp2 = '\0';
556: *sp = --cp;
557: return(TNUMBER);
558: }
559:
560: /*
561: * Check for single character tokens; return such
562: * if found.
563: */
564:
565: for (lp = &singles[0]; lp->l_char != 0; lp++)
566: if (c == lp->l_char) {
567: lexstring[0] = c;
568: lexstring[1] = '\0';
569: *sp = cp;
570: return(lp->l_token);
571: }
572:
573: /*
574: * We've got a string! Copy all the characters
575: * of the string into lexstring, until we see
576: * a null, space, or tab.
577: * If the lead character is a " or ', save it
578: * and scan until you get another.
579: */
580:
581: quotec = 0;
582: if (c == '\'' || c == '"') {
583: quotec = c;
584: c = *cp++;
585: }
586: while (c != '\0') {
587: if (c == quotec) {
588: cp++;
589: break;
590: }
591: if (quotec == 0 && (c == ' ' || c == '\t'))
592: break;
593: if (cp2 - lexstring < STRINGLEN-1)
594: *cp2++ = c;
595: c = *cp++;
596: }
597: if (quotec && c == 0) {
598: fprintf(stderr, "Missing %c\n", quotec);
1.5 ! millert 599: return(TERROR);
1.1 deraadt 600: }
601: *sp = --cp;
602: *cp2 = '\0';
603: return(TSTRING);
604: }
605:
606: /*
607: * Unscan the named token by pushing it onto the regret stack.
608: */
609: void
610: regret(token)
611: int token;
612: {
613: if (++regretp >= REGDEP)
614: panic("Too many regrets");
615: regretstack[regretp] = token;
616: lexstring[STRINGLEN-1] = '\0';
617: string_stack[regretp] = savestr(lexstring);
618: numberstack[regretp] = lexnumber;
619: }
620:
621: /*
622: * Reset all the scanner global variables.
623: */
624: void
625: scaninit()
626: {
627: regretp = -1;
628: }
629:
630: /*
631: * Find the first message whose flags & m == f and return
632: * its message number.
633: */
634: int
635: first(f, m)
636: int f, m;
637: {
638: register struct message *mp;
639:
640: if (msgCount == 0)
1.5 ! millert 641: return(0);
1.1 deraadt 642: f &= MDELETED;
643: m &= MDELETED;
644: for (mp = dot; mp < &message[msgCount]; mp++)
645: if ((mp->m_flag & m) == f)
1.5 ! millert 646: return(mp - message + 1);
1.1 deraadt 647: for (mp = dot-1; mp >= &message[0]; mp--)
648: if ((mp->m_flag & m) == f)
1.5 ! millert 649: return(mp - message + 1);
! 650: return(0);
1.1 deraadt 651: }
652:
653: /*
654: * See if the passed name sent the passed message number. Return true
655: * if so.
656: */
657: int
658: matchsender(str, mesg)
659: char *str;
660: int mesg;
661: {
662: register char *cp, *cp2, *backup;
663:
664: if (!*str) /* null string matches nothing instead of everything */
1.5 ! millert 665: return(0);
1.1 deraadt 666: backup = cp2 = nameof(&message[mesg - 1], 0);
667: cp = str;
668: while (*cp2) {
669: if (*cp == 0)
670: return(1);
671: if (raise(*cp++) != raise(*cp2++)) {
672: cp2 = ++backup;
673: cp = str;
674: }
675: }
676: return(*cp == 0);
677: }
678:
679: /*
1.5 ! millert 680: * See if the passed name received the passed message number. Return true
! 681: * if so.
! 682: */
! 683:
! 684: static char *to_fields[] = { "to", "cc", "bcc", NULL };
! 685:
! 686: int
! 687: matchto(str, mesg)
! 688: char *str;
! 689: {
! 690: register struct message *mp;
! 691: register char *cp, *cp2, *backup, **to;
! 692:
! 693: str++;
! 694:
! 695: if (*str == 0) /* null string matches nothing instead of everything */
! 696: return(0);
! 697:
! 698: mp = &message[mesg-1];
! 699:
! 700: for (to = to_fields; *to; to++) {
! 701: cp = str;
! 702: cp2 = hfield(*to, mp);
! 703: if (cp2 != NOSTR) {
! 704: backup = cp2;
! 705: while (*cp2) {
! 706: if (*cp == 0)
! 707: return(1);
! 708: if (raise(*cp++) != raise(*cp2++)) {
! 709: cp2 = ++backup;
! 710: cp = str;
! 711: }
! 712: }
! 713: if (*cp == 0)
! 714: return(1);
! 715: }
! 716: }
! 717: return(0);
! 718: }
! 719:
! 720: /*
1.1 deraadt 721: * See if the given string matches inside the subject field of the
722: * given message. For the purpose of the scan, we ignore case differences.
723: * If it does, return true. The string search argument is assumed to
724: * have the form "/search-string." If it is of the form "/," we use the
725: * previous search string.
726: */
727:
1.4 deraadt 728: char lastscan[STRINGLEN];
1.1 deraadt 729: int
730: matchsubj(str, mesg)
731: char *str;
732: int mesg;
733: {
734: register struct message *mp;
735: register char *cp, *cp2, *backup;
736:
737: str++;
1.5 ! millert 738: if (*str == '\0')
1.1 deraadt 739: str = lastscan;
1.4 deraadt 740: else {
1.5 ! millert 741: strncpy(lastscan, str, sizeof(lastscan) - 1);
! 742: lastscan[sizeof(lastscan) - 1] = '\0';
1.4 deraadt 743: }
1.1 deraadt 744: mp = &message[mesg-1];
745:
746: /*
747: * Now look, ignoring case, for the word in the string.
748: */
749:
1.3 millert 750: if (value("searchheaders") && (cp = strchr(str, ':'))) {
1.5 ! millert 751: /* Check for special case "/To:" */
! 752: if (raise(str[0]) == 'T' && raise(str[1]) == 'O' &&
! 753: str[2] == ':')
! 754: return(matchto(cp, mesg));
1.1 deraadt 755: *cp++ = '\0';
1.5 ! millert 756: cp2 = hfield(*str ? str : "subject", mp);
1.1 deraadt 757: cp[-1] = ':';
758: str = cp;
759: } else {
760: cp = str;
761: cp2 = hfield("subject", mp);
762: }
763: if (cp2 == NOSTR)
764: return(0);
765: backup = cp2;
766: while (*cp2) {
767: if (*cp == 0)
768: return(1);
769: if (raise(*cp++) != raise(*cp2++)) {
770: cp2 = ++backup;
771: cp = str;
772: }
773: }
774: return(*cp == 0);
775: }
776:
777: /*
778: * Mark the named message by setting its mark bit.
779: */
780: void
781: mark(mesg)
782: int mesg;
783: {
784: register int i;
785:
786: i = mesg;
787: if (i < 1 || i > msgCount)
788: panic("Bad message number to mark");
789: message[i-1].m_flag |= MMARK;
790: }
791:
792: /*
793: * Unmark the named message.
794: */
795: void
796: unmark(mesg)
797: int mesg;
798: {
799: register int i;
800:
801: i = mesg;
802: if (i < 1 || i > msgCount)
803: panic("Bad message number to unmark");
804: message[i-1].m_flag &= ~MMARK;
805: }
806:
807: /*
808: * Return the message number corresponding to the passed meta character.
809: */
810: int
811: metamess(meta, f)
812: int meta, f;
813: {
814: register int c, m;
815: register struct message *mp;
816:
817: c = meta;
818: switch (c) {
819: case '^':
820: /*
821: * First 'good' message left.
822: */
823: for (mp = &message[0]; mp < &message[msgCount]; mp++)
824: if ((mp->m_flag & MDELETED) == f)
825: return(mp - &message[0] + 1);
1.5 ! millert 826: puts("No applicable messages");
1.1 deraadt 827: return(-1);
828:
829: case '$':
830: /*
831: * Last 'good message left.
832: */
833: for (mp = &message[msgCount-1]; mp >= &message[0]; mp--)
834: if ((mp->m_flag & MDELETED) == f)
835: return(mp - &message[0] + 1);
1.5 ! millert 836: puts("No applicable messages");
1.1 deraadt 837: return(-1);
838:
839: case '.':
1.5 ! millert 840: /*
1.1 deraadt 841: * Current message.
842: */
843: m = dot - &message[0] + 1;
844: if ((dot->m_flag & MDELETED) != f) {
845: printf("%d: Inappropriate message\n", m);
846: return(-1);
847: }
848: return(m);
849:
850: default:
851: printf("Unknown metachar (%c)\n", c);
852: return(-1);
853: }
854: }