Diff
Not logged in

Differences From:

File src/http.c part of check-in [83c876b447] - Win32 port: compiles, all tests pass but many functions fail due to path separators. Incomplete. Path fixes to come next by anonymous on 2007-09-21 21:53:28. [view]

To:

File src/http.c part of check-in [c7278fd013] - Win32 port now functional except network operations. This commit was done on windows :-). See win32.txt for status of all commands. No networking commands are functional yet. All path operations are now functioning. by jnc on 2007-09-22 06:47:11. [view]

@@ -42,8 +42,26 @@
 ** Persistent information about the HTTP connection.
 */
 static FILE *pSocket = 0;   /* The socket on which we talk to the server */
 
+#ifdef __MINGW32__
+static WSADATA ws_info;
+#endif
+
+static void ws_init(){
+#ifdef __MINGW32__
+  if (WSAStartup(MAKEWORD(1,1), &ws_info) != 0){
+    fossil_panic("can't initialize winsock");
+  }
+#endif
+}
+
+static void ws_cleanup(){
+#ifdef __MINGW32__
+  WSACleanup();
+#endif
+}
+
 /*
 ** Open a socket connection to the server.  Return 0 on success and
 ** non-zero if an error occurs.
 */
@@ -52,8 +70,10 @@
   static int addrIsInit = 0;       /* True once addr is initialized */
   int s;
 
   if( !addrIsInit ){
+    ws_init();
+
     addr.sin_family = AF_INET;
     addr.sin_port = htons(g.urlPort);
     *(int*)&addr.sin_addr = inet_addr(g.urlName);
     if( -1 == *(int*)&addr.sin_addr ){
@@ -270,6 +290,7 @@
 void http_close(void){
   if( pSocket ){
     fclose(pSocket);
     pSocket = 0;
+    ws_cleanup();
   }
 }