/*
* 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
* @param s String to encode
* @return Encoded string
*/
-const char *urlencodestring(const char *s) {
+char *urlencodestring(const char *s) {
struct dynstr d;
dynstr_init(&d);
/** @brief URL-decode @p s
* @param s String to decode
* @param ns Length of string
- * @return Decoded string
+ * @return Decoded string or NULL
*/
-const char *urldecodestring(const char *s, size_t ns) {
+char *urldecodestring(const char *s, size_t ns) {
struct dynstr d;
dynstr_init(&d);
- urldecode(sink_dynstr(&d), s, ns);
+ if(urldecode(sink_dynstr(&d), s, ns))
+ return NULL;
dynstr_terminate(&d);
return d.vec;
}