Annotation of 43BSD/contrib/mh/zotnet/mf/mmdfI/src/uucp/uu_wtmail.c, revision 1.1

1.1     ! root        1: /* uu_wtmail.c - write mail to UUCP */
        !             2: 
        !             3: #include "util.h"
        !             4: #include "mmdf.h"
        !             5: #include "ch.h"
        !             6: #include <signal.h>
        !             7: 
        !             8: /*  */
        !             9: 
        !            10: extern int  errno;
        !            11: 
        !            12: int     broken_pipe;
        !            13: void   pipeser ();
        !            14: 
        !            15: extern struct ll_struct *logptr;
        !            16: 
        !            17: FILE * uucpf;
        !            18: 
        !            19: Chan * curchan;
        !            20: 
        !            21: 
        !            22: char   *index ();
        !            23: FILE * popen ();
        !            24: 
        !            25: /*  */
        !            26: 
        !            27: uu_init (chanptr)
        !            28: Chan * chanptr;
        !            29: {
        !            30: #ifdef DEBUG
        !            31:     ll_log (logptr, LLOGBTR, "uu_init (chanptr=%s)", chanptr -> ch_spec);
        !            32: #endif
        !            33: 
        !            34:     curchan = chanptr;
        !            35: 
        !            36:     return RP_OK;
        !            37: }
        !            38: 
        !            39: 
        !            40: uu_end (result)
        !            41: short   result;
        !            42: {
        !            43: #ifdef DEBUG
        !            44:     ll_log (logptr, LLOGBTR, "uu_end (result=0%o)", result);
        !            45: #endif
        !            46: 
        !            47:     return RP_OK;
        !            48: }
        !            49: 
        !            50: /*  */
        !            51: 
        !            52: uu_sbinit () {
        !            53: #ifdef DEBUG
        !            54:     ll_log (logptr, LLOGBTR, "uu_sbinit ()");
        !            55: #endif
        !            56: 
        !            57:     return RP_OK;
        !            58: }
        !            59: 
        !            60: uu_sbend () {
        !            61: #ifdef DEBUG
        !            62:     ll_log (logptr, LLOGBTR, "uu_sbend ()");
        !            63: #endif
        !            64: 
        !            65:     return RP_OK;
        !            66: }
        !            67: 
        !            68: /*  */
        !            69: 
        !            70: uu_wtadr (host, adr, sender)
        !            71: char   *host,
        !            72:        *adr,
        !            73:        *sender;
        !            74: {
        !            75:     char   *p,
        !            76:             linebuf[LINESIZE],
        !            77:             nextnode[LINESIZE],
        !            78:             who[LINESIZE];
        !            79: 
        !            80: #ifdef DEBUG
        !            81:     ll_log (logptr, LLOGBTR, "uu_wtadr(host='%s',adr='%s')", host, adr);
        !            82: #endif
        !            83: 
        !            84:     if (host == NULL || host[0] == NULL)
        !            85:        strcpy (who, adr);
        !            86:     else {
        !            87:        if (!ch_h2adr (curchan, TRUE, host, nextnode))
        !            88:            return RP_USER;     /* No such host */
        !            89:        sprintf (who, nextnode, adr);
        !            90:     }
        !            91: 
        !            92:     if ((p = index (who, '!')) != NULL) {
        !            93:        *p++ = NULL;
        !            94:        strcpy (nextnode, who);
        !            95:        strcpy (who, p);
        !            96:        lowerfy (nextnode);
        !            97:     }
        !            98:     else
        !            99:        strcpy (nextnode, "");
        !           100: 
        !           101:     printx ("Queuing UUCP mail for %s via %s...\n", who, nextnode);
        !           102:     sprintf (linebuf, "uux -p %s!rmail \\(%s\\)", nextnode, who);
        !           103:     if ((uucpf = popen (linebuf, "w")) == NULL) {
        !           104:        ll_log (logptr, LLOGFAT, "unable to popen() UUX (errno %d)", errno);
        !           105:        return RP_AGN;
        !           106:     }
        !           107: 
        !           108:     return RP_OK;
        !           109: }
        !           110: 
        !           111: /*  */
        !           112: 
        !           113: uu_txtcpy () {
        !           114:     short   result;
        !           115:     int     len;
        !           116:     int     (*pstat) ();
        !           117:     char    buffer[BUFSIZ];
        !           118: 
        !           119: #ifdef DEBUG
        !           120:     ll_log (logptr, LLOGBTR, " uu_txtcpy()");
        !           121: #endif
        !           122: 
        !           123:     mf_rtinit (0L);
        !           124:     broken_pipe = 0;
        !           125:     pstat = signal (SIGPIPE, pipeser);
        !           126: 
        !           127:     while (rp_gval (result = mf_rtxt (buffer, &len)) == RP_OK && !broken_pipe)
        !           128:        if (fwrite (buffer, sizeof *buffer, len, uucpf) != len) {
        !           129:            ll_log (logptr, LLOGFAT, "write on pipe lost (errno %d)", errno);
        !           130:            ll_log (logptr, LLOGFAT, "pclose() returns %d", pclose (uucpf));
        !           131:            signal (SIGPIPE, pstat);
        !           132:            return (broken_pipe ? RP_USER : RP_LIO);
        !           133:        }
        !           134: 
        !           135:     fflush (uucpf);
        !           136:     if (broken_pipe) {
        !           137:        ll_log (logptr, LLOGFAT, "pipe to UUX broke -- probably bad host");
        !           138:        ll_log (logptr, LLOGFAT, "pclose() returns %d", pclose (uucpf));
        !           139:        signal (SIGPIPE, pstat);
        !           140:        return RP_USER;
        !           141:     }
        !           142:     signal (SIGPIPE, pstat);
        !           143: 
        !           144:     return (rp_gval (result) == RP_DONE ? RP_MOK : result);
        !           145: }
        !           146: 
        !           147: /*  */
        !           148: 
        !           149: uu_wttend () {
        !           150:     short   result;
        !           151:     int     (*pstat) ();
        !           152: 
        !           153:     pstat = signal (SIGPIPE, pipeser);
        !           154:     result = pclose (uucpf) ? (broken_pipe ? RP_USER : RP_LIO) : RP_MOK;
        !           155:     signal (SIGPIPE, pstat);
        !           156: 
        !           157:     return result;
        !           158: }
        !           159: 
        !           160: /*  */
        !           161: 
        !           162: lowerfy (s)
        !           163: char   *s;
        !           164: {
        !           165:     while (*s = uptolow (*s))
        !           166:        s++;
        !           167: }
        !           168: 
        !           169: 
        !           170: void pipeser (i)
        !           171: int     i;
        !           172: {
        !           173:     broken_pipe++;
        !           174:     signal (SIGPIPE, SIG_IGN);
        !           175: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.