From: chris mikkelson Date: Fri, 3 Apr 2009 01:19:27 +0000 (-0500) Subject: Merge branch 'master' into modules X-Git-Url: https://git.mikk.net/?a=commitdiff_plain;h=a2fd6a8afc26936b680a92d43b5c5bc226d4a586;p=smtpsink Merge branch 'master' into modules Conflicts: smtp.c --- a2fd6a8afc26936b680a92d43b5c5bc226d4a586 diff --cc module_api.c index 7a2ec32,0000000..e4829d2 mode 100644,000000..100644 --- a/module_api.c +++ b/module_api.c @@@ -1,54 -1,0 +1,58 @@@ +#include +#include +#include +#include +#include ++#include +#include +#include + +#include +#include +#include +#include "smtpsink.h" + +int +respond(struct conn *c, const char *fmt, ...) +{ + va_list ap; + char buf[2048]; + int ret, nw; + + va_start(ap, fmt); + ret = vsnprintf(buf, sizeof(buf), fmt, ap); + if (ret < 0) assert(0); + nw = write(c->fd, buf, ret); + if (nw < 0) { - c->state = SMTP_CLOSED; - return 0; ++ if (errno != EAGAIN) { ++ c->state = SMTP_CLOSED; ++ return 0; ++ } ++ nw = 0; + } + if (nw < ret) { + if (!(c->wdata.s = malloc(ret - nw))) { + c->state = SMTP_CLOSED; + return 0; + } + memcpy(c->wdata.s, buf + nw, ret - nw); + c->wdata.off = 0; + c->wdata.len = ret - nw; + return 0; + } + return 1; +} + +void * +ssm_getpriv(struct smtpsink_module *m, struct conn *c) +{ + assert(c->priv_data); + return c->priv_data[m->ssm_module_index]; +} + +void +ssm_setpriv(struct smtpsink_module *m, struct conn *c, void *data) +{ + assert(c->priv_data); + c->priv_data[m->ssm_module_index] = data; +}