diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2016-11-21 13:00:44 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2016-11-21 13:00:44 +0000 |
commit | d330bd7bd0c711fc07489e718a441b514c66232d (patch) | |
tree | 622bf179c86b2d1418ddb0c99681fde3b6b79aed /usr.sbin/smtpd/bounce.c | |
parent | f93b9d7a816f35f591f05fa7b3575772f0d5f34f (diff) |
replace calls to iobuf_*() functions with the corresponding io_*() wrappers.
ok sunil@ gilles@
Diffstat (limited to 'usr.sbin/smtpd/bounce.c')
-rw-r--r-- | usr.sbin/smtpd/bounce.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index 05144e03b37..92fe56283be 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.74 2016/11/20 08:43:36 eric Exp $ */ +/* $OpenBSD: bounce.c,v 1.75 2016/11/21 13:00:43 eric Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@poolp.org> @@ -313,7 +313,7 @@ bounce_send(struct bounce_session *s, const char *fmt, ...) log_trace(TRACE_BOUNCE, "bounce: %p: >>> %s", s, p); - iobuf_xfqueue(&s->iobuf, "bounce_send", "%s\n", p); + io_xprintf(&s->io, "%s\n", p); free(p); } @@ -452,7 +452,7 @@ bounce_next(struct bounce_session *s) case BOUNCE_DATA_NOTICE: /* Construct an appropriate notice. */ - iobuf_xfqueue(&s->iobuf, "bounce_next: HEADER", + io_xprintf(&s->io, "Subject: Delivery status notification: %s\n" "From: Mailer Daemon <MAILER-DAEMON@%s>\n" "To: %s\n" @@ -470,7 +470,7 @@ bounce_next(struct bounce_session *s) s->boundary, s->smtpname); - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "--%16" PRIu64 "/%s\n" "Content-Description: Notification\n" "Content-Type: text/plain; charset=us-ascii\n" @@ -481,17 +481,14 @@ bounce_next(struct bounce_session *s) switch (s->msg->bounce.type) { case B_ERROR: - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", - notice_error); + io_xprint(&s->io, notice_error); break; case B_WARNING: - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", - notice_warning, + io_xprintf(&s->io, notice_warning, bounce_duration(s->msg->bounce.delay)); break; case B_DSN: - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", - s->msg->bounce.mta_without_dsn ? + io_xprint(&s->io, s->msg->bounce.mta_without_dsn ? notice_relay : notice_success); break; default: @@ -499,35 +496,32 @@ bounce_next(struct bounce_session *s) } TAILQ_FOREACH(evp, &s->msg->envelopes, entry) { - iobuf_xfqueue(&s->iobuf, - "bounce_next: DATA_NOTICE", - "%s", evp->report); + io_xprint(&s->io, evp->report); } - iobuf_xfqueue(&s->iobuf, "bounce_next: DATA_NOTICE", "\n"); + io_xprint(&s->io, "\n"); if (s->msg->bounce.type == B_WARNING) - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", - notice_warning2, + io_xprintf(&s->io, notice_warning2, bounce_duration(s->msg->bounce.expire)); - iobuf_xfqueue(&s->iobuf, "bounce_next: DATA_NOTICE", + io_xprintf(&s->io, " Below is a copy of the original message:\n" "\n"); - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "--%16" PRIu64 "/%s\n" "Content-Description: Delivery Report\n" "Content-Type: message/delivery-status\n" "\n", s->boundary, s->smtpname); - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "Reporting-MTA: dns; %s\n" "\n", s->smtpname); TAILQ_FOREACH(evp, &s->msg->envelopes, entry) { - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "Final-Recipient: rfc822; %s@%s\n" "Action: %s\n" "Status: %s\n" @@ -539,21 +533,21 @@ bounce_next(struct bounce_session *s) } log_trace(TRACE_BOUNCE, "bounce: %p: >>> [... %zu bytes ...]", - s, iobuf_queued(&s->iobuf)); + s, io_queued(&s->io)); s->state = BOUNCE_DATA_MESSAGE; break; case BOUNCE_DATA_MESSAGE: - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "--%16" PRIu64 "/%s\n" "Content-Description: Message headers\n" "Content-Type: text/rfc822-headers\n" "\n", s->boundary, s->smtpname); - n = iobuf_queued(&s->iobuf); - while (iobuf_queued(&s->iobuf) < BOUNCE_HIWAT) { + n = io_queued(&s->io); + while (io_queued(&s->io) < BOUNCE_HIWAT) { if ((len = getline(&line, &sz, s->msgfp)) == -1) break; if (len == 1 && line[0] == '\n' && /* end of headers */ @@ -562,7 +556,7 @@ bounce_next(struct bounce_session *s) free(line); fclose(s->msgfp); s->msgfp = NULL; - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "\n--%16" PRIu64 "/%s--\n", s->boundary, s->smtpname); bounce_send(s, "."); @@ -570,8 +564,7 @@ bounce_next(struct bounce_session *s) return (0); } line[len - 1] = '\0'; - iobuf_xfqueue(&s->iobuf, - "bounce_next: DATA_MESSAGE", "%s%s\n", + io_xprintf(&s->io, "%s%s\n", (len == 2 && line[0] == '.') ? "." : "", line); } free(line); @@ -585,11 +578,11 @@ bounce_next(struct bounce_session *s) return (-1); } - iobuf_xfqueue(&s->iobuf, "bounce_next: BODY", + io_xprintf(&s->io, "\n--%16" PRIu64 "/%s--\n", s->boundary, s->smtpname); log_trace(TRACE_BOUNCE, "bounce: %p: >>> [... %zu bytes ...]", - s, iobuf_queued(&s->iobuf) - n); + s, io_queued(&s->io) - n); if (feof(s->msgfp)) { fclose(s->msgfp); @@ -728,8 +721,8 @@ bounce_io(struct io *io, int evt, void *arg) switch (evt) { case IO_DATAIN: nextline: - line = iobuf_getline(&s->iobuf, &len); - if (line == NULL && iobuf_len(&s->iobuf) >= LINE_MAX) { + line = io_getline(&s->io, &len); + if (line == NULL && io_datalen(&s->io) >= LINE_MAX) { bounce_status(s, "Input too long"); bounce_free(s); return; @@ -776,7 +769,7 @@ bounce_io(struct io *io, int evt, void *arg) bounce_free(s); return; } - if (iobuf_queued(&s->iobuf) == 0) + if (io_queued(&s->io) == 0) io_set_read(io); break; |