From: Shantonu Sen Date: Tue, 9 Jan 2001 06:10:03 +0000 (+0000) Subject: deleting zotnet/ dir -- parts moved to sbr/ X-Git-Tag: RELEASE_1_2~146 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=2d3eed4014c861333bef889406ef2511dab09271;p=mmh deleting zotnet/ dir -- parts moved to sbr/ --- diff --git a/zotnet/Makefile.in b/zotnet/Makefile.in deleted file mode 100644 index 0a75e14..0000000 --- a/zotnet/Makefile.in +++ /dev/null @@ -1,113 +0,0 @@ -# -# Makefile for zotnet subdirectory -# -# $Id$ -# - -SHELL = /bin/sh - -srcdir = @srcdir@ -VPATH = @srcdir@ - -LORDER = @LORDER@ -TSORT = @TSORT@ -RANLIB = @RANLIB@ -LIBTOOL = @LIBTOOL@ -GNU_LIBTOOL = @GNU_LIBTOOL@ - -# flags passed to recursive makes in subdirectories -MAKEDEFS = CC='$(CC)' CPPFLAGS='$(CPPFLAGS)' DEFS='$(DEFS)' \ -CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' LIBS='$(LIBS)' \ -prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \ -etcdir='$(etcdir)' libdir='$(libdir)' mandir='$(mandir)' \ -mailspool='$(mailspool)' sendmailpath='$(sendmailpath)' \ -default_editor='$(default_editor)' default_pager='$(default_pager)' - -# object files in libzot.a -OBJS = mts/mts.o mts/client.o - -# auxiliary files -AUX = Makefile.in - -# all files in this directory included in the distribution -DIST = $(AUX) - -# subdirectories -SUBDIRS = mts - -# ========= DEPENDENCIES FOR BUILDING AND INSTALLING ========== - -all: all-recursive libzot.a - -libzot.a: $(OBJS) - rm -f $@ - if test x$(LIBTOOL) != x -a x$(GNU_LIBTOOL) = x ; then \ - $(LIBTOOL) -static -c $(OBJS) -o $@ ; \ - else \ - ar cr $@ `$(LORDER) $(OBJS) | $(TSORT)` ; \ - $(RANLIB) $@ ; \ - fi - -all-recursive: - for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(MAKEDEFS) all) || exit 1; \ - done - -install uninstall: - for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(MAKEDEFS) $@) || exit 1; \ - done - -# ========== DEPENDENCIES FOR CLEANUP ========== - -mostlyclean: mostlyclean-recursive mostlyclean-local -clean: clean-recursive clean-local -distclean: distclean-recursive distclean-local -realclean: realclean-recursive realclean-local -superclean: superclean-recursive superclean-local - -mostlyclean-local: - rm -f *~ - -clean-local: mostlyclean-local - rm -f libzot.a - -distclean-local: clean-local - rm -f Makefile - -realclean-local: distclean-local - -superclean-local: realclean-local - -mostlyclean-recursive clean-recursive distclean-recursive realclean-recursive superclean-recursive: - for subdir in $(SUBDIRS); do \ - target=`echo $@ | sed 's/-recursive//'`; \ - (cd $$subdir && $(MAKE) $(MAKEDEFS) $$target) || exit 1; \ - done - -# ========== DEPENDENCIES FOR LINT ================= - -lint: - for subdir in $(SUBDIRS) ; do \ - (cd $$subdir && $(MAKE) $(MAKEDEFS) lint) || exit 1; \ - done - -# ========== DEPENDENCIES FOR MAINTENANCE ========== - -subdir = zotnet - -Makefile: Makefile.in ../config.status - cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -distdir = ../`cat ../distname`/$(subdir) -nmhdist: $(DIST) - @echo "Copying distribution files in $(subdir)" - @for file in $(DIST); do \ - cp -p $(srcdir)/$$file $(distdir); \ - done - @for subdir in $(SUBDIRS); do \ - mkdir $(distdir)/$$subdir; \ - chmod 755 $(distdir)/$$subdir; \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done - diff --git a/zotnet/bboards/Makefile.in b/zotnet/bboards/Makefile.in deleted file mode 100644 index 80615a3..0000000 --- a/zotnet/bboards/Makefile.in +++ /dev/null @@ -1,84 +0,0 @@ -# -# Makefile for zotnet/bboards subdirectory -# -# $Id$ -# - -SHELL = /bin/sh - -top_srcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -CFLAGS = @CFLAGS@ -DEFS = @DEFS@ -INCLUDES = -I../.. -I$(srcdir) -I$(top_srcdir) - -LINT = @LINT@ -LINTFLAGS = @LINTFLAGS@ - -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(COMPILE) $< - -# header files -HDRS = bboards.h - -# source files -SRCS = getbbent.c - -# object files -OBJS = getbbent.o - -# auxiliary files -AUX = Makefile.in - -# all files in this directory included in the distribution -DIST = $(HDRS) $(SRCS) $(AUX) - -# ========= DEPENDENCIES FOR BUILDING ========== - -all: $(OBJS) - -install: - -uninstall: - -# ========== DEPENDENCIES FOR CLEANUP ========== - -mostlyclean: - rm -f *.o *~ - -clean: mostlyclean - -distclean: clean - rm -f Makefile - -realclean: distclean - -superclean: realclean - -# ========== DEPENDENCIES FOR LINT ================= - -lint: - $(LINT) $(LINTFLAGS) $(INCLUDES) $(DEFS) $(SRCS) - -# ========== DEPENDENCIES FOR MAINTENANCE ========== - -subdir = zotnet/bboards - -Makefile: Makefile.in ../../config.status - cd ../.. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -distdir = ../../`cat ../../distname`/$(subdir) -nmhdist: $(DIST) - @echo "Copying distribution files in $(subdir)" - @for file in $(DIST); do \ - cp -p $(srcdir)/$$file $(distdir); \ - done - diff --git a/zotnet/bboards/bboards.h b/zotnet/bboards/bboards.h deleted file mode 100644 index 227bee5..0000000 --- a/zotnet/bboards/bboards.h +++ /dev/null @@ -1,88 +0,0 @@ - -/* - * bboards.h -- definition of a BBoard structure - * - * $Id$ - */ - -#define BBOARDS "bboards" /* name in /etc/passwd */ -#define BBDB "BBoards" /* file in BBOARDS' home directory */ -#define BBMODE 0644 /* default BBoards mode */ -#define DISTADR "dist-" /* prefix for distribution addresses */ - -#ifdef POP -# define POPUID "pop" /* name in /etc/passwd */ -# define POPDB "POP" /* file in POPUID's home directory */ -# define POMODE 0600 /* default POP subscriber maildrop mode */ -#endif /* POP */ - -#define BB_NULL 0x0000 -#define BB_ARCH 0x0007 /* archive policy */ -#define BB_ASAV 0x0001 /* save in archives/ directory */ -#define BB_AREM 0x0002 /* remove without saving */ -#define BB_INVIS 0x0010 /* invisible to bbc */ -#define BB_REMOTE 0x0020 /* remote to bbc */ -#define BB_SEEN 0x0040 /* seen by bbc */ -#define BBITS "\020\01ARCHIVE\02REMOVE\05INVIS\06REMOTE\07SEEN" - -struct bboard { - char *bb_name; /* name of the bboard */ - char **bb_aka; /* aliases for the bboards */ - - char *bb_file; /* file it resides in */ - char *bb_archive; /* file where archives reside */ - char *bb_info; /* file where maxima resides */ - char *bb_map; /* file where binary map resides */ - - char *bb_passwd; /* password for it */ - char **bb_leader; /* list of local leaders */ - - char *bb_addr; /* network address */ - char *bb_request; /* network address for requests */ - char *bb_relay; /* host acting as relay in local domain */ - char **bb_dist; /* distribution list */ - - unsigned int bb_flags; /* various flags */ - - union { /* unassigned */ - unsigned int un_count; - long un_mtime; - } bb_un; - - unsigned int bb_maxima; /* highest BBoard-Id in it */ - char *bb_date; /* date that maxima was written */ - - struct bboard *bb_next; /* unassigned */ - struct bboard *bb_link; /* unassigned */ - struct bboard *bb_chain; /* unassigned */ -}; - -#define bb_count bb_un.un_count -#define bb_mtime bb_un.un_mtime - -/* flags for setbbent() */ -#define SB_NULL 0x0000 -#define SB_STAY 0x0001 /* stay open between calls */ -#define SB_FAST 0x0002 /* fast parse of file */ - - -/* - * prototypes - */ -int setbbfile (char *, int); -int setbbinfo (char *, char *, int); -int setpwinfo (struct passwd *, char *, int); -int setbbent (int); -int endbbent (void); -long getbbtime (void); -struct bboard *getbbent (void); -struct bboard *getbbnam (char *); -struct bboard *getbbaka (char *); -static void BBread (void); -int ldrbb (struct bboard *); -int ldrchk (struct bboard *); -struct bboard *getbbcpy (struct bboard *); -int getbbdist (struct bboard *, int (*)()); -char *getbberr (void); -void make_lower (char *, char *); - diff --git a/zotnet/bboards/getbbent.c b/zotnet/bboards/getbbent.c deleted file mode 100644 index c820d69..0000000 --- a/zotnet/bboards/getbbent.c +++ /dev/null @@ -1,735 +0,0 @@ - -/* - * getbbent.c -- subroutines for accessing the BBoards file - * - * $Id$ - */ - -#include "h/mh.h" /* for snprintf() */ -#include - -#ifdef MMDFONLY -# include -# include -# include -#endif /* MMDFONLY */ - -#include -#include -#include - -#ifdef HAVE_CRYPT_H -# include -#endif - -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifndef MMDFONLY -# define NOTOK (-1) -# define OK 0 -#endif - -#define MaxBBAka 100 -#define MaxBBLdr 100 -#define MaxBBDist 100 - -#define NCOLON 9 /* currently 10 fields per entry */ - -#define COLON ':' -#define COMMA ',' -#define NEWLINE '\n' - -#define ARCHIVE "archive" -#define CNTFILE ".cnt" -#define DSTFILE ".dist" -#define MAPFILE ".map" - -static int BBuid = -1; - -static unsigned int BBflags = SB_NULL; - -static char BBName[BUFSIZ] = BBOARDS; -static char BBDir[BUFSIZ] = ""; -static char BBData[BUFSIZ] = ""; - -static FILE *BBfile = NULL; - -static struct bboard BB; -static struct bboard *bb = &BB; - -static int BBload = 1; - -static char BBFile[BUFSIZ]; -static char BBArchive[BUFSIZ]; -static char BBInfo[BUFSIZ]; -static char BBMap[BUFSIZ]; -static char *BBAkas[MaxBBAka]; -static char *BBLeaders[MaxBBLdr]; -static char *BBDists[MaxBBDist]; -static char BBAddr[BUFSIZ]; -static char BBRequest[BUFSIZ]; -static char BBDate[BUFSIZ]; -static char BBErrors[BUFSIZ]; - -#ifdef MMDFONLY -extern LLog *logptr; -#endif - -#ifdef UCL -int called_bbc = 0; -char *bbs[101]; -#endif - - -/* - * static prototypes - */ -static int setbbaux (char *, char *); -static int setpwaux (struct passwd *, char *); -static void BBread (void); -static int getbbitem (struct bboard *, char *, int (*)()); -static int bblose (char *, ...); -static char *bbskip (char *, char); -static char *our_getcpy (char *); - - -int -setbbfile (char *file, int f) -{ - if (BBuid == -1) - return setbbinfo (BBOARDS, file, f); - - strncpy (BBData, file, sizeof(BBData)); - - BBflags = SB_NULL; - endbbent (); - - return setbbent (f); -} - - -int -setbbinfo (char *user, char *file, int f) -{ - register struct passwd *pw; - - if ((pw = getpwnam (user)) == NULL) { - snprintf (BBErrors, sizeof(BBErrors), "unknown user: %s", user); - return 0; - } - - return setpwinfo (pw, file, f); -} - - -int -setpwinfo (struct passwd *pw, char *file, int f) -{ - if (!setpwaux (pw, file)) - return 0; - - BBflags = SB_NULL; - endbbent (); - - return setbbent (f); -} - - -static int -setbbaux (char *name, char *file) -{ - register struct passwd *pw; - - if ((pw = getpwnam (name)) == NULL) { - snprintf (BBErrors, sizeof(BBErrors), "unknown user: %s", name); - return 0; - } - - return setpwaux (pw, file); -} - - -static int -setpwaux (struct passwd *pw, char *file) -{ - strncpy (BBName, pw->pw_name, sizeof(BBName)); - BBuid = pw->pw_uid; - strncpy (BBDir, pw->pw_dir, sizeof(BBDir)); - snprintf (BBData, sizeof(BBData), "%s/%s", - *file != '/' ? BBDir : "", - *file != '/' ? file : file + 1); - - BBflags = SB_NULL; - - return 1; -} - - -int -setbbent (int f) -{ - if (BBfile == NULL) { - if (BBuid == -1 && !setbbaux (BBOARDS, BBDB)) - return 0; - - if ((BBfile = fopen (BBData, "r")) == NULL) { - snprintf (BBErrors, sizeof(BBErrors), "unable to open: %s", BBData); - return 0; - } - } - else - rewind (BBfile); - - BBflags |= f; - return (BBfile != NULL); -} - - -int -endbbent (void) -{ - if (BBfile != NULL && !(BBflags & SB_STAY)) { - fclose (BBfile); - BBfile = NULL; - } - - return 1; -} - - -long -getbbtime (void) -{ - struct stat st; - - if (BBfile == NULL) { - if (BBuid == -1 && !setbbaux (BBOARDS, BBDB)) - return 0; - - if (stat (BBData, &st) == NOTOK) { - snprintf (BBErrors, sizeof(BBErrors), "unable to stat: %s", BBData); - return 0; - } - } else { - if (fstat (fileno (BBfile), &st) == NOTOK) { - snprintf (BBErrors, sizeof(BBErrors), "unable to fstat: %s", BBData); - return 0; - } - } - - return ((long) st.st_mtime); -} - - -struct bboard * -getbbent (void) -{ - register int count; - register char *p, *q, *r, *d, *f, **s; - static char line[BUFSIZ]; - - if (BBfile == NULL && !setbbent (SB_NULL)) - return NULL; - -retry: ; - if ((p = fgets (line, sizeof line, BBfile)) == NULL) - return NULL; - - for (q = p, count = 0; *q != 0 && *q != NEWLINE; q++) - if (*q == COLON) - count++; - - if (count != NCOLON) { -#ifdef MMDFONLY - if (q = strchr(p, NEWLINE)) - *q = 0; - ll_log (logptr, LLOGTMP, "bad entry in %s: %s", BBData, p); -#endif /* MMDFONLY */ - goto retry; - } - - bb->bb_name = p; - p = q = bbskip (p, COLON); - p = bb->bb_file = bbskip (p, COLON); - bb->bb_archive = bb->bb_info = bb->bb_map = ""; - p = bb->bb_passwd = bbskip (p, COLON); - p = r = bbskip (p, COLON); - p = bb->bb_addr = bbskip (p, COLON); - p = bb->bb_request = bbskip (p, COLON); - p = bb->bb_relay = bbskip (p, COLON); - p = d = bbskip (p, COLON); - p = f = bbskip (p, COLON); - bbskip (p, NEWLINE); - - s = bb->bb_aka = BBAkas; - while (*q) { - *s++ = q; - q = bbskip (q, COMMA); - } - *s = 0; - - s = bb->bb_leader = BBLeaders; - if (*r == 0) { - if (!(BBflags & SB_FAST)) { - *s++ = BBName; - *s = 0; - } - } - else { - while (*r) { - *s++ = r; - r = bbskip (r, COMMA); - } - *s = 0; - } - - s = bb->bb_dist = BBDists; - while (*d) { - *s++ = d; - d = bbskip (d, COMMA); - } - *s = 0; - - if (*f) - sscanf (f, "%o", &bb->bb_flags); - else - bb->bb_flags = BB_NULL; - bb->bb_count = bb->bb_maxima = 0; - bb->bb_date = NULL; - bb->bb_next = bb->bb_link = bb->bb_chain = NULL; - -#ifdef UCL - /* - * Only do a BBread on bboards that the user has expressed an - * interest in, if we were called by bbc. - */ - if (BBload) { - register char **ap, *cp; - register int bbp; - - if (called_bbc == 0) - BBread(); - else { - for (bbp = 0; cp = bbs[bbp]; bbp++) { - if (!strcmp(bb->bb_name, cp)) { - BBread(); - break; - } - for (ap = bb->bb_aka; *ap; ap++) - if (!strcmp(*ap, cp)) { - BBread(); - break; - } - } - } - } -#else - if (BBload) - BBread (); -#endif - - return bb; -} - - -struct bboard * -getbbnam (char *name) -{ - register struct bboard *b = NULL; - - if (!setbbent (SB_NULL)) - return NULL; - BBload = 0; - while ((b = getbbent ()) && strcmp (name, b->bb_name)) - continue; - BBload = 1; - endbbent (); - - if (b != NULL) - BBread (); - - return b; -} - - -struct bboard * -getbbaka (char *aka) -{ - register char **ap; - register struct bboard *b = NULL; - - if (!setbbent (SB_NULL)) - return NULL; - BBload = 0; - while ((b = getbbent ()) != NULL) - for (ap = b->bb_aka; *ap; ap++) - if (strcmp (aka, *ap) == 0) - goto hit; -hit: ; - BBload = 1; - endbbent (); - - if (b != NULL) - BBread (); - - return b; -} - - -static void -BBread (void) -{ - register int i; - register char *cp, *dp, *p, *r; - char prf[BUFSIZ]; - static char line[BUFSIZ]; - register FILE * info; - - if (BBflags & SB_FAST) - return; - - p = strchr(bb->bb_request, '@'); - r = strchr(bb->bb_addr, '@'); - BBRequest[0] = 0; - - if (*bb->bb_request == '-') { - if (p == NULL && r && *r == '@') - snprintf (BBRequest, sizeof(BBRequest), "%s%s%s", bb->bb_name, bb->bb_request, r); - else - snprintf (BBRequest, sizeof(BBRequest), "%s%s", bb->bb_name, bb->bb_request); - } - else - if (p == NULL && r && *r == '@' && *bb->bb_request) - snprintf (BBRequest, sizeof(BBRequest), "%s%s", bb->bb_request, r); - - if (BBRequest[0]) - bb->bb_request = BBRequest; - else - if (*bb->bb_request == 0) - bb->bb_request = *bb->bb_addr ? bb->bb_addr - : bb->bb_leader[0]; - - if (*bb->bb_addr == '@') { - snprintf (BBAddr, sizeof(BBAddr), "%s%s", bb->bb_name, bb->bb_addr); - bb->bb_addr = BBAddr; - } - else - if (*bb->bb_addr == 0) - bb->bb_addr = bb->bb_name; - - if (*bb->bb_file == 0) - return; - if (*bb->bb_file != '/') { - snprintf (BBFile, sizeof(BBFile), "%s/%s", BBDir, bb->bb_file); - bb->bb_file = BBFile; - } - - if ((cp = strrchr(bb->bb_file, '/')) == NULL || *++cp == 0) { - strcpy (prf, ""); - cp = bb->bb_file; - } else { - snprintf (prf, sizeof(prf), "%.*s", cp - bb->bb_file, bb->bb_file); - } - if ((dp = strchr(cp, '.')) == NULL) - dp = cp + strlen (cp); - - snprintf (BBArchive, sizeof(BBArchive), "%s%s/%s", prf, ARCHIVE, cp); - bb->bb_archive = BBArchive; - snprintf (BBInfo, sizeof(BBInfo), "%s.%.*s%s", prf, dp - cp, cp, CNTFILE); - bb->bb_info = BBInfo; - snprintf (BBMap, sizeof(BBMap), "%s.%.*s%s", prf, dp - cp, cp, MAPFILE); - bb->bb_map = BBMap; - - if ((info = fopen (bb->bb_info, "r")) == NULL) - return; - - if (fgets (line, sizeof line, info) && (i = atoi (line)) > 0) - bb->bb_maxima = (unsigned) i; - if (!feof (info) && fgets (line, sizeof line, info)) { - strncpy (BBDate, line, sizeof(BBData)); - if ((cp = strchr(BBDate, NEWLINE))) - *cp = 0; - bb->bb_date = BBDate; - } - - fclose (info); -} - - -int -ldrbb (struct bboard *b) -{ - register char *p, **q, **r; - static uid_t uid = 0; - static gid_t gid = 0; - static char username[10] = ""; - register struct passwd *pw; - register struct group *gr; - - if (b == NULL) - return 0; - if (BBuid == -1 && !setbbaux (BBOARDS, BBDB)) - return 0; - - if (username[0] == 0) { - if ((pw = getpwuid (uid = getuid ())) == NULL) - return 0; - gid = getgid (); - strncpy (username, pw->pw_name, sizeof(username)); - } - - if (uid == BBuid) - return 1; - - q = b->bb_leader; - while ((p = *q++)) - if (*p == '=') { - if ((gr = getgrnam (++p)) == NULL) - continue; - if (gid == gr->gr_gid) - return 1; - r = gr->gr_mem; - while ((p = *r++)) - if (strcmp (username, p) == 0) - return 1; - } - else - if (strcmp (username, p) == 0) - return 1; - - return 0; -} - - -int -ldrchk (struct bboard *b) -{ - if (b == NULL) - return 0; - - if (*b->bb_passwd == 0) - return 1; - - if (strcmp (b->bb_passwd, - crypt (nmh_getpass ("Password: "), b->bb_passwd)) == 0) - return 1; - - fprintf (stderr, "Sorry\n"); - return 0; -} - - -struct bboard * -getbbcpy (struct bboard *bp) -{ - register char **p, **q; - register struct bboard *b; - - if (bp == NULL) - return NULL; - - b = (struct bboard *) malloc ((unsigned) sizeof *b); - if (b == NULL) - return NULL; - - b->bb_name = our_getcpy (bp->bb_name); - b->bb_file = our_getcpy (bp->bb_file); - b->bb_archive = our_getcpy (bp->bb_archive); - b->bb_info = our_getcpy (bp->bb_info); - b->bb_map = our_getcpy (bp->bb_map); - b->bb_passwd = our_getcpy (bp->bb_passwd); - b->bb_flags = bp->bb_flags; - b->bb_count = bp->bb_count; - b->bb_maxima = bp->bb_maxima; - b->bb_date = our_getcpy (bp->bb_date); - b->bb_addr = our_getcpy (bp->bb_addr); - b->bb_request = our_getcpy (bp->bb_request); - b->bb_relay = our_getcpy (bp->bb_relay); - - for (p = bp->bb_aka; *p; p++) - continue; - b->bb_aka = - q = (char **) calloc ((unsigned) (p - bp->bb_aka + 1), sizeof *q); - if (q == NULL) - return NULL; - for (p = bp->bb_aka; *p; *q++ = our_getcpy (*p++)) - continue; - *q = NULL; - - for (p = bp->bb_leader; *p; p++) - continue; - b->bb_leader = - q = (char **) calloc ((unsigned) (p - bp->bb_leader + 1), sizeof *q); - if (q == NULL) - return NULL; - for (p = bp->bb_leader; *p; *q++ = our_getcpy (*p++)) - continue; - *q = NULL; - - for (p = bp->bb_dist; *p; p++) - continue; - b->bb_dist = - q = (char **) calloc ((unsigned) (p - bp->bb_dist + 1), sizeof *q); - if (q == NULL) - return NULL; - for (p = bp->bb_dist; *p; *q++ = our_getcpy (*p++)) - continue; - *q = NULL; - - b->bb_next = bp->bb_next; - b->bb_link = bp->bb_link; - b->bb_chain = bp->bb_chain; - - return b; -} - - -int -getbbdist (struct bboard *bb, int (*action)()) -{ - register int result; - register char **dp; - - BBErrors[0] = 0; - for (dp = bb->bb_dist; *dp; dp++) - if ((result = getbbitem (bb, *dp, action))) - return result; - - return result; -} - -char * -getbberr (void) -{ - return (BBErrors[0] ? BBErrors : NULL); -} - - -static int -getbbitem (struct bboard *bb, char *item, int (*action)()) -{ - register int result; - register char *cp, *dp, *hp, *np; - char mbox[BUFSIZ], - buffer[BUFSIZ], - file[BUFSIZ], - host[BUFSIZ], - prf[BUFSIZ]; - register FILE *fp; - - switch (*item) { - case '*': - switch (*++item) { - case '/': - hp = item; - break; - - case 0: - if ((cp = strrchr(bb->bb_file, '/')) == NULL || *++cp == 0) { - strcpy (prf, ""); - cp = bb->bb_file; - } else { - snprintf (prf, sizeof(prf), "%.*s", cp - bb->bb_file, bb->bb_file); - } - if ((dp = strchr(cp, '.')) == NULL) - dp = cp + strlen (cp); - snprintf (file, sizeof(file), "%s.%.*s%s", prf, dp - cp, cp, DSTFILE); - hp = file; - break; - - default: - snprintf (file, sizeof(file), "%s/%s", BBDir, item); - hp = file; - break; - } - - if ((fp = fopen (hp, "r")) == NULL) - return bblose ("unable to read file %s", hp); - while (fgets (buffer, sizeof buffer, fp)) { - if ((np = strchr(buffer, '\n'))) - *np = 0; - if ((result = getbbitem (bb, buffer, action))) { - fclose (fp); - bblose ("error with file %s, item %s", hp, buffer); - return result; - } - } - fclose (fp); - return OK; - - default: - if ((hp = strrchr(item, '@'))) { - *hp++ = 0; - strncpy (mbox, item, sizeof(mbox)); - strncpy (host, hp, sizeof(host)); - *--hp = '@'; - } - else { - snprintf (mbox, sizeof(mbox), "%s%s", DISTADR, bb->bb_name); - strncpy (host, item, sizeof(host)); - } - if ((result = (*action) (mbox, host))) - bblose ("action (%s, %s) returned 0%o", mbox, host, result); - return result; - } -} - - -static int -bblose (char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - if (BBErrors[0] == 0) - vsnprintf (BBErrors, sizeof(BBErrors), fmt, ap); - - va_end(ap); - return NOTOK; -} - - -void -make_lower (char *s1, char *s2) -{ - if (!s1 || !s2) - return; - - for (; *s2; s2++) - *s1++ = isupper (*s2) ? tolower (*s2) : *s2; - *s1 = 0; -} - - -static char * -bbskip (char *p, char c) -{ - if (p == NULL) - return NULL; - - while (*p && *p != c) - p++; - if (*p) - *p++ = 0; - - return p; -} - - -static char * -our_getcpy (char *s) -{ - register char *p; - size_t len; - - if (s == NULL) - return NULL; - - len = strlen (s) + 1; - if ((p = malloc (len))) - memcpy (p, s, len); - return p; -} - diff --git a/zotnet/mf/Makefile.in b/zotnet/mf/Makefile.in deleted file mode 100644 index 0187714..0000000 --- a/zotnet/mf/Makefile.in +++ /dev/null @@ -1,83 +0,0 @@ -# -# Makefile for zotnet/mf subdirectory -# -# $Id$ -# - -SHELL = /bin/sh - -top_srcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -CFLAGS = @CFLAGS@ -DEFS = @DEFS@ -INCLUDES = -I../.. -I$(srcdir) -I$(top_srcdir) -LINT = @LINT@ -LINTFLAGS = @LINTFLAGS@ - -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(COMPILE) $< - -# header files -HDRS = mf.h - -# source files -SRCS = mf.c - -# object files -OBJS = mf.o - -# auxiliary files -AUX = Makefile.in - -# all files in this directory included in the distribution -DIST = $(HDRS) $(SRCS) $(AUX) - -# ========= DEPENDENCIES FOR BUILDING ========== - -all: $(OBJS) - -install: - -uninstall: - -# ========== DEPENDENCIES FOR CLEANUP ========== - -mostlyclean: - rm -f *.o *~ - -clean: mostlyclean - -distclean: clean - rm -f Makefile - -realclean: distclean - -superclean: realclean - -# ========== DEPENDENCIES FOR LINT ================ - -lint: - $(LINT) $(LINTFLAGS) $(INCLUDES) $(DEFS) $(SRCS) - -# ========== DEPENDENCIES FOR MAINTENANCE ========== - -subdir = zotnet/mf - -Makefile: Makefile.in ../../config.status - cd ../.. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -distdir = ../../`cat ../../distname`/$(subdir) -nmhdist: $(DIST) - @echo "Copying distribution files in $(subdir)" - @for file in $(DIST); do \ - cp -p $(srcdir)/$$file $(distdir); \ - done - diff --git a/zotnet/mf/mf.c b/zotnet/mf/mf.c deleted file mode 100644 index ab6dfa4..0000000 --- a/zotnet/mf/mf.c +++ /dev/null @@ -1,968 +0,0 @@ - -/* - * mf.c -- mail filter subroutines - * - * $Id$ - */ - -#include -#include -#include - -/* - * static prototypes - */ -static char *getcpy (char *); -static char *add (char *, char *); -static void compress (char *, char *); -static int isat (char *); -static int parse_address (void); -static int phrase (char *); -static int route_addr (char *); -static int local_part (char *); -static int domain (char *); -static int route (char *); -static int my_lex (char *); - - -static char * -getcpy (char *s) -{ - register char *p; - - if (!s) { -/* causes compiles to blow up because the symbol _cleanup is undefined - where did this ever come from? */ - /* _cleanup(); */ - abort(); - for(;;) - pause(); - } - if ((p = malloc ((size_t) (strlen (s) + 2)))) - strcpy (p, s); - return p; -} - - -static char * -add (char *s1, char *s2) -{ - register char *p; - - if (!s2) - return getcpy (s1); - - if ((p = malloc ((size_t) (strlen (s1) + strlen (s2) + 2)))) - sprintf (p, "%s%s", s2, s1); - free (s2); - return p; -} - -int -isfrom(char *string) -{ - return (strncmp (string, "From ", 5) == 0 - || strncmp (string, ">From ", 6) == 0); -} - - -int -lequal (char *a, char *b) -{ - for (; *a; a++, b++) - if (*b == 0) - return FALSE; - else { - char c1 = islower (*a) ? toupper (*a) : *a; - char c2 = islower (*b) ? toupper (*b) : *b; - if (c1 != c2) - return FALSE; - } - - return (*b == 0); -} - - -/* - * seekadrx() is tricky. We want to cover both UUCP-style and ARPA-style - * addresses, so for each list of addresses we see if we can find some - * character to give us a hint. - */ - - -#define CHKADR 0 /* undertermined address style */ -#define UNIXDR 1 /* UNIX-style address */ -#define ARPADR 2 /* ARPAnet-style address */ - - -static char *punctuators = ";<>.()[]"; -static char *vp = NULL; -static char *tp = NULL; - -static struct adrx adrxs1; - - -struct adrx * -seekadrx (char *addrs) -{ - static int state = CHKADR; - register char *cp; - register struct adrx *adrxp; - - if (state == CHKADR) - for (state = UNIXDR, cp = addrs; *cp; cp++) - if (strchr(punctuators, *cp)) { - state = ARPADR; - break; - } - - switch (state) { - case UNIXDR: - adrxp = uucpadrx (addrs); - break; - - case ARPADR: - default: - adrxp = getadrx (addrs); - break; - } - - if (adrxp == NULL) - state = CHKADR; - - return adrxp; -} - - -/* - * uucpadrx() implements a partial UUCP-style address parser. It's based - * on the UUCP notion that addresses are separated by spaces or commas. - */ - - -struct adrx * -uucpadrx (char *addrs) -{ - register char *cp, *wp, *xp, *yp, *zp; - register struct adrx *adrxp = &adrxs1; - - if (vp == NULL) { - vp = tp = getcpy (addrs); - compress (addrs, vp); - } - else - if (tp == NULL) { - free (vp); - vp = NULL; - return NULL; - } - - for (cp = tp; isspace (*cp); cp++) - continue; - if (*cp == 0) { - free (vp); - vp = tp = NULL; - return NULL; - } - - if ((wp = strchr(cp, ',')) == NULL) { - if ((wp = strchr(cp, ' ')) != NULL) { - xp = wp; - while (isspace (*xp)) - xp++; - if (*xp != 0 && isat (--xp)) { - yp = xp + 4; - while (isspace (*yp)) - yp++; - if (*yp != 0) { - if ((zp = strchr(yp, ' ')) != NULL) - *zp = 0, tp = ++zp; - else - tp = NULL; - } - else - *wp = 0, tp = ++wp; - } - else - *wp = 0, tp = ++wp; - } - else - tp = NULL; - } - else - *wp = 0, tp = ++wp; - - if (adrxp->text) - free (adrxp->text); - adrxp->text = getcpy (cp); - adrxp->mbox = cp; - adrxp->host = adrxp->path = NULL; - if ((wp = strrchr(cp, '@')) != NULL) { - *wp++ = 0; - adrxp->host = *wp ? wp : NULL; - } - else - for (wp = cp + strlen (cp) - 4; wp >= cp; wp--) - if (isat (wp)) { - *wp++ = 0; - adrxp->host = wp + 3; - } - - adrxp->pers = adrxp->grp = adrxp->note = adrxp->err = NULL; - adrxp->ingrp = 0; - - return adrxp; -} - - -static void -compress (char *fp, char *tp) -{ - register char c, *cp; - - for (c = ' ', cp = tp; (*tp = *fp++) != 0;) - if (isspace (*tp)) { - if (c != ' ') - *tp++ = c = ' '; - } - else - c = *tp++; - - if (c == ' ' && cp < tp) - *--tp = 0; -} - - -static int -isat (char *p) -{ - return (strncmp (p, " AT ", 4) - && strncmp (p, " At ", 4) - && strncmp (p, " aT ", 4) - && strncmp (p, " at ", 4) ? FALSE : TRUE); -} - - -/* - * - * getadrx() implements a partial 822-style address parser. The parser - * is neither complete nor correct. It does however recognize nearly all - * of the 822 address syntax. In addition it handles the majority of the - * 733 syntax as well. Most problems arise from trying to accomodate both. - * - * In terms of 822, the route-specification in - * - * "<" [route] local-part "@" domain ">" - * - * is parsed and returned unchanged. Multiple at-signs are compressed - * via source-routing. Recursive groups are not allowed as per the - * standard. - * - * In terms of 733, " at " is recognized as equivalent to "@". - * - * In terms of both the parser will not complain about missing hosts. - * - * ----- - * - * We should not allow addresses like - * - * Marshall T. Rose - * - * but should insist on - * - * "Marshall T. Rose" - * - * Unfortunately, a lot of mailers stupidly let people get away with this. - * - * ----- - * - * We should not allow addresses like - * - * - * - * but should insist on - * - * MRose@UCI - * - * Unfortunately, a lot of mailers stupidly let people's UAs get away with - * this. - * - * ----- - * - * We should not allow addresses like - * - * @UCI:MRose@UCI-750a - * - * but should insist on - * - * Marshall Rose <@UCI:MRose@UCI-750a> - * - * Unfortunately, a lot of mailers stupidly do this. - * - */ - -#define QUOTE '\\' - -#define LX_END 0 -#define LX_ERR 1 -#define LX_ATOM 2 -#define LX_QSTR 3 -#define LX_DLIT 4 -#define LX_SEMI 5 -#define LX_COMA 6 -#define LX_LBRK 7 -#define LX_RBRK 8 -#define LX_COLN 9 -#define LX_DOT 10 -#define LX_AT 11 - -struct specials { - char lx_chr; - int lx_val; -}; - -static struct specials special[] = { - { ';', LX_SEMI }, - { ',', LX_COMA }, - { '<', LX_LBRK }, - { '>', LX_RBRK }, - { ':', LX_COLN }, - { '.', LX_DOT }, - { '@', LX_AT }, - { '(', LX_ERR }, - { ')', LX_ERR }, - { QUOTE, LX_ERR }, - { '"', LX_ERR }, - { '[', LX_ERR }, - { ']', LX_ERR }, - { 0, 0 } -}; - -static int glevel = 0; -static int ingrp = 0; -static int last_lex = LX_END; - -static char *dp = NULL; -static char *cp = NULL; -static char *ap = NULL; -static char *pers = NULL; -static char *mbox = NULL; -static char *host = NULL; -static char *path = NULL; -static char *grp = NULL; -static char *note = NULL; -static char err[BUFSIZ]; -static char adr[BUFSIZ]; - -static struct adrx adrxs2; - - -struct adrx * -getadrx (char *addrs) -{ - register char *bp; - register struct adrx *adrxp = &adrxs2; - - if (pers) - free (pers); - if (mbox) - free (mbox); - if (host) - free (host); - if (path) - free (path); - if (grp) - free (grp); - if (note) - free (note); - pers = mbox = host = path = grp = note = NULL; - err[0] = 0; - - if (dp == NULL) { - dp = cp = getcpy (addrs ? addrs : ""); - glevel = 0; - } - else - if (cp == NULL) { - free (dp); - dp = NULL; - return NULL; - } - - switch (parse_address ()) { - case DONE: - free (dp); - dp = cp = NULL; - return NULL; - - case OK: - switch (last_lex) { - case LX_COMA: - case LX_END: - break; - - default: /* catch trailing comments */ - bp = cp; - my_lex (adr); - cp = bp; - break; - } - break; - - default: - break; - } - - if (err[0]) - for (;;) { - switch (last_lex) { - case LX_COMA: - case LX_END: - break; - - default: - my_lex (adr); - continue; - } - break; - } - while (isspace (*ap)) - ap++; - if (cp) - sprintf (adr, "%.*s", cp - ap, ap); - else - strcpy (adr, ap); - bp = adr + strlen (adr) - 1; - if (*bp == ',' || *bp == ';' || *bp == '\n') - *bp = 0; - - adrxp->text = adr; - adrxp->pers = pers; - adrxp->mbox = mbox; - adrxp->host = host; - adrxp->path = path; - adrxp->grp = grp; - adrxp->ingrp = ingrp; - adrxp->note = note; - adrxp->err = err[0] ? err : NULL; - - return adrxp; -} - - -static int -parse_address (void) -{ - char buffer[BUFSIZ]; - -again: ; - ap = cp; - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_QSTR: - pers = getcpy (buffer); - break; - - case LX_SEMI: - if (glevel-- <= 0) { - strcpy (err, "extraneous semi-colon"); - return NOTOK; - } - case LX_COMA: - if (note) { - free (note); - note = NULL; - } - goto again; - - case LX_END: - return DONE; - - case LX_LBRK: /* sigh (2) */ - goto get_addr; - - case LX_AT: /* sigh (3) */ - cp = ap; - if (route_addr (buffer) == NOTOK) - return NOTOK; - return OK; /* why be choosy? */ - - default: - sprintf (err, "illegal address construct (%s)", buffer); - return NOTOK; - } - - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_QSTR: - pers = add (buffer, add (" ", pers)); - more_phrase: ; /* sigh (1) */ - if (phrase (buffer) == NOTOK) - return NOTOK; - - switch (last_lex) { - case LX_LBRK: - get_addr: ; - if (route_addr (buffer) == NOTOK) - return NOTOK; - if (last_lex == LX_RBRK) - return OK; - sprintf (err, "missing right-bracket (%s)", buffer); - return NOTOK; - - case LX_COLN: - get_group: ; - if (glevel++ > 0) { - sprintf (err, "nested groups not allowed (%s)", pers); - return NOTOK; - } - grp = add (": ", pers); - pers = NULL; - { - char *pp = cp; - - for (;;) - switch (my_lex (buffer)) { - case LX_SEMI: - case LX_END: /* tsk, tsk */ - glevel--; - return OK; - - case LX_COMA: - continue; - - default: - cp = pp; - return parse_address (); - } - } - - case LX_DOT: /* sigh (1) */ - pers = add (".", pers); - goto more_phrase; - - default: - sprintf (err, "no mailbox in address, only a phrase (%s%s)", - pers, buffer); - return NOTOK; - } - - case LX_LBRK: - goto get_addr; - - case LX_COLN: - goto get_group; - - case LX_DOT: - mbox = add (buffer, pers); - pers = NULL; - if (route_addr (buffer) == NOTOK) - return NOTOK; - goto check_end; - - case LX_AT: - ingrp = glevel; - mbox = pers; - pers = NULL; - if (domain (buffer) == NOTOK) - return NOTOK; - check_end: ; - switch (last_lex) { - case LX_SEMI: - if (glevel-- <= 0) { - strcpy (err, "extraneous semi-colon"); - return NOTOK; - } - case LX_COMA: - case LX_END: - return OK; - - default: - sprintf (err, "junk after local@domain (%s)", buffer); - return NOTOK; - } - - case LX_SEMI: /* no host */ - case LX_COMA: - case LX_END: - ingrp = glevel; - if (last_lex == LX_SEMI && glevel-- <= 0) { - strcpy (err, "extraneous semi-colon"); - return NOTOK; - } - mbox = pers; - pers = NULL; - return OK; - - default: - sprintf (err, "missing mailbox (%s)", buffer); - return NOTOK; - } -} - - -static int -phrase (char *buffer) -{ - for (;;) - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_QSTR: - pers = add (buffer, add (" ", pers)); - continue; - - default: - return OK; - } -} - - -static int -route_addr (char *buffer) -{ - register char *pp = cp; - - if (my_lex (buffer) == LX_AT) { - if (route (buffer) == NOTOK) - return NOTOK; - } - else - cp = pp; - - if (local_part (buffer) == NOTOK) - return NOTOK; - - switch (last_lex) { - case LX_AT: - return domain (buffer); - - case LX_SEMI: /* if in group */ - case LX_RBRK: /* no host */ - case LX_COMA: - case LX_END: - return OK; - - default: - sprintf (err, "no at-sign after local-part (%s)", buffer); - return NOTOK; - } -} - - -static int -local_part (char *buffer) -{ - ingrp = glevel; - - for (;;) { - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_QSTR: - mbox = add (buffer, mbox); - break; - - default: - sprintf (err, "no mailbox in local-part (%s)", buffer); - return NOTOK; - } - - switch (my_lex (buffer)) { - case LX_DOT: - mbox = add (buffer, mbox); - continue; - - default: - return OK; - } - } -} - - -static int -domain (char *buffer) -{ - for (;;) { - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_DLIT: - host = add (buffer, host); - break; - - default: - sprintf (err, "no sub-domain in domain-part of address (%s)", buffer); - return NOTOK; - } - - switch (my_lex (buffer)) { - case LX_DOT: - host = add (buffer, host); - continue; - - case LX_AT: /* sigh (0) */ - mbox = add (host, add ("%", mbox)); - free (host); - host = NULL; - continue; - - default: - return OK; - } - } -} - - -static int -route (char *buffer) -{ - path = getcpy ("@"); - - for (;;) { - switch (my_lex (buffer)) { - case LX_ATOM: - case LX_DLIT: - path = add (buffer, path); - break; - - default: - sprintf (err, "no sub-domain in domain-part of address (%s)", buffer); - return NOTOK; - } - switch (my_lex (buffer)) { - case LX_COMA: - path = add (buffer, path); - for (;;) { - switch (my_lex (buffer)) { - case LX_COMA: - continue; - - case LX_AT: - path = add (buffer, path); - break; - - default: - sprintf (err, "no at-sign found for next domain in route (%s)", - buffer); - } - break; - } - continue; - - case LX_AT: /* XXX */ - case LX_DOT: - path = add (buffer, path); - continue; - - case LX_COLN: - path = add (buffer, path); - return OK; - - default: - sprintf (err, "no colon found to terminate route (%s)", buffer); - return NOTOK; - } - } -} - - -static int -my_lex (char *buffer) -{ - int i, gotat = 0; - register char c, *bp; - - bp = buffer; - *bp = 0; - if (!cp) - return (last_lex = LX_END); - - gotat = isat (cp); - c = *cp++; - while (isspace (c)) - c = *cp++; - if (c == 0) { - cp = NULL; - return (last_lex = LX_END); - } - - if (c == '(') - for (*bp++ = c, i = 0;;) - switch (c = *cp++) { - case 0: - cp = NULL; - return (last_lex = LX_ERR); - case QUOTE: - *bp++ = c; - if ((c = *cp++) == 0) { - cp = NULL; - return (last_lex = LX_ERR); - } - *bp++ = c; - continue; - case '(': - i++; - default: - *bp++ = c; - continue; - case ')': - *bp++ = c; - if (--i < 0) { - *bp = 0; - note = note ? add (buffer, add (" ", note)) - : getcpy (buffer); - return my_lex (buffer); - } - } - - if (c == '"') - for (*bp++ = c;;) - switch (c = *cp++) { - case 0: - cp = NULL; - return (last_lex = LX_ERR); - case QUOTE: - *bp++ = c; - if ((c = *cp++) == 0) { - cp = NULL; - return (last_lex = LX_ERR); - } - default: - *bp++ = c; - continue; - case '"': - *bp++ = c; - *bp = 0; - return (last_lex = LX_QSTR); - } - - if (c == '[') - for (*bp++ = c;;) - switch (c = *cp++) { - case 0: - cp = NULL; - return (last_lex = LX_ERR); - case QUOTE: - *bp++ = c; - if ((c = *cp++) == 0) { - cp = NULL; - return (last_lex = LX_ERR); - } - default: - *bp++ = c; - continue; - case ']': - *bp++ = c; - *bp = 0; - return (last_lex = LX_DLIT); - } - - *bp++ = c; - *bp = 0; - for (i = 0; special[i].lx_chr != 0; i++) - if (c == special[i].lx_chr) - return (last_lex = special[i].lx_val); - - if (iscntrl (c)) - return (last_lex = LX_ERR); - - for (;;) { - if ((c = *cp++) == 0) - break; - for (i = 0; special[i].lx_chr != 0; i++) - if (c == special[i].lx_chr) - goto got_atom; - if (iscntrl (c) || isspace (c)) - break; - *bp++ = c; - } -got_atom: ; - if (c == 0) - cp = NULL; - else - cp--; - *bp = 0; - last_lex = !gotat || cp == NULL || strchr(cp, '<') != NULL - ? LX_ATOM : LX_AT; - return last_lex; -} - - -char * -legal_person (char *p) -{ - int i; - register char *cp; - static char buffer[BUFSIZ]; - - if (*p == '"') - return p; - for (cp = p; *cp; cp++) - for (i = 0; special[i].lx_chr; i++) - if (*cp == special[i].lx_chr) { - sprintf (buffer, "\"%s\"", p); - return buffer; - } - - return p; -} - - -int -mfgets (FILE *in, char **bp) -{ - int i; - register char *cp, *dp, *ep; - static int len = 0; - static char *pp = NULL; - - if (pp == NULL) - if (!(pp = malloc ((size_t) (len = BUFSIZ)))) - return NOTOK; - - for (ep = (cp = pp) + len - 2;;) { - switch (i = getc (in)) { - case EOF: - eol: ; - if (cp != pp) { - *cp = 0; - *bp = pp; - return OK; - } - eoh: ; - *bp = NULL; - free (pp); - pp = NULL; - return DONE; - - case 0: - continue; - - case '\n': - if (cp == pp) /* end of headers, gobble it */ - goto eoh; - switch (i = getc (in)) { - default: /* end of line */ - case '\n': /* end of headers, save for next call */ - ungetc (i, in); - goto eol; - - case ' ': /* continue headers */ - case '\t': - *cp++ = '\n'; - break; - } /* fall into default case */ - - default: - *cp++ = i; - break; - } - if (cp >= ep) { - if (!(dp = realloc (pp, (size_t) (len += BUFSIZ)))) { - free (pp); - pp = NULL; - return NOTOK; - } - else - cp += dp - pp, ep = (pp = cp) + len - 2; - } - } -} diff --git a/zotnet/mf/mf.h b/zotnet/mf/mf.h deleted file mode 100644 index a4c81e8..0000000 --- a/zotnet/mf/mf.h +++ /dev/null @@ -1,82 +0,0 @@ - -/* - * mf.h -- include file for mailbox filters - * - * $Id$ - */ - -#include - -#ifndef TRUE -# define TRUE 1 -#endif - -#ifndef FALSE -# define FALSE 0 -#endif - -#ifndef NOTOK -# define NOTOK (-1) -#endif - -#ifndef OK -# define OK 0 -#endif - -#ifndef DONE -# define DONE 1 -#endif - -#define LINESIZ 512 - -#define MBXMODE 0600 -#define TMPMODE 0600 - -#define OWIDTH 75 /* length of a header line */ - -#define HFROM 1 /* header has From: component */ -#define HSNDR 2 /* header has Sender: component */ -#define HADDR 3 /* header has address component */ -#define HDATE 4 /* header has Date: component */ -#define HOTHR 5 /* header is unimportant */ - - -struct adrx { - char *text; - char *pers; - char *mbox; - char *host; - char *path; - char *grp; - int ingrp; - char *note; - char *err; -}; - - -/* - * Codes returned by uucp2mmdf(), mmdf2uucp() - */ - -#define MFOK 0 /* all went well */ - /* remaining codes must > DONE */ -#define MFPRM 2 /* bad parameter */ -#define MFSIO 3 /* stdio package went screwy */ -#define MFROM 4 /* from line was bad */ -#define MFHDR 5 /* headers were bad */ -#define MFTXT 6 /* text was bad */ -#define MFERR 7 /* I/O or system error */ -#define MFDLM 8 /* Bad delimiter in MMDF file */ - - -/* - * prototypes - */ -int isfrom(char *); -int lequal (char *, char *); -int mfgets (FILE *, char **); -char *legal_person (char *); -struct adrx *seekadrx (char *); -struct adrx *getadrx (char *); -struct adrx *uucpadrx (char *); - diff --git a/zotnet/mts/Makefile.in b/zotnet/mts/Makefile.in deleted file mode 100644 index a57b2f1..0000000 --- a/zotnet/mts/Makefile.in +++ /dev/null @@ -1,101 +0,0 @@ -# -# Makefile for zotnet/mts subdirectory -# -# $Id$ -# - -SHELL = /bin/sh - -top_srcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ -libdir = @libdir@ -etcdir = @sysconfdir@ - -mailspool = @mailspool@ -sendmailpath = @sendmailpath@ - -CC = @CC@ -CFLAGS = @CFLAGS@ -DEFS = @DEFS@ -KRB4_INCLUDES = @KRB4_INCLUDES@ -HESIOD_INCLUDES = @HESIOD_INCLUDES@ -INCLUDES = -I../.. -I$(srcdir) -I$(top_srcdir) $(KRB4_INCLUDES) $(HESIOD_INCLUDES) -CONFIGDEFS = -DNMHETCDIR='"$(etcdir)"' -DMAILSPOOL='"$(mailspool)"' -DSENDMAILPATH='"$(sendmailpath)"' -LINT = @LINT@ -LINTFLAGS = @LINTFLAGS@ - -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) -COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(CFLAGS) - -SED = sed - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(COMPILE) $< - -# header files -HDRS = mts.h - -# source files -SRCS = mts.c client.c - -# object files -OBJS = mts.o client.o - -# auxiliary files -AUX = Makefile.in - -# all files in this directory included in the distribution -DIST = $(HDRS) $(SRCS) $(AUX) - -# ========= DEPENDENCIES FOR BUILDING AND INSTALLING ========== - -all: $(OBJS) - -mts.o: mts.c - $(COMPILE2) $< - -install: - -uninstall: - -# ========== DEPENDENCIES FOR CLEANUP ========== - -mostlyclean: - rm -f *.o *~ - -clean: mostlyclean - -distclean: clean - rm -f Makefile - -realclean: distclean - -superclean: realclean - -# ========== DEPENDENCIES FOR LINT ================ - -lint: - $(LINT) $(LINTFLAGS) $(INCLUDES) $(DEFS) $(SRCS) - -# ========== DEPENDENCIES FOR MAINTENANCE ========== - -subdir = zotnet/mts - -Makefile: Makefile.in ../../config.status - cd ../.. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -distdir = ../../`cat ../../distname`/$(subdir) -nmhdist: $(DIST) - @echo "Copying distribution files in $(subdir)" - @for file in $(DIST); do \ - cp -p $(srcdir)/$$file $(distdir); \ - done - diff --git a/zotnet/mts/client.c b/zotnet/mts/client.c deleted file mode 100644 index 0095959..0000000 --- a/zotnet/mts/client.c +++ /dev/null @@ -1,479 +0,0 @@ - -/* - * client.c -- connect to a server - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#ifdef HESIOD -# include -#endif - -#ifdef KPOP -# include -# include -#endif /* KPOP */ - -#define TRUE 1 -#define FALSE 0 - -#define OOPS1 (-2) -#define OOPS2 (-3) - -#define MAXARGS 1000 -#define MAXNETS 5 -#define MAXHOSTS 25 - -struct addrent { - int a_addrtype; /* assumes AF_INET for inet_netof () */ - union { - int un_net; - char un_addr[14]; - } un; -}; - -#define a_net un.un_net -#define a_addr un.un_addr - -static struct addrent *n1, *n2; -static struct addrent nets[MAXNETS]; -static struct addrent *h1, *h2; -static struct addrent hosts[MAXHOSTS]; - -#ifdef KPOP -static CREDENTIALS cred; -static MSG_DAT msg_data; -static KTEXT ticket = (KTEXT) NULL; -static Key_schedule schedule; -static char *kservice; /* "pop" if using kpop */ -char krb_realm[REALM_SZ]; -char *PrincipalHostname(); -#endif /* KPOP */ - -#if !defined(h_addr) -# define h_addr h_addr_list[0] -#endif - -#define inaddr_copy(hp,sin) \ - memcpy(&((sin)->sin_addr), (hp)->h_addr, (hp)->h_length) - -/* - * static prototypes - */ -static int rcaux (struct servent *, struct hostent *, int, char *, int); -static int getport (int, int, char *, int); -static int inet (struct hostent *, int); -struct hostent *gethostbystring (char *s); - -/* client's own static version of several nmh subroutines */ -static char **client_brkstring (char *, char *, char *); -static int client_brkany (char, char *); -static char **client_copyip (char **, char **, int); -static char *client_getcpy (char *); - - -int -client (char *args, char *protocol, char *service, int rproto, - char *response, int len_response) -{ - int sd; - register char **ap; - char *arguments[MAXARGS]; - register struct hostent *hp; - register struct servent *sp; -#ifndef HAVE_GETHOSTBYNAME - register struct netent *np; -#endif - -#ifdef KPOP - char *cp; - - kservice = service; - if (cp = strchr (service, '/')) { /* "pop/kpop" */ - *cp++ = '\0'; /* kservice = "pop" */ - service = cp; /* service = "kpop" */ - } else { - kservice = NULL; /* not using KERBEROS */ - } -#endif /* KPOP */ - - - if ((sp = getservbyname (service, protocol)) == NULL) { -#ifdef HESIOD - if ((sp = hes_getservbyname (service, protocol)) == NULL) { - snprintf (response, len_response, "%s/%s: unknown service", protocol, service); - return NOTOK; - } -#else - snprintf (response, len_response, "%s/%s: unknown service", protocol, service); - return NOTOK; -#endif - } - - ap = arguments; - if (args != NULL && *args != 0) { - ap = client_copyip (client_brkstring (client_getcpy (args), " ", "\n"), - ap, MAXARGS); - } else { - if (servers != NULL && *servers != 0) - ap = client_copyip (client_brkstring (client_getcpy (servers), " ", "\n"), - ap, MAXARGS); - } - if (ap == arguments) { - *ap++ = client_getcpy ("localhost"); - *ap = NULL; - } - - n1 = nets; - n2 = nets + sizeof(nets) / sizeof(nets[0]); - - h1 = hosts; - h2 = hosts + sizeof(hosts) / sizeof(hosts[0]); - - for (ap = arguments; *ap; ap++) { - if (**ap == '\01') { -/* - * the assumption here is that if the system doesn't have a - * gethostbyname() function, it must not use DNS. So we need to look - * into the /etc/hosts using gethostent(). There probablly aren't any - * systems still like this, but you never know. On every system I have - * access to, this section is ignored. - */ -#ifndef HAVE_GETHOSTBYNAME - if ((np = getnetbyname (*ap + 1))) { -#ifdef HAVE_SETHOSTENT - sethostent (1); -#endif /* HAVE_SETHOSTENT */ - while ((hp = gethostent())) - if (np->n_addrtype == hp->h_addrtype - && inet (hp, np->n_net)) { - switch (sd = rcaux (sp, hp, rproto, response, len_response)) { - case NOTOK: - continue; - case OOPS1: - break; - case OOPS2: - return NOTOK; - - default: - return sd; - } - break; - } - } -#endif /* don't HAVE_GETHOSTBYNAME */ - continue; - } - - if ((hp = gethostbystring (*ap))) { - switch (sd = rcaux (sp, hp, rproto, response, len_response)) { - case NOTOK: - case OOPS1: - break; - case OOPS2: - return NOTOK; - - default: - return sd; - } - continue; - } - } - - strncpy (response, "no servers available", len_response); - return NOTOK; -} - - -static int -rcaux (struct servent *sp, struct hostent *hp, int rproto, - char *response, int len_response) -{ - int sd; - struct in_addr in; - register struct addrent *ap; - struct sockaddr_in in_socket; - register struct sockaddr_in *isock = &in_socket; - -#ifdef KPOP - int rem; - struct hostent *hp2; -#endif /* KPOP */ - - for (ap = nets; ap < n1; ap++) - if (ap->a_addrtype == hp->h_addrtype && inet (hp, ap->a_net)) - return NOTOK; - - for (ap = hosts; ap < h1; ap++) - if (ap->a_addrtype == hp->h_addrtype - && memcmp(ap->a_addr, hp->h_addr, hp->h_length) == 0) - return NOTOK; - - if ((sd = getport (rproto, hp->h_addrtype, response, len_response)) == NOTOK) - return OOPS2; - - memset (isock, 0, sizeof(*isock)); - isock->sin_family = hp->h_addrtype; - inaddr_copy (hp, isock); - isock->sin_port = sp->s_port; - - if (connect (sd, (struct sockaddr *) isock, sizeof(*isock)) == NOTOK) - switch (errno) { - case ENETDOWN: - case ENETUNREACH: - close (sd); - if (n1 < n2) { - n1->a_addrtype = hp->h_addrtype; - memcpy(&in, hp->h_addr, sizeof(in)); - n1->a_net = inet_netof (in); - n1++; - } - return OOPS1; - - case ETIMEDOUT: - case ECONNREFUSED: - default: - close (sd); - if (h1 < h2) { - h1->a_addrtype = hp->h_addrtype; - memcpy(h1->a_addr, hp->h_addr, hp->h_length); - h1++; - } - return NOTOK; - } - -#ifdef KPOP - if (kservice) { /* "pop" */ - char *instance; - - if (( hp2 = gethostbyaddr( hp->h_addr, hp->h_length, hp->h_addrtype )) - == NULL ) { - return NOTOK; - } - if ((instance = strdup (hp2->h_name)) == NULL) { - close (sd); - strncpy (response, "Out of memory.", len_response); - return OOPS2; - } - ticket = (KTEXT) malloc (sizeof(KTEXT_ST)); - rem = krb_sendauth (0L, sd, ticket, kservice, instance, - (char *) krb_realmofhost (instance), - (unsigned long) 0, &msg_data, &cred, schedule, - (struct sockaddr_in *) NULL, - (struct sockaddr_in *) NULL, - "KPOPV0.1"); - free (instance); - if (rem != KSUCCESS) { - close (sd); - strncpy (response, "Post office refused connection: ", len_response); - strncat (response, krb_err_txt[rem], len_response - strlen(response)); - return OOPS2; - } - } -#endif /* KPOP */ - - return sd; -} - - -static int -getport (int rproto, int addrtype, char *response, int len_response) -{ - int sd, port; - struct sockaddr_in in_socket, *isock; - - isock = &in_socket; - if (rproto && addrtype != AF_INET) { - snprintf (response, len_response, "reserved ports not supported for af=%d", addrtype); - errno = ENOPROTOOPT; - return NOTOK; - } - - if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == NOTOK) { - char *s; - - if ((s = strerror (errno))) - snprintf (response, len_response, "unable to create socket: %s", s); - else - snprintf (response, len_response, "unable to create socket: unknown error"); - return NOTOK; - } -#ifdef KPOP - if (kservice) /* "pop" */ - return(sd); -#endif /* KPOP */ - if (!rproto) - return sd; - - memset(isock, 0, sizeof(*isock)); - isock->sin_family = addrtype; - for (port = IPPORT_RESERVED - 1;;) { - isock->sin_port = htons ((unsigned short) port); - if (bind (sd, (struct sockaddr *) isock, sizeof(*isock)) != NOTOK) - return sd; - - switch (errno) { - char *s; - - case EADDRINUSE: - case EADDRNOTAVAIL: - if (--port <= IPPORT_RESERVED / 2) { - strncpy (response, "ports available", len_response); - return NOTOK; - } - break; - - default: - if ((s = strerror (errno))) - snprintf (response, len_response, "unable to bind socket: %s", s); - else - snprintf (response, len_response, "unable to bind socket: unknown error"); - return NOTOK; - } - } -} - - -static int -inet (struct hostent *hp, int net) -{ - struct in_addr in; - - memcpy(&in, hp->h_addr, sizeof(in)); - return (inet_netof (in) == net); -} - - -/* - * taken from ISODE's compat/internet.c - */ - -static char *empty = NULL; - -#ifdef h_addr -static char *addrs[2] = { NULL }; -#endif - -struct hostent * -gethostbystring (char *s) -{ - register struct hostent *h; - static struct hostent hs; -#ifdef DG - static struct in_addr iaddr; -#else - static unsigned long iaddr; -#endif - - iaddr = inet_addr (s); -#ifdef DG - if (iaddr.s_addr == NOTOK && strcmp (s, "255.255.255.255")) -#else - if (((int) iaddr == NOTOK) && strcmp (s, "255.255.255.255")) -#endif - return gethostbyname (s); - - h = &hs; - h->h_name = s; - h->h_aliases = ∅ - h->h_addrtype = AF_INET; - h->h_length = sizeof(iaddr); -#ifdef h_addr - h->h_addr_list = addrs; - memset(addrs, 0, sizeof(addrs)); -#endif - h->h_addr = (char *) &iaddr; - - return h; -} - - -/* - * static copies of three nmh subroutines - */ - -static char *broken[MAXARGS + 1]; - -static char ** -client_brkstring (char *strg, char *brksep, char *brkterm) -{ - register int bi; - register char c, *sp; - - sp = strg; - - for (bi = 0; bi < MAXARGS; bi++) { - while (client_brkany (c = *sp, brksep)) - *sp++ = 0; - if (!c || client_brkany (c, brkterm)) { - *sp = 0; - broken[bi] = 0; - return broken; - } - - broken[bi] = sp; - while ((c = *++sp) && !client_brkany (c, brksep) && !client_brkany (c, brkterm)) - continue; - } - broken[MAXARGS] = 0; - - return broken; -} - - -/* - * returns 1 if chr in strg, 0 otherwise - */ -static int -client_brkany (char chr, char *strg) -{ - register char *sp; - - if (strg) - for (sp = strg; *sp; sp++) - if (chr == *sp) - return 1; - return 0; -} - - -/* - * copy a string array and return pointer to end - */ -static char ** -client_copyip (char **p, char **q, int len_q) -{ - while (*p && --len_q > 0) - *q++ = *p++; - - *q = NULL; - - return q; -} - - -static char * -client_getcpy (char *str) -{ - char *cp; - size_t len; - - len = strlen(str) + 1; - if (!(cp = malloc(len))) - return NULL; - - memcpy (cp, str, len); - return cp; -} - diff --git a/zotnet/mts/mts.c b/zotnet/mts/mts.c deleted file mode 100644 index 7d9b718..0000000 --- a/zotnet/mts/mts.c +++ /dev/null @@ -1,523 +0,0 @@ - -/* - * mts.c -- definitions for the mail transport system - * - * $Id$ - */ - -#include "h/mh.h" /* for snprintf() */ -#include - -#define nmhetcdir(file) NMHETCDIR#file - -#include -#include -#include -#include -#include - -#ifdef HAVE_SYS_UTSNAME_H -# include -#endif - -#define NOTOK (-1) -#define OK 0 - -extern int errno; - -/* - * static prototypes - */ -static char *tailor_value (char *); -static void getuserinfo (void); - -/* - * *mmdfldir and *uucpldir are the maildrop directories. If maildrops - * are kept in the user's home directory, then these should be empty - * strings. In this case, the appropriate ...lfil array should contain - * the name of the file in the user's home directory. Usually, this is - * something like ".mail". - */ - -/* - * nmh mail transport interface customization file - */ -static char *mtsconf = nmhetcdir(/mts.conf); - -static char *localname = ""; -static char *localdomain = ""; -static char *systemname = ""; - -char *mmdfldir = MAILSPOOL; -char *mmdflfil = ""; -char *uucpldir = "/usr/spool/mail"; -char *uucplfil = ""; - -char *mmdlm1 = "\001\001\001\001\n"; -char *mmdlm2 = "\001\001\001\001\n"; - -/* Cache the username and fullname of the user */ -static char username[BUFSIZ]; -static char fullname[BUFSIZ]; - -/* Variables for username masquerading: */ - boolean draft_from_masquerading = FALSE; /* also used from post.c */ -static boolean mmailid_masquerading = FALSE; - boolean username_extension_masquerading = FALSE; /* " from addrsbr.c */ -static char* masquerade = ""; - -/* - * MTS specific variables - */ -#if defined(SMTPMTS) -static char *sm_method = "smtp"; -int sm_mts = MTS_SMTP; -char *hostable = nmhetcdir(/hosts); -char *sendmail = SENDMAILPATH; -#endif - -/* - * SMTP/POP stuff - */ -char *clientname = NULL; -char *servers = "localhost \01localnet"; -char *pophost = ""; - -/* - * BBoards-specific variables - */ -char *bb_domain = ""; - - -/* - * POP BBoards-specific variables - */ -#ifdef BPOP -char *popbbhost = ""; -char *popbbuser = ""; -char *popbblist = nmhetcdir(/hosts.popbb); -#endif /* BPOP */ - -/* - * Global MailDelivery file - */ -char *maildelivery = nmhetcdir(/maildelivery); - - -/* - * Aliasing Facility (doesn't belong here) - */ -int Everyone = NOTOK; -static char *everyone = "-1"; -char *NoShell = ""; - -/* - * Customize the MTS settings for nmh by adjusting - * the file mts.conf in the nmh etc directory. - */ - -struct bind { - char *keyword; - char **value; -}; - -static struct bind binds[] = { - { "localname", &localname }, - { "localdomain", &localdomain }, - { "systemname", &systemname }, - { "mmdfldir", &mmdfldir }, - { "mmdflfil", &mmdflfil }, - { "uucpldir", &uucpldir }, - { "uucplfil", &uucplfil }, - { "mmdelim1", &mmdlm1 }, - { "mmdelim2", &mmdlm2 }, - { "masquerade", &masquerade }, - -#if defined(SMTPMTS) - { "mts", &sm_method }, - { "hostable", &hostable }, - { "sendmail", &sendmail }, -#endif - - { "clientname", &clientname }, - { "servers", &servers }, - { "pophost", &pophost }, - { "bbdomain", &bb_domain }, - -#ifdef BPOP - { "popbbhost", &popbbhost }, - { "popbbuser", &popbbuser }, - { "popbblist", &popbblist }, -#endif - -#ifdef NNTP - { "nntphost", &popbbhost }, -#endif - - { "maildelivery", &maildelivery }, - { "everyone", &everyone }, - { "noshell", &NoShell }, - { NULL, NULL } -}; - - -/* - * Read the configuration file for the nmh interface - * to the mail transport system (MTS). - */ - -void -mts_init (char *name) -{ - char *bp, *cp, buffer[BUFSIZ]; - struct bind *b; - FILE *fp; - static int inited = 0; - - if (inited++ || (fp = fopen (mtsconf, "r")) == NULL) - return; - - while (fgets (buffer, sizeof(buffer), fp)) { - if (!(cp = strchr(buffer, '\n'))) - break; - *cp = 0; - if (*buffer == '#' || *buffer == '\0') - continue; - if (!(bp = strchr(buffer, ':'))) - break; - *bp++ = 0; - while (isspace (*bp)) - *bp++ = 0; - - for (b = binds; b->keyword; b++) - if (!strcmp (buffer, b->keyword)) - break; - if (b->keyword && (cp = tailor_value (bp))) - *b->value = cp; - } - - fclose (fp); - - Everyone = atoi (everyone); - - if (strstr(masquerade, "draft_from") != NULL) - draft_from_masquerading = TRUE; - - if (strstr(masquerade, "mmailid") != NULL) - mmailid_masquerading = TRUE; - - if (strstr(masquerade, "username_extension") != NULL) - username_extension_masquerading = TRUE; - -#ifdef SMTPMTS - if (strcmp(sm_method, "smtp") == 0) - sm_mts = MTS_SMTP; - else if (strcmp(sm_method, "sendmail") == 0) - sm_mts = MTS_SENDMAIL; - else { - advise(NULL, "unsupported \"mts\" value in mts.conf: %s", sm_method); - sm_mts = MTS_SMTP; - } -#endif -} - - -#define QUOTE '\\' - -/* - * Convert escaped values, malloc some new space, - * and copy string to malloc'ed memory. - */ - -static char * -tailor_value (char *s) -{ - int i, r; - char *bp; - char buffer[BUFSIZ]; - size_t len; - - for (bp = buffer; *s; bp++, s++) { - if (*s != QUOTE) { - *bp = *s; - } else { - switch (*++s) { - case 'b': *bp = '\b'; break; - case 'f': *bp = '\f'; break; - case 'n': *bp = '\n'; break; - case 't': *bp = '\t'; break; - - case 0: s--; - case QUOTE: - *bp = QUOTE; - break; - - default: - if (!isdigit (*s)) { - *bp++ = QUOTE; - *bp = *s; - } - r = *s != '0' ? 10 : 8; - for (i = 0; isdigit (*s); s++) - i = i * r + *s - '0'; - s--; - *bp = toascii (i); - break; - } - } - } - *bp = 0; - - len = strlen (buffer) + 1; - if ((bp = malloc (len))) - memcpy (bp, buffer, len); - - return bp; -} - -/* - * Get the fully qualified name of the local host. - */ - -char * -LocalName (void) -{ - static char buffer[BUFSIZ] = ""; - struct hostent *hp; - -#ifdef HAVE_UNAME - struct utsname name; -#endif - - /* check if we have cached the local name */ - if (buffer[0]) - return buffer; - - mts_init ("mts"); - - /* check if the mts.conf file specifies a "localname" */ - if (*localname) { - strncpy (buffer, localname, sizeof(buffer)); - } else { -#ifdef HAVE_UNAME - /* first get our local name */ - uname (&name); - strncpy (buffer, name.nodename, sizeof(buffer)); -#else - /* first get our local name */ - gethostname (buffer, sizeof(buffer)); -#endif -#ifdef HAVE_SETHOSTENT - sethostent (1); -#endif - /* now fully qualify our name */ - if ((hp = gethostbyname (buffer))) - strncpy (buffer, hp->h_name, sizeof(buffer)); - } - - /* - * If the mts.conf file specifies a "localdomain", - * we append that now. This should rarely be needed. - */ - if (*localdomain) { - strcat (buffer, "."); - strcat (buffer, localdomain); - } - - return buffer; -} - - -/* - * This is only for UUCP mail. It gets the hostname - * as part of the UUCP "domain". - */ - -char * -SystemName (void) -{ - static char buffer[BUFSIZ] = ""; - -#ifdef HAVE_UNAME - struct utsname name; -#endif - - /* check if we have cached the system name */ - if (buffer[0]) - return buffer; - - mts_init ("mts"); - - /* check if mts.conf file specifies a "systemname" */ - if (*systemname) { - strncpy (buffer, systemname, sizeof(buffer)); - return buffer; - } - -#ifdef HAVE_UNAME - uname (&name); - strncpy (buffer, name.nodename, sizeof(buffer)); -#else - gethostname (buffer, sizeof(buffer)); -#endif - - return buffer; -} - - -/* - * Get the username of current user - */ - -char * -getusername (void) -{ - if (username[0] == '\0') - getuserinfo(); - - return username; -} - - -/* - * Get full name of current user (typically from GECOS - * field of password file). - */ - -char * -getfullname (void) -{ - if (username[0] == '\0') - getuserinfo(); - - return fullname; -} - - -/* - * Find the user's username and full name, and cache them. - * Also, handle "mmailid" username masquerading controlled from the GECOS field - * of the passwd file. - */ - -static void -getuserinfo (void) -{ - register char *cp, *np; - register struct passwd *pw; - -#ifdef KPOP - uid_t uid; - - uid = getuid (); - if (uid == geteuid () && (cp = getenv ("USER")) != NULL - && (pw = getpwnam (cp)) != NULL) - strncpy (username, cp, sizeof(username)); - else if ((pw = getpwuid (uid)) == NULL - || pw->pw_name == NULL - || *pw->pw_name == '\0') { -#else /* KPOP */ - if ((pw = getpwuid (getuid ())) == NULL - || pw->pw_name == NULL - || *pw->pw_name == '\0') { -#endif /* KPOP */ - strncpy (username, "unknown", sizeof(username)); - snprintf (fullname, sizeof(fullname), "The Unknown User-ID (%d)", - (int) getuid ()); - return; - } - - np = pw->pw_gecos; - - /* Get the user's real name from the GECOS field. Stop once we hit a ',', - which some OSes use to separate other 'finger' information in the GECOS - field, like phone number. Also, if mmailid masquerading is turned on due - to "mmailid" appearing on the "masquerade:" line of mts.conf, stop if we - hit a '<' (which should precede any ','s). */ -#ifndef BSD42 - if (mmailid_masquerading) - /* Stop at ',' or '<'. */ - for (cp = fullname; *np != '\0' && *np != ',' && *np != '<'; - *cp++ = *np++) - continue; - else - /* Allow '<' as a legal character of the user's name. This code is - basically a duplicate of the code above the "else" -- we don't - collapse it down to one copy and put the mmailid_masquerading check - inside the loop with "(x ? y : z)" because that's inefficient and the - value'll never change while it's in there. */ - for (cp = fullname; *np != '\0' && *np != ','; - *cp++ = *np++) - continue; -#else /* BSD42 */ - /* On BSD(-derived) systems, the system utilities that deal with the GECOS - field (finger, mail, sendmail, etc.) translate any '&' character in it to - the login name, with the first letter capitalized. So, for instance, - fingering a user "bob" with the GECOS field "& Jones" would reveal him to - be "In real life: Bob Jones". Surprisingly, though, the OS doesn't do - the translation for you, so we have to do it manually here. */ - if (mmailid_masquerading) - /* Stop at ',' or '<'. */ - for (cp = fullname; - *np != '\0' && *np != ',' && *np != '<';) { - if (*np == '&') { /* blech! */ - strcpy (cp, pw->pw_name); - *cp = toupper(*cp); - while (*cp) - cp++; - np++; - } else { - *cp++ = *np++; - } - } - else - /* Allow '<' as a legal character of the user's name. This code is - basically a duplicate of the code above the "else" -- we don't - collapse it down to one copy and put the mmailid_masquerading check - inside the loop with "(x ? y : z)" because that's inefficient and the - value'll never change while it's in there. */ - for (cp = fullname; - *np != '\0' && *np != ',';) { - if (*np == '&') { /* blech! */ - strcpy (cp, pw->pw_name); - *cp = toupper(*cp); - while (*cp) - cp++; - np++; - } else { - *cp++ = *np++; - } - } -#endif /* BSD42 */ - *cp = '\0'; - - if (mmailid_masquerading) { - /* Do mmailid processing. The GECOS field should have the form - "Full Name ". For instance, - "Dan Harkless ". Naturally, you'll want your MTA to - have an alias (e.g. in /etc/aliases) from "fakeusername" to your - account name. */ - if (*np) - np++; - for (cp = username; *np && *np != '>'; *cp++ = *np++) - continue; - *cp = '\0'; - } - if (!mmailid_masquerading || *np == '\0') - strncpy (username, pw->pw_name, sizeof(username)); - - /* The $SIGNATURE environment variable overrides the GECOS field's idea of - your real name. */ - if ((cp = getenv ("SIGNATURE")) && *cp) - strncpy (fullname, cp, sizeof(fullname)); - - if (strchr(fullname, '.')) { /* quote any .'s */ - char tmp[BUFSIZ]; - - /* should quote "'s too */ - snprintf (tmp, sizeof(tmp), "\"%s\"", fullname); - strncpy (fullname, tmp, sizeof(fullname)); - } - - return; -} diff --git a/zotnet/mts/mts.h b/zotnet/mts/mts.h deleted file mode 100644 index ce063d9..0000000 --- a/zotnet/mts/mts.h +++ /dev/null @@ -1,88 +0,0 @@ - -/* - * mts.h -- definitions for the mail system - * - * $Id$ - */ - -/* - * Local and UUCP Host Name - */ -char *LocalName(void); -char *SystemName(void); - -/* - * Mailboxes - */ -extern char *mmdfldir; -extern char *mmdflfil; -extern char *uucpldir; -extern char *uucplfil; - -#define MAILDIR (mmdfldir && *mmdfldir ? mmdfldir : getenv ("HOME")) -#define MAILFIL (mmdflfil && *mmdflfil ? mmdflfil : getusername ()) -#define UUCPDIR (uucpldir && *uucpldir ? uucpldir : getenv ("HOME")) -#define UUCPFIL (uucplfil && *uucplfil ? uucplfil : getusername ()) - -char *getusername(void); -char *getfullname(void); - -/* - * Separators - */ -extern char *mmdlm1; -extern char *mmdlm2; - -#define isdlm1(s) (strcmp (s, mmdlm1) == 0) -#define isdlm2(s) (strcmp (s, mmdlm2) == 0) - -/* - * Read mts.conf file - */ -void mts_init (char *); - -/* - * MTS specific variables - */ -#if defined (SMTPMTS) - -/* whether to speak SMTP to localhost:25 or to /usr/sbin/sendmail */ -#define MTS_SMTP 0 -#define MTS_SENDMAIL 1 -extern int sm_mts; - -extern char *hostable; -extern char *sendmail; -#endif - -/* - * SMTP/POP stuff - */ -extern char *clientname; -extern char *servers; -extern char *pophost; - -/* - * BBoards-specific variables - */ -extern char *bb_domain; - -/* - * POP BBoards-specific variables - */ -#ifdef BPOP -extern char *popbbhost; -extern char *popbbuser; -extern char *popbblist; -#endif /* BPOP */ - -/* - * Global MailDelivery File - */ -extern char *maildelivery; - -/* - * Aliasing Facility (doesn't belong here) - */ -extern int Everyone; -extern char *NoShell; diff --git a/zotnet/tws/Makefile.in b/zotnet/tws/Makefile.in deleted file mode 100644 index b14f24e..0000000 --- a/zotnet/tws/Makefile.in +++ /dev/null @@ -1,106 +0,0 @@ -# -# Makefile for zotnet/tws subdirectory -# -# $Id$ -# - -SHELL = /bin/sh - -top_srcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -CFLAGS = @CFLAGS@ -DEFS = @DEFS@ -INCLUDES = -I../.. -I$(srcdir) -I$(top_srcdir) - -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) - -AWK = @AWK@ -# LEX = @LEX@ -LEX = lex -SED = sed -LINT = @LINT@ -LINTFLAGS = @LINTFLAGS@ - -.SUFFIXES: -.SUFFIXES: .c .o - -.c.o: - $(COMPILE) $< - -# header files -HDRS = tws.h - -# source files -SRCS = dtime.c lexstring.c - -# object files -OBJS = dtimep.o dtime.o lexstring.o - -# auxiliary files -AUX = Makefile.in dtimep.lex lexedit.sed dtimep.c-lexed - -# all files in this directory included in the distribution -DIST = $(HDRS) $(SRCS) $(AUX) - -# ========= DEPENDENCIES FOR BUILDING ========== - -all: $(OBJS) - -# This will bomb if lex is really flex, so check -# file and use pre-generated version if necessary -dtimep.c: $(srcdir)/dtimep.c-lexed $(srcdir)/dtimep.lex $(srcdir)/lexedit.sed - $(LEX) -nt $(srcdir)/dtimep.lex | $(SED) -f $(srcdir)/lexedit.sed > $@ - -@len=`wc -l $@ | $(AWK) ' { print $$1 } '`; \ - if [ $$len -gt 500 ]; \ - then exit 0; \ - else \ - echo "LEX FAILED: using pre-lexed $@"; \ - cp $(srcdir)/$@-lexed $@; \ - fi - -# This needs to be generated by lex, not flex -dtimep.c-lexed: $(srcdir)/dtimep.lex $(srcdir)/lexedit.sed - $(LEX) -nt $(srcdir)/dtimep.lex | $(SED) -f $(srcdir)/lexedit.sed > $(srcdir)/$@ - -install: - -uninstall: - -# ========== DEPENDENCIES FOR CLEANUP ========== - -mostlyclean: - rm -f *.o *~ - -clean: mostlyclean - rm -f dtimep.c - -distclean: clean - rm -f Makefile - -realclean: distclean - rm -f dtimep.c-lexed - -superclean: realclean - -# ========== DEPENDENCIES FOR LINT ================= - -lint: - $(LINT) $(LINTFLAGS) $(INCLUDES) $(DEFS) $(SRCS) - -# ========== DEPENDENCIES FOR MAINTENANCE ========== - -subdir = zotnet/tws - -Makefile: Makefile.in ../../config.status - cd ../.. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -distdir = ../../`cat ../../distname`/$(subdir) -nmhdist: $(DIST) - @echo "Copying distribution files in $(subdir)" - @for file in $(DIST); do \ - cp -p $(srcdir)/$$file $(distdir); \ - done - diff --git a/zotnet/tws/dtime.c b/zotnet/tws/dtime.c deleted file mode 100644 index adf153b..0000000 --- a/zotnet/tws/dtime.c +++ /dev/null @@ -1,511 +0,0 @@ - -/* - * dtime.c -- time/date routines - * - * $Id$ - */ - -#include "h/mh.h" /* for snprintf() */ -#include -#include - -#if !defined(HAVE_TM_GMTOFF) && !defined(HAVE_TZSET) -# include -#endif - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) -extern int daylight; -extern long timezone; -extern char *tzname[]; -#endif - -#ifndef abs -# define abs(a) (a >= 0 ? a : -a) -#endif - -/* - * The number of days in the year, accounting for leap years - */ -#define dysize(y) \ - (((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366))) - -char *tw_moty[] = { - "Jan", "Feb", "Mar", "Apr", - "May", "Jun", "Jul", "Aug", - "Sep", "Oct", "Nov", "Dec", - NULL -}; - -char *tw_dotw[] = { - "Sun", "Mon", "Tue", - "Wed", "Thu", "Fri", - "Sat", NULL -}; - -char *tw_ldotw[] = { - "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", - "Saturday", NULL -}; - -struct zone { - char *std; - char *dst; - int shift; -}; - -static struct zone zones[] = { - { "GMT", "BST", 0 }, - { "EST", "EDT", -5 }, - { "CST", "CDT", -6 }, - { "MST", "MDT", -7 }, - { "PST", "PDT", -8 }, -#if 0 -/* RFC1123 specifies do not use military TZs */ - { "A", NULL, -1 }, - { "B", NULL, -2 }, - { "C", NULL, -3 }, - { "D", NULL, -4 }, - { "E", NULL, -5 }, - { "F", NULL, -6 }, - { "G", NULL, -7 }, - { "H", NULL, -8 }, - { "I", NULL, -9 }, - { "K", NULL, -10 }, - { "L", NULL, -11 }, - { "M", NULL, -12 }, - { "N", NULL, 1 }, -#ifndef HUJI - { "O", NULL, 2 }, -#else - { "JST", "JDT", 2 }, -#endif - { "P", NULL, 3 }, - { "Q", NULL, 4 }, - { "R", NULL, 5 }, - { "S", NULL, 6 }, - { "T", NULL, 7 }, - { "U", NULL, 8 }, - { "V", NULL, 9 }, - { "W", NULL, 10 }, - { "X", NULL, 11 }, - { "Y", NULL, 12 }, -#endif - { NULL, NULL, 0 } -}; - -static int dmsize[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - - -/* - * Get current time (adjusted for local time - * zone and daylight savings time) expressed - * as nmh "broken-down" time structure. - */ - -struct tws * -dlocaltimenow (void) -{ - time_t clock; - - time (&clock); - return dlocaltime (&clock); -} - - -/* - * Take clock value and return pointer to nmh time structure - * containing "broken-down" time. The time is adjusted for - * local time zone and daylight savings time. - */ - -struct tws * -dlocaltime (time_t *clock) -{ - static struct tws tw; - struct tm *tm; - -#if !defined(HAVE_TM_GMTOFF) && !defined(HAVE_TZSET) - struct timeb tb; -#endif - - if (!clock) - return NULL; - - tm = localtime (clock); - - tw.tw_sec = tm->tm_sec; - tw.tw_min = tm->tm_min; - tw.tw_hour = tm->tm_hour; - tw.tw_mday = tm->tm_mday; - tw.tw_mon = tm->tm_mon; - - /* - * tm_year is always "year - 1900". - * So we correct for this. - */ - tw.tw_year = tm->tm_year + 1900; - tw.tw_wday = tm->tm_wday; - tw.tw_yday = tm->tm_yday; - - tw.tw_flags = TW_NULL; - if (tm->tm_isdst) - tw.tw_flags |= TW_DST; - -#ifdef HAVE_TM_GMTOFF - tw.tw_zone = tm->tm_gmtoff / 60; - if (tm->tm_isdst) /* if DST is in effect */ - tw.tw_zone -= 60; /* reset to normal offset */ -#else -# ifdef HAVE_TZSET - tzset(); - tw.tw_zone = -(timezone / 60); -# else - ftime (&tb); - tw.tw_zone = -tb.timezone; -# endif -#endif - - tw.tw_flags &= ~TW_SDAY; - tw.tw_flags |= TW_SEXP; - tw.tw_flags &= ~TW_SZONE; - tw.tw_flags |= TW_SZEXP; - - tw.tw_clock = *clock; - - return (&tw); -} - - -/* - * Take clock value and return pointer to nmh time - * structure containing "broken-down" time. Time is - * expressed in UTC (Coordinated Universal Time). - */ - -struct tws * -dgmtime (time_t *clock) -{ - static struct tws tw; - struct tm *tm; - - if (!clock) - return NULL; - - tm = gmtime (clock); - - tw.tw_sec = tm->tm_sec; - tw.tw_min = tm->tm_min; - tw.tw_hour = tm->tm_hour; - tw.tw_mday = tm->tm_mday; - tw.tw_mon = tm->tm_mon; - - /* - * tm_year is always "year - 1900" - * So we correct for this. - */ - tw.tw_year = tm->tm_year + 1900; - tw.tw_wday = tm->tm_wday; - tw.tw_yday = tm->tm_yday; - - tw.tw_flags = TW_NULL; - if (tm->tm_isdst) - tw.tw_flags |= TW_DST; - - tw.tw_zone = 0; - - tw.tw_flags &= ~TW_SDAY; - tw.tw_flags |= TW_SEXP; - tw.tw_flags &= ~TW_SZONE; - tw.tw_flags |= TW_SZEXP; - - tw.tw_clock = *clock; - - return (&tw); -} - - -/* - * Using a nmh "broken-down" time structure, - * produce a 26-byte date/time string, such as - * - * Tue Jan 14 17:49:03 1992\n\0 - */ - -char * -dctime (struct tws *tw) -{ - static char buffer[26]; - - if (!tw) - return NULL; - - snprintf (buffer, sizeof(buffer), "%.3s %.3s %02d %02d:%02d:%02d %.4d\n", - tw_dotw[tw->tw_wday], tw_moty[tw->tw_mon], tw->tw_mday, - tw->tw_hour, tw->tw_min, tw->tw_sec, - tw->tw_year < 100 ? tw->tw_year + 1900 : tw->tw_year); - - return buffer; -} - - -/* - * Produce a date/time string of the form - * - * Mon, 16 Jun 1992 15:30:48 -700 (or) - * Mon, 16 Jun 1992 15:30:48 EDT - * - * for the current time, as specified by rfc822. - * The first form is required by rfc1123. - */ - -char * -dtimenow (int alpha_timezone) -{ - time_t clock; - - time (&clock); - return dtime (&clock, alpha_timezone); -} - - -/* - * Using a local calendar time value, produce - * a date/time string of the form - * - * Mon, 16 Jun 1992 15:30:48 -700 (or) - * Mon, 16 Jun 1992 15:30:48 EDT - * - * as specified by rfc822. The first form is required - * by rfc1123 for outgoing messages. - */ - -char * -dtime (time_t *clock, int alpha_timezone) -{ - if (alpha_timezone) - /* use alpha-numeric timezones */ - return dasctime (dlocaltime (clock), TW_NULL); - else - /* use numeric timezones */ - return dasctime (dlocaltime (clock), TW_ZONE); -} - - -/* - * Using a nmh "broken-down" time structure, produce - * a date/time string of the form - * - * Mon, 16 Jun 1992 15:30:48 -0700 - * - * as specified by rfc822 and rfc1123. - */ - -char * -dasctime (struct tws *tw, int flags) -{ - char buffer[80]; - static char result[80]; - - if (!tw) - return NULL; - - /* Display timezone if known */ - if ((tw->tw_flags & TW_SZONE) == TW_SZNIL) - result[0] = '\0'; - else - snprintf(result, sizeof(result), " %s", dtimezone(tw->tw_zone, tw->tw_flags | flags)); - - snprintf(buffer, sizeof(buffer), "%02d %s %0*d %02d:%02d:%02d%s", - tw->tw_mday, tw_moty[tw->tw_mon], - tw->tw_year < 100 ? 2 : 4, tw->tw_year, - tw->tw_hour, tw->tw_min, tw->tw_sec, result); - - if ((tw->tw_flags & TW_SDAY) == TW_SEXP) - snprintf (result, sizeof(result), "%s, %s", tw_dotw[tw->tw_wday], buffer); - else - if ((tw->tw_flags & TW_SDAY) == TW_SNIL) - strncpy (result, buffer, sizeof(result)); - else - snprintf (result, sizeof(result), "%s (%s)", buffer, tw_dotw[tw->tw_wday]); - - return result; -} - - -/* - * Get the timezone for given offset - */ - -char * -dtimezone (int offset, int flags) -{ - int hours, mins; - struct zone *z; - static char buffer[10]; - - if (offset < 0) { - mins = -((-offset) % 60); - hours = -((-offset) / 60); - } else { - mins = offset % 60; - hours = offset / 60; - } - - if (!(flags & TW_ZONE) && mins == 0) { -#if defined(HAVE_TZSET) && defined(HAVE_TZNAME) - tzset(); - return ((flags & TW_DST) ? tzname[1] : tzname[0]); -#else - for (z = zones; z->std; z++) - if (z->shift == hours) - return (z->dst && (flags & TW_DST) ? z->dst : z->std); -#endif - } - -#if defined(DSTXXX) - if (flags & TW_DST) - hours += 1; -#endif /* defined(DSTXXX) */ - snprintf (buffer, sizeof(buffer), "%s%02d%02d", - offset < 0 ? "-" : "+", abs (hours), abs (mins)); - return buffer; -} - - -/* - * Convert nmh time structure for local "broken-down" - * time to calendar time (clock value). This routine - * is based on the gtime() routine written by Steven Shafer - * at CMU. It was forwarded to MTR by Jay Lepreau at Utah-CS. - */ - -time_t -dmktime (struct tws *tw) -{ - int i, sec, min, hour, mday, mon, year; - time_t result; - - if (tw->tw_clock != 0) - return tw->tw_clock; - - if ((sec = tw->tw_sec) < 0 || sec > 61 - || (min = tw->tw_min) < 0 || min > 59 - || (hour = tw->tw_hour) < 0 || hour > 23 - || (mday = tw->tw_mday) < 1 || mday > 31 - || (mon = tw->tw_mon + 1) < 1 || mon > 12) - return (tw->tw_clock = (time_t) -1); - - year = tw->tw_year; - - result = 0; - if (year < 100) - year += 1900; - - for (i = 1970; i < year; i++) - result += dysize (i); - if (dysize (year) == 366 && mon >= 3) - result++; - while (--mon) - result += dmsize[mon - 1]; - result += mday - 1; - result = 24 * result + hour; - result = 60 * result + min; - result = 60 * result + sec; - result -= 60 * tw->tw_zone; - if (tw->tw_flags & TW_DST) - result -= 60 * 60; - - return (tw->tw_clock = result); -} - - -/* - * Simple calculation of day of the week. Algorithm - * used is Zeller's congruence. We assume that - * if tw->tw_year < 100, then the century = 19. - */ - -void -set_dotw (struct tws *tw) -{ - int month, day, year, century; - - month = tw->tw_mon - 1; - day = tw->tw_mday; - year = tw->tw_year % 100; - century = tw->tw_year < 100 ? 19 : tw->tw_year / 100; - - if (month <= 0) { - month += 12; - if (--year < 0) { - year += 100; - century--; - } - } - - tw->tw_wday = - ((26 * month - 2) / 10 + day + year + year / 4 - - 3 * century / 4 + 1) % 7; - if (tw->tw_wday < 0) - tw->tw_wday += 7; - - tw->tw_flags &= ~TW_SDAY, tw->tw_flags |= TW_SIMP; -} - - -/* - * Copy nmh time structure - */ - -void -twscopy (struct tws *tb, struct tws *tw) -{ - *tb = *tw; /* struct copy */ - -#if 0 - tb->tw_sec = tw->tw_sec; - tb->tw_min = tw->tw_min; - tb->tw_hour = tw->tw_hour; - tb->tw_mday = tw->tw_mday; - tb->tw_mon = tw->tw_mon; - tb->tw_year = tw->tw_year; - tb->tw_wday = tw->tw_wday; - tb->tw_yday = tw->tw_yday; - tb->tw_zone = tw->tw_zone; - tb->tw_clock = tw->tw_clock; - tb->tw_flags = tw->tw_flags; -#endif -} - - -/* - * Compare two nmh time structures - */ - -int -twsort (struct tws *tw1, struct tws *tw2) -{ - time_t c1, c2; - - if (tw1->tw_clock == 0) - dmktime (tw1); - if (tw2->tw_clock == 0) - dmktime (tw2); - - return ((c1 = tw1->tw_clock) > (c2 = tw2->tw_clock) ? 1 - : c1 == c2 ? 0 : -1); -} diff --git a/zotnet/tws/dtimep.c-lexed b/zotnet/tws/dtimep.c-lexed deleted file mode 100644 index 9ad02fa..0000000 --- a/zotnet/tws/dtimep.c-lexed +++ /dev/null @@ -1,1682 +0,0 @@ -#include -static int start_cond = 0; -#define BEGIN start_cond = -struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops;}; -# define Z 2 -#include -#include -#if !defined(HAVE_TM_GMTOFF) && !defined(HAVE_TZSET) -# include -#endif - -#if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) -extern int daylight; -extern long timezone; -extern char *tzname[]; -#endif - - -# line 49 "./dtimep.lex" -/* - * Patchable flag that says how to interpret NN/NN/NN dates. When - * true, we do it European style: DD/MM/YY. When false, we do it - * American style: MM/DD/YY. Of course, these are all non-RFC822 - * compliant. - */ -int europeandate = 0; - - -# line 57 "./dtimep.lex" -/* - * Table to convert month names to numeric month. We use the - * fact that the low order 5 bits of the sum of the 2nd & 3rd - * characters of the name is a hash with no collisions for the 12 - * valid month names. (The mask to 5 bits maps any combination of - * upper and lower case into the same hash value). - */ -static int month_map[] = { - 0, - 6, /* 1 - Jul */ - 3, /* 2 - Apr */ - 5, /* 3 - Jun */ - 0, - 10, /* 5 - Nov */ - 0, - 1, /* 7 - Feb */ - 11, /* 8 - Dec */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, /*15 - Jan */ - 0, - 0, - 0, - 2, /*19 - Mar */ - 0, - 8, /*21 - Sep */ - 0, - 9, /*23 - Oct */ - 0, - 0, - 4, /*26 - May */ - 0, - 7 /*28 - Aug */ -}; - -# line 95 "./dtimep.lex" -/* - * Same trick for day-of-week using the hash function - * (c1 & 7) + (c2 & 4) - */ -static int day_map[] = { - 0, - 0, - 0, - 6, /* 3 - Sat */ - 4, /* 4 - Thu */ - 0, - 5, /* 6 - Fri */ - 0, /* 7 - Sun */ - 2, /* 8 - Tue */ - 1 /* 9 - Mon */, - 0, - 3 /*11 - Wed */ -}; -#define SETDAY { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)];\ - tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP;\ - cp += 2; } -#define SETMONTH { tw.tw_mon = month_map[(cp[0] + cp[1]) & 0x1f]; gotdate++;\ - cp += 2;\ - SKIPD;} -#define CVT1OR2 (i=(*cp++ - '0'), isdigit(*cp)? i*10 + (*cp++ - '0') : i) -#define CVT2 ((cp[0] - '0')*10 + (cp[1] - '0')) -#define CVT4 ((((cp[0] - '0')*10 + (cp[1] - '0'))*10 + \ - (cp[2] - '0'))*10 + (cp[3] - '0')) -#define SKIPD { while ( !isdigit(*cp++) ) ; --cp; } -#define EXPZONE { tw.tw_flags &= ~TW_SZONE; tw.tw_flags |= TW_SZEXP; } -#define ZONE(x) { tw.tw_zone=(x); EXPZONE; } -#define ZONED(x) { ZONE(x); tw.tw_flags |= TW_DST; } -#define LC(c) (isupper (c) ? tolower (c) : (c)) - -#ifdef DSTXXX -# ifdef TIME_WITH_SYS_TIME -# include -# include -# else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - -static void -zonehack (struct tws *tw) -{ - register struct tm *tm; - - if (dmktime (tw) == (time_t) -1) - return; - - tm = localtime (&tw->tw_clock); - if (tm->tm_isdst) { - tw->tw_flags |= TW_DST; - tw->tw_zone -= 60; - } -} -#endif /* DSTXXX */ -struct tws * -dparsetime (char *str) -{ - register int i; - static struct tws tw; - register char *cp; - register int gotdate = 0; - time_t tclock; - -#ifdef HAVE_TM_GMTOFF - struct tm *tm; - time_t clock; -#else -# ifndef HAVE_TZSET - struct timeb tb; -# endif /* not HAVE_TZSET */ -#endif /* HAVE_TM_GMTOFF */ - - start_cond = 0; - - /* Zero out the struct. */ - memset( (char *) &tw, 0, sizeof(tw)); - - /* Set default time zone. */ -#ifdef HAVE_TM_GMTOFF - time (&clock); - tm = localtime(&clock); - tw.tw_zone = tm->tm_gmtoff / 60; - if (tm->tm_isdst) /* if DST is in effect */ - tw.tw_zone -= 60; /* reset to normal offset */ -#else -# ifdef HAVE_TZSET - tzset(); - tw.tw_zone = -(timezone / 60); -# else - ftime(&tb); - tw.tw_zone = -tb.timezone; -# endif /* HAVE_TZSET */ -#endif /* HAVE_TM_GMTOFF */ - - while (isspace(*str)) - str++; - while (1) - switch (cp = str, *cp ? lex_string( &str, start_cond) : 0) { - - case -1: - if (!gotdate || tw.tw_year == 0) - return (struct tws *)0; - /* fall through */ - case 0: - if (tw.tw_year == 0) { - /* Set default year. */ - time (&tclock); - tw.tw_year = localtime(&tclock)->tm_year + 1900; - } else if (tw.tw_year < 100) { - /* assume no 2-digit years > 1999 */ - tw.tw_year += 1900; - } - return &tw; - -#ifdef __cplusplus -/* to avoid CC and lint complaining yyfussy not being used ...*/ -static int __lex_hack = 0; -if (__lex_hack) goto yyfussy; -#endif -case 1: - -# line 219 "./dtimep.lex" - SETDAY; -break; -case 2: - -# line 220 "./dtimep.lex" - { - cp++; - SETDAY; - } -break; -case 3: - -# line 224 "./dtimep.lex" -{ - if (europeandate) { - /* European: DD/MM/YY */ - tw.tw_mday = CVT1OR2; - cp++; - tw.tw_mon = CVT1OR2 - 1; - } else { - /* American: MM/DD/YY */ - tw.tw_mon = CVT1OR2 - 1; - cp++; - tw.tw_mday = CVT1OR2; - } - cp++; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; - gotdate++; /* XXX */ - } -break; -case 4: - -# line 242 "./dtimep.lex" - { - if (europeandate) { - tw.tw_mday = CVT1OR2; cp++; - tw.tw_mon = CVT1OR2 - 1; - } else { - tw.tw_mon = CVT1OR2 - 1; cp++; - tw.tw_mday = CVT1OR2; - } - gotdate++; - } -break; -case 5: - -# line 252 "./dtimep.lex" -{ - tw.tw_mday = CVT1OR2; - while ( !isalpha(*cp++) ) - ; - SETMONTH; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; -#ifdef FIX_NON_Y2K_COMPLIANT_MUA_DATES - /* handle broken mua's that don't add - 1900, or just use the last two - digits. Assume no email before - 1972. */ - if (tw.tw_year < 72) - tw.tw_year += 100; - if (tw.tw_year < 1900) - tw.tw_year += 1900; -#endif /* FIX_NON_Y2K_COMPLIANT_MUA_DATES */ - } -break; -case 6: - -# line 271 "./dtimep.lex" - { - tw.tw_mday = CVT1OR2; - while ( ! isalpha( *cp++ ) ) - ; - SETMONTH; - } -break; -case 7: - -# line 277 "./dtimep.lex" -{ - cp++; - SETMONTH; - tw.tw_mday = CVT1OR2; - SKIPD; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; - } -break; -case 8: - -# line 286 "./dtimep.lex" - { - cp++; - SETMONTH; - tw.tw_mday = CVT1OR2; - } -break; -case 9: - -# line 292 "./dtimep.lex" - { /* hack: ctime w/o TZ */ - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - SKIPD; - tw.tw_year = CVT4; cp+=4; - } -break; -case 10: - -# line 299 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -break; -case 11: - -# line 305 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -break; -case 12: - -# line 310 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour == 12) - tw.tw_hour = 0; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -break; -case 13: - -# line 317 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour == 12) - tw.tw_hour = 0; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -break; -case 14: - -# line 325 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour != 12) - tw.tw_hour += 12; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -break; -case 15: - -# line 332 "./dtimep.lex" - { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour != 12) - tw.tw_hour += 12; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -break; -case 16: - -# line 340 "./dtimep.lex" - { - tw.tw_hour = CVT2; cp+=2; - tw.tw_min = CVT2; cp+=2; - tw.tw_sec = CVT2; cp+=2; - BEGIN Z; - } -break; -case 17: - -# line 346 "./dtimep.lex" - { - /* - * Luckly, 4 digit times in the range - * 1960-1999 aren't legal as hour - * and minutes. - */ - tw.tw_year = CVT4; cp+=4; - } -break; -case 18: - -# line 354 "./dtimep.lex" - { - if (tw.tw_hour || tw.tw_min - || tw.tw_sec) { - tw.tw_year = CVT4; cp+=4; - tw.tw_zone = 0; - } else { - tw.tw_hour = CVT2; cp+=2; - tw.tw_min = CVT2; cp+=2; - BEGIN Z; - } - } -break; -case 19: - -# line 365 "./dtimep.lex" - ZONE(0 * 60); -break; -case 20: - -# line 366 "./dtimep.lex" - ZONE(0 * 60); -break; -case 21: - -# line 367 "./dtimep.lex" - ZONE(2 * 60); -break; -case 22: - -# line 368 "./dtimep.lex" - ZONED(2 * 60); -break; -case 23: - -# line 369 "./dtimep.lex" - ZONE(-5 * 60); -break; -case 24: - -# line 370 "./dtimep.lex" - ZONED(-5 * 60); -break; -case 25: - -# line 371 "./dtimep.lex" - ZONE(-6 * 60); -break; -case 26: - -# line 372 "./dtimep.lex" - ZONED(-6 * 60); -break; -case 27: - -# line 373 "./dtimep.lex" - ZONE(-7 * 60); -break; -case 28: - -# line 374 "./dtimep.lex" - ZONED(-7 * 60); -break; -case 29: - -# line 375 "./dtimep.lex" - ZONE(-8 * 60); -break; -case 30: - -# line 376 "./dtimep.lex" - ZONED(-8 * 60); -break; -case 31: - -# line 377 "./dtimep.lex" - ZONE(-(3 * 60 + 30)); -break; -case 32: - -# line 378 "./dtimep.lex" - ZONE(-4 * 60); -break; -case 33: - -# line 379 "./dtimep.lex" - ZONED(-4 * 60); -break; -case 34: - -# line 380 "./dtimep.lex" - ZONE(-9 * 60); -break; -case 35: - -# line 381 "./dtimep.lex" - ZONED(-9 * 60); -break; -case 36: - -# line 382 "./dtimep.lex" - ZONE(-10 * 60); -break; -case 37: - -# line 383 "./dtimep.lex" - ZONED(-10 * 60); -break; -case 38: - -# line 384 "./dtimep.lex" - ZONED(-1 * 60); -break; -case 39: - -# line 385 "./dtimep.lex" - { - tw.tw_zone = 60 * (('a'-1) - LC(*cp)); - EXPZONE; - } -break; -case 40: - -# line 389 "./dtimep.lex" - { - tw.tw_zone = 60 * ('a' - LC(*cp)); - EXPZONE; - } -break; -case 41: - -# line 393 "./dtimep.lex" - { - tw.tw_zone = 60 * (LC(*cp) - 'm'); - EXPZONE; - } -break; -case 42: - -# line 397 "./dtimep.lex" - { - cp++; - tw.tw_zone = ((cp[0] * 10 + cp[1]) - -('0' * 10 + '0'))*60 - +((cp[2] * 10 + cp[3]) - -('0' * 10 + '0')); - EXPZONE; -#ifdef DSTXXX - zonehack (&tw); -#endif /* DSTXXX */ - cp += 4; - } -break; -case 43: - -# line 409 "./dtimep.lex" - { - cp++; - tw.tw_zone = (('0' * 10 + '0') - -(cp[0] * 10 + cp[1]))*60 - +(('0' * 10 + '0') - -(cp[2] * 10 + cp[3])); - EXPZONE; -#ifdef DSTXXX - zonehack (&tw); -#endif /* DSTXXX */ - cp += 4; - } -break; -case 44: - -# line 421 "./dtimep.lex" - { - SKIPD; - tw.tw_year = CVT4; cp+=4; - } -break; -case 45: - -# line 425 "./dtimep.lex" -case 46: - -# line 426 "./dtimep.lex" -; -break; - default: return(0); -} } -/* end of yylex */ -int yyvstop[] = { -0, - -46, -0, - -45, -0, - -46, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -39, -0, - -40, -0, - -40, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -41, -0, - -19, -0, - -4, -0, - -4, -0, - -11, -0, - -1, -0, - -1, -0, - -1, -0, - -1, -0, - -1, -0, - -1, -0, - -1, -0, - -33, -0, - -32, -0, - -38, -0, - -26, -0, - -25, -0, - -24, -0, - -23, -0, - -20, -0, - -37, -0, - -36, -0, - -22, -0, - -21, -0, - -28, -0, - -27, -0, - -31, -0, - -30, -0, - -29, -0, - -35, -0, - -34, -0, - -4, -0, - -4, -0, - -4, -0, - -18, -0, - -11, -0, - -11, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -6, -0, - -17, -18, -0, - -1, -0, - -2, -0, - -18, -0, - -10, -0, - -12, -0, - -14, -0, - -6, -0, - -17, -18, -0, - -8, -0, - -44, -0, - -42, -0, - -43, -0, - -2, -0, - -3, -0, - -16, -0, - -10, -0, - -10, -0, - -5, -0, - -8, -0, - -8, -0, - -1, -0, - -3, -0, - -3, -0, - -13, -0, - -15, -0, - -6, -0, - -5, -0, - -5, -0, - -5, -0, - -5, -0, - -7, -0, - -9, -0, - -7, -0, - -7, -0, -0}; -# define YYTYPE int -struct yywork { YYTYPE verify, advance; } yycrank[] = { -0,0, 0,0, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 0,0, 1,5, 1,6, -5,5, 0,0, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 1,5, 0,0, 5,5, -3,21, 3,6, 0,0, 0,0, -0,0, 1,7, 0,0, 0,0, -0,0, 0,0, 0,0, 0,0, -0,0, 1,8, 1,9, 1,8, -1,10, 1,10, 1,10, 1,10, -1,10, 1,10, 1,10, 3,21, -9,63, 22,83, 22,83, 0,0, -0,0, 0,0, 0,0, 3,7, -0,0, 0,0, 3,22, 0,0, -3,23, 0,0, 0,0, 3,8, -3,9, 3,8, 3,10, 3,10, -3,10, 3,10, 3,10, 3,10, -3,10, 10,64, 10,64, 10,64, -10,64, 10,64, 10,64, 10,64, -10,64, 10,64, 10,64, 0,0, -0,0, 0,0, 1,11, 15,72, -59,143, 1,12, 14,70, 1,13, -12,67, 13,68, 17,75, 1,14, -19,79, 20,81, 1,15, 1,16, -1,17, 15,73, 11,65, 16,74, -1,18, 1,19, 13,69, 11,66, -1,20, 19,80, 14,71, 25,99, -3,24, 3,25, 3,26, 3,27, -3,28, 3,29, 3,30, 3,31, -3,32, 3,33, 3,34, 3,34, -3,35, 3,36, 3,37, 3,38, -3,39, 3,39, 3,40, 3,41, -3,42, 3,39, 3,43, 3,39, -3,44, 7,45, 8,50, 18,76, -26,100, 28,102, 30,104, 18,77, -7,46, 24,97, 42,114, 45,117, -31,105, 21,21, 7,47, 7,48, -23,84, 23,84, 7,49, 26,101, -28,103, 24,65, 38,112, 18,78, -24,98, 8,50, 24,66, 31,106, -36,74, 46,118, 49,123, 56,139, -36,111, 57,140, 55,137, 60,144, -21,21, 38,113, 8,51, 55,138, -8,52, 8,53, 8,53, 8,53, -8,53, 8,53, 8,53, 8,53, -8,53, 8,53, 8,53, 8,54, -21,82, 21,82, 21,82, 21,82, -21,82, 21,82, 21,82, 21,82, -21,82, 21,82, 47,119, 61,145, -62,146, 23,85, 23,86, 23,87, -44,115, 23,88, 35,72, 23,89, -23,90, 35,109, 23,91, 50,50, -33,70, 23,92, 23,93, 33,107, -23,94, 58,141, 47,120, 44,116, -35,73, 23,95, 65,148, 48,121, -35,110, 23,96, 8,55, 51,124, -66,149, 8,56, 33,108, 8,57, -33,71, 67,150, 50,50, 8,58, -48,122, 58,142, 8,59, 8,60, -8,61, 68,151, 69,152, 70,153, -8,62, 73,158, 71,154, 50,124, -71,155, 74,159, 51,124, 52,134, -52,134, 52,134, 52,134, 52,134, -52,134, 52,134, 52,134, 52,134, -52,134, 75,160, 76,161, 77,162, -78,163, 79,164, 51,133, 51,133, -51,133, 51,133, 51,133, 51,133, -51,133, 51,133, 51,133, 51,133, -53,135, 53,135, 53,135, 53,135, -53,135, 53,135, 53,135, 53,135, -53,135, 53,135, 54,136, 54,136, -54,136, 54,136, 54,136, 54,136, -54,136, 54,136, 54,136, 54,136, -72,156, 80,165, 81,166, 50,125, -93,111, 85,97, 50,126, 72,157, -50,127, 97,170, 91,107, 92,109, -50,128, 64,50, 98,171, 50,129, -50,130, 50,131, 99,172, 51,55, -85,98, 50,132, 51,56, 100,173, -51,57, 91,108, 92,110, 101,174, -51,58, 102,175, 103,176, 51,59, -51,60, 51,61, 104,177, 105,178, -64,50, 51,62, 63,135, 63,135, -63,135, 63,135, 63,135, 63,135, -63,147, 63,147, 63,147, 63,147, -106,179, 64,51, 107,180, 64,52, -82,167, 82,167, 82,167, 82,167, -82,167, 82,167, 82,167, 82,167, -82,167, 82,167, 64,54, 83,168, -83,168, 83,168, 83,168, 83,168, -83,168, 83,168, 83,168, 83,168, -83,168, 84,169, 84,169, 84,169, -84,169, 84,169, 84,169, 84,169, -84,169, 84,169, 84,169, 108,181, -109,182, 110,183, 111,184, 112,185, -113,186, 115,187, 116,188, 117,189, -118,190, 119,191, 120,192, 121,193, -122,194, 123,195, 124,124, 126,198, -125,196, 64,55, 127,199, 128,200, -64,56, 125,197, 64,57, 129,202, -130,203, 131,204, 64,58, 132,205, -133,206, 64,59, 64,60, 64,61, -137,216, 138,217, 139,218, 64,62, -140,219, 124,124, 141,220, 128,201, -134,206, 135,210, 135,210, 135,210, -135,210, 135,210, 135,210, 135,210, -135,210, 135,210, 135,210, 133,206, -142,221, 143,223, 142,222, 144,225, -145,226, 146,227, 153,236, 155,157, -143,224, 158,238, 159,239, 134,206, -133,207, 160,240, 162,242, 133,208, -133,208, 133,208, 133,208, 133,208, -133,208, 133,208, 133,208, 133,208, -133,208, 148,229, 134,207, 134,209, -134,209, 134,209, 134,209, 134,209, -134,209, 134,209, 134,209, 134,209, -134,209, 136,211, 147,228, 147,228, -147,228, 147,228, 147,228, 147,228, -147,228, 147,228, 147,228, 147,228, -148,229, 149,229, 124,125, 150,229, -154,229, 124,126, 163,243, 124,127, -190,252, 192,254, 196,258, 124,128, -136,211, 191,250, 124,129, 124,130, -124,131, 151,229, 156,229, 152,234, -124,132, 157,229, 161,234, 164,234, -149,229, 165,234, 150,229, 154,229, -136,212, 136,212, 136,212, 136,212, -136,212, 136,212, 136,212, 136,212, -136,212, 136,212, 136,213, 166,234, -151,229, 156,229, 152,234, 194,250, -157,229, 161,234, 164,234, 189,250, -165,234, 195,250, 193,250, 197,259, -198,260, 199,261, 152,234, 200,262, -203,267, 161,234, 164,234, 201,263, -165,234, 201,264, 166,234, 167,247, -167,247, 167,247, 167,247, 167,247, -167,247, 167,247, 167,247, 167,247, -167,247, 148,230, 166,234, 204,268, -205,269, 136,214, 168,248, 168,248, -168,248, 168,248, 168,248, 168,248, -168,248, 168,248, 168,248, 168,248, -206,206, 191,253, 208,207, 209,207, -136,215, 212,213, 214,274, 150,232, -169,249, 169,249, 169,249, 169,249, -169,249, 169,249, 169,249, 169,249, -169,249, 169,249, 189,251, 202,265, -156,237, 149,231, 152,235, 206,206, -210,271, 211,211, 202,266, 215,275, -154,157, 194,256, 195,257, 220,283, -222,224, 225,285, 151,233, 193,255, -226,286, 227,287, 230,157, 231,290, -164,244, 232,291, 161,241, 165,245, -233,292, 235,293, 236,294, 210,271, -211,211, 237,157, 238,295, 239,296, -166,246, 207,270, 207,270, 207,270, -207,270, 207,270, 207,270, 207,270, -207,270, 207,270, 207,270, 210,272, -210,272, 210,272, 210,272, 210,272, -210,272, 210,272, 210,272, 210,272, -210,272, 213,273, 213,273, 213,273, -213,273, 213,273, 213,273, 213,273, -213,273, 213,273, 213,273, 240,297, -228,288, 234,234, 241,298, 242,299, -243,300, 244,301, 245,302, 216,276, -246,303, 247,304, 247,304, 247,304, -247,304, 247,304, 247,304, 247,304, -247,304, 247,304, 247,304, 250,307, -251,308, 252,309, 217,276, 228,288, -234,234, 253,310, 254,311, 255,312, -256,313, 211,214, 216,276, 257,314, -276,330, 258,266, 260,266, 279,224, -218,276, 265,266, 280,332, 281,333, -282,334, 283,335, 284,224, 216,277, -211,215, 217,276, 216,278, 216,278, -216,278, 216,278, 216,278, 216,278, -216,278, 216,278, 216,278, 216,278, -258,266, 260,266, 217,277, 218,276, -265,266, 217,278, 217,278, 217,278, -217,278, 217,278, 217,278, 217,278, -217,278, 217,278, 217,278, 219,276, -218,277, 259,266, 285,336, 218,278, -218,278, 218,278, 218,278, 218,278, -218,278, 218,278, 218,278, 218,278, -218,278, 264,266, 263,266, 286,337, -287,338, 290,157, 291,342, 292,343, -293,344, 294,345, 219,276, 296,346, -259,266, 221,276, 266,266, 271,271, -297,347, 274,274, 262,266, 216,279, -298,348, 299,349, 301,350, 219,277, -264,266, 263,266, 219,278, 219,278, -219,278, 219,278, 219,278, 219,278, -219,278, 219,278, 219,278, 219,278, -221,276, 266,266, 271,271, 223,276, -274,274, 262,266, 260,317, 265,320, -218,281, 258,315, 217,280, 261,266, -268,266, 221,277, 269,266, 275,275, -221,278, 221,278, 221,278, 221,278, -221,278, 221,278, 221,278, 221,278, -221,278, 221,278, 223,276, 302,351, -303,352, 224,276, 267,266, 288,288, -308,353, 310,354, 261,266, 268,266, -312,355, 269,266, 275,275, 223,277, -229,229, 313,356, 223,278, 223,278, -223,278, 223,278, 223,278, 223,278, -223,278, 223,278, 223,278, 223,278, -224,276, 267,266, 288,288, 314,357, -219,282, 264,266, 315,266, 316,358, -317,359, 259,316, 318,360, 229,229, -319,361, 224,277, 320,266, 321,362, -224,278, 224,278, 224,278, 224,278, -224,278, 224,278, 224,278, 224,278, -224,278, 224,278, 263,266, 229,289, -229,289, 229,289, 229,289, 229,289, -229,289, 229,289, 229,289, 229,289, -229,289, 221,224, 262,319, 322,363, -323,364, 223,284, 248,305, 248,305, -248,305, 248,305, 248,305, 248,305, -248,305, 248,305, 248,305, 248,305, -249,306, 249,306, 249,306, 249,306, -249,306, 249,306, 249,306, 249,306, -249,306, 249,306, 268,322, 328,368, -261,318, 329,369, 330,370, 332,224, -273,326, 269,323, 267,321, 270,324, -270,324, 270,324, 270,324, 270,324, -270,324, 270,324, 270,324, 270,324, -270,324, 272,325, 272,325, 272,325, -272,325, 272,325, 272,325, 272,325, -272,325, 272,325, 272,325, 273,326, -333,373, 334,374, 277,277, 278,331, -278,331, 278,331, 278,331, 278,331, -278,331, 278,331, 278,331, 278,331, -278,331, 324,365, 325,325, 273,327, -273,327, 273,327, 273,327, 273,327, -273,327, 273,327, 273,327, 273,327, -273,327, 277,277, 335,375, 336,376, -289,339, 337,377, 338,378, 341,340, -342,380, 343,381, 344,234, 345,157, -324,365, 325,325, 346,382, 347,157, -348,383, 277,278, 277,278, 277,278, -277,278, 277,278, 277,278, 277,278, -277,278, 277,278, 277,278, 289,339, -324,366, 324,366, 324,366, 324,366, -324,366, 324,366, 324,366, 324,366, -324,366, 324,366, 326,326, 289,340, -273,328, 327,326, 331,371, 289,341, -289,341, 289,341, 289,341, 289,341, -289,341, 289,341, 289,341, 289,341, -289,341, 339,339, 340,379, 273,329, -349,384, 350,385, 352,386, 353,250, -354,387, 326,326, 355,388, 357,389, -327,326, 331,371, 358,266, 359,390, -360,391, 361,392, 362,393, 363,394, -364,395, 365,365, 367,396, 373,399, -339,339, 340,379, 326,367, 374,400, -375,224, 331,372, 331,372, 331,372, -331,372, 331,372, 331,372, 331,372, -331,372, 331,372, 331,372, 368,368, -369,369, 370,370, 371,371, 376,401, -365,365, 366,365, 366,365, 366,365, -366,365, 366,365, 366,365, 366,365, -366,365, 366,365, 366,365, 377,224, -378,402, 384,404, 386,405, 389,406, -390,407, 391,408, 368,368, 369,369, -370,370, 371,371, 392,266, 379,379, -393,409, 394,266, 395,410, 397,412, -402,413, 410,415, 326,328, 398,371, -412,412, 327,328, 372,398, 372,398, -372,398, 372,398, 372,398, 372,398, -372,398, 372,398, 372,398, 372,398, -0,0, 326,329, 379,379, 0,0, -327,329, 396,411, 396,411, 396,411, -396,411, 0,0, 398,371, 412,412, -0,0, 0,0, 0,0, 414,417, -417,417, 0,0, 379,403, 379,403, -379,403, 379,403, 379,403, 379,403, -379,403, 379,403, 379,403, 379,403, -403,414, 403,414, 403,414, 403,414, -403,414, 403,414, 403,414, 403,414, -403,414, 403,414, 414,417, 417,417, -0,0, 0,0, 371,397, 411,416, -411,416, 411,416, 411,416, 411,416, -411,416, 411,416, 411,416, 411,416, -411,416, 0,0, 414,418, 414,418, -414,418, 414,418, 414,418, 414,418, -414,418, 414,418, 414,418, 414,418, -418,417, 418,417, 418,417, 418,417, -418,417, 418,417, 418,417, 418,417, -418,417, 418,417, 0,0, 0,0, -0,0}; -struct yysvf yysvec[] = { -0, 0, 0, -yycrank+1, 0, 0, -yycrank+0, yysvec+1, 0, -yycrank+27, 0, 0, -yycrank+0, yysvec+3, 0, -yycrank+3, 0, yyvstop+1, -yycrank+0, 0, yyvstop+3, -yycrank+47, 0, 0, -yycrank+141, 0, 0, -yycrank+3, yysvec+8, 0, -yycrank+37, yysvec+8, 0, -yycrank+2, 0, 0, -yycrank+3, 0, 0, -yycrank+4, 0, 0, -yycrank+5, 0, 0, -yycrank+2, 0, 0, -yycrank+4, 0, 0, -yycrank+7, 0, 0, -yycrank+54, 0, 0, -yycrank+4, 0, 0, -yycrank+8, 0, 0, -yycrank+152, 0, yyvstop+5, -yycrank+13, 0, 0, -yycrank+116, 0, 0, -yycrank+57, 0, yyvstop+7, -yycrank+8, 0, yyvstop+9, -yycrank+52, 0, yyvstop+11, -yycrank+0, yysvec+12, yyvstop+13, -yycrank+53, 0, yyvstop+15, -yycrank+0, yysvec+13, yyvstop+17, -yycrank+45, 0, yyvstop+19, -yycrank+60, 0, yyvstop+21, -yycrank+0, 0, yyvstop+23, -yycrank+127, 0, 0, -yycrank+0, 0, yyvstop+25, -yycrank+121, 0, yyvstop+27, -yycrank+65, 0, yyvstop+29, -yycrank+0, yysvec+17, yyvstop+31, -yycrank+70, 0, yyvstop+33, -yycrank+0, 0, yyvstop+35, -yycrank+0, yysvec+18, yyvstop+37, -yycrank+0, yysvec+19, yyvstop+39, -yycrank+42, 0, yyvstop+41, -yycrank+0, yysvec+20, yyvstop+43, -yycrank+116, 0, yyvstop+45, -yycrank+45, 0, 0, -yycrank+66, 0, 0, -yycrank+113, 0, 0, -yycrank+131, 0, 0, -yycrank+77, 0, 0, -yycrank+214, 0, 0, -yycrank+230, 0, 0, -yycrank+215, 0, 0, -yycrank+240, yysvec+8, 0, -yycrank+250, 0, 0, -yycrank+70, 0, 0, -yycrank+78, 0, 0, -yycrank+80, 0, 0, -yycrank+132, 0, 0, -yycrank+3, 0, 0, -yycrank+72, 0, 0, -yycrank+112, 0, 0, -yycrank+111, 0, 0, -yycrank+298, yysvec+8, 0, -yycrank+312, 0, 0, -yycrank+120, 0, 0, -yycrank+137, 0, 0, -yycrank+146, 0, 0, -yycrank+155, 0, 0, -yycrank+149, 0, 0, -yycrank+145, 0, 0, -yycrank+150, 0, 0, -yycrank+194, 0, 0, -yycrank+147, 0, 0, -yycrank+143, 0, 0, -yycrank+157, 0, 0, -yycrank+158, 0, 0, -yycrank+163, 0, 0, -yycrank+166, 0, 0, -yycrank+160, 0, 0, -yycrank+208, 0, 0, -yycrank+210, 0, 0, -yycrank+312, 0, 0, -yycrank+323, 0, 0, -yycrank+333, 0, 0, -yycrank+213, 0, 0, -yycrank+0, yysvec+25, 0, -yycrank+0, yysvec+26, 0, -yycrank+0, yysvec+28, 0, -yycrank+0, yysvec+30, 0, -yycrank+0, yysvec+31, 0, -yycrank+218, 0, 0, -yycrank+219, 0, 0, -yycrank+197, 0, 0, -yycrank+0, yysvec+38, 0, -yycrank+0, yysvec+42, 0, -yycrank+0, yysvec+44, 0, -yycrank+201, 0, 0, -yycrank+206, 0, 0, -yycrank+210, 0, 0, -yycrank+215, 0, 0, -yycrank+219, 0, 0, -yycrank+221, 0, 0, -yycrank+222, 0, 0, -yycrank+226, 0, 0, -yycrank+227, 0, 0, -yycrank+240, 0, 0, -yycrank+242, 0, 0, -yycrank+275, 0, 0, -yycrank+276, 0, 0, -yycrank+277, 0, 0, -yycrank+278, 0, 0, -yycrank+279, 0, 0, -yycrank+280, 0, 0, -yycrank+0, 0, yyvstop+47, -yycrank+281, 0, 0, -yycrank+282, 0, 0, -yycrank+294, 0, 0, -yycrank+290, 0, 0, -yycrank+285, 0, 0, -yycrank+292, 0, 0, -yycrank+286, 0, 0, -yycrank+303, 0, 0, -yycrank+305, 0, 0, -yycrank+397, 0, 0, -yycrank+296, 0, 0, -yycrank+306, 0, 0, -yycrank+309, 0, 0, -yycrank+314, 0, 0, -yycrank+318, 0, 0, -yycrank+305, 0, 0, -yycrank+318, 0, 0, -yycrank+318, 0, 0, -yycrank+411, 0, yyvstop+49, -yycrank+423, 0, yyvstop+51, -yycrank+385, 0, 0, -yycrank+472, 0, yyvstop+53, -yycrank+310, 0, 0, -yycrank+322, 0, 0, -yycrank+327, 0, 0, -yycrank+330, 0, 0, -yycrank+320, 0, 0, -yycrank+336, 0, 0, -yycrank+331, 0, 0, -yycrank+329, 0, 0, -yycrank+332, 0, 0, -yycrank+337, 0, 0, -yycrank+434, 0, 0, -yycrank+460, 0, 0, -yycrank+484, 0, 0, -yycrank+486, 0, 0, -yycrank+500, 0, 0, -yycrank+502, 0, yyvstop+55, -yycrank+333, yysvec+149, 0, -yycrank+487, 0, 0, -yycrank+350, yysvec+150, 0, -yycrank+501, 0, 0, -yycrank+504, 0, 0, -yycrank+353, yysvec+152, yyvstop+57, -yycrank+353, yysvec+150, 0, -yycrank+346, yysvec+157, 0, -yycrank+505, 0, yyvstop+59, -yycrank+342, yysvec+157, 0, -yycrank+398, yysvec+152, yyvstop+61, -yycrank+506, 0, yyvstop+63, -yycrank+508, 0, yyvstop+65, -yycrank+522, 0, yyvstop+67, -yycrank+507, 0, 0, -yycrank+522, 0, 0, -yycrank+540, 0, 0, -yycrank+0, 0, yyvstop+69, -yycrank+0, 0, yyvstop+71, -yycrank+0, 0, yyvstop+73, -yycrank+0, 0, yyvstop+75, -yycrank+0, 0, yyvstop+77, -yycrank+0, 0, yyvstop+79, -yycrank+0, 0, yyvstop+81, -yycrank+0, 0, yyvstop+83, -yycrank+0, 0, yyvstop+85, -yycrank+0, 0, yyvstop+87, -yycrank+0, 0, yyvstop+89, -yycrank+0, 0, yyvstop+91, -yycrank+0, 0, yyvstop+93, -yycrank+0, 0, yyvstop+95, -yycrank+0, 0, yyvstop+97, -yycrank+0, 0, yyvstop+99, -yycrank+0, 0, yyvstop+101, -yycrank+0, 0, yyvstop+103, -yycrank+0, 0, yyvstop+105, -yycrank+498, 0, 0, -yycrank+400, yysvec+189, 0, -yycrank+464, 0, 0, -yycrank+401, yysvec+189, 0, -yycrank+501, 0, 0, -yycrank+494, 0, 0, -yycrank+500, 0, 0, -yycrank+388, 0, 0, -yycrank+440, 0, 0, -yycrank+445, 0, 0, -yycrank+447, 0, 0, -yycrank+437, 0, 0, -yycrank+443, 0, 0, -yycrank+485, 0, 0, -yycrank+430, 0, 0, -yycrank+451, 0, 0, -yycrank+456, 0, 0, -yycrank+571, 0, yyvstop+107, -yycrank+585, 0, 0, -yycrank+537, yysvec+206, yyvstop+109, -yycrank+536, yysvec+206, yyvstop+111, -yycrank+595, 0, yyvstop+113, -yycrank+596, 0, yyvstop+115, -yycrank+527, yysvec+211, yyvstop+117, -yycrank+605, 0, 0, -yycrank+477, 0, 0, -yycrank+498, 0, 0, -yycrank+662, 0, yyvstop+119, -yycrank+677, 0, yyvstop+121, -yycrank+691, 0, yyvstop+123, -yycrank+726, 0, yyvstop+125, -yycrank+494, yysvec+217, yyvstop+127, -yycrank+752, 0, yyvstop+129, -yycrank+511, yysvec+218, yyvstop+131, -yycrank+778, 0, yyvstop+133, -yycrank+804, 0, yyvstop+135, -yycrank+512, yysvec+218, yyvstop+137, -yycrank+505, yysvec+224, yyvstop+139, -yycrank+501, yysvec+224, yyvstop+141, -yycrank+655, yysvec+210, yyvstop+143, -yycrank+815, 0, 0, -yycrank+510, 0, 0, -yycrank+504, 0, 0, -yycrank+512, 0, 0, -yycrank+507, 0, 0, -yycrank+656, 0, yyvstop+146, -yycrank+528, 0, 0, -yycrank+529, 0, 0, -yycrank+525, 0, 0, -yycrank+533, 0, 0, -yycrank+522, 0, 0, -yycrank+565, 0, 0, -yycrank+552, 0, 0, -yycrank+566, 0, 0, -yycrank+571, 0, 0, -yycrank+554, 0, 0, -yycrank+570, 0, 0, -yycrank+571, 0, 0, -yycrank+625, 0, 0, -yycrank+830, 0, 0, -yycrank+840, 0, 0, -yycrank+639, 0, yyvstop+148, -yycrank+587, 0, 0, -yycrank+588, 0, 0, -yycrank+575, 0, 0, -yycrank+593, 0, 0, -yycrank+576, 0, 0, -yycrank+592, 0, 0, -yycrank+594, 0, 0, -yycrank+688, yysvec+216, 0, -yycrank+728, yysvec+217, 0, -yycrank+689, yysvec+218, 0, -yycrank+786, yysvec+219, 0, -yycrank+757, yysvec+217, 0, -yycrank+741, yysvec+221, 0, -yycrank+740, yysvec+218, 0, -yycrank+692, yysvec+223, 0, -yycrank+753, yysvec+224, 0, -yycrank+805, yysvec+218, 0, -yycrank+787, yysvec+224, 0, -yycrank+789, yysvec+224, 0, -yycrank+859, 0, 0, -yycrank+754, 0, yyvstop+150, -yycrank+869, 0, 0, -yycrank+895, 0, yyvstop+152, -yycrank+756, 0, yyvstop+154, -yycrank+790, 0, yyvstop+156, -yycrank+599, yysvec+224, yyvstop+158, -yycrank+921, 0, 0, -yycrank+883, 0, 0, -yycrank+591, 0, 0, -yycrank+587, 0, 0, -yycrank+594, 0, 0, -yycrank+587, 0, 0, -yycrank+608, 0, 0, -yycrank+602, 0, 0, -yycrank+629, 0, 0, -yycrank+653, 0, 0, -yycrank+651, 0, 0, -yycrank+806, 0, yyvstop+160, -yycrank+947, 0, yyvstop+163, -yycrank+637, 0, 0, -yycrank+656, 0, 0, -yycrank+658, 0, 0, -yycrank+635, 0, 0, -yycrank+643, 0, 0, -yycrank+0, yysvec+293, 0, -yycrank+661, 0, 0, -yycrank+663, 0, 0, -yycrank+668, 0, 0, -yycrank+660, 0, 0, -yycrank+0, yysvec+293, 0, -yycrank+670, 0, 0, -yycrank+714, 0, 0, -yycrank+697, 0, 0, -yycrank+0, 0, yyvstop+165, -yycrank+0, 0, yyvstop+167, -yycrank+0, 0, yyvstop+169, -yycrank+0, 0, yyvstop+171, -yycrank+695, 0, 0, -yycrank+0, yysvec+308, 0, -yycrank+717, 0, 0, -yycrank+0, yysvec+308, 0, -yycrank+720, 0, 0, -yycrank+728, 0, 0, -yycrank+724, 0, 0, -yycrank+734, 0, 0, -yycrank+728, 0, 0, -yycrank+735, 0, 0, -yycrank+729, 0, 0, -yycrank+751, 0, 0, -yycrank+746, 0, 0, -yycrank+742, 0, 0, -yycrank+777, 0, 0, -yycrank+775, 0, 0, -yycrank+932, 0, yyvstop+173, -yycrank+933, 0, yyvstop+175, -yycrank+981, 0, yyvstop+177, -yycrank+984, 0, yyvstop+179, -yycrank+790, 0, 0, -yycrank+792, 0, 0, -yycrank+786, 0, 0, -yycrank+985, 0, yyvstop+181, -yycrank+787, 0, 0, -yycrank+830, 0, 0, -yycrank+832, 0, 0, -yycrank+840, 0, 0, -yycrank+857, 0, 0, -yycrank+856, 0, 0, -yycrank+849, 0, 0, -yycrank+996, 0, yyvstop+183, -yycrank+997, 0, 0, -yycrank+915, yysvec+339, yyvstop+185, -yycrank+859, 0, 0, -yycrank+847, 0, 0, -yycrank+918, yysvec+234, yyvstop+187, -yycrank+842, 0, 0, -yycrank+865, 0, 0, -yycrank+853, 0, 0, -yycrank+871, 0, 0, -yycrank+910, 0, 0, -yycrank+912, 0, 0, -yycrank+0, yysvec+293, 0, -yycrank+910, 0, 0, -yycrank+970, 0, 0, -yycrank+915, 0, 0, -yycrank+917, 0, 0, -yycrank+0, yysvec+308, 0, -yycrank+915, 0, 0, -yycrank+902, 0, 0, -yycrank+921, 0, 0, -yycrank+923, 0, 0, -yycrank+907, 0, 0, -yycrank+924, 0, 0, -yycrank+922, 0, 0, -yycrank+915, 0, 0, -yycrank+1016, 0, yyvstop+189, -yycrank+1001, yysvec+324, yyvstop+191, -yycrank+969, 0, 0, -yycrank+1034, 0, yyvstop+193, -yycrank+1035, 0, yyvstop+195, -yycrank+1036, 0, yyvstop+197, -yycrank+1037, 0, yyvstop+199, -yycrank+1034, yysvec+331, yyvstop+201, -yycrank+926, 0, 0, -yycrank+917, 0, 0, -yycrank+911, 0, 0, -yycrank+946, 0, 0, -yycrank+945, 0, 0, -yycrank+962, 0, 0, -yycrank+1062, 0, 0, -yycrank+0, yysvec+347, 0, -yycrank+0, yysvec+345, 0, -yycrank+0, yysvec+347, 0, -yycrank+0, yysvec+293, 0, -yycrank+960, 0, 0, -yycrank+0, yysvec+293, 0, -yycrank+965, 0, 0, -yycrank+0, yysvec+308, 0, -yycrank+0, yysvec+308, 0, -yycrank+966, 0, 0, -yycrank+963, 0, 0, -yycrank+951, 0, 0, -yycrank+949, 0, 0, -yycrank+971, 0, 0, -yycrank+959, 0, 0, -yycrank+976, 0, 0, -yycrank+1043, 0, 0, -yycrank+959, 0, 0, -yycrank+1070, 0, yyvstop+203, -yycrank+0, yysvec+377, 0, -yycrank+0, yysvec+375, 0, -yycrank+0, yysvec+377, 0, -yycrank+975, 0, 0, -yycrank+1072, 0, 0, -yycrank+0, yysvec+347, 0, -yycrank+0, yysvec+293, 0, -yycrank+0, yysvec+308, 0, -yycrank+0, yysvec+394, 0, -yycrank+0, yysvec+392, 0, -yycrank+0, yysvec+394, 0, -yycrank+976, 0, 0, -yycrank+1087, 0, 0, -yycrank+1071, 0, yyvstop+205, -yycrank+0, yysvec+377, 0, -yycrank+1098, 0, yyvstop+207, -yycrank+0, yysvec+394, 0, -yycrank+0, 0, yyvstop+209, -yycrank+1099, 0, yyvstop+211, -yycrank+1108, yysvec+414, yyvstop+213, -0, 0, 0}; -struct yywork *yytop = yycrank+1165; -struct yysvf *yybgin = yysvec+1; -char yymatch[] = { - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 9, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 9, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 48, 48, 50, 51, 51, 51, 54, 54, - 54, 54, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 1, 107, 107, 107, 110, 110, -110, 110, 110, 110, 110, 110, 110, 110, -110, 110, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, -0}; -char yyextra[] = { -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0}; -/* Copyright (c) 1989 AT&T */ -/* All Rights Reserved */ - -/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ -/* The copyright notice above does not evidence any */ -/* actual or intended publication of such source code. */ - -#pragma ident "@(#)ncform 6.11 97/01/06 SMI" - diff --git a/zotnet/tws/dtimep.lex b/zotnet/tws/dtimep.lex deleted file mode 100644 index ab2e4f5..0000000 --- a/zotnet/tws/dtimep.lex +++ /dev/null @@ -1,427 +0,0 @@ -%e 2000 -%p 5000 -%n 1000 -%a 4000 -%START Z -sun (sun(day)?) -mon (mon(day)?) -tue (tue(sday)?) -wed (wed(nesday)?) -thu (thu(rsday)?) -fri (fri(day)?) -sat (sat(urday)?) - -DAY ({sun}|{mon}|{tue}|{wed}|{thu}|{fri}|{sat}) - -jan (jan(uary)?) -feb (feb(ruary)?) -mar (mar(ch)?) -apr (apr(il)?) -may (may) -jun (jun(e)?) -jul (jul(y)?) -aug (aug(ust)?) -sep (sep(tember)?) -oct (oct(ober)?) -nov (nov(ember)?) -dec (dec(ember)?) - -MONTH ({jan}|{feb}|{mar}|{apr}|{may}|{jun}|{jul}|{aug}|{sep}|{oct}|{nov}|{dec}) - -w ([ \t]*) -W ([ \t]+) -D ([0-9]?[0-9]) -d [0-9] -%{ -#include -#include -#if !defined(HAVE_TM_GMTOFF) && !defined(HAVE_TZSET) -# include -#endif - -#if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) -extern int daylight; -extern long timezone; -extern char *tzname[]; -#endif - -/* - * Patchable flag that says how to interpret NN/NN/NN dates. When - * true, we do it European style: DD/MM/YY. When false, we do it - * American style: MM/DD/YY. Of course, these are all non-RFC822 - * compliant. - */ -int europeandate = 0; - -/* - * Table to convert month names to numeric month. We use the - * fact that the low order 5 bits of the sum of the 2nd & 3rd - * characters of the name is a hash with no collisions for the 12 - * valid month names. (The mask to 5 bits maps any combination of - * upper and lower case into the same hash value). - */ -static int month_map[] = { - 0, - 6, /* 1 - Jul */ - 3, /* 2 - Apr */ - 5, /* 3 - Jun */ - 0, - 10, /* 5 - Nov */ - 0, - 1, /* 7 - Feb */ - 11, /* 8 - Dec */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, /*15 - Jan */ - 0, - 0, - 0, - 2, /*19 - Mar */ - 0, - 8, /*21 - Sep */ - 0, - 9, /*23 - Oct */ - 0, - 0, - 4, /*26 - May */ - 0, - 7 /*28 - Aug */ -}; -/* - * Same trick for day-of-week using the hash function - * (c1 & 7) + (c2 & 4) - */ -static int day_map[] = { - 0, - 0, - 0, - 6, /* 3 - Sat */ - 4, /* 4 - Thu */ - 0, - 5, /* 6 - Fri */ - 0, /* 7 - Sun */ - 2, /* 8 - Tue */ - 1 /* 9 - Mon */, - 0, - 3 /*11 - Wed */ -}; -#define SETDAY { tw.tw_wday= day_map[(cp[0] & 7) + (cp[1] & 4)];\ - tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP;\ - cp += 2; } -#define SETMONTH { tw.tw_mon = month_map[(cp[0] + cp[1]) & 0x1f]; gotdate++;\ - cp += 2;\ - SKIPD;} -#define CVT1OR2 (i=(*cp++ - '0'), isdigit(*cp)? i*10 + (*cp++ - '0') : i) -#define CVT2 ((cp[0] - '0')*10 + (cp[1] - '0')) -#define CVT4 ((((cp[0] - '0')*10 + (cp[1] - '0'))*10 + \ - (cp[2] - '0'))*10 + (cp[3] - '0')) -#define SKIPD { while ( !isdigit(*cp++) ) ; --cp; } -#define EXPZONE { tw.tw_flags &= ~TW_SZONE; tw.tw_flags |= TW_SZEXP; } -#define ZONE(x) { tw.tw_zone=(x); EXPZONE; } -#define ZONED(x) { ZONE(x); tw.tw_flags |= TW_DST; } -#define LC(c) (isupper (c) ? tolower (c) : (c)) - -#ifdef DSTXXX -# ifdef TIME_WITH_SYS_TIME -# include -# include -# else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - -static void -zonehack (struct tws *tw) -{ - register struct tm *tm; - - if (dmktime (tw) == (time_t) -1) - return; - - tm = localtime (&tw->tw_clock); - if (tm->tm_isdst) { - tw->tw_flags |= TW_DST; - tw->tw_zone -= 60; - } -} -#endif /* DSTXXX */ -%} -%% -%{ -struct tws * -dparsetime (char *str) -{ - register int i; - static struct tws tw; - register char *cp; - register int gotdate = 0; - time_t tclock; - -#ifdef HAVE_TM_GMTOFF - struct tm *tm; - time_t clock; -#else -# ifndef HAVE_TZSET - struct timeb tb; -# endif /* not HAVE_TZSET */ -#endif /* HAVE_TM_GMTOFF */ - - start_cond = 0; - - /* Zero out the struct. */ - memset( (char *) &tw, 0, sizeof(tw)); - - /* Set default time zone. */ -#ifdef HAVE_TM_GMTOFF - time (&clock); - tm = localtime(&clock); - tw.tw_zone = tm->tm_gmtoff / 60; - if (tm->tm_isdst) /* if DST is in effect */ - tw.tw_zone -= 60; /* reset to normal offset */ -#else -# ifdef HAVE_TZSET - tzset(); - tw.tw_zone = -(timezone / 60); -# else - ftime(&tb); - tw.tw_zone = -tb.timezone; -# endif /* HAVE_TZSET */ -#endif /* HAVE_TM_GMTOFF */ - - while (isspace(*str)) - str++; - while (1) - switch (cp = str, *cp ? lex_string( &str, start_cond) : 0) { - - case -1: - if (!gotdate || tw.tw_year == 0) - return (struct tws *)0; - /* fall through */ - case 0: - if (tw.tw_year == 0) { - /* Set default year. */ - time (&tclock); - tw.tw_year = localtime(&tclock)->tm_year + 1900; - } else if (tw.tw_year < 100) { - /* assume no 2-digit years > 1999 */ - tw.tw_year += 1900; - } - return &tw; - -%} -{DAY}","?{w} SETDAY; -"("{DAY}")"(","?) { - cp++; - SETDAY; - } -{D}(("-"{D}"-")|("/"{D}"/")){D}?{d}{d}{w} { - if (europeandate) { - /* European: DD/MM/YY */ - tw.tw_mday = CVT1OR2; - cp++; - tw.tw_mon = CVT1OR2 - 1; - } else { - /* American: MM/DD/YY */ - tw.tw_mon = CVT1OR2 - 1; - cp++; - tw.tw_mday = CVT1OR2; - } - cp++; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; - gotdate++; /* XXX */ - } -{D}("/"|"-"){D}{w} { - if (europeandate) { - tw.tw_mday = CVT1OR2; cp++; - tw.tw_mon = CVT1OR2 - 1; - } else { - tw.tw_mon = CVT1OR2 - 1; cp++; - tw.tw_mday = CVT1OR2; - } - gotdate++; - } -{D}{w}(-)?{w}{MONTH}{w}(-)?{w}{D}?{d}{d}({W}at)?{w} { - tw.tw_mday = CVT1OR2; - while ( !isalpha(*cp++) ) - ; - SETMONTH; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; -#ifdef FIX_NON_Y2K_COMPLIANT_MUA_DATES - /* handle broken mua's that don't add - 1900, or just use the last two - digits. Assume no email before - 1972. */ - if (tw.tw_year < 72) - tw.tw_year += 100; - if (tw.tw_year < 1900) - tw.tw_year += 1900; -#endif /* FIX_NON_Y2K_COMPLIANT_MUA_DATES */ - } -{D}"-"?{MONTH}({W}at)?{w} { - tw.tw_mday = CVT1OR2; - while ( ! isalpha( *cp++ ) ) - ; - SETMONTH; - } -{MONTH}{W}{D}","{W}{D}?{d}{d}{w} { - cp++; - SETMONTH; - tw.tw_mday = CVT1OR2; - SKIPD; - for (i = 0; isdigit(*cp); ) - i = i*10 + (*cp++ - '0'); - tw.tw_year = i; - } -{MONTH}{W}{D}{w} { - cp++; - SETMONTH; - tw.tw_mday = CVT1OR2; - } - -{D}:{D}:{D}{W}19[6-9]{d} { /* hack: ctime w/o TZ */ - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - SKIPD; - tw.tw_year = CVT4; cp+=4; - } -{D}:{D}:{D}{w} { - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -{D}:{D}{w} { - tw.tw_hour = CVT1OR2; cp++; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -{D}:{D}{w}am{w} { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour == 12) - tw.tw_hour = 0; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -{D}:{D}:{D}{w}am{w} { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour == 12) - tw.tw_hour = 0; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -{D}:{D}{w}pm{w} { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour != 12) - tw.tw_hour += 12; - tw.tw_min = CVT1OR2; - BEGIN Z; - } -{D}:{D}:{D}{w}pm{w} { - tw.tw_hour = CVT1OR2; cp++; - if (tw.tw_hour != 12) - tw.tw_hour += 12; - tw.tw_min = CVT1OR2; cp++; - tw.tw_sec = CVT1OR2; - BEGIN Z; - } -[0-2]{d}{d}{d}{d}{d}{w} { - tw.tw_hour = CVT2; cp+=2; - tw.tw_min = CVT2; cp+=2; - tw.tw_sec = CVT2; cp+=2; - BEGIN Z; - } -19[6-9]{d}{w} { - /* - * Luckly, 4 digit times in the range - * 1960-1999 aren't legal as hour - * and minutes. - */ - tw.tw_year = CVT4; cp+=4; - } -[0-2]{d}{d}{d}{w} { - if (tw.tw_hour || tw.tw_min - || tw.tw_sec) { - tw.tw_year = CVT4; cp+=4; - tw.tw_zone = 0; - } else { - tw.tw_hour = CVT2; cp+=2; - tw.tw_min = CVT2; cp+=2; - BEGIN Z; - } - } -"-"?ut ZONE(0 * 60); -"-"?gmt ZONE(0 * 60); -"-"?jst ZONE(2 * 60); -"-"?jdt ZONED(2 * 60); -"-"?est ZONE(-5 * 60); -"-"?edt ZONED(-5 * 60); -"-"?cst ZONE(-6 * 60); -"-"?cdt ZONED(-6 * 60); -"-"?mst ZONE(-7 * 60); -"-"?mdt ZONED(-7 * 60); -"-"?pst ZONE(-8 * 60); -"-"?pdt ZONED(-8 * 60); -"-"?nst ZONE(-(3 * 60 + 30)); -"-"?ast ZONE(-4 * 60); -"-"?adt ZONED(-4 * 60); -"-"?yst ZONE(-9 * 60); -"-"?ydt ZONED(-9 * 60); -"-"?hst ZONE(-10 * 60); -"-"?hdt ZONED(-10 * 60); -"-"?bst ZONED(-1 * 60); -[a-i] { - tw.tw_zone = 60 * (('a'-1) - LC(*cp)); - EXPZONE; - } -[k-m] { - tw.tw_zone = 60 * ('a' - LC(*cp)); - EXPZONE; - } -[n-y] { - tw.tw_zone = 60 * (LC(*cp) - 'm'); - EXPZONE; - } -"+"[0-1]{d}{d}{d} { - cp++; - tw.tw_zone = ((cp[0] * 10 + cp[1]) - -('0' * 10 + '0'))*60 - +((cp[2] * 10 + cp[3]) - -('0' * 10 + '0')); - EXPZONE; -#ifdef DSTXXX - zonehack (&tw); -#endif /* DSTXXX */ - cp += 4; - } -"-"[0-1]{d}{d}{d} { - cp++; - tw.tw_zone = (('0' * 10 + '0') - -(cp[0] * 10 + cp[1]))*60 - +(('0' * 10 + '0') - -(cp[2] * 10 + cp[3])); - EXPZONE; -#ifdef DSTXXX - zonehack (&tw); -#endif /* DSTXXX */ - cp += 4; - } -{W}{d}{d}{d}{d} { - SKIPD; - tw.tw_year = CVT4; cp+=4; - } -\n | -{W} ; -%% diff --git a/zotnet/tws/lexedit.sed b/zotnet/tws/lexedit.sed deleted file mode 100644 index 601df0f..0000000 --- a/zotnet/tws/lexedit.sed +++ /dev/null @@ -1,20 +0,0 @@ -2,/^extern int yylineno;$/c\ -static int start_cond = 0;\ -#define BEGIN start_cond = -/^struct yysvf \*yyestate;$/,/^extern struct yysvf yysvec/d -/^# define YYNEWLINE /,/^[ ]*int nstr;/d -/^[ ]*while((nstr = yylook()/,/^[ ]*if(yywrap()) /d -/^case -1:$/,/^} return(0); }/c\ - default: return(0);\ -} } -/^struct yysvf *yybgin = yysvec+1;$/d -/^int yylineno /,$d -/^# define YYTYPE short/c\ -# define YYTYPE int -/^unsigned char yymatch\[\] = {/c\ -char yymatch[] = { -/^unsigned char yyextra\[\] = {/c\ -char yyextra[] = { -/^# define YYTYPE unsigned short/c\ -# define YYTYPE int -/^if (__once_yylex) {$/,/if(yymbcurmax<=0) yymbcurmax=MB_CUR_MAX;$/d diff --git a/zotnet/tws/lexstring.c b/zotnet/tws/lexstring.c deleted file mode 100644 index 91506e7..0000000 --- a/zotnet/tws/lexstring.c +++ /dev/null @@ -1,257 +0,0 @@ - -/* - * lexstring.c - * - * $Id$ - */ - -#define ONECASE 1 - -#include -#include - -#define YYLERR yysvec -#define YYTYPE int -#define YYLMAX 256 - -struct yysvf { -#ifndef hpux - struct yywork *yystoff; -#else /* hpux */ - int yystoff; -#endif /* hpux */ - struct yysvf *yyother; - int *yystops; -}; - -struct yywork { - YYTYPE verify; - YYTYPE advance; -}; - -extern int yyvstop[]; -extern struct yywork yycrank[]; -extern struct yysvf yysvec[]; -extern char yymatch[]; -extern char yyextra[]; - -#ifdef LEXDEBUG -static int debug = 0; -#endif /* LEXDEBUG */ - -#ifdef ONECASE -static char case_map[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; -#endif /* ONECASE */ - - -int -lex_string (char **strptr, int start_cond) -{ - struct yysvf *state, **lsp; - struct yywork *tran; - int statenum; - int ch; - char *cp = *strptr; - int *found; - struct yysvf *yylstate[YYLMAX]; - - /* start off machines */ - lsp = yylstate; - statenum = 1 + start_cond; - state = yysvec + statenum; - for (;;) { -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,"%d ",statenum - 1); - } -#endif -#ifndef hpux - tran = state->yystoff; -#else /* hpux */ - tran = &yycrank[state->yystoff]; -#endif /* hpux */ - if(tran == yycrank) - /* may not be any transitions */ - if (state->yyother == 0 || -#ifndef hpux - state->yyother->yystoff == yycrank) -#else /* hpux */ - state->yyother->yystoff == 0) -#endif /* hpux */ - break; - -#ifdef ONECASE - ch = case_map[(unsigned char) *cp++]; -#else /* not ONECASE */ - ch = *cp++; -#endif /* ONECASE */ -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,"("); - allprint(ch); - fprintf(stderr, ")"); - } -#endif -tryagain: -#ifndef hpux - if ( tran > yycrank){ -#else /* hpux */ - if ( (int)tran > (int)yycrank){ -#endif /* hpux */ - tran += ch; - if (tran->verify == statenum){ - if ((statenum = tran->advance) == 0){ - /* error transitions */ - --cp; - break; - } - state = statenum + yysvec; - *lsp++ = state; - goto contin; - } - -#ifndef hpux - } else if(tran < yycrank) { -#else /* hpux */ - } else if( (int)tran < (int)yycrank) { -#endif /* hpux */ - tran = yycrank+(yycrank-tran) + ch; -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr," compressed"); - } -#endif - if (tran->verify == statenum){ - if ((statenum = tran->advance) == 0) - /* error transitions */ - break; - - state = statenum + yysvec; - *lsp++ = state; - goto contin; - } - tran += (yymatch[ch] - ch); -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,"(fb "); - allprint(yymatch[ch]); - fprintf(stderr,")"); - } -#endif - if (tran->verify == statenum){ - if((statenum = tran->advance) == 0) - /* error transition */ - break; - - state = statenum + yysvec; - *lsp++ = state; - goto contin; - } - } - if ((state = state->yyother) && -#ifndef hpux - (tran = state->yystoff) != yycrank){ -#else /* hpux */ - (tran = &yycrank[state->yystoff]) != yycrank){ -#endif /* hpux */ - statenum = state - yysvec; -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,"fb %d", statenum - 1); - } -#endif - goto tryagain; - } else - break; - -contin: -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,">"); - } -#endif - ; - } -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr,"\nStopped in state %d (",*(lsp-1)-yysvec-1); - allprint(ch); - fprintf(stderr, ") "); - } -#endif - while (lsp-- > yylstate){ - if (*lsp != 0 && (found= (*lsp)->yystops) && *found > 0){ - if(yyextra[*found]){ - /* must backup */ - ch = -*found; - do { - while (*found && *found++ != ch) - ; - } while (lsp > yylstate && - (found = (*--lsp)->yystops)); - } -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr," Match \""); - for ( cp = *strptr; - cp <= ((*strptr)+(lsp-yylstate)); - cp++) - allprint( *cp ); - fprintf(stderr,"\" action %d\n",*found); - } -#endif - *strptr += (lsp - yylstate + 1); - return(*found); - } - } - /* the string didn't match anything - if we're looking at - * eos, just return 0. Otherwise, bump the string pointer - * and return -1. - */ -#ifdef LEXDEBUG - if (debug) { - fprintf(stderr," No match\n"); - } -#endif /* LEXDEBUG */ - if ( **strptr ) { - (*strptr)++; - return (-1); - } - return (0); -} - -#ifdef LEXDEBUG -void -allprint(char c) -{ - if ( c < 32 ) { - putc( '^', stderr ); - c += 32; - } else if ( c == 127 ) { - putc( '^', stderr ); - c = '?'; - } - putc( c, stderr ); -} -#endif /* LEXDEBUG */ diff --git a/zotnet/tws/tws.h b/zotnet/tws/tws.h deleted file mode 100644 index 29702db..0000000 --- a/zotnet/tws/tws.h +++ /dev/null @@ -1,62 +0,0 @@ - -/* - * tws.h - * - * $Id$ - */ - -/* DST vs. GMT nonsense */ -#define DSTXXX - -struct tws { - int tw_sec; /* seconds after the minute - [0, 61] */ - int tw_min; /* minutes after the hour - [0, 59] */ - int tw_hour; /* hour since midnight - [0, 23] */ - int tw_mday; /* day of the month - [1, 31] */ - int tw_mon; /* months since January - [0, 11] */ - int tw_year; /* 4 digit year (ie, 1997) */ - int tw_wday; /* days since Sunday - [0, 6] */ - int tw_yday; /* days since January 1 - [0, 365] */ - int tw_zone; - time_t tw_clock; /* if != 0, corresponding calendar value */ - int tw_flags; -}; - -#define TW_NULL 0x0000 - -#define TW_SDAY 0x0003 /* how day-of-week was determined */ -#define TW_SNIL 0x0000 /* not given */ -#define TW_SEXP 0x0001 /* explicitly given */ -#define TW_SIMP 0x0002 /* implicitly given */ - -#define TW_SZONE 0x0004 /* how timezone was determined */ -#define TW_SZNIL 0x0000 /* not given */ -#define TW_SZEXP 0x0004 /* explicitly given */ - -#define TW_DST 0x0010 /* daylight savings time */ -#define TW_ZONE 0x0020 /* use numeric timezones only */ - -#define dtwszone(tw) dtimezone (tw->tw_zone, tw->tw_flags) - -extern char *tw_dotw[]; -extern char *tw_ldotw[]; -extern char *tw_moty[]; - -/* - * prototypes - */ -char *dtime (time_t *, int); -char *dtimenow (int); -char *dctime (struct tws *); -struct tws *dlocaltimenow (void); -struct tws *dlocaltime (time_t *); -struct tws *dgmtime (time_t *); -char *dasctime (struct tws *, int); -char *dtimezone (int, int); -void twscopy (struct tws *, struct tws *); -int twsort (struct tws *, struct tws *); -time_t dmktime (struct tws *); -void set_dotw (struct tws *); - -struct tws *dparsetime (char *); -