inc.c
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 1,510 行 · 第 1/3 页
C
1,510 行
/* PDW: following 3 lines not from MH6.6 */#ifndef lintstatic char *sccsid = "@(#)inc.c 4.1 (ULTRIX) 11/23/87";#endif lint/* inc.c - incorporate messages from a maildrop into a folder */#include "../h/mh.h"#ifdef POP#include "../h/dropsbr.h"#endif POP#include "../h/formatsbr.h"#include "../h/scansbr.h"#include "../zotnet/tws.h"#include <stdio.h>#include "../zotnet/mts.h"#include <errno.h>#include <signal.h>#include <sys/types.h>#include <sys/stat.h>/* PDW: old version : *//* #ifndef NFSFLOCK *//* int onhup(); *//* int onintr(); *//* int onquit(); *//* int onterm(); *//* char *newmail; *//* FILE *in, *aud = NULL; *//* #endif NFSFLOCK *//* */#ifndef MF#define MFminc(a) (a)#else MF#define MFminc(a) 0#endif MF#ifndef POP#define POPminc(a) (a)#else POP#define POPminc(a) 0#endif POP#ifndef RPOP#define RPOPminc(a) (a)#else RPOP#define RPOPminc(a) 0#endif RPOP#ifndef TMA#define TMAminc(a) (a)#else TMA#define TMAminc(a) 0#endif TMA#ifndef X400#define X400minc(a) (a)#else X400#define X400minc(a) (0)#endif X400static struct swit switches[] = {#define AUDSW 0 "audit audit-file", 0,#define NAUDSW 1 "noaudit", 0,#define CHGSW 2 "changecur", 0,#define NCHGSW 3 "nochangecur", 0,#define DECRSW 4 "decrypt", TMAminc (-7),#define NDECRSW 5 "nodecrypt", TMAminc (-9),#define MSW 6 "file name", 0,#define FORMSW 7 "form formatfile", 0,#define FMTSW 8 "format string", 5,#define HOSTSW 9 "host host", POPminc (-4),#define USERSW 10 "user user", POPminc (-4),#define PACKSW 11 "pack file", POPminc (-4),#define NPACKSW 12 "nopack", POPminc (-6),#define RPOPSW 13 "rpop", RPOPminc (-4),#define NRPOPSW 14 "norpop", RPOPminc (-6),#define SILSW 15 "silent", 0,#define NSILSW 16 "nosilent", 0,#define TRNCSW 17 "truncate", 0,#define NTRNCSW 18 "notruncate", 0,#define UUCPSW 19 "uucp", MFminc (-4),#define NUUCPSW 20 "nouucp", MFminc (-6),#define WIDSW 21 "width columns", 0,/* PDW: SOURCESW */#define SOURCESW 22#if defined (POP) && defined (X400) "source x400|file|pop", X400minc(-4),#endif#if defined (POP) && !(defined (X400)) "source file|pop", RPOPminc (-4),#endif#if defined (X400) && !(defined (POP)) "source x400|file", X400minc(-4),#endif#if !(defined (X400)) && !(defined (POP)) "source file", 0,#endif#define HELPSW 23 "help", 4, NULL, NULL};/* *//* PDW: defines for 'source' flag : */#define NONESRC 0#define FILESRC 1 #ifdef POP#define POPSRC 2 #endif POP#ifdef X400#define X400SRC 4 #endif X400static struct srcent { char *name; char bitflag;} srctbl[] = {#ifdef POP "pop", POPSRC,#endif POP#ifdef X400 "x400", X400SRC,#endif X400 "file", FILESRC};static char all_src = 0; /* PDW: "all_src", "bitposn" are used */static int bitposn = 0; /* when the "-source" option is given */static char this_src = 0; /* holds the value of current source option. */static int done_inc = 0; /* flag for when mail has been inc'd. */static cur_updtd = 0; /* flag for when current message has been */ /* updated. */int real_uid; /* holds the UID of the user */extern int errno;#if defined (POP) || defined (X400)static char *file = NULL;#endif defined (POP) || defined (X400)#ifdef POPint snoop = 0;extern char response[];static int size;static long pos;static long start;static long stop;static int pd = NOTOK;static FILE *pf = NULL;static int pop_action (), pop_pack ();static int map_count();#endif POP#ifdef X400int x400_snoop = 0;extern char x400_response[];static int x400_size;static long x400_pos;static long x400_start;static long x400_stop;static int x400_pd = NOTOK;static FILE *x400_pf = NULL;static int x400_action (), x400_pack ();static int x400_map_count();#endif X400/* * //* ARGSUSED */main (argc, argv)int argc;char *argv[];{ int chgflag = 1, trnflag = 1, decflag = 1, noisy = 1, width = 0,/* PDW: old version - rtrnflag : */ rtrnflag = 0,#ifdef MF uucp = 1,#endif MF locked = 0,#ifdef POP nmsgs, nbytes, p,#endif POP#ifdef X400 x400_nmsgs, x400_nbytes, x400_p,#endif X400 rpop = 1, i, hghnum, msgnum, source_arg = 0; /* PDW: source_arg for use with "-source" flag */ char *cp, *maildir, *folder = NULL, *form = NULL, *format = NULL, *audfile = NULL, *from = NULL,/* PDW: host *host = NULL, */ *user = NULL,#ifdef X400 *x400_user = NULL,#endif X400#ifdef POP *pass = NULL,#endif POP#ifdef X400 *x400_pass = NULL,#endif X400/* PDW: old version : *//* #ifndef NFSFLOCK */ *newmail,/* PDW: old version : *//* #endif */ buf[100], **ap, **argp, *nfs, *arguments[MAXARGS]; struct msgs *mp; struct stat st, s1;/* PDW: old version : *//* #ifndef NFSFLOCK */ FILE *in, *aud = NULL;/* PDW: old version : *//* #endif NFSFLOCK */#ifdef MHE FILE *mhe = NULL;#endif MHE invo_name = r1bindex (argv[0], '/'); mts_init (invo_name);#ifdef POP if ((cp = getenv ("MHPOPDEBUG")) && *cp) snoop++;#endif POP#ifdef X400 if ((cp = getenv ("MHX400DEBUG")) && *cp) x400_snoop++;#endif X400 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;/* */ 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 [+folder] [switches]", invo_name); help (buf, switches); done (1); case AUDSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); audfile = getcpy (m_maildir (cp)); continue; case NAUDSW: audfile = NULL; continue; case CHGSW: chgflag++; continue; case NCHGSW: chgflag = 0; continue; case TRNCSW: /* PDW: old version - rtrnflag : */ rtrnflag++; trnflag++; continue; case MSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); from = path (cp, TFILE);/* fall *//* PJS: Don't set the source flag, as otherwise just specifying '-file filename' * switches off the default behaviour of all sources... */ all_src |= FILESRC; /* Falling through is wrong. If the user gives the command: * * inc -truncate -file /filename * * we will cancel the requested truncate flag.. * * On the other hand, if the user reverses the order to: * * inc -file /filename -truncate * * We will do the requested function.. * * The default is NOT to truncate the file unless specifically * requested to do so by the user. *//* PDW: next if stmt from old version : */ if (rtrnflag) continue; case NTRNCSW: trnflag = 0; continue; case SILSW: noisy = 0; continue; case NSILSW: noisy++; continue; case FORMSW: if (!(form = *argp++) || *form == '-') adios (NULLCP, "missing argument to %s", argp[-2]); format = NULL; continue; case FMTSW: if (!(format = *argp++) || *format == '-') adios (NULLCP, "missing argument to %s", argp[-2]); form = NULL; continue; case WIDSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); width = atoi (cp); continue; case DECRSW: decflag++; continue; case NDECRSW: decflag = 0; continue; case UUCPSW: #ifdef MF uucp++;#endif MF continue; case NUUCPSW: #ifdef MF uucp = 0;#endif MF continue;/* PDW: host changed to pophost */ case HOSTSW: if (!(pophost = *argp++) || *pophost == '-') adios (NULLCP, "missing argument to %s", argp[-2]); x400host = pophost; continue; case USERSW: if (!(user = *argp++) || *user == '-') adios (NULLCP, "missing argument to %s", argp[-2]); continue; case PACKSW:/*#ifndef POP if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]);#else POP if (!(file = *argp++) || *file == '-') adios (NULLCP, "missing argument to %s", argp[-2]);#endif POP*/#if !(defined (POP)) && !(defined (X400)) if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]);#endif !(undefined (POP)) && !(undefined (X400))#if defined (POP) || defined (X400) if (!(file = *argp++) || *file == '-') adios (NULLCP, "missing argument to %s", argp[-2]);#endif defined (POP) || defined (X400) continue; case NPACKSW:#if defined (POP) || defined (X400) file = NULLCP;#endif defined (POP) || defined (X400) continue; case RPOPSW: rpop++; continue; case NRPOPSW: rpop = 0; continue;/* PDW: -source {x400|file|pop} */ case SOURCESW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); source_arg = get_source_arg (cp); if (source_arg == NONESRC) adios (NULLCP, "missing argument to %s", argp[-2]); all_src |= source_arg; continue; } if (*cp == '+' || *cp == '@') { if (folder) adios (NULLCP, "only one folder at a time!"); else folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF); } else adios (NULLCP, "usage: %s [+folder] [switches]", invo_name); }/* */ if (all_src == 0) { /* if no sources specified, then check all */ all_src = ~0; /* sources. *//* MMS : if pophost exists then check pop */#ifdef POP if (!pophost || !(*pophost)) all_src ^= POPSRC;#endif POP/* MMS : if x400host exists then check x400 */#ifdef X400 if (!x400host || !(*x400host)) all_src ^= X400SRC;#endif X400
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?