httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soc-r...@apache.org
Subject svn commit: r265531 - in /httpd/mod_smtpd/trunk: Makefile.in mod_smtpd.h smtp_core.c smtp_util.c
Date Wed, 31 Aug 2005 17:01:46 GMT
Author: soc-rian
Date: Wed Aug 31 10:01:42 2005
New Revision: 265531

URL: http://svn.apache.org/viewcvs?rev=265531&view=rev
Log:
took exported functions out of smtp_core.c and put them in smtp_util.c

Added:
    httpd/mod_smtpd/trunk/smtp_util.c
Modified:
    httpd/mod_smtpd/trunk/Makefile.in
    httpd/mod_smtpd/trunk/mod_smtpd.h
    httpd/mod_smtpd/trunk/smtp_core.c

Modified: httpd/mod_smtpd/trunk/Makefile.in
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/Makefile.in?rev=265531&r1=265530&r2=265531&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/Makefile.in (original)
+++ httpd/mod_smtpd/trunk/Makefile.in Wed Aug 31 10:01:42 2005
@@ -2,7 +2,7 @@
 CFLAGS=-Wall
 APXSFLAGS=-L`$(APXS) -q LIBDIR`
 LIBS=-lapreq2
-SMTPD_SRC=smtp_core.c smtp_protocol.c
+SMTPD_SRC=smtp_core.c smtp_protocol.c smtp_util.c
 
 all: mod_smtpd.la
 

Modified: httpd/mod_smtpd/trunk/mod_smtpd.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/mod_smtpd.h?rev=265531&r1=265530&r2=265531&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/mod_smtpd.h (original)
+++ httpd/mod_smtpd/trunk/mod_smtpd.h Wed Aug 31 10:01:42 2005
@@ -20,6 +20,7 @@
 #include "apr_pools.h"
 #include "apr_hash.h"
 #include "apr_file_io.h"
+#include "util_filter.h"
 #include "httpd.h"
 
 #ifdef __cplusplus

Modified: httpd/mod_smtpd/trunk/smtp_core.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp_core.c?rev=265531&r1=265530&r2=265531&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/smtp_core.c (original)
+++ httpd/mod_smtpd/trunk/smtp_core.c Wed Aug 31 10:01:42 2005
@@ -14,10 +14,6 @@
  * limitations under the License.
  */
 
-/* todo:
-   write postfix passer
-*/
-
 #define CORE_PRIVATE
 #include "httpd.h"
 #include "http_protocol.h"
@@ -128,174 +124,11 @@
 					(scr, in),
 					SMTPD_OK, SMTPD_DECLINED);
 
-/* public methods */
-/* functions other modules can use */
-
-/* should be called at smtpd_hook_connect
- * at least by convention
- */
-SMTPD_DECLARE_NONSTD(void) smtpd_register_extension(smtpd_conn_rec *scr,
-                                                    const char *line)
-{
-    (*((char **)apr_array_push(scr->extensions))) =
-      apr_pstrdup(scr->p, line);
-}
-
-/* how to reset the transaction */
-SMTPD_DECLARE_NONSTD(void) smtpd_reset_transaction(smtpd_conn_rec *scr)
-{
-  /* REVIEW: don't know whether to run clear request first
-   * then run reset hooks, or run reset hooks then clear request
-   * depends on whether hooks want to save info before it gets cleared out
-   * or if they want to overwrite default values in the request rec
-   */
-    smtpd_run_reset_transaction(scr);
-
-    smtpd_clear_trans_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_read_type read_type)
-{
-    apr_status_t rc;
-    apr_bucket *e;
-    const char *str;
-    char *pos, *last_char = data;
-    apr_size_t len, bytes_handled = 0;
-    ap_filter_t *input_filters = read_type == SMTPD_READ_DATA ?
-      scr->transaction->input_filters :
-      scr->c->input_filters;
-
-    while (1) {
-        rc = ap_get_brigade(input_filters, scr->bb_in, AP_MODE_GETLINE,
-                            APR_BLOCK_READ, 0);
-        if (rc != APR_SUCCESS)
-            return rc;
-        
-        while(!APR_BRIGADE_EMPTY(scr->bb_in)) {
-            e = APR_BRIGADE_FIRST(scr->bb_in);
-            
-            rc = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
-            if (rc != APR_SUCCESS)
-                return rc;      
-
-            apr_bucket_delete(e);
-            
-            if (len == 0)
-                continue;
-            
-            /* Would this overrun our buffer?  If so, we'll die. */
-            if (dlen < bytes_handled + len) {
-                if (data) {
-                    /* ensure this string is NUL terminated */
-                    if (bytes_handled > 0) {
-                        data[bytes_handled-1] = '\0';
-                    }
-                    else {
-                        data[0] = '\0';
-                    }
-                }
-                return APR_ENOSPC;
-            }
-            
-            /* Just copy the rest of the data to the end of the old buffer. */
-            pos = data + bytes_handled;
-            memcpy(pos, str, len);
-            last_char = pos + len - 1;
-            
-            /* We've now processed that new data - update accordingly. */
-            bytes_handled += len;
-
-        }
-        
-        /* If we got a full line of input, stop reading */
-        if (last_char && (*last_char == APR_ASCII_LF)) {
-            break;
-        }
-    }
-    
-    /* Now NUL-terminate the string at the end of the line; 
-     * if the last-but-one character is a CR, terminate there */
-    if (last_char > data && last_char[-1] == APR_ASCII_CR) {
-        last_char--;
-    }
-    
-    *last_char = '\0';
-    if (outlen)
-        *outlen = last_char - data;
-    return APR_SUCCESS;
-}
-
-SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_multiline(smtpd_conn_rec *scr,
-                                                           int code,
-                                                           apr_array_header_t
-                                                           *msgs)
+apr_hash_t *smtpd_get_handlers()
 {
-    int i;
-    
-    for (i = 0; i < msgs->nelts - 1; i++) {
-        ap_fprintf(scr->c->output_filters, scr->bb_out, "%d-%s\r\n", code,
-                   ((char **)msgs->elts)[i]);
-        ap_fflush(scr->c->output_filters, scr->bb_out);
-    }
-    
-    ap_fprintf(scr->c->output_filters, scr->bb_out, "%d %s\r\n", code,
-               ((char **)msgs->elts)[i]);
-    ap_fflush(scr->c->output_filters, scr->bb_out);
-    
-    return APR_SUCCESS;
-}
-
-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);
-    ap_fflush(scr->c->output_filters, scr->bb_out);
-    
-    return APR_SUCCESS;
-}
-
-#define INSERT_BEFORE(f, before_this) ((before_this) == NULL \
-                           || (before_this)->frec->ftype > (f)->frec->ftype
\
-                           || (before_this)->r != (f)->r)
-SMTPD_DECLARE_NONSTD(ap_filter_t *)
-     smtpd_add_input_filter_handle(ap_filter_rec_t *frec, void *ctx, 
-                                   smtpd_conn_rec *scr)
-{
-    apr_pool_t* p = scr->p;
-    ap_filter_t *f = apr_palloc(p, sizeof(*f));
-    ap_filter_t **outf;
-
-    outf = &(scr->transaction->input_filters);
-
-    f->frec = frec;
-    f->ctx = ctx;
-    f->c = scr->c;
-    f->next = NULL;
-
-    if (INSERT_BEFORE(f, *outf)) {
-        f->next = *outf;
-        *outf = f;
-    }
-    else {
-        ap_filter_t *fscan = *outf;
-        while (!INSERT_BEFORE(f, fscan->next))
-            fscan = fscan->next;
-
-        f->next = fscan->next;
-	fscan->next = f;
-    }
-
-    return f;
+    return smtpd_handlers;
 }
 
