27 #pragma comment(lib, "wininet.lib")
30 #ifdef HAVE_CONFIG_H //
41 #include <curl/curl.h>
51 const std::string
ALPHA =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
63 for (
int i = 0; i < len; i++) {
65 if (s[i] <=
'9' && s[i] >=
'0')
66 value = (i == 0) ? (s[i] -
'0') : radix * value + (s[i] -
'0');
71 else if (radix == 16) {
73 if (s[i] <=
'9' && s[i] >= 0)
74 value = (i == 0) ? (s[i] -
'0') : radix * value + (s[i] -
'0');
76 else if (s[i] <=
'F' && s[i] >=
'A')
79 0) ? (s[i] -
'A') + 10 : radix * value + (s[i] -
'A') + 10;
81 else if (s[i] <=
'f' && s[i] >=
'a')
82 value =(i ==0) ? (s[i] -
'a') + 10 : radix * value + (s[i] -
'a') + 10;
99 return str << std::endl <<
"*************" << std::endl;
109 std::string& filename)
111 if(uri.find(
"http://")!=std::string::npos ||
112 uri.find(
"https://")!=std::string::npos ||
113 uri.find(
"ftp://") !=std::string::npos)
116 if (urlCache_.find(uri) != urlCache_.end()) {
118 filename=urlCache_[uri];
121 tfs.open(filename.c_str());
123 urlCache_.erase(uri);
131 filename=uri.substr(uri.rfind(
'/')+1);
132 if (filename.empty()) {
138 for (
int i = 0; i < 8; i++){
140 filename +=
ALPHA.at(rand()%52);
142 filename.append(
".wp-tmp");
145 std::string dir=
"/tmp/";
146 filename = dir + filename;
149 urlCache_[uri]=filename;
153 curl=curl_easy_init();
156 file=fopen(filename.c_str(),
"w");
159 fprintf(stderr,
"Can't open file %s: %s\n", filename.c_str(),
164 curl_easy_setopt(curl, CURLOPT_URL,uri.c_str());
165 curl_easy_setopt(curl,CURLOPT_FILE,(
void*)file);
166 curl_easy_setopt(curl,CURLOPT_TIMEOUT,60);
167 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
168 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
173 curl_easy_setopt(curl,CURLOPT_PROXYUSERPWD,tmp.c_str());
175 res = curl_easy_perform(curl);
177 curl_easy_cleanup(curl);
185 std::ofstream ofs(filename.c_str());
189 if(w3.Connect(uri.c_str())){
190 if(w3.Request(w3.GetURI())){
191 unsigned char buf[1024]=
"\0";
192 while((nread=w3.Response(buf, 1023))){
218 if ((p=uri.find(
"file:///"))!=std::string::npos)
220 uri = uri.substr(p+7, uri.length()-p-7);
222 else if ((p=uri.find(
"file://"))!=std::string::npos)
224 uri = uri.substr(p+6, uri.length()-p-6);
226 else if ((p=uri.find(
"file:/"))!=std::string::npos)
228 uri = uri.substr(p+5, uri.length()-p-5);
234 ifs.open(filename.c_str(),std::ios::in);
252 std::cerr<<field<<
": ";
257 tcgetattr(STDIN_FILENO, &term);
258 oflags = term.c_lflag;
259 term.c_lflag = oflags & ~(ECHO | ECHOK | ICANON);
260 term.c_cc[VTIME] = 1;
261 tcsetattr(STDIN_FILENO, TCSANOW, &term);
263 scanf(
"%s", password);
265 term.c_lflag = oflags;
266 term.c_cc[VTIME] = 0;
267 tcsetattr(STDIN_FILENO, TCSANOW, &term);
269 scanf(
"%s", password);
276 XmlUtils::winPost(
const std::string uri,
const std::string username,
277 const std::string password,
const std::string data,
278 std::string action,
char* &results)
282 const char* d = data.c_str() ;
283 if(w3.Connect(uri.c_str())){
284 w3.InitializePostArguments();
285 w3.setContentType(
"Content-Type: text/xml; charset=UTF-8\r\n");
286 w3.setAcceptTypes(
"Accept: text/xml\r\n");
287 w3.AddPostArgument(d,data.length());
288 std::string tmp=
"SOAPAction: ";
293 w3.setSoapAction(tmp.c_str());
295 if(w3.RequestPost(w3.GetURI())){
296 unsigned long nread = 0,tot=0;
299 while((nread=w3.Response(reinterpret_cast<unsigned char *>(buf), 1023))){
303 results = (
char*)malloc(
sizeof(
unsigned char) * (nread+1));
306 results = (
char*) realloc(results,
sizeof(
unsigned char) * (nread + tot+1));
308 memcpy (results+tot,buf,nread);
349 g_sProxyHost = sProxyHost;
363 g_sProxyUser = sProxyUser;
377 g_sProxyPass = sProxyPass;
std::map< std::string, std::string > urlCache_
static std::string g_sProxyUser
std::ostream & blk(std::ostream &str)
void WSDLPULL_EXPORT setProxyPass(const std::string &sProxyPass)
static std::string g_sProxyHost
static std::string g_sProxyPass
std::ostream & dbsp(std::ostream &str)
void WSDLPULL_EXPORT setProxyHost(const std::string &sProxyHost)
std::string WSDLPULL_EXPORT getProxyHost()
std::string WSDLPULL_EXPORT getProxyPass()
bool WSDLPULL_EXPORT getProxy()
bool WSDLPULL_EXPORT fetchUri(std::string uri, std::string &path)
std::string WSDLPULL_EXPORT getProxyUser()
std::string WSDLPULL_EXPORT acceptSecretKey(const std::string &field)
void WSDLPULL_EXPORT setProxyUser(const std::string &sProxyUser)
void WSDLPULL_EXPORT setProxy(const bool bProxy)
int parseInt(std::string s, int radix=10)