char *regexp_escape ( const char *str );
+/* URL decoding */
+char to_hex(char code);
+char *url_encode(char *str);
+
static inline int32_t deltaI32(int32_t a, int32_t b) { return (a > b) ? (a - b) : (b - a); }
static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - b) : (b - a); }
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
+#include <ctype.h>
#include "tvheadend.h"
#if defined(PLATFORM_DARWIN)
*b = 0;
return tmp;
}
+
+/* Converts an integer value to its hex character
+ http://www.geekhideout.com/urlcode.shtml */
+char to_hex(char code) {
+ static char hex[] = "0123456789abcdef";
+ return hex[code & 15];
+}
+
+/* Returns a url-encoded version of str
+ IMPORTANT: be sure to free() the returned string after use
+ http://www.geekhideout.com/urlcode.shtml */
+char *url_encode(char *str) {
+ char *pstr = str, *buf = malloc(strlen(str) * 3 + 1), *pbuf = buf;
+ while (*pstr) {
+ if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
+ *pbuf++ = *pstr;
+ /*else if (*pstr == ' ')
+ *pbuf++ = '+';*/
+ else
+ *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
+ pstr++;
+ }
+ *pbuf = '\0';
+ return buf;
+}
+