diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-03-09 10:22:18 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-03-09 10:22:18 +0000 |
commit | 4a3b530ab2fb03e3a2d5db84a06d60ece2eafce9 (patch) | |
tree | 0da3a2d54782accebfffbfb63a8f6f2c504aff64 /gacopyz | |
parent | f340b89d4722df3bce8a5bef92ab3b5f76241868 (diff) | |
download | mailfromd-4a3b530ab2fb03e3a2d5db84a06d60ece2eafce9.tar.gz mailfromd-4a3b530ab2fb03e3a2d5db84a06d60ece2eafce9.tar.bz2 |
* src/engine.c, src/gram.y, src/mailfromd.h: Implement prog data
* src/mtasim.c: Implement headers
* gacopyz/gacopyz_priv.h, gacopyz/gacopyz.c: Fix processing of
data and eoh
* gacopyz/server.c: Implement most of the stuff
git-svn-id: file:///svnroot/mailfromd/trunk@1283 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'gacopyz')
-rw-r--r-- | gacopyz/gacopyz.c | 8 | ||||
-rw-r--r-- | gacopyz/gacopyz_priv.h | 3 | ||||
-rw-r--r-- | gacopyz/server.c | 107 |
3 files changed, 99 insertions, 19 deletions
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c index d88a2496..3d9ac8e8 100644 --- a/gacopyz/gacopyz.c +++ b/gacopyz/gacopyz.c @@ -796,9 +796,17 @@ shan_macro(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd) ind = maci_rcpt; break; + case SMFIC_DATA: + ind = maci_data; + break; + case SMFIC_BODYEOB: ind = maci_eom; break; + + case SMFIC_EOH: + ind = maci_eoh; + break; default: return sret_fail; diff --git a/gacopyz/gacopyz_priv.h b/gacopyz/gacopyz_priv.h index 54bc4fcf..046bf76d 100644 --- a/gacopyz/gacopyz_priv.h +++ b/gacopyz/gacopyz_priv.h @@ -27,7 +27,10 @@ enum macro_index { maci_helo, maci_mail, maci_rcpt, + maci_data, maci_eom, + maci_eoh, + maci_max, maci_none = maci_max }; diff --git a/gacopyz/server.c b/gacopyz/server.c index 0b6c2aaa..c010127a 100644 --- a/gacopyz/server.c +++ b/gacopyz/server.c @@ -844,8 +844,16 @@ gacopyz_srv_abort(gacopyz_srv_t srv) int gacopyz_srv_helo(gacopyz_srv_t srv, const char *domain) { - return gacopyz_srv_send_command(srv, SMFIC_HELO, - domain, strlen(domain) + 1); + int rc; + + if (!srv) + return MI_FAILURE; + if (srv->proto & SMFIP_NOHELO) + rc = SMFIR_CONTINUE; + else + rc = gacopyz_srv_send_command(srv, SMFIC_HELO, + domain, strlen(domain) + 1); + return rc; } static int @@ -880,14 +888,20 @@ int gacopyz_srv_envfrom(gacopyz_srv_t srv, char **argv) { int rc; - size_t size; - char *buf; + if (!srv) return MI_FAILURE; - if (format_argv(srv, argv, &buf, &size)) - return MI_FAILURE; - rc = gacopyz_srv_send_command(srv, SMFIC_MAIL, buf, size); - free (buf); + if (srv->proto & SMFIP_NOMAIL) + rc = SMFIR_CONTINUE; + else { + size_t size; + char *buf; + + if (format_argv(srv, argv, &buf, &size)) + return MI_FAILURE; + rc = gacopyz_srv_send_command(srv, SMFIC_MAIL, buf, size); + free (buf); + } return rc; } @@ -895,39 +909,86 @@ int gacopyz_srv_envrcpt(gacopyz_srv_t srv, char **argv) { int rc; - size_t size; - char *buf; + if (!srv) return MI_FAILURE; - if (format_argv(srv, argv, &buf, &size)) - return MI_FAILURE; - rc = gacopyz_srv_send_command(srv, SMFIC_RCPT, buf, size); - free (buf); + if (srv->proto & SMFIP_NORCPT) + rc = SMFIR_CONTINUE; + else { + size_t size; + char *buf; + + if (format_argv(srv, argv, &buf, &size)) + return MI_FAILURE; + rc = gacopyz_srv_send_command(srv, SMFIC_RCPT, buf, size); + free (buf); + } return rc; } int gacopyz_srv_header(gacopyz_srv_t srv, char *name, char *value) { - return not_implemented(srv); + int rc; + + if (!srv || !name || !value) + return MI_FAILURE; + if (srv->proto & SMFIP_NOHDRS) + rc = SMFIR_CONTINUE; + else { + size_t nlen, vlen, size; + char *buf; + + nlen = strlen (name); + vlen = strlen (value); + size = nlen + vlen + 2; + buf = malloc (size); + if (!buf) { + gacopyz_io_log(&srv->iod, + SMI_LOG_FATAL, + "Not enough memory"); + return MI_FAILURE; + } + memcpy (buf, name, nlen + 1); + memcpy (buf + nlen + 1, value, vlen + 1); + rc = gacopyz_srv_send_command(srv, SMFIC_HEADER, buf, size); + free (buf); + } + return rc; } int gacopyz_srv_eoh(gacopyz_srv_t srv) { - return not_implemented(srv); + int rc; + if (!srv) + return MI_FAILURE; + if (srv->proto & SMFIP_NOEOH) + rc = SMFIR_CONTINUE; + else + rc = gacopyz_srv_send_command(srv, SMFIC_EOH, NULL, 0); + return rc; } int gacopyz_srv_body(gacopyz_srv_t srv, unsigned char *str, size_t size) { - return not_implemented(srv); + int rc; + if (!srv) + return MI_FAILURE; + if (srv->proto & SMFIP_NOBODY) + rc = SMFIR_CONTINUE; + else + rc = gacopyz_srv_send_command(srv, SMFIC_BODY, str, size); + return rc; } int gacopyz_srv_eom(gacopyz_srv_t srv) { - return not_implemented(srv); + if (!srv) + return MI_FAILURE; + return gacopyz_srv_send_command(srv, SMFIC_BODYEOB, NULL, 0); } int @@ -941,6 +1002,14 @@ gacopyz_srv_close(gacopyz_srv_t srv) int gacopyz_srv_data(gacopyz_srv_t srv) { - return not_implemented(srv); + int rc; + + if (!srv) + return MI_FAILURE; + if (srv->proto & SMFIP_NODATA) + rc = SMFIR_CONTINUE; + else + rc = gacopyz_srv_send_command(srv, SMFIC_DATA, NULL, 0); + return rc; } |