⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 post.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
static	int sigser (i)int     i;{#ifndef	BSD42    (void) signal (i, SIG_IGN);#endif	not BSD42    (void) unlink (tmpfil);    if (msgflags & MINV)	(void) unlink (bccfil);#ifdef	MMDFMTS    if (!whomsw || checksw)	(void) mm_end (NOTOK);#endif	MMDFMTS#ifdef	SENDMTS    if (!whomsw || checksw)	(void) sm_end (NOTOK);#endif	SENDMTS    done (1);}#endif	not MHMTSstatic  sigon () {    if (debug)	return;#ifndef	MHMTS    setsigx (hstat, SIGHUP, sigser);    setsigx (istat, SIGINT, sigser);    setsigx (qstat, SIGQUIT, sigser);    setsigx (tstat, SIGTERM, sigser);#else	MHMTS    setsigx (hstat, SIGHUP, SIG_IGN);    setsigx (istat, SIGINT, SIG_IGN);    setsigx (qstat, SIGQUIT, SIG_IGN);    setsigx (tstat, SIGTERM, SIG_IGN);#endif	MHMTS}static sigoff () {    if (debug)	return;    (void) signal (SIGHUP, hstat);    (void) signal (SIGINT, istat);    (void) signal (SIGQUIT, qstat);    (void) signal (SIGTERM, tstat);}/*    FCC INTERACTION */static  p_refile (file)register char   *file;{    register int     i;    if (fccind == 0)	return;#ifdef	MHMTS    (void) setuid (myuid);#endif	MHMTS    if (verbose)	printf (" -- Filing Folder Copies --\n");    for (i = 0; i < fccind; i++)	fcc (file, fccfold[i]);    if (verbose)	printf (" -- Folder Copies Filed --\n");}static fcc (file, folder)register char   *file,		*folder;{    int     i,            child_id,	    status;    char    fold[BUFSIZ];    if (verbose)	printf ("  %sFcc %s: ", msgstate == RESENT ? "Resent-" : "", folder);    (void) fflush (stdout);    for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)	sleep (5);    switch (child_id) {	case NOTOK: 	    if (!verbose)		fprintf (stderr, "  %sFcc %s: ",			msgstate == RESENT ? "Resent-" : "", folder);	    fprintf (verbose ? stdout : stderr, "no forks, so not ok\n");	    break;	case OK: 	    (void) sprintf (fold, "%s%s",		    *folder == '+' || *folder == '@' ? "" : "+", folder);	    execlp (fileproc, r1bindex (fileproc, '/'),		    "-link", "-file", file, fold, NULLCP);            fprintf (verbose?stdout:stderr, "\nNo fileproc '%s'\n",fileproc);	    _exit (-1);	default: 	    if (status = pidwait (child_id, OK)) {		if (!verbose)		    fprintf (stderr, "  %sFcc %s: ",			    msgstate == RESENT ? "Resent-" : "", folder);		(void) pidstatus (status, verbose ? stdout : stderr, NULLCP);	    }	    else		if (verbose)		    printf ("folder ok\n");    }    (void) fflush (stdout);}/*    TERMINATION *//* VARARGS2 */static die (what, fmt, a, b, c, d)char   *what,       *fmt,       *a,       *b,       *c,       *d;{#ifndef	MHMTS    (void) unlink (tmpfil);    if (msgflags & MINV)	(void) unlink (bccfil);#endif	MHMTS#ifdef	MMDFMTS    if (!whomsw || checksw)	(void) mm_end (NOTOK);#endif	MMDFMTS#ifdef  X400    if (mts_arg == X400MTS) {        if (!whomsw || checksw)            (void) x400s_end (NOTOK);    }    else#endif  X400#ifdef	SENDMTS    if (!whomsw || checksw)	(void) sm_end (NOTOK);#endif	SENDMTS    adios (what, fmt, a, b, c, d);}#ifdef	MMDFMTS/*  *    err_abrt() is used by the mm_ routines *    		 do not, under *ANY* circumstances, remove it from post, *		 or you will lose *BIG* */err_abrt (code, fmt, a, b, c)int     code;char   *fmt,       *a,       *b,       *c;{    char    buffer[BUFSIZ];    (void) sprintf (buffer, "[%s]", rp_valstr (code));    adios (buffer, fmt, a, b, c);}#endif	MMDFMTS/*    STAND-ALONE DELIVERY */#ifdef	MHMTS/* BUG: MHMTS ignores 822-style route addresses... */static  localmail (lp, talk, fd)register struct mailname *lp;int     talk,        fd;{    int     md;    char    mailbox[BUFSIZ],	    ddate[BUFSIZ];    register struct home *hp;    if (talk)	printf ("  %s: ", lp -> m_mbox);    (void) fflush (stdout);    if ((hp = seek_home (lp -> m_mbox)) == NULL) {	if (!talk)	    fprintf (stderr, "  %s: ", lp -> m_mbox);	fprintf (talk ? stdout : stderr,		"not deliverable; unknown address\n");	unkadr++;	return;    }    (void) sprintf (mailbox, "%s/%s",	    mmdfldir[0] ? mmdfldir : hp -> h_home,	    mmdflfil[0] ? mmdflfil : hp -> h_name);/*  */    switch (access (slocalproc, 01)) {	default: 	    if (talk)		printf ("(invoking hook)\n\t");	    (void) fflush (stdout);	    if (usr_hook (lp, talk, fd, hp, mailbox) != NOTOK)		return;	    if (talk)		printf ("  %s: ", lp -> m_mbox);	    (void) fflush (stdout);	case NOTOK: 	    (void) lseek (fd, 0L, 0);	    if ((md = mbx_open (mailbox, hp -> h_uid, hp -> h_gid, m_gmprot ()))		    == NOTOK) {		if (!talk)		    fprintf (stderr, "  %s: ", lp -> m_mbox);		fprintf (talk ? stdout : stderr,			"error in transmission; unable to open maildrop\n");		unkadr++;		return;	    }	    (void) sprintf (ddate, "Delivery-Date: %s\n", dtimenow ());	    if (mbx_copy (mailbox, md, fd, 0, ddate, 0) == NOTOK) {		if (!talk)		    fprintf (stderr, "  %s: ", lp -> m_mbox);		fprintf (talk ? stdout : stderr,			"error in transmission; write to maildrop failed\n");		unkadr++;		(void) close (md);		return;	    }	    mbx_close (mailbox, md);	    if (talk)		printf ("sent\n");	    break;    }    (void) fflush (stdout);}/*  */static int  usr_hook (lp, talk, fd, hp, mailbox)register struct mailname *lp;int     talk,        fd;register struct home *hp;register char   *mailbox;{    int     i,            child_id,            status;    char    tmpfil[BUFSIZ];    if ((fd = copyfile (fd, tmpfil)) == NOTOK) {	if (!talk)	    fprintf (stderr, "  %s: ", lp -> m_mbox);	fprintf (talk ? stdout : stderr,		"unable to copy message; skipping hook\n");	return NOTOK;    }    (void) chown (tmpfil, hp -> h_uid, hp -> h_gid);    (void) fflush (stdout);    for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)	sleep (5);    switch (child_id) {	case NOTOK: 	    if (!talk)		fprintf (stderr, "  %s: ", lp -> m_mbox);	    fprintf (talk ? stdout : stderr,		    "unable to invoke hook; fork() failed\n");	    return NOTOK;	case OK: 	    if (fd != 0)		(void) dup2 (fd, 0);	    (void) freopen ("/dev/null", "w", stdout);	    (void) freopen ("/dev/null", "w", stderr);	    if (fd != 3)	/* backwards compatible... */		(void) dup2 (fd, 3);	    closefds (4);#ifdef	TIOCNOTTY	    if ((fd = open ("/dev/tty", 2)) != NOTOK) {		(void) ioctl (fd, TIOCNOTTY, NULLCP);		(void) close (fd);	    }#endif	TIOCNOTTY#ifdef	BSD42	    (void) setpgrp (0, getpid ());#endif	BSD42	    *environ = NULL;	    (void) putenv ("USER", hp -> h_name);	    (void) putenv ("HOME", hp -> h_home);	    (void) putenv ("SHELL", hp -> h_shell);	    if (chdir (hp -> h_home) == NOTOK)		(void) chdir ("/");	    (void) umask (0077);#ifdef	BSD41A	    (void) inigrp (hp -> h_name, hp -> h_gid);#endif	BSD41A	    (void) setgid (hp -> h_gid);#ifdef	BSD42	    (void) initgroups (hp -> h_name, hp -> h_gid);#endif	BSD42	    (void) setuid (hp -> h_uid);	    execlp (slocalproc, r1bindex (slocalproc, '/'),		    "-file", tmpfil, "-mailbox", mailbox,		    "-home", hp -> h_home, "-addr", lp -> m_aka,		    "-user", hp -> h_name, "-sender", from,		    talk ? "-verbose" : NULLCP, NULLCP);	    _exit (-1);/*  */	default: 	    (void) close (fd);	    status = pidwait (child_id, OK);	    (void) unlink (tmpfil);	    if (status == 0) {		if (talk)		    printf ("accepted\n");		return OK;	    }	    if (!talk)		fprintf (stderr, "  %s: ", lp -> m_mbox);	    fprintf (talk ? stdout : stderr,		    "%s error on hook; status=0%o\n",		    status & 0x00ff ? "system" : "user",		    status & 0x00ff ? status & 0xff		    : (status & 0xff00) >> 8);	    return NOTOK;    }}/*  */static int  copyfile (qd, tmpfil)int     qd;register char   *tmpfil;{    int     i,            fd;    char    buffer[BUFSIZ];    (void) strcpy (tmpfil, m_tmpfil ("hook"));    if ((fd = creat (tmpfil, 0600)) == NOTOK)	return NOTOK;    (void) close (fd);    if ((fd = open (tmpfil, 2)) == NOTOK)	return NOTOK;    (void) lseek (qd, 0L, 0);    while ((i = read (qd, buffer, sizeof buffer)) > 0)	if (write (fd, buffer, i) != i) {	    (void) close (fd);	    return NOTOK;	}    if (i == NOTOK) {	(void) close (fd);	return NOTOK;    }    (void) lseek (fd, 0L, 0);    return fd;}/*  */static  uucpmail (lp, talk, fd, from)register struct mailname *lp;int     talk,        fd,	from;{    int     i;    TYPESIG     (*pstat) ();    char    addr[BUFSIZ],            buffer[BUFSIZ];    register FILE *fp;    (void) sprintf (addr, "%s!%s", lp -> m_host, lp -> m_mbox);    if (talk)	printf ("  %s: ", addr);    (void) fflush (stdout);#ifndef	UCI    (void) sprintf (buffer, "uux -r -p %s!rmail \\(%s\\)",		lp -> m_host, lp -> m_mbox);#else	UCI    (void) sprintf (buffer, "uux -p %s!rmail \\(%s\\)", lp -> m_host,	    lp -> m_mbox);#endif	UCI    if ((fp = popen (buffer, "w")) == NULL) {	if (!talk)	    fprintf (stderr, "  %s: ", addr);	fprintf (talk ? stdout : stderr,		"unable to start uux; popen() failed\n");	unkadr++;	return;    }    pstat = signal (SIGPIPE, SIG_IGN);    if (from) {			/* no mail filtering, so... */	(void) sprintf (buffer, "From %s %.24s remote from %s\n",		getusr (), ctime (&clock), SystemName ());	i = strlen (buffer);	if (fwrite (buffer, sizeof *buffer, i, fp) != i)	    goto oops;    }    (void) lseek (fd, 0L, 0);    while ((i = read (fd, buffer, sizeof buffer)) > 0)	if (fwrite (buffer, sizeof *buffer, i, fp) != i) {    oops:   ;	    if (!talk)		fprintf (stderr, "  %s: ", addr);	    fprintf (talk ? stdout : stderr,		    "error in transmission; write to uux failed\n");	    unkadr++;	    (void) pclose (fp);	    return;	}    if (pclose (fp))	goto oops;    (void) signal (SIGPIPE, pstat);    if (i < 0) {	if (!talk)	    fprintf (stderr, "  %s: ", addr);	fprintf (talk ? stdout : stderr,		"error in transmission; read failed\n");	unkadr++;	return;    }    if (talk)	printf ("queued (via uux)\n");    (void) fflush (stdout);}/*  */#ifdef	MFstatic int  make_uucp_file (td)int     td;{    int     i,            qd,            fd;    char    tmpfil[BUFSIZ];    (void) lseek (td, 0L, 0);    if ((qd = dup (td)) == NOTOK)	adios ("fd", "unable to dup");    (void) strcpy (tmpfil, m_tmpfil ("uumf"));    if ((fd = creat (tmpfil, 0600)) == NOTOK)	adios (tmpfil, "unable to create");    (void) close (fd);    if ((fd = open (tmpfil, 2)) == NOTOK)	adios (tmpfil, "unable to re-open");    switch (i = mmdf2uucp (qd, fd, 1)) {	case OK: 	    if (!debug)		(void) unlink (tmpfil);	    break;	default: 	    adios (NULLCP, "unable to filter mail(%d), examine %s", i, tmpfil);    }    (void) close (qd);    return fd;}#endif	MF/*  */static  netmail (talk, fd, bccque)int     talk,        fd,        bccque;{    int     i,            naddrs;    char    buffer[BUFSIZ];    register struct mailname *lp;    naddrs = 0;    if (nm_init (getusr (), &clock) == NOTOK) {	for (lp = netaddrs.m_next; lp; lp = lp -> m_next)	    if (lp -> m_bcc ? bccque : !bccque)		fprintf (stderr, "  %s at %s: unable to get queue file\n",			lp -> m_mbox, lp -> m_host);	return;    }    for (lp = netaddrs.m_next; lp; lp = lp -> m_next)	if (lp -> m_bcc ? bccque : !bccque) {	    (void) nm_wadr (lp -> m_mbox, lp -> m_host);	    naddrs++;	    if (talk)		printf ("  %s at %s: queued\n", lp -> m_mbox, lp -> m_host);	    (void) fflush (stdout);	}    nm_waend ();    (void) lseek (fd, 0L, 0);    while ((i = read (fd, buffer, sizeof buffer)) > 0)	if (nm_wtxt (buffer, i) == NOTOK) {	    fprintf (stderr,		    "error in transmission; write to temporary failed");	    unkadr += naddrs;	    return;	}    if (i < 0) {	fprintf (stderr, "error in transmission; read failed\n");	unkadr += naddrs;	return;    }    if (nm_wtend () == NOTOK) {	fprintf (stderr, "error in transmission; unable to queue message\n");	unkadr += naddrs;	return;    }}#endif	MHMTS#ifdef X400static int get_mts_val (cp)char *cp;{    int numents,	loop = 0;    char *p;    p = cp;    while (*p != '\0' && *p != '\n') 	p++;    if (*p == '\n')	*p = '\0';    cp = trimcpy (cp);    numents = sizeof (mts_vals) / sizeof (mts_vals[0]);    for (loop = 0; loop < numents; loop++)	if (uleq (mts_vals[loop], cp))	    break;    if (loop == X4MTS)	loop = X400MTS;    return ((loop == numents) ? NONEMTS : loop);}#endif X400

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -