summaryrefslogtreecommitdiff
path: root/src/Misc.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-02-01 21:20:27 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-02-01 21:20:27 (GMT)
commitf86091d421989ead46940cc12b77e48cfb127608 (patch)
tree978f64c6ab2e90789e73ab3af52f9528429fe8a0 /src/Misc.cpp
parent038da72c61ea6a251d805e2de3662f240da52b02 (diff)
downloadpowder-f86091d421989ead46940cc12b77e48cfb127608.zip
powder-f86091d421989ead46940cc12b77e48cfb127608.tar.gz
Use useragent for version, fix URl encoding
Diffstat (limited to 'src/Misc.cpp')
-rw-r--r--src/Misc.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Misc.cpp b/src/Misc.cpp
index 1e73574..fcea100 100644
--- a/src/Misc.cpp
+++ b/src/Misc.cpp
@@ -205,6 +205,35 @@ void strcaturl(char *dst, char *src)
*d = 0;
}
+std::string URLEscape(std::string source)
+{
+ char * src = (char *)source.c_str();
+ char * dst = (char *)calloc((source.length()*3)+2, 1);
+ char *d;
+ unsigned char *s;
+
+ for (d=dst; *d; d++) ;
+
+ for (s=(unsigned char *)src; *s; s++)
+ {
+ if ((*s>='0' && *s<='9') ||
+ (*s>='a' && *s<='z') ||
+ (*s>='A' && *s<='Z'))
+ *(d++) = *s;
+ else
+ {
+ *(d++) = '%';
+ *(d++) = hex[*s>>4];
+ *(d++) = hex[*s&15];
+ }
+ }
+ *d = 0;
+
+ std::string finalString(dst);
+ free(dst);
+ return finalString;
+}
+
void strappend(char *dst, char *src)
{
char *d;