httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ic...@apache.org
Subject svn commit: r1696264 - in /httpd/httpd/trunk: include/httpd.h modules/http2/h2_switch.c server/protocol.c server/util.c
Date Mon, 17 Aug 2015 12:45:57 GMT
Author: icing
Date: Mon Aug 17 12:45:57 2015
New Revision: 1696264

URL: http://svn.apache.org/r1696264
Log:
introducing ap_array_index in util, used in protocol and mod_h2

Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/modules/http2/h2_switch.c
    httpd/httpd/trunk/server/protocol.c
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1696264&r1=1696263&r2=1696264&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Mon Aug 17 12:45:57 2015
@@ -2402,6 +2402,14 @@ AP_DECLARE(char *) ap_get_exec_line(apr_
 
 #define AP_NORESTART APR_OS_START_USEERR + 1
 
+/**
+ * Get the index of the string in the array or -1 if not found.
+ * @param array the array the check
+ * @param s the string to find
+ * @return index of string in array or -1
+ */
+AP_DECLARE(int) ap_array_index(apr_array_header_t *array, const char *s);
+
 #ifdef __cplusplus
 }
 #endif

Modified: httpd/httpd/trunk/modules/http2/h2_switch.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_switch.c?rev=1696264&r1=1696263&r2=1696264&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_switch.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_switch.c Mon Aug 17 12:45:57 2015
@@ -60,18 +60,6 @@ apr_status_t h2_switch_init(apr_pool_t *
 static const char *const mod_ssl[]        = { "mod_ssl.c", NULL};
 static const char *const mod_core[]       = { "core.c", NULL};
 
-static int h2_util_array_index(const apr_array_header_t *array, const char *s)
-{
-    int i;
-    for (i = 0; i < array->nelts; i++) {
-        const char *p = APR_ARRAY_IDX(array, i, const char*);
-        if (!strcmp(p, s)) {
-            return i;
-        }
-    }
-    return -1;
-}
-
 static int h2_protocol_propose(conn_rec *c, request_rec *r,
                                server_rec *s,
                                const apr_array_header_t *offers,
@@ -125,7 +113,7 @@ static int h2_protocol_propose(conn_rec
         /* Add all protocols we know (tls or clear) and that
          * were offered as options for the switch. 
          */
-        if (h2_util_array_index(offers, *protos) >= 0) {
+        if (ap_array_index(offers, *protos) >= 0) {
             ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
                           "proposing protocol '%s'", *protos);
             APR_ARRAY_PUSH(proposals, const char*) = *protos;

Modified: httpd/httpd/trunk/server/protocol.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/protocol.c?rev=1696264&r1=1696263&r2=1696264&view=diff
==============================================================================
--- httpd/httpd/trunk/server/protocol.c (original)
+++ httpd/httpd/trunk/server/protocol.c Mon Aug 17 12:45:57 2015
@@ -1947,19 +1947,6 @@ AP_DECLARE(void) ap_send_interim_respons
     apr_brigade_destroy(x.bb);
 }
 
-/* Something like this must be in APR, only I do not find it... */
-static int array_index(apr_array_header_t *array, const char *s)
-{
-    int i;
-    for (i = 0; i < array->nelts; i++) {
-        const char *p = APR_ARRAY_IDX(array, i, const char *);
-        if (!strcmp(p, s)) {
-            return i;
-        }
-    }
-    return -1;
-}
-
 /*
  * Compare two protocol identifier. Result is similar to strcmp():
  * 0 gives same precedence, >0 means proto1 is preferred.
@@ -1969,8 +1956,8 @@ static int protocol_cmp(apr_array_header
                         const char *proto2)
 {
     if (preferences && preferences->nelts > 0) {
-        int index1 = array_index(preferences, proto1);
-        int index2 = array_index(preferences, proto2);
+        int index1 = ap_array_index(preferences, proto1);
+        int index2 = ap_array_index(preferences, proto2);
         if (index2 > index1) {
             return (index1 >= 0) ? 1 : -1;
         }
@@ -2013,8 +2000,8 @@ AP_DECLARE(const char *) ap_select_proto
         /* If the existing protocol has not been proposed, but is a choice,
          * add it to the proposals implicitly.
          */
-        if (array_index(proposals, existing) < 0 
-            && array_index(choices, existing) >= 0) {
+        if (ap_array_index(proposals, existing) < 0 
+            && ap_array_index(choices, existing) >= 0) {
             APR_ARRAY_PUSH(proposals, const char*) = existing;
         }
         
@@ -2028,7 +2015,7 @@ AP_DECLARE(const char *) ap_select_proto
         for (i = 0; i < proposals->nelts; ++i) {
             const char *p = APR_ARRAY_IDX(proposals, i, const char *);
             if (conf->protocols->nelts > 0 
-                && array_index(conf->protocols, p) < 0) {
+                && ap_array_index(conf->protocols, p) < 0) {
                 /* not a permitted protocol here */
                 continue;
             }

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1696264&r1=1696263&r2=1696264&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Mon Aug 17 12:45:57 2015
@@ -3148,3 +3148,16 @@ AP_DECLARE(char *) ap_get_exec_line(apr_
 
     return apr_pstrndup(p, buf, k);
 }
+
+AP_DECLARE(int) ap_array_index(apr_array_header_t *array, const char *s)
+{
+    int i;
+    for (i = 0; i < array->nelts; i++) {
+        const char *p = APR_ARRAY_IDX(array, i, const char *);
+        if (!strcmp(p, s)) {
+            return i;
+        }
+    }
+    return -1;
+}
+



Mime
View raw message