httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soc-r...@apache.org
Subject svn commit: r366239 - in /httpd/mod_smtpd/trunk/src: smtp.h smtp_core.c smtp_protocol.c
Date Thu, 05 Jan 2006 18:36:18 GMT
Author: soc-rian
Date: Thu Jan  5 10:36:15 2006
New Revision: 366239

URL: http://svn.apache.org/viewcvs?rev=366239&view=rev
Log:
Removed hash based mechanism for calling SMTP command handlers. Too
complicated for only calling nine or so functions. Also changed name of data
returned from hooks from in_data to out_data, because it's really out data.


Modified:
    httpd/mod_smtpd/trunk/src/smtp.h
    httpd/mod_smtpd/trunk/src/smtp_core.c
    httpd/mod_smtpd/trunk/src/smtp_protocol.c

Modified: httpd/mod_smtpd/trunk/src/smtp.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/smtp.h?rev=366239&r1=366238&r2=366239&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/smtp.h (original)
+++ httpd/mod_smtpd/trunk/src/smtp.h Thu Jan  5 10:36:15 2006
@@ -41,12 +41,6 @@
 } smtpd_svr_config_rec;
 
 typedef struct {
-    smtpd_handler *func;
-    const char *help_text;
-    void *data;
-} smtpd_handler_st;
-
-typedef struct {
     int headers_parsed;
     smtpd_conn_rec *scr;
     apreq_parser_t *rfc822_parser;
@@ -56,19 +50,6 @@
 void smtpd_process_connection_internal(smtpd_conn_rec *str);
 
 void smtpd_clear_trans_rec(smtpd_conn_rec *);
-
-apr_hash_t *smtpd_get_handlers(void);
-
-    
-HANDLER_DECLARE(ehlo);
-HANDLER_DECLARE(helo);
-HANDLER_DECLARE(mail);
-HANDLER_DECLARE(rcpt);
-HANDLER_DECLARE(data);
-HANDLER_DECLARE(rset);
-HANDLER_DECLARE(noop);
-HANDLER_DECLARE(quit);
-HANDLER_DECLARE(vrfy);
 
 #ifdef __cplusplus
 }

Modified: httpd/mod_smtpd/trunk/src/smtp_core.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/smtp_core.c?rev=366239&r1=366238&r2=366239&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/smtp_core.c (original)
+++ httpd/mod_smtpd/trunk/src/smtp_core.c Thu Jan  5 10:36:15 2006
@@ -42,7 +42,6 @@
 ap_filter_rec_t *smtpd_data_input_filter_handle;
 ap_filter_rec_t *smtpd_header_input_filter_handle;
 
-static apr_hash_t *smtpd_handlers;
 
 APR_HOOK_STRUCT(
     APR_HOOK_LINK(unrecognized_command)
@@ -142,11 +141,6 @@
 				    (scr),
 				    SMTPD_OK, SMTPD_DECLINED);
 
