]> granicus.if.org Git - apache/commitdiff
* Move ap_timeout_parameter_parse from mod_proxy.c to server/util.c and thus
authorRuediger Pluem <rpluem@apache.org>
Wed, 22 Oct 2008 10:23:52 +0000 (10:23 +0000)
committerRuediger Pluem <rpluem@apache.org>
Wed, 22 Oct 2008 10:23:52 +0000 (10:23 +0000)
  make it part of the public API.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@707022 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/httpd.h
modules/proxy/mod_proxy.c
server/util.c

diff --git a/CHANGES b/CHANGES
index e0e1623e75039afa74a8e3d55bf74a9b7dd59c89..06c1e47314268770a92d89dfe38412b3e1e6e38b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) core: Add ap_timeout_parameter_parse to public API. [Ruediger Pluem]
+
   *) mod_proxy: Prevent segmentation faults by correctly flushing all buckets
      from the proxy backend. PR 45792 [Ruediger Pluem]
 
index 85814ee772c0e1ee79ee760a687b695194b0284f..8e217fa2651bf0387a43b6ddfce8d2c717bebfe2 100644 (file)
  * 20080830.0 (2.3.0-dev)  Cookies can be set on headers_out and err_headers_out
  * 20080920.0 (2.3.0-dev)  Add ap_mpm_register_timed_callback. 
  * 20080920.1 (2.3.0-dev)  Export mod_rewrite.h in the public API.
+ * 20080920.2 (2.3.0-dev)  Added ap_timeout_parameter_parse to util.c / httpd.h
  *
  */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20080920
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 2be3bf7361e3a41e1d5daf4112466c25bf1a3b35..57e8ed380f23f6e2c0df14b8d7ff9360dd9a217b 100644 (file)
@@ -1746,6 +1746,29 @@ AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
 AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
                                  const char *delim);
 
+/**
+ * Parse a given timeout parameter string into an apr_interval_time_t value.
+ * The unit of the time interval is given as postfix string to the numeric
+ * string. Currently the following units are understood:
+ *
+ * ms    : milliseconds
+ * s     : seconds
+ * mi[n] : minutes
+ * h     : hours
+ *
+ * If no unit is contained in the given timeout parameter the default_time_unit
+ * will be used instead.
+ * @param timeout_parameter The string containing the timeout parameter.
+ * @param timeout The timeout value to be returned.
+ * @param default_time_unit The default time unit to use if none is specified
+ * in timeout_parameter.
+ * @return Status value indicating whether the parsing was successful or not.
+ */
+AP_DECLARE(apr_status_t) ap_timeout_parameter_parse(
+                                               const char *timeout_parameter,
+                                               apr_interval_time_t *timeout,
+                                               const char *default_time_unit);
+
 /* Misc system hackery */
 /**
  * Given the name of an object in the file system determine if it is a directory
index 6be8d5f1c6536c19549ef774fb0e15f516dbe04d..f703129db260807234e21a8d345d6828e1e4d720 100644 (file)
@@ -41,76 +41,6 @@ static int ap_proxy_lb_worker_size(void)
     return sizeof(proxy_worker_stat);
 }
 
-/**
- * Parse a given timeout parameter string into an apr_interval_time_t value.
- * The unit of the time interval is given as postfix string to the numeric
- * string. Currently the following units are understood:
- *
- * ms    : milliseconds
- * s     : seconds
- * mi[n] : minutes
- * h     : hours
- *
- * If no unit is contained in the given timeout parameter the default_time_unit
- * will be used instead.
- * @param timeout_parameter The string containing the timeout parameter.
- * @param timeout The timeout value to be returned.
- * @param default_time_unit The default time unit to use if none is specified
- * in timeout_parameter.
- * @return Status value indicating whether the parsing was successful or not.
- */
-/*
- * XXX: Once this function has its final status parameter wise it makes sense
- * to move it to some of the util??? files under server/ as public API.
- */
-static apr_status_t ap_timeout_parameter_parse(const char *timeout_parameter,
-                                               apr_interval_time_t *timeout,
-                                               const char *default_time_unit)
-{
-    char *endp;
-    const char *time_str;
-    apr_int64_t tout;
-
-    tout = apr_strtoi64(timeout_parameter, &endp, 10);
-    if (errno) {
-        return errno;
-    }
-    if (!endp || !*endp) {
-        time_str = default_time_unit;
-    }
-    else {
-        time_str = endp;
-    }
-
-    switch (*time_str) {
-        /* Time is in seconds */
-    case 's':
-        *timeout = (apr_interval_time_t) apr_time_from_sec(tout);
-        break;
-    case 'h':
-        /* Time is in hours */
-        *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 3600);
-        break;
-    case 'm':
-        switch (*(++time_str)) {
-        /* Time is in miliseconds */
-        case 's':
-            *timeout = (apr_interval_time_t) tout * 1000;
-            break;
-        /* Time is in minutes */
-        case 'i':
-            *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 60);
-            break;
-        default:
-            return APR_EGENERAL;
-        }
-        break;
-    default:
-        return APR_EGENERAL;
-    }
-    return APR_SUCCESS;
-}
-
 /*
  * A Web proxy module. Stages:
  *
index de23e514e24bd22873b7468d497b42fd42b8b134..3651e05931af172a2b9b005f090d3e8151f3dead 100644 (file)
@@ -2152,3 +2152,71 @@ AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
                         delim, getpid());
 
 }
+
+/**
+ * Parse a given timeout parameter string into an apr_interval_time_t value.
+ * The unit of the time interval is given as postfix string to the numeric
+ * string. Currently the following units are understood:
+ *
+ * ms    : milliseconds
+ * s     : seconds
+ * mi[n] : minutes
+ * h     : hours
+ *
+ * If no unit is contained in the given timeout parameter the default_time_unit
+ * will be used instead.
+ * @param timeout_parameter The string containing the timeout parameter.
+ * @param timeout The timeout value to be returned.
+ * @param default_time_unit The default time unit to use if none is specified
+ * in timeout_parameter.
+ * @return Status value indicating whether the parsing was successful or not.
+ */
+AP_DECLARE(apr_status_t) ap_timeout_parameter_parse(
+                                               const char *timeout_parameter,
+                                               apr_interval_time_t *timeout,
+                                               const char *default_time_unit)
+{
+    char *endp;
+    const char *time_str;
+    apr_int64_t tout;
+
+    tout = apr_strtoi64(timeout_parameter, &endp, 10);
+    if (errno) {
+        return errno;
+    }
+    if (!endp || !*endp) {
+        time_str = default_time_unit;
+    }
+    else {
+        time_str = endp;
+    }
+
+    switch (*time_str) {
+        /* Time is in seconds */
+    case 's':
+        *timeout = (apr_interval_time_t) apr_time_from_sec(tout);
+        break;
+    case 'h':
+        /* Time is in hours */
+        *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 3600);
+        break;
+    case 'm':
+        switch (*(++time_str)) {
+        /* Time is in miliseconds */
+        case 's':
+            *timeout = (apr_interval_time_t) tout * 1000;
+            break;
+        /* Time is in minutes */
+        case 'i':
+            *timeout = (apr_interval_time_t) apr_time_from_sec(tout * 60);
+            break;
+        default:
+            return APR_EGENERAL;
+        }
+        break;
+    default:
+        return APR_EGENERAL;
+    }
+    return APR_SUCCESS;
+}
+