masqmail-0.2
diff src/smtp_in.c @ 10:26e34ae9a3e3
changed indention and line wrapping to a more consistent style
author | meillo@marmaro.de |
---|---|
date | Mon, 27 Oct 2008 16:23:10 +0100 |
parents | 08114f7dcc23 |
children | f671821d8222 |
line diff
1.1 --- a/src/smtp_in.c Mon Oct 27 16:21:27 2008 +0100 1.2 +++ b/src/smtp_in.c Mon Oct 27 16:23:10 2008 +0100 1.3 @@ -30,329 +30,329 @@ 1.4 1.5 #ifdef ENABLE_SMTP_SERVER 1.6 1.7 -smtp_cmd smtp_cmds[] = 1.8 -{ 1.9 - { SMTP_HELO, "HELO", }, 1.10 - { SMTP_EHLO, "EHLO", }, 1.11 - { SMTP_MAIL_FROM, "MAIL FROM:", }, 1.12 - { SMTP_RCPT_TO, "RCPT TO:", }, 1.13 - { SMTP_DATA, "DATA", }, 1.14 - { SMTP_QUIT, "QUIT", }, 1.15 - { SMTP_RSET, "RSET", }, 1.16 - { SMTP_NOOP, "NOOP", }, 1.17 - { SMTP_HELP, "HELP" }, 1.18 +smtp_cmd smtp_cmds[] = { 1.19 + {SMTP_HELO, "HELO",} 1.20 + , 1.21 + {SMTP_EHLO, "EHLO",} 1.22 + , 1.23 + {SMTP_MAIL_FROM, "MAIL FROM:",} 1.24 + , 1.25 + {SMTP_RCPT_TO, "RCPT TO:",} 1.26 + , 1.27 + {SMTP_DATA, "DATA",} 1.28 + , 1.29 + {SMTP_QUIT, "QUIT",} 1.30 + , 1.31 + {SMTP_RSET, "RSET",} 1.32 + , 1.33 + {SMTP_NOOP, "NOOP",} 1.34 + , 1.35 + {SMTP_HELP, "HELP"} 1.36 + , 1.37 }; 1.38 1.39 -static 1.40 -smtp_cmd_id get_id(const gchar *line) 1.41 +static smtp_cmd_id 1.42 +get_id(const gchar * line) 1.43 { 1.44 - gint i; 1.45 - for(i = 0; i < SMTP_NUM_IDS; i++){ 1.46 - if(strncasecmp(smtp_cmds[i].cmd, line, strlen(smtp_cmds[i].cmd)) == 0) 1.47 - return (smtp_cmd_id)i; 1.48 - } 1.49 - return SMTP_ERROR; 1.50 + gint i; 1.51 + for (i = 0; i < SMTP_NUM_IDS; i++) { 1.52 + if (strncasecmp(smtp_cmds[i].cmd, line, strlen(smtp_cmds[i].cmd)) == 0) 1.53 + return (smtp_cmd_id) i; 1.54 + } 1.55 + return SMTP_ERROR; 1.56 } 1.57 1.58 /* this is a quick hack: we expect the address to be syntactically correct 1.59 and containing the mailbox only: 1.60 */ 1.61 1.62 -static 1.63 -gboolean get_address(gchar *line, gchar *addr) 1.64 +static gboolean 1.65 +get_address(gchar * line, gchar * addr) 1.66 { 1.67 - gchar *p = line, *q = addr; 1.68 + gchar *p = line, *q = addr; 1.69 1.70 - /* skip MAIL FROM: and RCPT TO: */ 1.71 - while(*p && (*p != ':')) p++; 1.72 - p++; 1.73 + /* skip MAIL FROM: and RCPT TO: */ 1.74 + while (*p && (*p != ':')) 1.75 + p++; 1.76 + p++; 1.77 1.78 - /* skip spaces: */ 1.79 - while(*p && isspace(*p)) p++; 1.80 + /* skip spaces: */ 1.81 + while (*p && isspace(*p)) 1.82 + p++; 1.83 1.84 - /* get address: */ 1.85 - while(*p && !isspace(*p) && (q < addr+MAX_ADDRESS-1)) *(q++) = *(p++); 1.86 - *q = 0; 1.87 + /* get address: */ 1.88 + while (*p && !isspace(*p) && (q < addr + MAX_ADDRESS - 1)) 1.89 + *(q++) = *(p++); 1.90 + *q = 0; 1.91 1.92 - return TRUE; 1.93 + return TRUE; 1.94 } 1.95 1.96 -static 1.97 -smtp_connection *create_base(gchar *remote_host) 1.98 +static smtp_connection* 1.99 +create_base(gchar * remote_host) 1.100 { 1.101 - smtp_connection *base = g_malloc(sizeof(smtp_connection)); 1.102 - if(base){ 1.103 - base->remote_host = g_strdup(remote_host); 1.104 + smtp_connection *base = g_malloc(sizeof(smtp_connection)); 1.105 + if (base) { 1.106 + base->remote_host = g_strdup(remote_host); 1.107 1.108 - base->prot = PROT_SMTP; 1.109 - base->next_id = 0; 1.110 - base->helo_seen = 0; 1.111 - base->from_seen = 0; 1.112 - base->rcpt_seen = 0; 1.113 - base->msg = NULL; 1.114 + base->prot = PROT_SMTP; 1.115 + base->next_id = 0; 1.116 + base->helo_seen = 0; 1.117 + base->from_seen = 0; 1.118 + base->rcpt_seen = 0; 1.119 + base->msg = NULL; 1.120 1.121 - return base; 1.122 - } 1.123 - return NULL; 1.124 + return base; 1.125 + } 1.126 + return NULL; 1.127 } 1.128 1.129 -static 1.130 -void smtp_printf(FILE *out, gchar *fmt, ...) 1.131 +static void 1.132 +smtp_printf(FILE * out, gchar * fmt, ...) 1.133 { 1.134 - va_list args; 1.135 - va_start(args, fmt); 1.136 + va_list args; 1.137 + va_start(args, fmt); 1.138 1.139 - DEBUG(4){ 1.140 - gchar buf[256]; 1.141 - va_list args_copy; 1.142 + DEBUG(4) { 1.143 + gchar buf[256]; 1.144 + va_list args_copy; 1.145 1.146 - va_copy(args_copy, args); 1.147 - vsnprintf(buf, 255, fmt, args_copy); 1.148 - va_end(args_copy); 1.149 + va_copy(args_copy, args); 1.150 + vsnprintf(buf, 255, fmt, args_copy); 1.151 + va_end(args_copy); 1.152 1.153 - debugf(">>>%s", buf); 1.154 - } 1.155 + debugf(">>>%s", buf); 1.156 + } 1.157 1.158 - vfprintf(out, fmt, args); fflush(out); 1.159 + vfprintf(out, fmt, args); 1.160 + fflush(out); 1.161 1.162 - va_end(args); 1.163 + va_end(args); 1.164 } 1.165 1.166 -void smtp_in(FILE *in, FILE *out, gchar *remote_host, gchar *ident) 1.167 +void 1.168 +smtp_in(FILE * in, FILE * out, gchar * remote_host, gchar * ident) 1.169 { 1.170 - gchar *buffer; 1.171 - smtp_cmd_id cmd_id; 1.172 - message *msg = NULL; 1.173 - smtp_connection *psc; 1.174 - int len; 1.175 + gchar *buffer; 1.176 + smtp_cmd_id cmd_id; 1.177 + message *msg = NULL; 1.178 + smtp_connection *psc; 1.179 + int len; 1.180 1.181 - DEBUG(5) debugf("smtp_in entered, remote_host = %s\n", remote_host); 1.182 + DEBUG(5) debugf("smtp_in entered, remote_host = %s\n", remote_host); 1.183 1.184 - psc = create_base(remote_host); 1.185 - psc->msg = msg; 1.186 + psc = create_base(remote_host); 1.187 + psc->msg = msg; 1.188 1.189 - buffer = (gchar *)g_malloc(BUF_LEN); 1.190 - if(buffer){ 1.191 - /* send greeting string, containing ESMTP: */ 1.192 - smtp_printf(out, "220 %s MasqMail %s ESMTP\r\n", 1.193 - conf.host_name, VERSION); 1.194 - 1.195 - while((len = read_sockline(in, buffer, BUF_LEN, 5*60, READSOCKL_CHUG)) >= 0){ 1.196 - cmd_id = get_id(buffer); 1.197 - 1.198 - switch(cmd_id){ 1.199 - case SMTP_EHLO: 1.200 - psc->prot = PROT_ESMTP; 1.201 - /* fall through */ 1.202 - case SMTP_HELO: 1.203 - psc->helo_seen = TRUE; 1.204 + buffer = (gchar *) g_malloc(BUF_LEN); 1.205 + if (buffer) { 1.206 + /* send greeting string, containing ESMTP: */ 1.207 + smtp_printf(out, "220 %s MasqMail %s ESMTP\r\n", conf.host_name, VERSION); 1.208 1.209 - if(!conf.defer_all){ /* I need this to debug delivery failures */ 1.210 - if(psc->prot == PROT_ESMTP){ 1.211 - smtp_printf(out, "250-%s Nice to meet you with ESMTP\r\n", 1.212 - conf.host_name); 1.213 - /* not yet: fprintf(out, "250-SIZE\r\n"); */ 1.214 - smtp_printf(out, 1.215 - "250-PIPELINING\r\n" 1.216 - "250 HELP\r\n"); 1.217 - }else{ 1.218 - smtp_printf(out, "250 %s pretty old mailer, huh?\r\n", 1.219 - conf.host_name); 1.220 - } 1.221 - break; 1.222 - }else{ 1.223 - smtp_printf(out, "421 %s service temporarily unavailable.\r\n", 1.224 - conf.host_name); 1.225 + while ((len = read_sockline(in, buffer, BUF_LEN, 5 * 60, READSOCKL_CHUG)) >= 0) { 1.226 + cmd_id = get_id(buffer); 1.227 + 1.228 + switch (cmd_id) { 1.229 + case SMTP_EHLO: 1.230 + psc->prot = PROT_ESMTP; 1.231 + /* fall through */ 1.232 + case SMTP_HELO: 1.233 + psc->helo_seen = TRUE; 1.234 + 1.235 + if (!conf.defer_all) { /* I need this to debug delivery failures */ 1.236 + if (psc->prot == PROT_ESMTP) { 1.237 + smtp_printf(out, "250-%s Nice to meet you with ESMTP\r\n", conf.host_name); 1.238 + /* not yet: fprintf(out, "250-SIZE\r\n"); */ 1.239 + smtp_printf(out, "250-PIPELINING\r\n" "250 HELP\r\n"); 1.240 + } else { 1.241 + smtp_printf(out, "250 %s pretty old mailer, huh?\r\n", conf.host_name); 1.242 + } 1.243 + break; 1.244 + } else { 1.245 + smtp_printf(out, "421 %s service temporarily unavailable.\r\n", conf.host_name); 1.246 + } 1.247 + 1.248 + case SMTP_MAIL_FROM: 1.249 + if (psc->helo_seen && !psc->from_seen) { 1.250 + gchar buf[MAX_ADDRESS]; 1.251 + address *addr; 1.252 + 1.253 + msg = create_message(); 1.254 + msg->received_host = remote_host ? g_strdup(remote_host) : NULL; 1.255 + msg->received_prot = psc->prot; 1.256 + msg->ident = ident ? g_strdup(ident) : NULL; 1.257 + /* get transfer id and increment for next one */ 1.258 + msg->transfer_id = (psc->next_id)++; 1.259 + 1.260 + get_address(buffer, buf); 1.261 + if ((addr = remote_host 1.262 + ? create_address(buf, TRUE) 1.263 + : create_address_qualified(buf, TRUE, conf.host_name))) { 1.264 + if (addr->domain != NULL) { 1.265 + psc->from_seen = TRUE; 1.266 + msg->return_path = addr; 1.267 + smtp_printf(out, "250 OK %s is a nice guy.\r\n", addr->address); 1.268 + } else { 1.269 + smtp_printf(out, "501 return path must be qualified.\r\n", buf); 1.270 + } 1.271 + } else { 1.272 + smtp_printf(out, "501 %s: syntax error.\r\n", buf); 1.273 + } 1.274 + } else { 1.275 + if (!psc->helo_seen) 1.276 + smtp_printf(out, "503 need HELO or EHLO\r\n"); 1.277 + else 1.278 + smtp_printf(out, "503 MAIL FROM: already given.\r\n"); 1.279 + } 1.280 + break; 1.281 + 1.282 + case SMTP_RCPT_TO: 1.283 + 1.284 + if (psc->helo_seen && psc->from_seen) { 1.285 + char buf[MAX_ADDRESS]; 1.286 + address *addr; 1.287 + 1.288 + get_address(buffer, buf); 1.289 + if ((addr = remote_host 1.290 + ? create_address(buf, TRUE) 1.291 + : create_address_qualified(buf, TRUE, conf.host_name))) { 1.292 + if (addr->local_part[0] != '|') { 1.293 + if (addr->domain != NULL) { 1.294 + gboolean do_relay = conf.do_relay; 1.295 + if (!do_relay) { 1.296 + if ((do_relay = addr_is_local(msg->return_path))) { 1.297 + } 1.298 + if (!do_relay) { 1.299 + do_relay = addr_is_local(addr); 1.300 + } 1.301 + } 1.302 + if (do_relay) { 1.303 + psc->rcpt_seen = TRUE; 1.304 + msg->rcpt_list = g_list_append(msg->rcpt_list, addr); 1.305 + smtp_printf(out, "250 OK %s is our friend.\r\n", addr->address); 1.306 + } else { 1.307 + smtp_printf(out, "550 relaying to %s denied.\r\n", addr_string(addr)); 1.308 + } 1.309 + } else { 1.310 + smtp_printf(out, "501 recipient address must be qualified.\r\n", buf); 1.311 + } 1.312 + } else 1.313 + smtp_printf(out, "501 %s: no pipe allowed for SMTP connections\r\n", buf); 1.314 + } else { 1.315 + smtp_printf(out, "501 %s: syntax error in address.\r\n", buf); 1.316 + } 1.317 + } else { 1.318 + 1.319 + if (!psc->helo_seen) 1.320 + smtp_printf(out, "503 need HELO or EHLO.\r\n"); 1.321 + else 1.322 + smtp_printf(out, "503 need MAIL FROM: before RCPT TO:\r\n"); 1.323 + } 1.324 + break; 1.325 + 1.326 + case SMTP_DATA: 1.327 + if (psc->helo_seen && psc->rcpt_seen) { 1.328 + accept_error err; 1.329 + 1.330 + smtp_printf(out, "354 okay, and do not forget the dot\r\n"); 1.331 + 1.332 + if ((err = accept_message(in, msg, conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0)) == AERR_OK) { 1.333 + if (spool_write(msg, TRUE)) { 1.334 + pid_t pid; 1.335 + smtp_printf(out, "250 OK id=%s\r\n", msg->uid); 1.336 + 1.337 + if (remote_host != NULL) 1.338 + logwrite(LOG_NOTICE, "%s <= <%s@%s> host=%s with %s\n", msg->uid, msg->return_path->local_part, 1.339 + msg->return_path->domain, remote_host, prot_names[psc->prot]); 1.340 + else 1.341 + logwrite(LOG_NOTICE, "%s <= <%s@%s> with %s\n", msg->uid, msg->return_path->local_part, 1.342 + msg->return_path->domain, prot_names[psc->prot]); 1.343 + 1.344 + if (!conf.do_queue) { 1.345 + if ((pid = fork()) == 0) { 1.346 + 1.347 + if (deliver(msg)) 1.348 + _exit(EXIT_SUCCESS); 1.349 + else 1.350 + _exit(EXIT_FAILURE); 1.351 + 1.352 + } else if (pid < 0) { 1.353 + logwrite(LOG_ALERT, "could not fork for delivery, id = %s", msg->uid); 1.354 + } 1.355 + } else { 1.356 + DEBUG(1) debugf("queuing forced by configuration or option.\n"); 1.357 + } 1.358 + } else { 1.359 + smtp_printf(out, "451 Could not write spool file\r\n"); 1.360 + return; 1.361 + } 1.362 + } else { 1.363 + switch (err) { 1.364 + case AERR_TIMEOUT: 1.365 + return; 1.366 + case AERR_EOF: 1.367 + return; 1.368 + default: 1.369 + /* should never happen: */ 1.370 + smtp_printf(out, "451 Unknown error\r\n"); 1.371 + return; 1.372 + } 1.373 + } 1.374 + psc->rcpt_seen = psc->from_seen = FALSE; 1.375 + destroy_message(msg); 1.376 + msg = NULL; 1.377 + } else { 1.378 + if (!psc->helo_seen) 1.379 + smtp_printf(out, "503 need HELO or EHLO.\r\n"); 1.380 + else 1.381 + smtp_printf(out, "503 need RCPT TO: before DATA\r\n"); 1.382 + } 1.383 + break; 1.384 + case SMTP_QUIT: 1.385 + smtp_printf(out, "221 goodbye\r\n"); 1.386 + if (msg != NULL) 1.387 + destroy_message(msg); 1.388 + return; 1.389 + case SMTP_RSET: 1.390 + psc->from_seen = psc->rcpt_seen = FALSE; 1.391 + if (msg != NULL) 1.392 + destroy_message(msg); 1.393 + msg = NULL; 1.394 + smtp_printf(out, "250 OK\r\n"); 1.395 + break; 1.396 + case SMTP_NOOP: 1.397 + smtp_printf(out, "250 OK\r\n"); 1.398 + break; 1.399 + case SMTP_HELP: 1.400 + { 1.401 + int i; 1.402 + 1.403 + smtp_printf(out, "214-supported commands:\r\n"); 1.404 + for (i = 0; i < SMTP_NUM_IDS - 1; i++) { 1.405 + smtp_printf(out, "214-%s\r\n", smtp_cmds[i].cmd); 1.406 + } 1.407 + smtp_printf(out, "214 %s\r\n", smtp_cmds[i].cmd); 1.408 + } 1.409 + break; 1.410 + default: 1.411 + smtp_printf(out, "501 command not recognized\r\n"); 1.412 + DEBUG(1) debugf("command not recognized, was '%s'\n", buffer); 1.413 + break; 1.414 + } 1.415 + } 1.416 + switch (len) { 1.417 + case -3: 1.418 + logwrite(LOG_NOTICE, "connection timed out\n"); 1.419 + break; 1.420 + case -2: 1.421 + logwrite(LOG_NOTICE, "line overflow\n"); 1.422 + break; 1.423 + case -1: 1.424 + logwrite(LOG_NOTICE, "received EOF\n"); 1.425 + break; 1.426 + default: 1.427 + break; 1.428 + } 1.429 } 1.430 - 1.431 - case SMTP_MAIL_FROM: 1.432 - if(psc->helo_seen && !psc->from_seen){ 1.433 - gchar buf[MAX_ADDRESS]; 1.434 - address *addr; 1.435 - 1.436 - msg = create_message(); 1.437 - msg->received_host = remote_host ? g_strdup(remote_host) : NULL; 1.438 - msg->received_prot = psc->prot; 1.439 - msg->ident = ident ? g_strdup(ident) : NULL; 1.440 - /* get transfer id and increment for next one */ 1.441 - msg->transfer_id = (psc->next_id)++; 1.442 - 1.443 - get_address(buffer, buf); 1.444 - if((addr = remote_host ? 1.445 - create_address(buf, TRUE) : 1.446 - create_address_qualified(buf, TRUE, conf.host_name))){ 1.447 - if(addr->domain != NULL){ 1.448 - psc->from_seen = TRUE; 1.449 - msg->return_path = addr; 1.450 - smtp_printf(out, "250 OK %s is a nice guy.\r\n", addr->address); 1.451 - }else{ 1.452 - smtp_printf(out, 1.453 - "501 return path must be qualified.\r\n", buf); 1.454 - } 1.455 - }else{ 1.456 - smtp_printf(out, "501 %s: syntax error.\r\n", buf); 1.457 - } 1.458 - }else{ 1.459 - if(!psc->helo_seen) 1.460 - smtp_printf(out, "503 need HELO or EHLO\r\n"); 1.461 - else 1.462 - smtp_printf(out, "503 MAIL FROM: already given.\r\n"); 1.463 - } 1.464 - break; 1.465 - 1.466 - case SMTP_RCPT_TO: 1.467 - 1.468 - if(psc->helo_seen && psc->from_seen){ 1.469 - char buf[MAX_ADDRESS]; 1.470 - address *addr; 1.471 - 1.472 - get_address(buffer, buf); 1.473 - if((addr = remote_host ? 1.474 - create_address(buf, TRUE) : 1.475 - create_address_qualified(buf, TRUE, conf.host_name))){ 1.476 - if(addr->local_part[0] != '|'){ 1.477 - if(addr->domain != NULL){ 1.478 - gboolean do_relay = conf.do_relay; 1.479 - if(!do_relay){ 1.480 - if((do_relay = addr_is_local(msg->return_path))); 1.481 - if(!do_relay){ 1.482 - do_relay = addr_is_local(addr); 1.483 - } 1.484 - } 1.485 - if(do_relay){ 1.486 - psc->rcpt_seen = TRUE; 1.487 - msg->rcpt_list = g_list_append(msg->rcpt_list, addr); 1.488 - smtp_printf(out, "250 OK %s is our friend.\r\n", addr->address); 1.489 - }else{ 1.490 - smtp_printf(out, "550 relaying to %s denied.\r\n", 1.491 - addr_string(addr)); 1.492 - } 1.493 - }else{ 1.494 - smtp_printf(out, 1.495 - "501 recipient address must be qualified.\r\n", buf); 1.496 - } 1.497 - }else 1.498 - smtp_printf(out, "501 %s: no pipe allowed for SMTP connections\r\n", buf); 1.499 - }else{ 1.500 - smtp_printf(out, "501 %s: syntax error in address.\r\n", buf); 1.501 - } 1.502 - }else{ 1.503 - 1.504 - if(!psc->helo_seen) 1.505 - smtp_printf(out, "503 need HELO or EHLO.\r\n"); 1.506 - else 1.507 - smtp_printf(out, "503 need MAIL FROM: before RCPT TO:\r\n"); 1.508 - } 1.509 - break; 1.510 - 1.511 - case SMTP_DATA: 1.512 - if(psc->helo_seen && psc->rcpt_seen){ 1.513 - accept_error err; 1.514 - 1.515 - smtp_printf(out, "354 okay, and do not forget the dot\r\n"); 1.516 - 1.517 - if((err = accept_message(in, msg, conf.do_save_envelope_to ? ACC_SAVE_ENVELOPE_TO : 0)) 1.518 - == AERR_OK){ 1.519 - if(spool_write(msg, TRUE)){ 1.520 - pid_t pid; 1.521 - smtp_printf(out, "250 OK id=%s\r\n", msg->uid); 1.522 - 1.523 - if(remote_host != NULL) 1.524 - logwrite(LOG_NOTICE, "%s <= <%s@%s> host=%s with %s\n", 1.525 - msg->uid, msg->return_path->local_part, 1.526 - msg->return_path->domain, remote_host, 1.527 - prot_names[psc->prot]); 1.528 - else 1.529 - logwrite(LOG_NOTICE, "%s <= <%s@%s> with %s\n", 1.530 - msg->uid, msg->return_path->local_part, 1.531 - msg->return_path->domain, 1.532 - prot_names[psc->prot]); 1.533 - 1.534 - if(!conf.do_queue){ 1.535 - if((pid = fork()) == 0){ 1.536 - 1.537 - if(deliver(msg)) 1.538 - _exit(EXIT_SUCCESS); 1.539 - else 1.540 - _exit(EXIT_FAILURE); 1.541 - 1.542 - }else if(pid < 0){ 1.543 - logwrite(LOG_ALERT, "could not fork for delivery, id = %s", 1.544 - msg->uid); 1.545 - } 1.546 - }else{ 1.547 - DEBUG(1) debugf("queuing forced by configuration or option.\n"); 1.548 - } 1.549 - }else{ 1.550 - smtp_printf(out, "451 Could not write spool file\r\n"); 1.551 - return; 1.552 - } 1.553 - }else{ 1.554 - switch(err){ 1.555 - case AERR_TIMEOUT: 1.556 - return; 1.557 - case AERR_EOF: 1.558 - return; 1.559 - default: 1.560 - /* should never happen: */ 1.561 - smtp_printf(out, "451 Unknown error\r\n"); 1.562 - return; 1.563 - } 1.564 - } 1.565 - psc->rcpt_seen = psc->from_seen = FALSE; 1.566 - destroy_message(msg); 1.567 - msg = NULL; 1.568 - }else{ 1.569 - if(!psc->helo_seen) 1.570 - smtp_printf(out, "503 need HELO or EHLO.\r\n"); 1.571 - else 1.572 - smtp_printf(out, "503 need RCPT TO: before DATA\r\n"); 1.573 - } 1.574 - break; 1.575 - case SMTP_QUIT: 1.576 - smtp_printf(out, "221 goodbye\r\n"); 1.577 - if(msg != NULL) destroy_message(msg); 1.578 - return; 1.579 - case SMTP_RSET: 1.580 - psc->from_seen = psc->rcpt_seen = FALSE; 1.581 - if(msg != NULL) 1.582 - destroy_message(msg); 1.583 - msg = NULL; 1.584 - smtp_printf(out, "250 OK\r\n"); 1.585 - break; 1.586 - case SMTP_NOOP: 1.587 - smtp_printf(out, "250 OK\r\n"); 1.588 - break; 1.589 - case SMTP_HELP: 1.590 - { 1.591 - int i; 1.592 - 1.593 - smtp_printf(out, "214-supported commands:\r\n"); 1.594 - for(i = 0; i < SMTP_NUM_IDS-1; i++){ 1.595 - smtp_printf(out, "214-%s\r\n", smtp_cmds[i].cmd); 1.596 - } 1.597 - smtp_printf(out, "214 %s\r\n", smtp_cmds[i].cmd); 1.598 - } 1.599 - break; 1.600 - default: 1.601 - smtp_printf(out, "501 command not recognized\r\n"); 1.602 - DEBUG(1) debugf("command not recognized, was '%s'\n", buffer); 1.603 - break; 1.604 - } 1.605 - } 1.606 - switch(len){ 1.607 - case -3: 1.608 - logwrite(LOG_NOTICE, "connection timed out\n"); 1.609 - break; 1.610 - case -2: 1.611 - logwrite(LOG_NOTICE, "line overflow\n"); 1.612 - break; 1.613 - case -1: 1.614 - logwrite(LOG_NOTICE, "received EOF\n"); 1.615 - break; 1.616 - default: 1.617 - break; 1.618 - } 1.619 - } 1.620 } 1.621 #endif