You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by so...@apache.org on 2005/08/24 01:15:06 UTC

svn commit: r239480 - in /httpd/mod_smtpd/trunk: mod_smtpd.h smtp.h smtp_core.c smtp_protocol.c

Author: soc-rian
Date: Tue Aug 23 16:14:55 2005
New Revision: 239480

URL: http://svn.apache.org/viewcvs?rev=239480&view=rev
Log:
fixed getline function so it returns amount of characters read, exported io functions so other smtpd related modules can use them, and fixed data read loop

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

Modified: httpd/mod_smtpd/trunk/mod_smtpd.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/mod_smtpd.h?rev=239480&r1=239479&r2=239480&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/mod_smtpd.h (original)
+++ httpd/mod_smtpd/trunk/mod_smtpd.h Tue Aug 23 16:14:55 2005
@@ -123,6 +123,19 @@
        
 SMTPD_DECLARE_NONSTD(void) smtpd_reset_transaction(smtpd_conn_rec *scr);
 
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_getline(smtpd_conn_rec *scr,
+                                                 char *data, apr_size_t dlen,
+                                                 apr_size_t *outlen);
+
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_multiline(smtpd_conn_rec *scr,
+                                                           int code,
+                                                           apr_array_header_t
+                                                           *msgs);
+
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_oneline(smtpd_conn_rec *scr,
+                                                         int code,
+                                                         char *message);
+
 APR_DECLARE_EXTERNAL_HOOK(smtpd, SMTPD, smtpd_retcode,
                           unrecognized_command,
                           (smtpd_conn_rec *scr, smtpd_return_data *in,

Modified: httpd/mod_smtpd/trunk/smtp.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp.h?rev=239480&r1=239479&r2=239480&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp.h (original)
+++ httpd/mod_smtpd/trunk/smtp.h Tue Aug 23 16:14:55 2005
@@ -90,13 +90,6 @@
 
 apr_hash_t *smtpd_get_handlers(void);
 
-apr_status_t smtpd_getline(smtpd_conn_rec *scr, char *data, apr_size_t dlen);
-
-apr_status_t smtpd_respond_multiline(smtpd_conn_rec *scr, int code,
-                                     apr_array_header_t *msgs);
-
-apr_status_t smtpd_respond_oneline(smtpd_conn_rec *scr, int code,
-                                   char *message);
     
 HANDLER_DECLARE(ehlo);
 HANDLER_DECLARE(helo);

Modified: httpd/mod_smtpd/trunk/smtp_core.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp_core.c?rev=239480&r1=239479&r2=239480&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp_core.c (original)
+++ httpd/mod_smtpd/trunk/smtp_core.c Tue Aug 23 16:14:55 2005
@@ -146,10 +146,10 @@
     smtpd_clear_trans_rec(scr->transaction);
 }
 
-/* friend methods */
-/* only our sources can call these */
 
-apr_status_t smtpd_getline(smtpd_conn_rec *scr, char *data, apr_size_t dlen)
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_getline(smtpd_conn_rec *scr,
+                                                 char *data, apr_size_t dlen,
+                                                 apr_size_t *outlen)
 {
     apr_status_t rc;
     apr_bucket *e;
@@ -214,11 +214,15 @@
     }
     
     *last_char = '\0';
+    if (outlen)
+        *outlen = last_char - data;
     return APR_SUCCESS;
 }
 
-apr_status_t smtpd_respond_multiline(smtpd_conn_rec *scr, int code,
-                                     apr_array_header_t *msgs)
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_multiline(smtpd_conn_rec *scr,
+                                                           int code,
+                                                           apr_array_header_t
+                                                           *msgs)
 {
     int i;
     
@@ -235,8 +239,9 @@
     return APR_SUCCESS;
 }
 
-apr_status_t smtpd_respond_oneline(smtpd_conn_rec *scr, int code,
-                                   char *message)
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_oneline(smtpd_conn_rec *scr,
+                                                         int code,
+                                                         char *message)
 {
     ap_fprintf(scr->c->output_filters, scr->bb_out, "%d %s\r\n", code,
                message);
@@ -244,6 +249,9 @@
     
     return APR_SUCCESS;
 }
+
+/* friend methods */
+/* only our sources can call these */
 
 void smtpd_clear_trans_rec(smtpd_trans_rec *str)
 {

Modified: httpd/mod_smtpd/trunk/smtp_protocol.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp_protocol.c?rev=239480&r1=239479&r2=239480&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp_protocol.c (original)
+++ httpd/mod_smtpd/trunk/smtp_protocol.c Tue Aug 23 16:14:55 2005
@@ -92,7 +92,7 @@
         break;
     }
     
-    while (smtpd_getline(scr, buffer, BUFFER_STR_LEN) == APR_SUCCESS) {
+    while (smtpd_getline(scr, buffer, BUFFER_STR_LEN, NULL) == APR_SUCCESS) {
         apr_pool_clear(p);
         command = ap_getword_white_nc(p, &buffer);
         ap_str_tolower(command);
@@ -464,6 +464,7 @@
                            &smtpd_module);
     int rv, retval = 0;
     char *tempfile;
+    char our_buffer[BUFFER_STR_LEN];
     apr_bucket_brigade *bb;
     apr_file_t *tfp;
     apr_size_t len, total_data = 0;
@@ -536,13 +537,15 @@
     /* just wait until we get the line with a dot. */
     /* or until we can't read anymore. */
     /* or until we have too much data */
-    while ((smtpd_getline(scr, buffer, BUFFER_STR_LEN) == APR_SUCCESS) &&
-           (strcmp(buffer, ".")) &&
+    while ((smtpd_getline(scr, our_buffer, BUFFER_STR_LEN, &len)
+            == APR_SUCCESS) &&
+           (strcmp(our_buffer, ".")) &&
            (total_data < pConfig->max_data)) {
-        apr_file_write(tfp, buffer, &len);
-        len = sizeof("\n");
+        /* character data read plus newline */
+        total_data += len + 1;
+        apr_file_write(tfp, our_buffer, &len);
+        len = 1;
         apr_file_write(tfp, "\n", &len);
-        total_data += len;
     }
     
     str->tfp = tfp;