-apr_hash_t *smtpd_get_handlers()
-{
-    return smtpd_handlers;
-}
-
 void smtpd_clear_trans_rec(smtpd_conn_rec *scr)
 {
     smtpd_trans_rec *str = scr->transaction;
@@ -165,22 +159,6 @@
 /* private methods */
 /* only used in this file */
 
-/* can overwrite currently registered handlers */
-static void smtpd_register_handler(char *key, smtpd_handler *func,
-                                   const char *help_text, void *data,
-                                   apr_pool_t *p)
-{
-    char *dupkey = apr_pstrdup(p, key);
-    smtpd_handler_st *hand = apr_palloc(p, sizeof(*hand));
-    
-    hand->func = func;
-    hand->data = data;
-    hand->help_text = help_text;
-    
-    ap_str_tolower(dupkey);
-    apr_hash_set(smtpd_handlers, dupkey, APR_HASH_KEY_STRING, hand);
-}
-
 /* Creates the main request record for the connection */
 static smtpd_conn_rec *smtpd_create_conn_rec(conn_rec *conn)
 {
@@ -308,18 +286,12 @@
     smtpd_header_input_filter_handle =
         ap_register_input_filter("SMTP_HEADER_IN", smtpd_header_filter,
                                  NULL, AP_FTYPE_PROTOCOL);
-    
-    smtpd_handlers = apr_hash_make(p);
-    
-    smtpd_register_handler("EHLO", HANDLER_FUNC(ehlo), "ehlo", NULL, p);
-    smtpd_register_handler("HELO", HANDLER_FUNC(helo), "helo", NULL, p);
-    smtpd_register_handler("MAIL", HANDLER_FUNC(mail), "mail", NULL, p);
-    smtpd_register_handler("RCPT", HANDLER_FUNC(rcpt), "rcpt", NULL, p);
-    smtpd_register_handler("DATA", HANDLER_FUNC(data), "data", NULL, p);
-    smtpd_register_handler("RSET", HANDLER_FUNC(rset), "rset", NULL, p);
-    smtpd_register_handler("NOOP", HANDLER_FUNC(noop), "noop", NULL, p);
-    smtpd_register_handler("QUIT", HANDLER_FUNC(quit), "quit", NULL, p);
-    smtpd_register_handler("VRFY", HANDLER_FUNC(vrfy), "vrfy", NULL, p);
+
+    /* XXX: implement a global (mod_smtpd wise) limit structure
+       for string limits */
+    /* XXX: implement a global (mod_smtpd wise) timeout structure */
+    /* modules can register their limit extensions, command help,
+       and extensions here */
 }
 
 module AP_MODULE_DECLARE_DATA smtpd_module = {

Modified: httpd/mod_smtpd/trunk/src/smtp_protocol.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/smtp_protocol.c?rev=366239&r1=366238&r2=366239&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/smtp_protocol.c (original)
+++ httpd/mod_smtpd/trunk/src/smtp_protocol.c Thu Jan  5 10:36:15 2006
@@ -41,34 +41,49 @@
 extern ap_filter_rec_t *smtpd_data_input_filter_handle;
 extern ap_filter_rec_t *smtpd_header_input_filter_handle;
 
+/* these functions are all inlined and static because they
+   are only called from one location and only in this file */
 inline static int smtpd_handle_unrecognized_command(smtpd_conn_rec *scr,
                                                     smtpd_return_data *in_data,
                                                     char *command, char *data);
+inline static int smtpd_handler_ehlo(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_helo(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_mail(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_rcpt(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_data(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_rset(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+inline static int smtpd_handler_quit(smtpd_conn_rec *scr, char *buffer,
+                                     smtpd_return_data *out_data);
+
 
 #define BUFFER_STR_LEN 1024
 void smtpd_process_connection_internal(smtpd_conn_rec *scr)
 {
-    apr_pool_t *p;
-    apr_hash_t *handlers = smtpd_get_handlers();
+    apr_pool_t *per_command_pool;
     char cmdbuff[BUFFER_STR_LEN];
-    smtpd_handler_st *handle_func;
     char *buffer = cmdbuff;
     char *command;
-    smtpd_return_data in_data;
+    smtpd_return_data out_data;
     smtpd_svr_config_rec *pConfig =
-      ap_get_module_config(scr->s->module_config,
-                           &smtpd_module);
+        ap_get_module_config(scr->s->module_config,
+                             &smtpd_module);
     
-    apr_pool_create(&p, scr->p);
-    in_data.p = p;
+    apr_pool_create(&per_command_pool, scr->p);
+    out_data.p = per_command_pool;
     
-    in_data.msgs = NULL;
-    switch(smtpd_run_connect(scr, &in_data)) {
+    out_data.msgs = NULL;
+    switch(smtpd_run_connect(scr, &out_data)) {
     case SMTPD_DENY:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "Connection Denied");
-        if (in_data.msgs) {
-            smtpd_respond_multiline(scr, 550, in_data.msgs);
+        if (out_data.msgs) {
+            smtpd_respond_multiline(scr, 550, out_data.msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550,
@@ -78,8 +93,8 @@
     case SMTPD_DENYSOFT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "Connection Denied");
-        if (in_data.msgs) {
-            smtpd_respond_multiline(scr, 450, in_data.msgs);
+        if (out_data.msgs) {
+            smtpd_respond_multiline(scr, 450, out_data.msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "Connection from you temporarily "
@@ -98,23 +113,47 @@
     }
     
     while (smtpd_getline(scr, buffer, BUFFER_STR_LEN, NULL) == APR_SUCCESS) {
-        apr_pool_clear(p);
-        command = ap_getword_white_nc(p, &buffer);
+        int return_code;
+        apr_pool_clear(per_command_pool);
+        command = ap_getword_white_nc(per_command_pool, &buffer);
         ap_str_tolower(command);
-        handle_func = apr_hash_get(handlers, command, APR_HASH_KEY_STRING);
-        
-        in_data.msgs = NULL;
-        /* command not recognized */
-        if (!handle_func)  {
-            if (!smtpd_handle_unrecognized_command(scr, &in_data, command,
-                                                   buffer))
-                break;
+
+        out_data.msgs = NULL;
+
+        if (ap_strcmp_match("ehlo", command) == 0) {
+            return_code = smtpd_handler_ehlo(scr, buffer, &out_data);
         }
-        else {
-            if (!handle_func->func(scr, buffer, &in_data, handle_func->data))
-                break;
+        else if (ap_strcmp_match("helo", command) == 0) {
+            return_code = smtpd_handler_helo(scr, buffer, &out_data);
+        }
+        else if (ap_strcmp_match("mail", command) == 0) {
+            return_code = smtpd_handler_mail(scr, buffer, &out_data);
+        }
+        else if (ap_strcmp_match("rcpt", command) == 0) {
+            return_code = smtpd_handler_rcpt(scr, buffer, &out_data);
+        }
+        else if (ap_strcmp_match("data", command) == 0) {
+            return_code = smtpd_handler_data(scr, buffer, &out_data);
+        }
+        else if (ap_strcmp_match("rset", command) == 0) {
+            return_code = smtpd_handler_rset(scr, buffer, &out_data);
+        }
+        else if (ap_strcmp_match("noop", command) == 0) {
+            smtpd_respond_oneline(scr, 250, "Ok");
+            return_code = 250;
+        }
+        else if (ap_strcmp_match("quit", command) == 0) {
+            return_code = smtpd_handler_quit(scr, buffer, &out_data);
+
+        } else {
+            return_code =
+                smtpd_handle_unrecognized_command(scr,&out_data, command,
+                                                  buffer);
         }
         
+        if (!return_code)
+            break;
+
         buffer = cmdbuff;
     }
     
@@ -123,13 +162,14 @@
 }
 
 inline static int smtpd_handle_unrecognized_command(smtpd_conn_rec *scr,
-                                                    smtpd_return_data *in_data,
+                                                    smtpd_return_data
+                                                    *out_data,
                                                     char *command, char *data)
 {
-    switch(smtpd_run_unrecognized_command(scr, in_data, command, data)) {
+    switch(smtpd_run_unrecognized_command(scr, out_data, command, data)) {
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 521, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 521, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 521, "Command Denied");
@@ -146,7 +186,8 @@
 
 }
 
-HANDLER_DECLARE(ehlo)
+inline static int smtpd_handler_ehlo(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_trans_rec *str = scr->transaction;
     
@@ -155,22 +196,22 @@
         return 501;
     }
     
-    switch(smtpd_run_ehlo(scr, in_data, buffer)) {
+    switch(smtpd_run_ehlo(scr, out_data, buffer)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
         return 0;
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "");
         }
         return 550;
     case SMTPD_DENYSOFT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "");
@@ -209,7 +250,8 @@
     return 250;
 }
 
-HANDLER_DECLARE(helo)
+inline static int smtpd_handler_helo(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_trans_rec *str = scr->transaction;
     
@@ -219,22 +261,22 @@
         return 501;
     }
     
-    switch(smtpd_run_helo(scr, in_data, buffer)) {
+    switch(smtpd_run_helo(scr, out_data, buffer)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
         return 0;
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "");
         }
         return 550;
     case SMTPD_DENYSOFT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "");
@@ -255,7 +297,8 @@
     return 250;
 }
 
-HANDLER_DECLARE(mail)
+inline static int smtpd_handler_mail(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_trans_rec *str = scr->transaction;
     char *loc;
@@ -289,7 +332,7 @@
         }
     }
 
-    switch(smtpd_run_mail(scr, in_data, loc)) {
+    switch(smtpd_run_mail(scr, out_data, loc)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
@@ -298,9 +341,9 @@
     case SMTPD_DENY:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "deny mail from %s (%s)", loc,
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");  
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
 
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "denied");
@@ -309,9 +352,9 @@
     case SMTPD_DENYSOFT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "denysoft mail from %s (%s)", loc,
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");  
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
 
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "temporarily denied");
@@ -320,9 +363,9 @@
     case SMTPD_DENY_DISCONNECT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "deny mail from %s (%s)", loc,
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");  
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
 
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "denied");
@@ -332,9 +375,9 @@
     case SMTPD_DENYSOFT_DISCONNECT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "denysoft mail from %s (%s)", loc,
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");  
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
 
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "temporarily denied");
@@ -353,7 +396,8 @@
     return 250;
 }
 
-HANDLER_DECLARE(rcpt)
+inline static int smtpd_handler_rcpt(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_trans_rec *str = scr->transaction;
     char *loc;
@@ -386,22 +430,22 @@
         }
     }
     
-    switch(smtpd_run_rcpt(scr, in_data, loc)) {
+    switch(smtpd_run_rcpt(scr, out_data, loc)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
         return 0;
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "relaying denied");
         }
         return 550;
     case SMTPD_DENYSOFT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "relaying temporarily denied");
@@ -410,9 +454,9 @@
     case SMTPD_DENY_DISCONNECT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "delivery denied (%s)",
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 550, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 550, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 550, "relaying denied");
@@ -421,9 +465,9 @@
     case SMTPD_DENYSOFT_DISCONNECT:
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, scr->s,
                      "delivery denied (%s)",
-                     in_data->msgs ? ((char **)in_data->msgs->elts)[0] : "");
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 450, in_data->msgs);
+                     out_data->msgs ? ((char **)out_data->msgs->elts)[0] : "");
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 450, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 450, "relaying temporarily denied");
@@ -446,40 +490,40 @@
 }
 
 
