]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
New support function: ap_getword_conf2[_nc] which acts
authorJim Jagielski <jim@apache.org>
Wed, 30 Dec 2015 12:03:01 +0000 (12:03 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 30 Dec 2015 12:03:01 +0000 (12:03 +0000)
just like ap_getword_conf[_nc] but allows for {} to be
used as word quotes. That is:

   {Hello World} Foo Bar
   "Hello World" Foo Bar

are equiv.

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

include/ap_mmn.h
include/httpd.h
server/util.c

index 7e05d8658297f96568c7e4bfff39f32469e240f6..53e2f1e1b25d7e0f32361aaae9f5d575bbcfff9d 100644 (file)
  *                         conn_rec.
  * 20150222.6 (2.5.0-dev)  Add async_filter to conn_rec.
  * 20150222.7 (2.5.0-dev)  Add ap_casecmpstr[n]();
+ * 20150222.8 (2.5.0-dev)  Add ap_getword_conf2[_nc]();
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20150222
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 7                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 8                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 1ac9a23f2e927e51628a0f7a26253e71b9c3d5ab..a3dcf4cec2951608bb3e47591746b56d14503eb4 100644 (file)
@@ -1532,6 +1532,25 @@ AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line);
  */
 AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
 
+/**
+ * Get the second word in the string paying attention to quoting,
+ * with {...} supported as well as "..." and '...'
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+ */
+AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line);
+
+/**
+ * Get the second word in the string paying attention to quoting,
+ * with {...} supported as well as "..." and '...'
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+ * @note The same as ap_getword_conf2(), except it doesn't use const char **.
+ */
+AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line);
+
 /**
  * Check a string for any config define or environment variable construct
  * and replace each of them by the value of that variable, if it exists.
index 62299f7c3039325b5504f4be7c9f0bdbfbab096b..f628d78a56b3d5d50d3f7a2a947f9e95712394e6 100644 (file)
@@ -821,6 +821,60 @@ AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line)
     return res;
 }
 
+AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line)
+{
+    return ap_getword_conf2(p, (const char **) line);
+}
+
+AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line)
+{
+    const char *str = *line, *strend;
+    char *res;
+    char quote;
+    int count = 1;
+
+    while (apr_isspace(*str))
+        ++str;
+
+    if (!*str) {
+        *line = str;
+        return "";
+    }
+
+    if ((quote = *str) == '"' || quote == '\'')
+        return ap_getword_conf(p, line);
+
+    if (quote == '{') {
+        strend = str + 1;
+        while (*strend) {
+            if (*strend == '}' && !--count)
+                break;
+            if (*strend == '{')
+                ++count;
+            if (*strend == '\\' && strend[1] && strend[1] == '\\') {
+                ++strend;
+            }
+            ++strend;
+        }
+        res = substring_conf(p, str + 1, strend - str - 1, 0);
+
+        if (*strend == '}')
+            ++strend;
+    }
+    else {
+        strend = str;
+        while (*strend && !apr_isspace(*strend))
+            ++strend;
+
+        res = substring_conf(p, str, strend - str, 0);
+    }
+
+    while (apr_isspace(*strend))
+        ++strend;
+    *line = strend;
+    return res;
+}
+
 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp)
 {
 #ifdef DEBUG