-/* friend methods */
-/* only our sources can call these */
-
 void smtpd_clear_trans_rec(smtpd_conn_rec *scr)
 {
     smtpd_trans_rec *str = scr->transaction;
@@ -308,10 +141,6 @@
     str->helo = NULL;
     str->headers = apr_table_make(str->p, 5);
     str->input_filters = scr->c->input_filters;
-}
-
-apr_hash_t *smtpd_get_handlers() {
-    return smtpd_handlers;
 }
 
 apr_status_t smtpd_smtp_filter(ap_filter_t *f, apr_bucket_brigade *b,

Added: httpd/mod_smtpd/trunk/smtp_util.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/smtp_util.c?rev=265531&view=auto
==============================================================================
--- httpd/mod_smtpd/trunk/smtp_util.c (added)
+++ httpd/mod_smtpd/trunk/smtp_util.c Wed Aug 31 10:01:42 2005
@@ -0,0 +1,184 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_strings.h"
+#include "apr_tables.h"
+#include "util_filter.h"
+
+#include "mod_smtpd.h"
+#include "smtp.h"
+
+/* should be called at smtpd_hook_connect
+ * at least by convention
+ */
+SMTPD_DECLARE_NONSTD(void) smtpd_register_extension(smtpd_conn_rec *scr,
+                                                    const char *line)
+{
+    (*((char **)apr_array_push(scr->extensions))) =
+      apr_pstrdup(scr->p, line);
+}
+
+/* how to reset the transaction */
+SMTPD_DECLARE_NONSTD(void) smtpd_reset_transaction(smtpd_conn_rec *scr)
+{
+  /* REVIEW: don't know whether to run clear request first
+   * then run reset hooks, or run reset hooks then clear request
+   * depends on whether hooks want to save info before it gets cleared out
+   * or if they want to overwrite default values in the request rec
+   */
+    smtpd_run_reset_transaction(scr);
+
+    smtpd_clear_trans_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_read_type read_type)
+{
+    apr_status_t rc;
+    apr_bucket *e;
+    const char *str;
+    char *pos, *last_char = data;
+    apr_size_t len, bytes_handled = 0;
+    ap_filter_t *input_filters = read_type == SMTPD_READ_DATA ?
+      scr->transaction->input_filters :
+      scr->c->input_filters;
+
+    while (1) {
+        rc = ap_get_brigade(input_filters, scr->bb_in, AP_MODE_GETLINE,
+                            APR_BLOCK_READ, 0);
+        if (rc != APR_SUCCESS)
+            return rc;
+        
+        while(!APR_BRIGADE_EMPTY(scr->bb_in)) {
+            e = APR_BRIGADE_FIRST(scr->bb_in);
+            
+            rc = apr_bucket_read(e, &str, &len, APR_BLOCK_READ);
+            if (rc != APR_SUCCESS)
+                return rc;      
+
+            apr_bucket_delete(e);
+            
+            if (len == 0)
+                continue;
+            
+            /* Would this overrun our buffer?  If so, we'll die. */
+            if (dlen < bytes_handled + len) {
+                if (data) {
+                    /* ensure this string is NUL terminated */
+                    if (bytes_handled > 0) {
+                        data[bytes_handled-1] = '\0';
+                    }
+                    else {
+                        data[0] = '\0';
+                    }
+                }
+                return APR_ENOSPC;
+            }
+            
+            /* Just copy the rest of the data to the end of the old buffer. */
+            pos = data + bytes_handled;
+            memcpy(pos, str, len);
+            last_char = pos + len - 1;
+            
+            /* We've now processed that new data - update accordingly. */
+            bytes_handled += len;
+
+        }
+        
+        /* If we got a full line of input, stop reading */
+        if (last_char && (*last_char == APR_ASCII_LF)) {
+            break;
+        }
+    }
+    
+    /* Now NUL-terminate the string at the end of the line; 
+     * if the last-but-one character is a CR, terminate there */
+    if (last_char > data && last_char[-1] == APR_ASCII_CR) {
+        last_char--;
+    }
+    
+    *last_char = '\0';
+    if (outlen)
+        *outlen = last_char - data;
+    return APR_SUCCESS;
+}
+
+SMTPD_DECLARE_NONSTD(apr_status_t) smtpd_respond_multiline(smtpd_conn_rec *scr,
+                                                           int code,
+                                                           apr_array_header_t
+                                                           *msgs)
+{
+    int i;
+    
+    for (i = 0; i < msgs->nelts - 1; i++) {
+        ap_fprintf(scr->c->output_filters, scr->bb_out, "%d-%s\r\n", code,
+                   ((char **)msgs->elts)[i]);
+        ap_fflush(scr->c->output_filters, scr->bb_out);
+    }
+    
+    ap_fprintf(scr->c->output_filters, scr->bb_out, "%d %s\r\n", code,
+               ((char **)msgs->elts)[i]);
+    ap_fflush(scr->c->output_filters, scr->bb_out);
+    
+    return APR_SUCCESS;
+}
+
+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);
+    ap_fflush(scr->c->output_filters, scr->bb_out);
+    
+    return APR_SUCCESS;
+}
+
+#define INSERT_BEFORE(f, before_this) ((before_this) == NULL \
+                           || (before_this)->frec->ftype > (f)->frec->ftype
\
+                           || (before_this)->r != (f)->r)
+SMTPD_DECLARE_NONSTD(ap_filter_t *)
+     smtpd_add_input_filter_handle(ap_filter_rec_t *frec, void *ctx, 
+                                   smtpd_conn_rec *scr)
+{
+    apr_pool_t* p = scr->p;
+    ap_filter_t *f = apr_palloc(p, sizeof(*f));
+    ap_filter_t **outf;
+
+    outf = &(scr->transaction->input_filters);
+
+    f->frec = frec;
+    f->ctx = ctx;
+    f->c = scr->c;
+    f->next = NULL;
+
+    if (INSERT_BEFORE(f, *outf)) {
+        f->next = *outf;
+        *outf = f;
+    }
+    else {
+        ap_filter_t *fscan = *outf;
+        while (!INSERT_BEFORE(f, fscan->next))
+            fscan = fscan->next;
+
+        f->next = fscan->next;
+	fscan->next = f;
+    }
+
+    return f;
+}



Mime
View raw message