📄 inc.c.6.7
字号:
/* inc.c - incorporate messages from a maildrop into a folder */#ifndef lintstatic char ident[] = "@(#)$Id: inc.c.6.7,v 1.1 90/11/25 19:04:44 sharpe Exp $";#endif lint#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>/* */#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 TMAstatic 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,#define HELPSW 22 "help", 4, NULL, NULL};/* */extern int errno;#ifdef POPint snoop = 0;extern char response[];static char *file = NULL;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/* * //* ARGSUSED */main (argc, argv)int argc;char *argv[];{ int chgflag = 1, trnflag = 1, decflag = 1, noisy = 1, width = 0,#ifdef MF uucp = 1,#endif MF locked = 0,#ifdef POP nmsgs, nbytes, p,#endif POP rpop = 1, i, hghnum, msgnum; char *cp, *maildir, *folder = NULL, *form = NULL, *format = NULL, *audfile = NULL, *from = NULL, *host = NULL, *user = NULL,#ifdef POP *pass = NULL,#endif POP *newmail, buf[100], **ap, **argp, *nfs, *arguments[MAXARGS]; struct msgs *mp; struct stat st, s1; FILE *in, *aud = NULL;#ifdef MHE FILE *mhe = NULL;#endif MHE invo_name = r1bindex (argv[0], '/'); mts_init (invo_name);#ifdef POP if (pophost && *pophost) host = pophost; if ((cp = getenv ("MHPOPDEBUG")) && *cp) snoop++;#endif POP 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: trnflag++; continue; case MSW: if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); from = path (cp, TFILE);/* fall */ 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; case HOSTSW: if (!(host = *argp++) || *host == '-') adios (NULLCP, "missing argument to %s", argp[-2]); 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 continue; case NPACKSW:#ifdef POP file = NULLCP;#endif POP continue; case RPOPSW: rpop++; continue; case NRPOPSW: rpop = 0; 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); }/* */#ifdef POP if (host && !*host) host = NULL; if (from || !host || !rpop) (void) setuid (getuid ());#endif POP if (from) { newmail = from;#ifdef POP host = NULL;#endif POP if (stat (newmail, &s1) == NOTOK || s1.st_size == 0) adios (NULLCP, "no mail to incorporate"); }#ifdef POP else if (host) { if (rpop) { if (user == NULL) user = getusr (); pass = getusr (); } else ruserpass (host, &user, &pass); if (pop_init (host, user, pass, snoop, rpop) == NOTOK || pop_stat (&nmsgs, &nbytes) == NOTOK) adios (NULLCP, "%s", response); if (rpop) (void) setuid (getuid ()); if (nmsgs == 0) { (void) pop_quit (); adios (NULLCP, "no mail to incorporate"); } }#endif POP else { if (((newmail = getenv ("MAILDROP")) && *newmail) || ((newmail = m_find ("maildrop")) && *newmail)) newmail = m_mailpath (newmail); else {#ifdef MF if (uucp && umincproc && *umincproc) get_uucp_mail ();#endif MF newmail = concat (MAILDIR, "/", MAILFIL, NULLCP); } if (stat (newmail, &s1) == NOTOK || s1.st_size == 0) adios (NULLCP, "no mail to incorporate"); }#ifdef POP if (host && file) goto go_to_it;#endif POP if (!m_find ("path")) free (path ("./", TFOLDER)); if (!folder) folder = defalt; maildir = m_maildir (folder); if (stat (maildir, &st) == NOTOK) { if (errno != ENOENT) adios (maildir, "error on folder"); cp = concat ("Create folder \"", maildir, "\"? ", NULLCP); if (noisy && !getanswer (cp)) done (1); free (cp); if (!makedir (maildir)) adios (NULLCP, "unable to create folder %s", maildir); } if (chdir (maildir) == NOTOK) adios (maildir, "unable to change directory to"); if (!(mp = m_gmsg (folder))) adios (NULLCP, "unable to read folder %s", folder);/* */#ifdef POPgo_to_it: ; if (host == NULL)#endif POP if (access (newmail, 02) == NOTOK) { trnflag = 0; if ((in = fopen (newmail, "r")) == NULL) adios (newmail, "unable to read"); } else { locked++; if (trnflag) { (void) signal (SIGHUP, SIG_IGN); (void) signal (SIGINT, SIG_IGN); (void) signal (SIGQUIT, SIG_IGN); (void) signal (SIGTERM, SIG_IGN); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -