head 1.11; access; symbols; locks; strict; comment @ * @; 1.11 date 92.12.15.00.20.22; author jromine; state Exp; branches; next 1.10; 1.10 date 92.11.04.02.28.49; author jromine; state Exp; branches; next 1.9; 1.9 date 92.05.19.21.00.21; author jromine; state Exp; branches; next 1.8; 1.8 date 92.02.10.17.33.44; author jromine; state Exp; branches; next 1.7; 1.7 date 92.01.31.22.30.01; author jromine; state Exp; branches; next 1.6; 1.6 date 92.01.31.16.35.55; author jromine; state Exp; branches; next 1.5; 1.5 date 92.01.30.22.39.58; author jromine; state Exp; branches; next 1.4; 1.4 date 90.04.05.15.00.25; author sources; state Exp; branches; next 1.3; 1.3 date 90.03.16.15.27.30; author sources; state Exp; branches; next 1.2; 1.2 date 90.02.05.15.32.06; author sources; state Exp; branches; next 1.1; 1.1 date 90.02.05.15.31.51; author sources; state Exp; branches; next ; desc @@ 1.11 log @endif sugar @ text @/* whom.c - report who a message would go to */ #ifndef lint static char ident[] = "@@(#)$Id: whom.c,v 1.10 1992/11/04 02:28:49 jromine Exp jromine $"; #endif /* lint */ #include "../h/mh.h" #include #include #ifdef LOCALE #include #endif /* */ static struct swit switches[] = { #define ALIASW 0 "alias aliasfile", 0, #define CHKSW 1 "check", 0, #define NOCHKSW 2 "nocheck", 0, #define DRAFTSW 3 "draft", 0, #define DFOLDSW 4 "draftfolder +folder", 6, #define DMSGSW 5 "draftmessage msg", 6, #define NDFLDSW 6 "nodraftfolder", 0, #define HELPSW 7 "help", 4, #define CLIESW 8 "client host", -6, #define SERVSW 9 "server host", -6, #define SNOOPSW 10 "snoop", -5, NULL, 0 }; /* */ /* ARGSUSED */ main (argc, argv) int argc; char *argv[]; { int child_id, i, status, isdf = 0, distsw = 0, vecp = 0; char *cp, *dfolder = NULL, *dmsg = NULL, *msg = NULL, **ap, **argp, backup[BUFSIZ], buf[100], *arguments[MAXARGS], *vec[MAXARGS]; #ifdef LOCALE setlocale(LC_ALL, ""); #endif invo_name = r1bindex (argv[0], '/'); if ((cp = m_find (invo_name)) != NULL) { ap = brkstring (cp = getcpy (cp), " ", "\n"); ap = copyip (ap, arguments); } else ap = arguments; (void) copyip (argv + 1, ap); argp = arguments; vec[vecp++] = invo_name; vec[vecp++] = "-whom"; vec[vecp++] = "-library"; vec[vecp++] = getcpy (m_maildir ("")); /* */ while (cp = *argp++) { if (*cp == '-') switch (smatch (++cp, switches)) { case AMBIGSW: ambigsw (cp, switches); done (1); case UNKWNSW: adios (NULLCP, "-%s unknown", cp); case HELPSW: (void) sprintf (buf, "%s [switches] [file]", invo_name); help (buf, switches); done (1); case CHKSW: case NOCHKSW: case SNOOPSW: vec[vecp++] = --cp; continue; case DRAFTSW: msg = draft; continue; case DFOLDSW: if (dfolder) adios (NULLCP, "only one draft folder at a time!"); if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp, *cp != '@@' ? TFOLDER : TSUBCWF); continue; case DMSGSW: if (dmsg) adios (NULLCP, "only one draft message at a time!"); if (!(dmsg = *argp++) || *dmsg == '-') adios (NULLCP, "missing argument to %s", argp[-2]); continue; case NDFLDSW: dfolder = NULL; isdf = NOTOK; continue; case ALIASW: case CLIESW: case SERVSW: vec[vecp++] = --cp; if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); vec[vecp++] = cp; continue; } if (msg) adios (NULLCP, "only one draft at a time!"); else vec[vecp++] = msg = cp; } if (cp = m_find ("Aliasfile")) { /* allow Aliasfile: profile entry */ char *dp = NULL; for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) { vec[vecp++] = "-alias"; vec[vecp++] = *ap; } } /* */ if (msg == NULL) { #ifdef WHATNOW if (dfolder || (cp = getenv ("mhdraft")) == NULL || *cp == '\0') #endif /* WHATNOW */ cp = getcpy (m_draft (dfolder, dmsg, 1, &isdf)); msg = vec[vecp++] = cp; } if ((cp = getenv ("mhdist")) && *cp && (distsw = atoi (cp)) && (cp = getenv ("mhaltmsg")) && *cp) { if (distout (msg, cp, backup) == NOTOK) done (1); vec[vecp++] = "-dist"; distsw++; } vec[vecp] = NULL; closefds (3); if (distsw) for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++) sleep (5); switch (distsw ? child_id : OK) { case NOTOK: advise (NULLCP, "unable to fork, so checking directly..."); case OK: execvp (postproc, vec); fprintf (stderr, "unable to exec "); perror (postproc); _exit (-1); default: (void) signal (SIGHUP, SIG_IGN); (void) signal (SIGINT, SIG_IGN); (void) signal (SIGQUIT, SIG_IGN); (void) signal (SIGTERM, SIG_IGN); status = pidwait (child_id, OK); (void) unlink (msg); if (rename (backup, msg) == NOTOK) adios (msg, "unable to rename %s to", backup); done (status); } } @ 1.10 log @LOCALE @ text @d3 2 a4 2 static char ident[] = "@@(#)$Id: whom.c,v 1.9 1992/05/19 21:00:21 jromine Exp jromine $"; #endif lint d162 1 a162 1 #endif WHATNOW @ 1.9 log @NULL->0 @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: whom.c,v 1.8 1992/02/10 17:33:44 jromine Exp jromine $"; d9 3 d72 3 @ 1.8 log @allow "Aliasfile" to be multiple files @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: whom.c,v 1.7 1992/01/31 22:30:01 jromine Exp jromine $"; d155 1 a155 1 if (dfolder || (cp = getenv ("mhdraft")) == NULL || *cp == NULL) @ 1.7 log @kerberos @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: whom.c,v 1.6 1992/01/31 16:35:55 jromine Exp jromine $"; d143 6 a148 2 vec[vecp++] = "-alias"; vec[vecp++] = getcpy(cp); @ 1.6 log @Multimedia MH @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: whom.c,v 1.5 1992/01/30 22:39:58 jromine Exp $"; d41 1 a41 1 NULL, NULL @ 1.5 log @remove WP @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: whom.c,v 1.4 1990/04/05 15:00:25 sources Exp jromine $"; d151 1 a151 1 if ((cp = getenv ("mhdraft")) == NULL || *cp == NULL) @ 1.4 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; a40 3 #define FILLSW 11 "fill-in file", -7, a130 1 case FILLSW: @ 1.3 log @add "Aliasfile: file" profile entry (like -alias file) @ text @d2 3 @ 1.2 log @WP Changes -- "-fill-in file" @ text @d143 4 @ 1.1 log @Initial revision @ text @d38 3 d131 1 @