tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r591507 - in /tomcat/connectors/trunk/jk/native: apache-1.3/mod_jk.c apache-2.0/mod_jk.c
Date Fri, 02 Nov 2007 23:09:53 GMT
Author: rjung
Date: Fri Nov  2 16:09:52 2007
New Revision: 591507

URL: http://svn.apache.org/viewvc?rev=591507&view=rev
Log:
Add utility function to mod_jk.c for merging
two tables.
Copy an entry from src to dst, if there is no
entry for the same key in dst.

Modified:
    tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
    tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c

Modified: tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c?rev=591507&r1=591506&r2=591507&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c Fri Nov  2 16:09:52 2007
@@ -2278,6 +2278,26 @@
 }
 
 
+/*
+ * Utility - copy items from apr table src to dst,
+ * for keys that exist in src but not in dst.
+ */
+static void merge_apr_table(apr_table_t *src, apr_table_t *dst)
+{
+    int i;
+    const array_header *arr;
+    const table_entry *elts;
+
+    arr = ap_table_elts(src);
+    elts = (const table_entry *)arr->elts;
+    for (i = 0; i < arr->nelts; ++i) {
+        if (!ap_table_get(dst, elts[i].key)) {
+            ap_table_setn(dst, elts[i].key, elts[i].val);
+        }
+    }
+}
+
+
 static void *merge_jk_config(ap_pool * p, void *basev, void *overridesv)
 {
     jk_server_conf_t *base = (jk_server_conf_t *) basev;
@@ -2314,29 +2334,14 @@
     overrides->options |= (base->options & ~base->exclude_options);
 
     if (base->envvars_in_use) {
-        int i;
-        const array_header *arr;
-        const table_entry *elts;
 
-        arr = ap_table_elts(base->envvars);
-        if (arr) {
+        if (ap_table_elts(base->envvars)) {
             overrides->envvars_in_use = JK_TRUE;
-            elts = (const table_entry *)arr->elts;
-            for (i = 0; i < arr->nelts; ++i) {
-                if (!ap_table_get(overrides->envvars, elts[i].key)) {
-                    ap_table_setn(overrides->envvars, elts[i].key, elts[i].val);
-                }
-            }
+            merge_apr_table(base->envvars, overrides->envvars);
         }
-        arr = ap_table_elts(base->envvars_def);
-        if (arr) {
+        if (ap_table_elts(base->envvars_def)) {
             overrides->envvars_in_use = JK_TRUE;
-            elts = (const table_entry *)arr->elts;
-            for (i = 0; i < arr->nelts; ++i) {
-                if (!ap_table_get(overrides->envvars_def, elts[i].key)) {
-                    ap_table_setn(overrides->envvars_def, elts[i].key, elts[i].val);
-                }
-            }
+            merge_apr_table(base->envvars_def, overrides->envvars_def);
         }
     }
 

Modified: tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c?rev=591507&r1=591506&r2=591507&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c Fri Nov  2 16:09:52 2007
@@ -2398,6 +2398,26 @@
 }
 
 
+/*
+ * Utility - copy items from apr table src to dst,
+ * for keys that exist in src but not in dst.
+ */
+static void merge_apr_table(apr_table_t *src, apr_table_t *dst)
+{
+    int i;
+    const apr_array_header_t *arr;
+    const apr_table_entry_t *elts;
+
+    arr = apr_table_elts(src);
+    elts = (const apr_table_entry_t *)arr->elts;
+    for (i = 0; i < arr->nelts; ++i) {
+        if (!apr_table_get(dst, elts[i].key)) {
+            apr_table_setn(dst, elts[i].key, elts[i].val);
+        }
+    }
+}
+
+
 /** Standard apache callback, merge jk options specified in <Directory>
     context or <Host>.
  */
@@ -2437,29 +2457,13 @@
     overrides->options |= (base->options & ~base->exclude_options);
 
     if (base->envvars_in_use) {
-        int i;
-        const apr_array_header_t *arr;
-        const apr_table_entry_t *elts;
-
-        arr = apr_table_elts(base->envvars);
-        if (arr) {
+        if (apr_table_elts(base->envvars)) {
             overrides->envvars_in_use = JK_TRUE;
-            elts = (const apr_table_entry_t *)arr->elts;
-            for (i = 0; i < arr->nelts; ++i) {
-                if (!apr_table_get(overrides->envvars, elts[i].key)) {
-                    apr_table_setn(overrides->envvars, elts[i].key, elts[i].val);
-                }
-            }
+            merge_apr_table(base->envvars, overrides->envvars);
         }
-        arr = apr_table_elts(base->envvars_def);
-        if (arr) {
+        if (apr_table_elts(base->envvars_def)) {
             overrides->envvars_in_use = JK_TRUE;
-            elts = (const apr_table_entry_t *)arr->elts;
-            for (i = 0; i < arr->nelts; ++i) {
-                if (!apr_table_get(overrides->envvars_def, elts[i].key)) {
-                    apr_table_setn(overrides->envvars_def, elts[i].key, elts[i].val);
-                }
-            }
+            merge_apr_table(base->envvars_def, overrides->envvars_def);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message