/*
* This file is part of DisOrder.
- * Copyright (C) 2004, 2005 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* USA
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <stdio.h>
+#include "common.h"
#include "mem.h"
#include "kvp.h"
return 0;
}
-const char *urlencodestring(const char *s) {
+/** @brief URL-encode @p s
+ * @param s String to encode
+ * @return Encoded string
+ */
+char *urlencodestring(const char *s) {
struct dynstr d;
dynstr_init(&d);
return d.vec;
}
+/** @brief URL-decode @p s
+ * @param s String to decode
+ * @param ns Length of string
+ * @return Decoded string or NULL
+ */
+char *urldecodestring(const char *s, size_t ns) {
+ struct dynstr d;
+
+ dynstr_init(&d);
+ if(urldecode(sink_dynstr(&d), s, ns))
+ return NULL;
+ dynstr_terminate(&d);
+ return d.vec;
+}
+
char *kvp_urlencode(const struct kvp *kvp, size_t *np) {
struct dynstr d;
struct sink *sink;
comment-column:40
End:
*/
-/* arch-tag:7c983bde915ec06fbda8d8cdc465dd9d */