-inline static int smtpd_queue(smtpd_conn_rec *scr, smtpd_return_data *in_data)
+inline static int smtpd_queue(smtpd_conn_rec *scr, smtpd_return_data *out_data)
 {
-    switch(smtpd_run_queue(scr, in_data)) {
+    switch(smtpd_run_queue(scr, out_data)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
         return 0;
     case SMTPD_OK:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 250, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 250, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 250, "Queued");
         }
         return 250;
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 552, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 552, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 552, "Message denied");
         }
         return 552;
     case SMTPD_DENYSOFT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 452, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 452, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 452, "Message denied temporarily");
         }
         return 452;
     default:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 451, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 451, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 451,
@@ -490,12 +534,13 @@
     }
 }
 
-HANDLER_DECLARE(data)
+inline static int smtpd_handler_data(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_trans_rec *str = scr->transaction;
     smtpd_svr_config_rec *pConfig =
-      ap_get_module_config(scr->s->module_config,
-                           &smtpd_module);
+        ap_get_module_config(scr->s->module_config,
+                             &smtpd_module);
     smtpd_header_filter_ctx header_ctx = {0, scr, NULL, NULL};
     int rv, retval = 0;
     char *tempfile;
@@ -505,7 +550,7 @@
     apr_bucket_brigade *bb;
     apr_bucket *e;
 
-    switch(smtpd_run_data(scr, in_data)) {
+    switch(smtpd_run_data(scr, out_data)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
@@ -513,8 +558,8 @@
     case SMTPD_DENY:
         /* REVIEW: should we reset state here? */
         /* smtpd_clear_request_rec(sr); */
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 554, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 554, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 554, "Message denied");
@@ -523,24 +568,24 @@
     case SMTPD_DENYSOFT:
         /* REVIEW: should we reset state here? */
         /* smtpd_clear_request_rec(sr); */
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 451, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 451, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 451, "Message denied temporarily");
         }
         return 451;
     case SMTPD_DENY_DISCONNECT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 554, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 554, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 554, "Message denied");
         }
         return 0;
     case SMTPD_DENYSOFT_DISCONNECT:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 451, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 451, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 451, "Message denied temporarily");
