summaryrefslogtreecommitdiffstats
path: root/src/server/urldecode.h
diff options
context:
space:
mode:
authorSimon Rettberg2017-10-28 00:03:18 +0200
committerSimon Rettberg2017-10-28 00:03:18 +0200
commitdc6ba44ea66c471305908a8053d7de56d705e499 (patch)
treee38ca2ac8c67523c0d3e5145e4f050831f16c0a6 /src/server/urldecode.h
parent[SERVER] Use picohttpparser from h2o (diff)
downloaddnbd3-dc6ba44ea66c471305908a8053d7de56d705e499.tar.gz
dnbd3-dc6ba44ea66c471305908a8053d7de56d705e499.tar.xz
dnbd3-dc6ba44ea66c471305908a8053d7de56d705e499.zip
[SERVER] Add function to parse x-www-form-urlencoded strings
Use it to properly parse RPC queries. Will also come in handy when parsing POST body for calls that actually trigger any actions in the server (reload, alt-servers, ...)
Diffstat (limited to 'src/server/urldecode.h')
-rw-r--r--src/server/urldecode.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/server/urldecode.h b/src/server/urldecode.h
new file mode 100644
index 0000000..e27f8f8
--- /dev/null
+++ b/src/server/urldecode.h
@@ -0,0 +1,19 @@
+#ifndef _URLENCODE_H_
+#define _URLENCODE_H_
+
+#include "picohttpparser/picohttpparser.h"
+
+struct field {
+ struct string name;
+ struct string value;
+};
+
+/**
+ * decode given x-form-urlencoded string. Breaks constness rules by
+ * casting the const char* s from str to char* and modifying it, then
+ * populating out with pointers into it, so make sure the memory
+ * is actually writable.
+ */
+void urldecode(struct string* str, struct field *out, size_t *out_num);
+
+#endif