76 for (
int i = 0; i < len; i++) {
78 if (s[i] <=
'9' && s[i] >=
'0')
79 value = (i == 0) ? (s[i] -
'0') : radix * value + (s[i] -
'0');
84 else if (radix == 16) {
86 if (s[i] <=
'9' && s[i] >= 0)
87 value = (i == 0) ? (s[i] -
'0') : radix * value + (s[i] -
'0');
89 else if (s[i] <=
'F' && s[i] >=
'A')
92 0) ? (s[i] -
'A') + 10 : radix * value + (s[i] -
'A') + 10;
94 else if (s[i] <=
'f' && s[i] >=
'a')
95 value =(i ==0) ? (s[i] -
'a') + 10 : radix * value + (s[i] -
'a') + 10;
176 std::map<std::string, std::string>::iterator iter;
177 std::list<std::string> uris;
185 ::DeleteFile((LPCSTR)iter->second.c_str());
187 unlink(iter->second.c_str());
190 uris.push_back(iter->first);
195 while (!uris.empty()) {
237 static volatile int initialized = 0;
243 mymtx = CreateMutex(NULL, 0, NULL);
244 if (InterlockedCompareExchangePointer(&mtx, mymtx, NULL) != NULL)
248 WaitForSingleObject(mtx, 0);
256 static pthread_once_t url_once = PTHREAD_ONCE_INIT;
294 std::string& filename)
298 if (uri.find(
"http://") != std::string::npos ||
299 uri.find(
"https://") != std::string::npos ||
300 uri.find(
"ftp://") != std::string::npos) {
306 bool file_cached =
false;
310 if (!filename.empty()) {
312 tfs.open(filename.c_str());
313 file_cached = !tfs.fail();
329 curl=curl_easy_init();
332 file=fopen(filename.c_str(),
"w");
335 fprintf(stderr,
"Can't open file %s: %s\n", filename.c_str(),
340 curl_easy_setopt(curl, CURLOPT_URL,uri.c_str());
341 curl_easy_setopt(curl,CURLOPT_FILE,(
void*)file);
342 curl_easy_setopt(curl,CURLOPT_TIMEOUT,60);
343 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
344 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
349 curl_easy_setopt(curl,CURLOPT_PROXYUSERPWD,tmp.c_str());
351 res = curl_easy_perform(curl);
353 curl_easy_cleanup(curl);
361 std::ofstream ofs(filename.c_str());
365 if(w3.Connect(uri.c_str())){
366 if(w3.Request(w3.GetURI())){
367 unsigned char buf[1024]=
"\0";
368 while((nread=w3.Response(buf, 1023))){
408 std::string::size_type p;
409 p = uri.find(
"file:");
410 if ( p !=std::string::npos)
418 ifs.open(filename.c_str(),std::ios::in);
436 std::cerr<<field<<
": ";
441 tcgetattr(STDIN_FILENO, &term);
442 oflags = term.c_lflag;
443 term.c_lflag = oflags & ~(ECHO | ECHOK | ICANON);
444 term.c_cc[VTIME] = 1;
445 tcsetattr(STDIN_FILENO, TCSANOW, &term);
447 scanf(
"%s", password);
449 term.c_lflag = oflags;
450 term.c_cc[VTIME] = 0;
451 tcsetattr(STDIN_FILENO, TCSANOW, &term);
453 scanf(
"%s", password);