*/
AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
+/**
+ * Get the second word in the string paying attention to quoting.
+ * The format {...} can be used instead of quotes with this implementation
+ * @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
+ * The format {...} can be used instead of quotes with this implementation
+ * @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.
#endif
}
-AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line)
-{
- return ap_getword_conf(p, (const char **) line);
-}
-
-AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line)
+static char *getword_conf_ex(apr_pool_t *p, const char **line, int curlyok)
{
const char *str = *line, *strend;
char *res;
char quote;
+ char curly = '{';
while (apr_isspace(*str))
++str;
return "";
}
- if ((quote = *str) == '"' || quote == '\'') {
+ if ((quote = *str) == '"' || quote == '\'' || quote == (curlyok ? curly : '\'')) {
+ if (quote == curly) {
+ /* only true if curlyok and we matched */
+ quote = '}';
+ }
strend = str + 1;
while (*strend && *strend != quote) {
if (*strend == '\\' && strend[1] &&
return res;
}
+AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line)
+{
+ return getword_conf_ex(p, (const char **) line, 0);
+}
+
+AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line)
+{
+ return getword_conf_ex(p, line, 0);
+}
+
+AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line)
+{
+ return getword_conf_ex(p, (const char **) line, 1);
+}
+
+AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line)
+{
+ return getword_conf_ex(p, line, 1);
+}
+
AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp)
{
#ifdef DEBUG