list.c (da52b4caaf187775f6b56a72c6b16e94ad728f7b) list.c (6d8484b0d0191b66f9bfd0dfa89c06a29647f02a)
1/*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 38 unchanged lines hidden (view full) ---

47
48/*
49 * Convert the user string of message numbers and
50 * store the numbers into vector.
51 *
52 * Returns the count of messages picked up or -1 on error.
53 */
54int
1/*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 38 unchanged lines hidden (view full) ---

47
48/*
49 * Convert the user string of message numbers and
50 * store the numbers into vector.
51 *
52 * Returns the count of messages picked up or -1 on error.
53 */
54int
55getmsglist(buf, vector, flags)
56 char *buf;
57 int *vector, flags;
55getmsglist(char *buf, int *vector, int flags)
58{
59 int *ip;
60 struct message *mp;
61
62 if (msgCount == 0) {
63 *vector = 0;
64 return (0);
65 }

--- 40 unchanged lines hidden (view full) ---

106 { 'd', CMDELETED, MDELETED, MDELETED},
107 { 'r', CMREAD, MREAD, MREAD },
108 { 0, 0, 0, 0 }
109};
110
111static int lastcolmod;
112
113int
56{
57 int *ip;
58 struct message *mp;
59
60 if (msgCount == 0) {
61 *vector = 0;
62 return (0);
63 }

--- 40 unchanged lines hidden (view full) ---

104 { 'd', CMDELETED, MDELETED, MDELETED},
105 { 'r', CMREAD, MREAD, MREAD },
106 { 0, 0, 0, 0 }
107};
108
109static int lastcolmod;
110
111int
114markall(buf, f)
115 char buf[];
116 int f;
112markall(char buf[], int f)
117{
118 char **np;
119 int i;
120 struct message *mp;
121 char *namelist[NMLSIZE], *bufp;
122 int tok, beg, mc, star, other, valdot, colmod, colresult;
123
124 valdot = dot - &message[0] + 1;

--- 213 unchanged lines hidden (view full) ---

338 return (0);
339}
340
341/*
342 * Turn the character after a colon modifier into a bit
343 * value.
344 */
345int
113{
114 char **np;
115 int i;
116 struct message *mp;
117 char *namelist[NMLSIZE], *bufp;
118 int tok, beg, mc, star, other, valdot, colmod, colresult;
119
120 valdot = dot - &message[0] + 1;

--- 213 unchanged lines hidden (view full) ---

334 return (0);
335}
336
337/*
338 * Turn the character after a colon modifier into a bit
339 * value.
340 */
341int
346evalcol(col)
347 int col;
342evalcol(int col)
348{
349 struct coltab *colp;
350
351 if (col == 0)
352 return (lastcolmod);
353 for (colp = &coltab[0]; colp->co_char != '\0'; colp++)
354 if (colp->co_char == col)
355 return (colp->co_bit);
356 return (0);
357}
358
359/*
360 * Check the passed message number for legality and proper flags.
361 * If f is MDELETED, then either kind will do. Otherwise, the message
362 * has to be undeleted.
363 */
364int
343{
344 struct coltab *colp;
345
346 if (col == 0)
347 return (lastcolmod);
348 for (colp = &coltab[0]; colp->co_char != '\0'; colp++)
349 if (colp->co_char == col)
350 return (colp->co_bit);
351 return (0);
352}
353
354/*
355 * Check the passed message number for legality and proper flags.
356 * If f is MDELETED, then either kind will do. Otherwise, the message
357 * has to be undeleted.
358 */
359int
365check(mesg, f)
366 int mesg, f;
360check(int mesg, int f)
367{
368 struct message *mp;
369
370 if (mesg < 1 || mesg > msgCount) {
371 printf("%d: Invalid message number\n", mesg);
372 return (-1);
373 }
374 mp = &message[mesg-1];

--- 4 unchanged lines hidden (view full) ---

379 return (0);
380}
381
382/*
383 * Scan out the list of string arguments, shell style
384 * for a RAWLIST.
385 */
386int
361{
362 struct message *mp;
363
364 if (mesg < 1 || mesg > msgCount) {
365 printf("%d: Invalid message number\n", mesg);
366 return (-1);
367 }
368 mp = &message[mesg-1];

--- 4 unchanged lines hidden (view full) ---

373 return (0);
374}
375
376/*
377 * Scan out the list of string arguments, shell style
378 * for a RAWLIST.
379 */
380int
387getrawlist(line, argv, argc)
388 char line[];
389 char **argv;
390 int argc;
381getrawlist(char line[], char **argv, int argc)
391{
392 char c, *cp, *cp2, quotec;
393 int argn;
394 char *linebuf;
395 size_t linebufsize = BUFSIZ;
396
397 if ((linebuf = malloc(linebufsize)) == NULL)
398 err(1, "Out of memory");

--- 107 unchanged lines hidden (view full) ---

506 { '-', TDASH },
507 { '+', TPLUS },
508 { '(', TOPEN },
509 { ')', TCLOSE },
510 { 0, 0 }
511};
512
513int
382{
383 char c, *cp, *cp2, quotec;
384 int argn;
385 char *linebuf;
386 size_t linebufsize = BUFSIZ;
387
388 if ((linebuf = malloc(linebufsize)) == NULL)
389 err(1, "Out of memory");

--- 107 unchanged lines hidden (view full) ---

497 { '-', TDASH },
498 { '+', TPLUS },
499 { '(', TOPEN },
500 { ')', TCLOSE },
501 { 0, 0 }
502};
503
504int
514scan(sp)
515 char **sp;
505scan(char **sp)
516{
517 char *cp, *cp2;
518 int c;
519 struct lex *lp;
520 int quotec;
521
522 if (regretp >= 0) {
523 strcpy(lexstring, string_stack[regretp]);

--- 84 unchanged lines hidden (view full) ---

608 *cp2 = '\0';
609 return (TSTRING);
610}
611
612/*
613 * Unscan the named token by pushing it onto the regret stack.
614 */
615void
506{
507 char *cp, *cp2;
508 int c;
509 struct lex *lp;
510 int quotec;
511
512 if (regretp >= 0) {
513 strcpy(lexstring, string_stack[regretp]);

--- 84 unchanged lines hidden (view full) ---

598 *cp2 = '\0';
599 return (TSTRING);
600}
601
602/*
603 * Unscan the named token by pushing it onto the regret stack.
604 */
605void
616regret(token)
617 int token;
606regret(int token)
618{
619 if (++regretp >= REGDEP)
620 errx(1, "Too many regrets");
621 regretstack[regretp] = token;
622 lexstring[STRINGLEN-1] = '\0';
623 string_stack[regretp] = savestr(lexstring);
624 numberstack[regretp] = lexnumber;
625}
626
627/*
628 * Reset all the scanner global variables.
629 */
630void
607{
608 if (++regretp >= REGDEP)
609 errx(1, "Too many regrets");
610 regretstack[regretp] = token;
611 lexstring[STRINGLEN-1] = '\0';
612 string_stack[regretp] = savestr(lexstring);
613 numberstack[regretp] = lexnumber;
614}
615
616/*
617 * Reset all the scanner global variables.
618 */
619void
631scaninit()
620scaninit(void)
632{
633 regretp = -1;
634}
635
636/*
637 * Find the first message whose flags & m == f and return
638 * its message number.
639 */
640int
621{
622 regretp = -1;
623}
624
625/*
626 * Find the first message whose flags & m == f and return
627 * its message number.
628 */
629int
641first(f, m)
642 int f, m;
630first(int f, int m)
643{
644 struct message *mp;
645
646 if (msgCount == 0)
647 return (0);
648 f &= MDELETED;
649 m &= MDELETED;
650 for (mp = dot; mp < &message[msgCount]; mp++)

--- 5 unchanged lines hidden (view full) ---

656 return (0);
657}
658
659/*
660 * See if the passed name sent the passed message number. Return true
661 * if so.
662 */
663int
631{
632 struct message *mp;
633
634 if (msgCount == 0)
635 return (0);
636 f &= MDELETED;
637 m &= MDELETED;
638 for (mp = dot; mp < &message[msgCount]; mp++)

--- 5 unchanged lines hidden (view full) ---

644 return (0);
645}
646
647/*
648 * See if the passed name sent the passed message number. Return true
649 * if so.
650 */
651int
664matchsender(str, mesg)
665 char *str;
666 int mesg;
652matchsender(char *str, int mesg)
667{
668 char *cp;
669
670 /* null string matches nothing instead of everything */
671 if (*str == '\0')
672 return (0);
673
674 cp = nameof(&message[mesg - 1], 0);
675 return (strcasestr(cp, str) != NULL);
676}
677
678/*
679 * See if the passed name received the passed message number. Return true
680 * if so.
681 */
682
683static char *to_fields[] = { "to", "cc", "bcc", NULL };
684
685static int
653{
654 char *cp;
655
656 /* null string matches nothing instead of everything */
657 if (*str == '\0')
658 return (0);
659
660 cp = nameof(&message[mesg - 1], 0);
661 return (strcasestr(cp, str) != NULL);
662}
663
664/*
665 * See if the passed name received the passed message number. Return true
666 * if so.
667 */
668
669static char *to_fields[] = { "to", "cc", "bcc", NULL };
670
671static int
686matchto(str, mesg)
687 char *str;
688 int mesg;
672matchto(char *str, int mesg)
689{
690 struct message *mp;
691 char *cp, **to;
692
693 str++;
694
695 /* null string matches nothing instead of everything */
696 if (*str == '\0')

--- 19 unchanged lines hidden (view full) ---

716 * The form '/to:y' is a special case, and will match all messages
717 * containing the substring 'y' in the 'To', 'Cc', or 'Bcc' header
718 * fields. The search for 'to' is case sensitive, so that '/To:y' can
719 * be used to limit the search to just the 'To' field.
720 */
721
722static char lastscan[STRINGLEN];
723int
673{
674 struct message *mp;
675 char *cp, **to;
676
677 str++;
678
679 /* null string matches nothing instead of everything */
680 if (*str == '\0')

--- 19 unchanged lines hidden (view full) ---

700 * The form '/to:y' is a special case, and will match all messages
701 * containing the substring 'y' in the 'To', 'Cc', or 'Bcc' header
702 * fields. The search for 'to' is case sensitive, so that '/To:y' can
703 * be used to limit the search to just the 'To' field.
704 */
705
706static char lastscan[STRINGLEN];
707int
724matchfield(str, mesg)
725 char *str;
726 int mesg;
708matchfield(char *str, int mesg)
727{
728 struct message *mp;
729 char *cp, *cp2;
730
731 str++;
732 if (*str == '\0')
733 str = lastscan;
734 else

--- 21 unchanged lines hidden (view full) ---

756
757 return (strcasestr(cp, str) != NULL);
758}
759
760/*
761 * Mark the named message by setting its mark bit.
762 */
763void
709{
710 struct message *mp;
711 char *cp, *cp2;
712
713 str++;
714 if (*str == '\0')
715 str = lastscan;
716 else

--- 21 unchanged lines hidden (view full) ---

738
739 return (strcasestr(cp, str) != NULL);
740}
741
742/*
743 * Mark the named message by setting its mark bit.
744 */
745void
764mark(mesg)
765 int mesg;
746mark(int mesg)
766{
767 int i;
768
769 i = mesg;
770 if (i < 1 || i > msgCount)
771 errx(1, "Bad message number to mark");
772 message[i-1].m_flag |= MMARK;
773}
774
775/*
776 * Unmark the named message.
777 */
778void
747{
748 int i;
749
750 i = mesg;
751 if (i < 1 || i > msgCount)
752 errx(1, "Bad message number to mark");
753 message[i-1].m_flag |= MMARK;
754}
755
756/*
757 * Unmark the named message.
758 */
759void
779unmark(mesg)
780 int mesg;
760unmark(int mesg)
781{
782 int i;
783
784 i = mesg;
785 if (i < 1 || i > msgCount)
786 errx(1, "Bad message number to unmark");
787 message[i-1].m_flag &= ~MMARK;
788}
789
790/*
791 * Return the message number corresponding to the passed meta character.
792 */
793int
761{
762 int i;
763
764 i = mesg;
765 if (i < 1 || i > msgCount)
766 errx(1, "Bad message number to unmark");
767 message[i-1].m_flag &= ~MMARK;
768}
769
770/*
771 * Return the message number corresponding to the passed meta character.
772 */
773int
794metamess(meta, f)
795 int meta, f;
774metamess(int meta, int f)
796{
797 int c, m;
798 struct message *mp;
799
800 c = meta;
801 switch (c) {
802 case '^':
803 /*

--- 34 unchanged lines hidden ---
775{
776 int c, m;
777 struct message *mp;
778
779 c = meta;
780 switch (c) {
781 case '^':
782 /*

--- 34 unchanged lines hidden ---