@@ -625,13 +670,13 @@
     /*
       XXX: Qpsmtpd code to add the Received Header, will get refactored
       $header->add("Received", "from ".$self->connection->remote_info
-       ." (HELO ".$self->connection->hello_host . ") (".$self->connection->remote_ip
-       . ")\n  $authheader  by ".$self->config('me')." (qpsmtpd/".$self->version
-       .") with $smtp; ". (strftime('%a, %d %b %Y %H:%M:%S %z', localtime)),
-       0);
+      ." (HELO ".$self->connection->hello_host . ") (".$self->connection->remote_ip
+      . ")\n  $authheader  by ".$self->config('me')." (qpsmtpd/".$self->version
+      .") with $smtp; ". (strftime('%a, %d %b %Y %H:%M:%S %z', localtime)),
+      0);
     */
 
-    switch(smtpd_run_data_post(scr, in_data)) {
+    switch(smtpd_run_data_post(scr, out_data)) {
     case SMTPD_DONE:
         retval = 1;
         goto cleanup;
@@ -640,8 +685,8 @@
         goto cleanup;
     case SMTPD_DENY:
         retval = 552;
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 552, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 552, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 552, "Message denied");
@@ -649,15 +694,15 @@
         break;
     case SMTPD_DENYSOFT:
         retval = 452;
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 452, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 452, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 452, "Message denied temporarily");
         }
         break;
     default:
-        retval = smtpd_queue(scr, in_data);
+        retval = smtpd_queue(scr, out_data);
     }
     
     smtpd_reset_transaction(scr);
@@ -667,7 +712,8 @@
     return retval;
 }
 
-HANDLER_DECLARE(rset)
+inline static int smtpd_handler_rset(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
     smtpd_reset_transaction(scr);
     smtpd_respond_oneline(scr, 250, "Ok");
@@ -675,48 +721,43 @@
     return 250;
 }
 
-HANDLER_DECLARE(noop)
-{
-    smtpd_respond_oneline(scr, 250, "Ok");
-    
-    return 250;
-}
-
-HANDLER_DECLARE(quit)
+inline static int smtpd_handler_quit(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
-    if (smtpd_run_quit(scr, in_data) != SMTPD_DONE) {
+    if (smtpd_run_quit(scr, out_data) != SMTPD_DONE) {
         smtpd_respond_oneline(scr, 221, "Bye");
     }
     /* zero to disconnect */
     return 0;
 }
 
-HANDLER_DECLARE(vrfy)
+inline static int smtpd_handler_vrfy(smtpd_conn_rec *scr, char *buffer,
+                       smtpd_return_data *out_data)
 {
-    switch(smtpd_run_vrfy(scr, in_data, buffer)) {
+    switch(smtpd_run_vrfy(scr, out_data, buffer)) {
     case SMTPD_DONE:
         return 1;
     case SMTPD_DONE_DISCONNECT:
         return 0;
     case SMTPD_DENY:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 554, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 554, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 554, "Address denied");
         }
         return 554;
     case SMTPD_OK: /* user is okay */
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 250, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 250, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 250, "Address okay");
         }
         return 250;
     default:
-        if (in_data->msgs) {
-            smtpd_respond_multiline(scr, 252, in_data->msgs);
+        if (out_data->msgs) {
+            smtpd_respond_multiline(scr, 252, out_data->msgs);
         }
         else {
             smtpd_respond_oneline(scr, 252,



Mime
View raw message