1 /* uu_wtmail.c - write mail to UUCP */
15 extern struct ll_struct *logptr;
31 ll_log (logptr, LLOGBTR, "uu_init (chanptr=%s)", chanptr -> ch_spec);
44 ll_log (logptr, LLOGBTR, "uu_end (result=0%o)", result);
54 ll_log (logptr, LLOGBTR, "uu_sbinit ()");
62 ll_log (logptr, LLOGBTR, "uu_sbend ()");
70 uu_wtadr (host, adr, sender)
81 ll_log (logptr, LLOGBTR, "uu_wtadr(host='%s',adr='%s')", host, adr);
84 if (host == NULL || host[0] == NULL)
87 if (!ch_h2adr (curchan, TRUE, host, nextnode))
88 return RP_USER; /* No such host */
89 sprintf (who, nextnode, adr);
92 if ((p = index (who, '!')) != NULL) {
94 strcpy (nextnode, who);
99 strcpy (nextnode, "");
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);
120 ll_log (logptr, LLOGBTR, " uu_txtcpy()");
125 pstat = signal (SIGPIPE, pipeser);
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);
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);
142 signal (SIGPIPE, pstat);
144 return (rp_gval (result) == RP_DONE ? RP_MOK : result);
153 pstat = signal (SIGPIPE, pipeser);
154 result = pclose (uucpf) ? (broken_pipe ? RP_USER : RP_LIO) : RP_MOK;
155 signal (SIGPIPE, pstat);
165 while (*s = uptolow (*s))
174 signal (SIGPIPE, SIG_IGN);