1 diff -r -w lbl/sbr/formatsbr.c ./sbr/formatsbr.c
4 > static char ident[] = "@(#)$Id: formatsbr.c,v 1.16 1992/02/09 07:11:55 jromine Exp $";
15 < int fmt_norm = AD_NAME;
19 > extern int fmt_norm; /* defined in sbr/formatdef.c = AD_NAME */
29 < for (dp = cp; *cp; cp++)
53 > /* MAJOR HACK: See MHCHANGES for discussion */
70 < new_fs(form, format, def)
71 < register char *form, *format, *def;
73 > char *new_fs (form, format, def)
74 > register char *form,
87 > static normalize (cp)
92 > for (dp = cp; *cp; cp++)
97 > #define grot(y,z) case y: *dp++ = z; break;
121 < register char *str, *sub;
124 > static int match (str, sub)
125 > register char *str,
131 > s1 = sub + 1; s2 = str;
135 < #define PUTDF(cp, num, wid, fill) {\
136 < if (cp + wid < ep) {\
137 < if ((i = (num)) < 0)\
139 < if ((c = (wid)) < 0)\
142 > #define PUTDF(cp, num, wid, fill) if (cp + wid < ep){\
143 > if((i = (num))<0) i = -(num);\
144 > if((c = (wid))<0) c = -c;\
147 < #define PUTD(cp, num) {\
149 < if ((i = (num)) == 0)\
153 > #define PUTD(cp, num) if (cp < ep){\
154 > if((i = (num))==0) *cp++ = '0';\
173 < else if (c == '\010') {\
188 < else if (c == '\010') {\
200 < static char *lmonth[] = {
201 < "January", "February", "March", "April", "May", "June",
202 < "July", "August", "September", "October", "November", "December"
205 > static char *lmonth[] = { "January", "February","March", "April",
206 > "May", "June", "July", "August",
207 > "September","October", "November","December" };
221 < PUTSF(cp, fmt->f_comp->c_text, fmt->f_width,
224 > PUTSF (cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill);
229 < ep += i; /* forced lits are `invisible' */
236 < /* By default we left justify */
238 < if ((i = fmt->f_width) < 0) {
246 > ljust++; /* XXX should do something with this */
253 < else while (j < i && cp < ep) {
254 < *cp++ = fmt->f_fill;
264 < if (str == NULLCP || *str == NULL) {
266 > if (!(value = (str && *str))) {
268 < if (str != NULLCP && *str != NULL) {
270 > if (!(value = (str == NULLCP || *str == 0))) {
272 < if (!str || !match(str, fmt->f_text)) {
274 > if (!(value = (str && match (str, fmt->f_text)))) {
276 < if (!str || !uprf(str, fmt->f_text)) {
278 > if (!(value = (str && uprf (str, fmt->f_text)))) {
285 < value = (str != NULLCP && *str != NULL);
287 > value = (str != NULLCP && *str != 0);
289 < value = (str == NULLCP || *str == NULL);
291 > value = (str == NULLCP || *str == 0);
294 > if (!(str = getenv (fmt->f_text)))
298 < /* Be careful since str can point into buffer */
299 < bcopy(str, buffer, strlen(str) + 1);
301 > (void) strcpy(buffer, str);
304 < /* Eat leading whitespace */
307 < /* Trim trailing whitespace */
308 < xp = str + strlen(str) - 1;
309 < while (xp > str && isspace(*xp))
312 < /* By default we left justify */
321 < /* If necessary, limit width and/or justify */
322 < if (i > 0 && (j = strlen(str)) > i) {
325 > if (!ljust && i > 0 && strlen(str) > i)
331 > xp += strlen(str) - 1;
332 > while (xp > str && isspace(*xp))
334 > if (ljust && i > 0 && strlen(str) > i)
335 > str += strlen(str) - i;
339 < value = (comp = fmt->f_comp)->c_text ?
340 < atoi(comp->c_text) : 0;
342 > value = (comp = fmt->f_comp)->c_text ? atoi(comp->c_text) : 0;
344 > case FT_LV_MODULO_L:
346 > value = value % fmt->f_value;
351 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
352 < (TW_SEXP | TW_SIMP)))
354 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
356 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
357 < (TW_SEXP | TW_SIMP)))
359 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
361 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
362 < (TW_SEXP | TW_SIMP)))
364 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
366 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
367 < (TW_SEXP | TW_SIMP)))
369 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
386 < if ((fmt->f_comp->c_tws->tw_flags & TW_SZONE) ==
389 > if ((fmt->f_comp->c_tws->tw_flags & TW_SZONE) == TW_SZEXP)
394 < mn = fmt->f_comp->c_mn;
397 > if ((mn = fmt -> f_comp -> c_mn) == &fmt_mnull) {
398 > str = fmt -> f_comp -> c_text;
401 > if (fmt -> f_type == FT_LS_ADDR)
404 > if ((str = mn -> m_note)) {
405 > (void) strcpy (buffer, str);
409 > sp = str + strlen(str) - 1;
430 < bzero((char *)comp->c_tws,
431 < sizeof(*comp->c_tws));
433 > bzero ((char *) comp -> c_tws, sizeof *comp -> c_tws);
435 < /* custom address list formatting hook */
437 > /* hook for custom address list formatting (see replsbr.c) */
440 < * Output the str register as an address component,
441 < * splitting it into multiple lines if necessary.
442 < * The value reg. contains the max line length. The
443 < * lit. field may contain a string to prepend to the
444 < * result (e.g., "To: ")
446 > /* output the str register as an address component,
447 > * splitting it into multiple lines if necessary. The
448 > * value reg. contains the max line length. The lit.
449 > * field may contain a string to prepend to the result
453 < * Try to break at a comma; failing
454 < * that, break at a space, failing
455 < * that, just split the line.
457 > /* try to break at a comma; failing that, break at a
458 > * space, failing that, just split the line.
463 > lastb = 0; sp = lp + wid;
468 > while (getname("")) /* XXX */
473 < * If there's no component, we say true. Otherwise
474 < * we say "true" only if we can parse the address and
475 < * it matches one of our addresses.
477 > * if there's no component, we say true. Otherwise we
478 > * say "true" only if we can parse the address and it
479 > * matches one of our addresses.
481 < (mn = getm(sp, NULLCP, 0,
484 > (mn = getm (sp, NULLCP, 0, AD_NAME, NULLCP)))
486 > while (getname("")) /* XXX */
490 < * If we're working on a folder (as opposed to a
491 < * file), add the current msg to sequence given in
492 < * literal field. Don't disturb string or value
496 > /* If we're working on a folder (as opposed to a file), add the
497 > * current msg to sequence given in literal field. Don't
498 > * disturb string or value registers.
500 < (void) m_seqadd(fmt_current_folder,
501 < fmt->f_text, dat[0], -1);
503 > (void)m_seqadd(fmt_current_folder, fmt->f_text, dat[0], -1);
515 > return ((struct format *)0);
517 > if (cp[-1] != '\n')
519 > while (fmt->f_type != FT_DONE)
524 > return (fmt -> f_value ? ++fmt : (struct format *)0);
527 diff -r -w lbl/sbr/m_gmsg.c ./sbr/m_gmsg.c
530 > static char ident[] = "@(#)$Id: m_gmsg.c,v 2.8 1992/02/11 21:32:04 jromine Exp $";
533 > #include "../h/local.h"
535 < #include <sys/types.h>
536 < #include <sys/stat.h>
545 < #include <sys/dir.h>
548 < static int m_getatr(), m_setatr();
555 > static int m_setatr();
560 > struct msgs *m_gmsg (name)
563 > register struct dirent *dp;
569 < mp = (struct msgs *) malloc (MSIZE (mp, 0, 0));
571 > mp = (struct msgs *) malloc (MHSIZE (mp, 0, 0));
573 < realloc ((char *) mp, MSIZE (mp, mp->lowoff, mp->hghoff));
575 > realloc ((char *) mp, MHSIZE (mp, mp -> lowoff, mp -> hghoff));
577 < calloc ((unsigned) 1, MSIZEX (mp, mp->lowmsg, mp->hghmsg));
579 > calloc ((unsigned) 1, MHSIZEX (mp, mp -> lowmsg, mp -> hghmsg));
581 < if (mp->msgstats < 0)
583 > if (mp -> msgstats < (int *)0) /* non portable */
588 > static m_getatr (mp)
594 < mp->msgattrs[0] = getcpy (current);
595 < mp->msgattrs[1] = NULL;
597 > mp -> msgattrs[i = 0] = getcpy (current);
598 > mp -> msgattrs[++i] = NULL;
602 < * sequence was too big for buffer: back up
605 < for (cp = &field[sizeof(field)-2]; !isspace(*cp); --cp)
607 < if (i = cp - &field[sizeof(field)-2]) {
613 < (void) m_setatr (mp, name, field);
617 < (void) m_setatr (mp, name, field);
619 > (void) m_setatr (mp, getcpy (name), trimcpy (field));
620 > if (state == FLDEOF)
624 < if ((i = m_setatr (mp, cp, np->n_field)) != NOTOK)
626 > if ((i = m_setatr (mp, cp, getcpy (np -> n_field))) != NOTOK)
631 < m_setatr(mp, name, field)
633 > static int m_setatr (mp, name, field)
635 < register char *name, *field;
637 > register char *name,
640 < register int bits, slot, first, last;
651 < if (strcmp (current, name) == 0) {
652 < mp->curmsg = atoi(field);
657 > hack = strcmp (current, name) == 0;/* hack... */
658 > /* if we're going to use UNSEEN, it should be set here! */
660 < for (slot = 0; mp->msgattrs[slot]; slot++)
661 < if (strcmp(mp->msgattrs[slot], name) == 0)
663 > for (i = 0; mp -> msgattrs[i]; i++)
664 > if (strcmp (mp -> msgattrs[i], name) == 0) {
665 > for (j = mp -> lowmsg; j <= mp -> hghmsg; j++)
666 > mp -> msgstats[j] &= ~(1 << (bits + i));
669 < if (slot >= NATTRS)
678 < if (mp->msgattrs[slot] == NULL) {
679 < mp->msgattrs[slot] = getcpy(name);
680 < mp->msgattrs[slot + 1] = NULL;
682 > if (mp -> msgattrs[i] == NULL) {
683 > mp -> msgattrs[i] = name;
684 > mp -> msgattrs[i + 1] = NULL;
689 < bits = 1 << (FFATTRSLOT + slot);
691 < for (cp = field; *cp; ) {
692 < while (isspace(*cp))
694 < if (! isdigit(*cp))
696 < for (first = 0; isdigit(*cp); ++cp)
697 < first = (first * 10) + (*cp - '0');
700 < if (*cp++ == '-') {
701 < /* have a range of msgs */
702 < for (last = 0; isdigit(*cp); ++cp)
703 < last = (last * 10) + (*cp - '0');
704 < if (last < first) {
706 < "seq %s msg range bad: first (%d) > last (%d)",
707 < name, first, last);
710 > for (ap = brkstring (field, " ", "\n");
713 > if (cp = index (*ap, '-'))
715 > if ((j = m_atoi (*ap)) > 0) {
717 > if (hack && j >= mp -> lowmsg && j <= mp -> hghmsg
718 > && (mp -> msgstats[j] & EXISTS))
724 > for (k = cp ? m_atoi (cp) : j; j <= k; j++)
725 > if (j >= mp -> lowmsg && j <= mp -> hghmsg
726 > && (mp -> msgstats[j] & EXISTS))
727 > mp -> msgstats[j] |= 1 << (bits + i);
729 < if (last < mp->lowmsg)
731 < if (last > mp->hghmsg)
733 < if (first < mp->lowmsg)
734 < first = mp->lowmsg;
736 < if (first < mp->lowmsg)
740 < for ( ; first <= last; ++first)
741 < if (mp->msgstats[first] & EXISTS)
742 < mp->msgstats[first] |= bits;
749 diff -r -w lbl/sbr/m_seq.c ./sbr/m_seq.c
752 > static char ident[] = "@(#)$Id: m_seq.c,v 1.7 1991/02/14 14:44:38 mh Exp $";
755 < static char *buffer;
756 < static int bufsize = BUFSIZ;
758 > /* new version from VJ 2/90 - faster? */
760 < register int i, j, linlen;
761 < register char *bp, *ep;
765 > static char buffer[BUFSIZ*2]; /* for big sequences */
768 < if ((buffer = malloc(bufsize)) == NULL)
769 < adios (NULLCP, "unable to allocate seq str storage");
772 > /* assume this is in sync with msgstats["cur"] */
773 > /* see m_seqadd() for details */
775 < ep = bp + bufsize - 16;
776 < linlen = strlen(cp) + 2;
778 < register char *oldbp;
784 < int oldoff = bp - buffer;
786 < if ((buffer = realloc(buffer, bufsize)) == NULL)
787 < adios (NULLCP, "unable to allocate seq str storage");
788 < oldbp = bp = buffer + oldoff;
789 < ep = bp + bufsize - 16;
791 < if (linlen >= 72) {
803 < linlen += bp - oldbp;
804 diff -r -w lbl/zotnet/tws/dtimep.lex ./zotnet/tws/dtimep.lex
808 < static char rcsid[] =
809 < #ifdef FLEX_SCANNER
810 < "@(#) $Header: dtimep.lex,v 1.15 90/10/16 14:57:20 leres Exp $ (LBL) (flex generated scanner)";
812 < "@(#) $Header: dtimep.lex,v 1.15 90/10/16 14:57:20 leres Exp $ (LBL) (lex generated scanner)";
822 > static char ident[] = "@(#)$Id: dtimep.lex,v 2.11 1992/02/10 20:32:29 jromine Exp jromine $";
825 > #include "../h/strings.h"
827 > #include <sys/types.h>
829 > #include <sys/timeb.h>
833 > extern int daylight;
834 > extern long timezone;
835 > extern char *tzname[];
839 < * American style: MM/DD/YY.
841 > * American style: MM/DD/YY. Of course, these are all non-RFC822
844 < #define CVT2 (i=(*cp++ - '0'),isdigit(*cp)? i*10 + (*cp++ - '0') : i)
846 > #define CVT1OR2 (i=(*cp++ - '0'), isdigit(*cp)? i*10 + (*cp++ - '0') : i)
847 > #define CVT2 ((cp[0] - '0')*10 + (cp[1] - '0'))
848 > #define CVT4 ((((cp[0] - '0')*10 + (cp[1] - '0'))*10 + \
849 > (cp[2] - '0'))*10 + (cp[3] - '0'))
851 < #ifdef FLEX_SCANNER
852 < /* We get passed a string and return a pointer to a static tws struct */
854 < #define YY_DECL struct tws *dparsetime(str) char *str;
860 > #include <sys/time.h>
863 < /* We assume that we're never passed more than max_size characters */
865 < #define YY_INPUT(buf,result,max_size) \
867 < register char *xp; \
869 < while (isspace(*xp)) \
872 < while (*xp != '\0') \
874 < result = xp - gstr; \
875 < bcopy(gstr, buf, result); \
880 > static zonehack (tw)
881 > register struct tws *tw;
883 > register struct tm *tm;
885 < /* Date strings aren't usually very long */
886 < #undef YY_READ_BUF_SIZE
887 < #define YY_READ_BUF_SIZE 128
889 > if (twclock (tw) == -1L)
892 < /* Use mh error reporting routine */
893 < #undef YY_FATAL_ERROR
894 < #define YY_FATAL_ERROR(s) adios("dparsetime()", s);
896 > tm = localtime (&tw -> tw_clock);
897 > if (tm -> tm_isdst) {
898 > tw -> tw_flags |= TW_DST;
899 > tw -> tw_zone -= 60;
906 > struct tws *dparsetime (str)
910 > static struct tws tw;
912 > register int gotdate = 0;
918 < /* We need a pointer to the matched text we can modify */
919 < #undef YY_USER_ACTION
920 < #define YY_USER_ACTION cp = yytext
924 < /* Used to initialize */
925 < static struct tws ztw = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
927 > /* Zero out the struct. */
928 > bzero( (char *) &tw, sizeof tw);
930 < /* Global for use by YY_INPUT() macro */
934 > /* Set default time zone. */
937 > tw.tw_zone = -tb.timezone;
940 > tw.tw_zone = -(timezone / 60);
945 > while (isspace(*str))
948 > switch (cp = str, *cp ? lex_string( &str, start_cond) : 0) {
951 < register int i, gotdate;
953 < static struct tws tw;
954 < static void zonehack();
957 > if (!gotdate || tw.tw_year == 0)
958 > return (struct tws *)0;
961 > if ( tw.tw_year == 0 ) {
962 > /* Set default year. */
964 > tw.tw_year = localtime(&tclock)->tm_year + 1900;
966 > else if (tw.tw_year < 100) {
967 > /* assume no 2-digit years > 1999 */
968 > tw.tw_year += 1900;
982 < {D}"/"{D}"/"(19)?[0-9][0-9]{w} {
984 > {D}(("-"{D}"-")|("/"{D}"/")){D}?{d}{d}{w} {
988 > tw.tw_mday = CVT1OR2;
990 < tw.tw_mon = CVT2 - 1;
992 > tw.tw_mon = CVT1OR2 - 1;
994 < tw.tw_mon = CVT2 - 1;
996 > tw.tw_mon = CVT1OR2 - 1;
1000 > tw.tw_mday = CVT1OR2;
1002 < tw.tw_year = i % 100;
1005 > gotdate++; /* XXX */
1007 > {D}("/"|"-"){D}{w} {
1008 > if (europeandate) {
1009 > tw.tw_mday = CVT1OR2; cp++;
1010 > tw.tw_mon = CVT1OR2 - 1;
1012 > tw.tw_mon = CVT1OR2 - 1; cp++;
1013 > tw.tw_mday = CVT1OR2;
1016 < {D}{w}(-)?{w}{MONTH}{w}(-)?{w}(19)?{D}{w}(\,{w}|at{W})? {
1017 < tw.tw_mday = CVT2;
1019 > {D}{w}(-)?{w}{MONTH}{w}(-)?{w}{D}?{d}{d}({W}at)?{w} {
1020 > tw.tw_mday = CVT1OR2;
1022 < tw.tw_year = i % 100;
1026 < {MONTH}{W}{D}","{W}(19)?{D}{w} {
1028 > {D}"-"?{MONTH}({W}at)?{w} {
1029 > tw.tw_mday = CVT1OR2;
1030 > while ( ! isalpha( *cp++ ) )
1034 > {MONTH}{W}{D}","{W}{D}?{d}{d}{w} {
1036 < tw.tw_mday = CVT2;
1038 > tw.tw_mday = CVT1OR2;
1040 < tw.tw_year = i % 100;
1046 < tw.tw_mday = CVT2;
1048 > tw.tw_mday = CVT1OR2;
1050 > {D}:{D}:{D}{W}19[6-9]{d} { /* hack: ctime w/o TZ */
1051 > tw.tw_hour = CVT1OR2; cp++;
1052 > tw.tw_min = CVT1OR2; cp++;
1053 > tw.tw_sec = CVT1OR2;
1055 > tw.tw_year = CVT4; cp+=4;
1058 < tw.tw_hour = CVT2; cp++;
1059 < tw.tw_min = CVT2; cp++;
1062 > tw.tw_hour = CVT1OR2; cp++;
1063 > tw.tw_min = CVT1OR2; cp++;
1064 > tw.tw_sec = CVT1OR2;
1066 < tw.tw_hour = CVT2; cp++;
1069 > tw.tw_hour = CVT1OR2; cp++;
1070 > tw.tw_min = CVT1OR2;
1072 < tw.tw_hour = CVT2; cp++;
1074 > tw.tw_hour = CVT1OR2; cp++;
1078 > tw.tw_min = CVT1OR2;
1080 > {D}:{D}:{D}{w}am{w} {
1081 > tw.tw_hour = CVT1OR2; cp++;
1082 > if (tw.tw_hour == 12)
1084 > tw.tw_min = CVT1OR2; cp++;
1085 > tw.tw_sec = CVT1OR2;
1089 < tw.tw_hour = CVT2; cp++;
1091 > tw.tw_hour = CVT1OR2; cp++;
1095 > tw.tw_min = CVT1OR2;
1097 > {D}:{D}:{D}{w}pm{w} {
1098 > tw.tw_hour = CVT1OR2; cp++;
1099 > if (tw.tw_hour != 12)
1101 > tw.tw_min = CVT1OR2; cp++;
1102 > tw.tw_sec = CVT1OR2;
1106 < tw.tw_hour = CVT2;
1110 > tw.tw_hour = CVT2; cp+=2;
1111 > tw.tw_min = CVT2; cp+=2;
1112 > tw.tw_sec = CVT2; cp+=2;
1114 < * and minutes. This rule must come
1115 < * the 4 digit hour and minute rule.
1120 < tw.tw_year = CVT2;
1122 > tw.tw_year = CVT4; cp+=4;
1124 < tw.tw_hour = CVT2;
1127 > if (tw.tw_hour || tw.tw_min
1129 > tw.tw_year = CVT4; cp+=4;
1132 > tw.tw_hour = CVT2; cp+=2;
1133 > tw.tw_min = CVT2; cp+=2;
1147 > <Z>{W}{d}{d}{d}{d} {
1149 > tw.tw_year = CVT4; cp+=4;
1153 < <INITIAL,Z><<EOF>> return(&tw);
1157 < * We jammed; it's an error if we
1158 < * didn't parse anything.
1160 < if (!gotdate || tw.tw_year == 0)
1168 < #include <sys/types.h>
1172 < #include <sys/time.h>
1177 < register struct tws *tw;
1179 < register struct tm *tm;
1181 < if (twclock (tw) == -1L)
1184 < tm = localtime (&tw -> tw_clock);
1185 < if (tm -> tm_isdst) {
1186 < tw -> tw_flags |= TW_DST;
1187 < tw -> tw_zone -= 60;