summaryrefslogtreecommitdiff
path: root/src/CurlTask.cc
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-20 21:31:41 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-20 21:31:41 -0700
commitdf9b8f8ae7a540988c20fdffaaff2442c349873a (patch)
treeff9be69934b6896c8d7e91412b63dd9cd9b37341 /src/CurlTask.cc
parentfcc66ce9f5d6db995536beab5539fd47e490bf14 (diff)
Moving tokenize, percentEncode and percentDecode around. Fixing a few warnings. Workarounding c-ares and pthreads compilation issue with unicode.
Diffstat (limited to 'src/CurlTask.cc')
-rw-r--r--src/CurlTask.cc81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/CurlTask.cc b/src/CurlTask.cc
index 2a792f9..2c37514 100644
--- a/src/CurlTask.cc
+++ b/src/CurlTask.cc
@@ -38,87 +38,6 @@ int Balau::CurlTask::debugFunctionStatic(CURL * easy, curl_infotype info, char *
return curlTask->debugFunction(info, str, str_len);
}
-Balau::String Balau::CurlTask::percentEncode(const String & src) {
- const size_t size = src.strlen();
- String ret;
- ret.reserve(size);
-
- static char toHex[] = "0123456789ABCDEF";
-
- for (size_t i = 0; i < size; i++) {
- char c = src[i];
- if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c == '-') || (c == '.') || (c == '_') || (c == '~')) {
- ret += c;
- } else {
- ret += '%';
- ret += toHex[c >> 4];
- ret += toHex[c & 15];
- }
- }
-
- return ret;
-}
-
-Balau::String Balau::CurlTask::percentDecode(const String & src) {
- const size_t size = src.strlen();
- String ret;
- ret.reserve(size);
-
- for (size_t i = 0; i < size; i++) {
- char c = src[i];
- if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c == '-') || (c == '.') || (c == '_') || (c == '~')) {
- ret += c;
- } else if ((c == '%') && ((i + 2) < size)) {
- char h1 = src[i + 1];
- char h2 = src[i + 2];
- if ((h1 >= '0') && (h1 <= '9')) {
- c = h1 - '0';
- } else if ((h1 >= 'A') && (h1 <= 'F')) {
- c = h1 - 'A' + 10;
- } else {
- // invalid
- return ret;
- }
- c <<= 4;
- if ((h2 >= '0') && (h2 <= '9')) {
- c |= h2 - '0';
- } else if ((h2 >= 'A') && (h2 <= 'F')) {
- c |= h2 - 'A' + 10;
- } else {
- // invalid
- return ret;
- }
- i += 2;
- } else {
- // invalid
- return ret;
- }
- }
-
- return ret;
-}
-
-std::vector<Balau::String> Balau::CurlTask::tokenize(const String & str, const String & delimiters, bool trimEmpty) {
- std::vector<String> tokens;
- size_t pos, lastPos = 0;
- for (;;) {
- pos = str.find_first_of(delimiters, lastPos);
- if (pos == String::npos) {
- pos = str.strlen();
-
- if ((pos != lastPos) || !trimEmpty)
- tokens.push_back(str.extract(lastPos, pos));
-
- return tokens;
- } else {
- if ((pos != lastPos) || !trimEmpty)
- tokens.push_back(str.extract(lastPos, pos));
- }
-
- lastPos = pos + 1;
- }
-}
-
Balau::DownloadTask::DownloadTask(const Balau::String & url) {
curl_easy_setopt(m_curlHandle, CURLOPT_URL, url.to_charp());
m_name.set("DownloadTask(%s)", url.to_charp());