📄 bb_wtmail.c
字号:
#ifdef DEBUG ll_log (logptr, LLOGBTR, "dist_adrs()");#endif if (getbbdist (curbb, ds_address)) return ds_log (RP_NO, LLOGTMP, "getbbdist failed: %s", getbberr ()); if (rp_isbad (result = mm_waend ())) return ds_log (result, LLOGFAT, "mm_waend() failed [%s]", rp_valstr (result)); return result;}/* */ds_address (addr, host)char *addr, /* local part */ *host; /* rest */{ short result; int len; struct rp_bufstruct reply;#ifdef DEBUG ll_log (logptr, LLOGBTR, "ds_address(addr='%s',host='%s')", addr, host);#endif printx ("\rperforming distribution to %s@%s...\n", addr, host); if (rp_isbad (result = mm_wadr (host, addr))) { ds_log (result, LLOGFAT, "mm_wadr('%s','%s') failed [%s]", host, addr, rp_valstr (result)); return NOTOK; } if (rp_isbad (result = mm_rrply (&reply, &len))) { ds_log (result, LLOGFAT, "mm_rrply() failed [%s] getting status of '%s@%s'", rp_valstr (result), addr, host); return NOTOK; } switch (rp_gval (reply.rp_val)) { case RP_AOK:#ifdef RP_DOK case RP_DOK:#endif RP_DOK#ifdef DEBUG ll_log (logptr, LLOGGEN, "address '%s@%s' [%s] -- %s", addr, host, rp_valstr (reply.rp_val), reply.rp_line);#endif return OK; case RP_NO:#ifdef RP_NS case RP_NS:#endif RP_NS case RP_USER: case RP_NDEL: case RP_AGN: case RP_NOOP: ds_log (reply.rp_val, LLOGTMP, "address '%s@%s' [%s] -- %s", addr, host, rp_valstr (reply.rp_val), reply.rp_line); return OK; /* fail-soft */ default: ds_log (reply.rp_val, LLOGFAT, "unexpected reply [%s] -- %s", rp_valstr (reply.rp_val), reply.rp_line); return NOTOK; }}/* */dist_text (){ short result; int len; char buffer[BUFSIZ];#ifdef DEBUG ll_log (logptr, LLOGBTR, "dist_text()");#endif qu_rtinit (0L); for (len = BUFSIZ; rp_gval (result = qu_rtxt (buffer, &len)) == RP_OK; len = BUFSIZ) if (rp_isbad (result = mm_wtxt (buffer, len))) return ds_log (result, LLOGFAT, "mm_wtxt() failed [%s]", rp_valstr (result)); if (result < 0) return ds_log (RP_FIO, LLOGTMP, "error reading from message file '%s'", qu_msgfile); if (rp_isbad (result = mm_wtend ())) return ds_log (result, LLOGFAT, "mm_wtend() failed [%s]", rp_valstr (result)); return result;}/* */dist_end (){ short result; int len; struct rp_bufstruct reply;#ifdef DEBUG ll_log (logptr, LLOGBTR, "dist_end()");#endif if (rp_isbad (result = mm_rrply (&reply, &len))) return ds_log (result, LLOGFAT, "mm_rrply() failed [%s] getting final status", rp_valstr (result)); switch (rp_gval (reply.rp_val)) { case RP_OK: case RP_MOK:#ifdef DEBUG ll_log (logptr, LLOGGEN, "message [%s] -- %s", rp_valstr (reply.rp_val), reply.rp_line);#endif mm_sbend (); mm_end (OK); return result; case RP_NO: case RP_NDEL: case RP_AGN: case RP_NOOP: return ds_log (RP_NO, LLOGTMP, "not delivered [%s] -- %s", rp_valstr (reply.rp_val), reply.rp_line); default: return ds_log (RP_RPLY, LLOGFAT, "unexpected final reply [%s] -- %s", rp_valstr (reply.rp_val), reply.rp_line); }}/* */dist_lose (result)short result;{ int i; char *cp, intro[BUFSIZ], buffer[BUFSIZ];#ifdef DEBUG ll_log (logptr, LLOGBTR, "dist_lose(result=0%o)", result);#endif DEBUG mm_end (NOTOK); printx ("\rerrors during distribution: "); if (domsg) (void) fflush (stdout); (void) sprintf (intro, "bboards%d distribution for %s failed [%s]\n", getpid (), curbb -> bb_name, rp_valstr (result)); if (loseaux (bbrdaddr, bbrdfrom, intro) != OK && loseaux (bbrdfrom, (char *) 0, intro) != OK) { printx ("unable to post advisory.\n"); ll_log (logptr, LLOGFAT, "unable to post failure notice"); if (err_fd != NOTOK) { (void) lseek (err_fd, (off_t)0, 0); if ((i = read (err_fd, buffer, sizeof buffer)) > 0) { buffer[i] = NULL; if (cp = index (buffer, '\n')) *cp = NULL; ll_log (logptr, LLOGFAT, "info: %s", buffer); } } if (loseaux (supportaddr, (char *) 0, intro) != NOTOK) ll_log (logptr, LLOGFAT, "unable to advise %s of failure!", supportaddr); } else printx ("advisory posted.\n"); if (domsg) (void) fflush (stdout); if (err_fd != NOTOK) { close (err_fd); err_fd = NOTOK; } return RP_MOK;}/* */int loseaux (to, cc, intro)char *to, *cc, *intro;{ int i; char buffer[BUFSIZ]; if (ml_init (NO, NO, sitesignature, "Re-distribution Failure") != OK || ml_adr (to) != OK) return NOTOK; if (cc && (ml_cc () != OK || ml_adr (cc) != OK)) return NOTOK; if (ml_aend () != OK || ml_tinit () != OK) return NOTOK; ml_txt (intro); if (err_fd != NOTOK) { lseek (err_fd, (off_t)0, 0); while ((i = read (err_fd, buffer, sizeof buffer)) > 0) { buffer[i] = NULL; ml_txt (buffer); } } encap (); return ml_end (OK);}/* *//* very similar to sbr/cpydgst.c */#define S1 0#define S2 1#define output(c) if (bp >= dp) {flush (); *bp++ = c;} else *bp++ = c#define flush() if (bp - outbuf) \ *bp = NULL, ml_txt (outbuf), bp = outbufstatic encap () { register int state; short result; int len, init; register char *cp, *ep; char buffer[BUFSIZ]; register char *bp, *dp; char outbuf[BUFSIZ]; qu_rtinit (0L); dp = (bp = outbuf) + sizeof outbuf; init = 0; for (state = S1, len = BUFSIZ; rp_gval (result = qu_rtxt (buffer, &len)) == RP_OK; len = BUFSIZ) for (ep = (cp = buffer) + len; cp < ep; cp++) { if (*cp == NULL) continue; switch (state) { case S1: if (*cp == '-') { if (init == 0) { ml_txt ("\n------- Forwarded Message\n\n"); init++; } output ('-'); output (' '); } state = S2; /* fall */ case S2: if (init == 0) { ml_txt ("\n------- Forwarded Message\n\n"); init++; } output (*cp); if (*cp == '\n') state = S1; break; } } flush (); if (result < 0) { ll_log (logptr, LLOGTMP, "error reading message when noting failure"); if (init) ml_txt ("\n------- End of Forwarded Message\n\n"); ml_txt ("[ error reading message ]\n"); } else if (init) ml_txt ("\n------- End of Forwarded Message\n\n"); else { ll_log (logptr, LLOGTMP, "message empty when noting failure"); ml_txt ("[ message empty ]\n"); }}/* *//* VARARGS3 */ds_log (result, level, fmt, a, b, c, d, e)short result;int level;char *fmt, *a, *b, *c, *d, *e;{ int i; char buffer[BUFSIZ], tmpfil[BUFSIZ]; ll_log (logptr, level, fmt, a, b, c, d, e); sprintf (buffer, fmt, a, b, c, d, e); strcat (buffer, "\n"); printx ("\rerror: %s", buffer); if (err_fd == NOTOK) { unlink (mktemp (strcpy (tmpfil, "/tmp/bboardsXXXXXX"))); if ((err_fd = creat (tmpfil, 0600)) == NOTOK) return result; close (err_fd); if ((err_fd = open (tmpfil, 2)) == NOTOK) return result; unlink (tmpfil); lseek (err_fd, (off_t)0, 0); } i = strlen (buffer); write (err_fd, buffer, i); return result;}#endif not POP/* *//* mbx_ local mailbox routines */#ifndef POPmbx_init () { int fd, clear; char name[BUFSIZ]; FILE * fp; if ((fd = mbx_Xopen (curbb -> bb_info, bbrduid, bbrdgid, MBXMODE, &clear)) == NOTOK) { if (errno == ETXTBSY) { printx ("\runable to lock %s\n", curbb -> bb_info); ll_err (logptr, LLOGTMP, "unable to lock %s", curbb -> bb_info); return RP_LOCK; } printx ("\runable to open '%s'", curbb -> bb_info); ll_log (logptr, LLOGTMP, "unable to open '%s'", curbb -> bb_info); return RP_FOPN; } if ((fp = fdopen (fd, "w")) == (FILE *) NULL) { printx ("\runable to fdopen '%s'", curbb -> bb_info); ll_err (logptr, LLOGTMP, "unable to fdopen '%s'", curbb -> bb_info); mbx_close (curbb -> bb_info, fd); return RP_LIO; } strcpy (name, curbb -> bb_name); if ((curbb = getbbnam (name)) == (struct bboard *) NULL) { printx ("\runable to get information on BBoard %s\n", name); ll_err (logptr, LLOGFAT, "unable to get info on %s", name); lkfclose (fp, curbb -> bb_info); return RP_LIO; } sprintf (bbrdheader, "BBoard-ID: %d\nBB-Posted: %s\n", ++curbb -> bb_maxima, cnvtdate (TIMREG, bbrdtime)); fprintf (fp, "%d\n%s\n", curbb -> bb_maxima, bbrdtime); lkfclose (fp, curbb -> bb_info); return RP_OK;}#endif not POP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -