aboutsummaryrefslogtreecommitdiff
path: root/web/apache/service.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-14 16:29:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-16 16:42:35 +0200
commit03905bcf1bcfd9e7932fcac4283c5817058a25ce (patch)
treeb643d3bedf436bfcd8956b25133d5674b6b18e36 /web/apache/service.cxx
parent96281a6c4f818311a6df90c0d8b8f537a61e1090 (diff)
Invent root path web interface configuration option
Diffstat (limited to 'web/apache/service.cxx')
-rw-r--r--web/apache/service.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/web/apache/service.cxx b/web/apache/service.cxx
index 782e09b..42a31bd 100644
--- a/web/apache/service.cxx
+++ b/web/apache/service.cxx
@@ -10,8 +10,10 @@
#include <httpd.h>
#include <http_config.h>
-#include <memory> // unique_ptr
+#include <memory> // unique_ptr
#include <string>
+#include <cassert>
+#include <cstring> // strlen()
#include <exception>
using namespace std;
@@ -47,7 +49,10 @@ namespace web
reinterpret_cast<cmd_func> (add_option),
this,
RSRC_CONF,
- TAKE1,
+ // Move away from TAKE1 to be able to handle empty string and
+ // no-value.
+ //
+ RAW_ARGS,
nullptr
};
}
@@ -58,19 +63,31 @@ namespace web
}
const char* service::
- add_option (cmd_parms* parms, void*, const char* value) noexcept
+ add_option (cmd_parms* parms, void*, const char* args) noexcept
{
service& srv (*reinterpret_cast<service*> (parms->cmd->cmd_data));
string name (parms->cmd->name + srv.name_.length () + 1);
+ optional<string> value;
+
+ // 'args' is an optionally double-quoted string. Use double quotes to
+ // distinguish empty string from no-value case.
+ //
+ assert (args != nullptr);
+ if (auto l = strlen (args))
+ value = l >= 2 && args[0] == '"' && args[l - 1] == '"'
+ ? string (args + 1, l - 2)
+ : args;
for (auto& v: srv.options_)
+ {
if (v.name == name)
{
v.value = value;
return 0;
}
+ }
- srv.options_.emplace_back (name, string (value));
+ srv.options_.emplace_back (name, value);
return 0;
}