]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/httpget.cxx
Fix windows build
[simgear.git] / simgear / io / httpget.cxx
index 513bb4b22feea91243b7454dccb290d285e1da28..e10a29b41659dd3fc992b77358296ca5d40ce65b 100644 (file)
@@ -1,15 +1,18 @@
 
 #include <cstdio>
 #include <cstring>
+#include <signal.h>
 
-#include <unistd.h> // for STDOUT_FILENO
 #include <iostream>
 #include <boost/foreach.hpp>
 
+
 #include <simgear/io/sg_file.hxx>
 #include <simgear/io/HTTPClient.hxx>
 #include <simgear/io/HTTPRequest.hxx>
 #include <simgear/io/sg_netChannel.hxx>
+#include <simgear/misc/strutils.hxx>
+#include <simgear/misc/sg_sleep.hxx>
 
 using namespace simgear;
 using std::cout;
@@ -119,11 +122,23 @@ int main(int argc, char* argv[])
     } // of arguments iteration
 
     if (!proxy.empty()) {
-        cl.setProxy(proxy, proxyAuth);
+        int colonPos = proxy.find(':');
+        string proxyHost = proxy;
+        int proxyPort = 8800;
+        if (colonPos >= 0) {
+            proxyHost = proxy.substr(0, colonPos);
+            proxyPort = strutils::to_int(proxy.substr(colonPos + 1));
+        }
+        
+        cl.setProxy(proxyHost, proxyPort, proxyAuth);
     }
 
+#ifndef WIN32
+    signal(SIGPIPE, SIG_IGN);
+#endif
+
     if (!outFile) {
-        outFile = new SGFile(STDOUT_FILENO);
+        outFile = new SGFile(fileno(stdout));
     }
 
     if (url.empty()) {
@@ -140,9 +155,10 @@ int main(int argc, char* argv[])
     cl.makeRequest(req);
     
     while (!req->complete()) {
-        NetChannel::poll(100);
+        cl.update();
+        sleepForMSec(100);
     }
-    
+        
     if (req->responseCode() != 200) {
         cerr << "got response:" << req->responseCode() << endl;
         cerr << "\treason:" << req->responseReason() << endl;