win32sockets.c is now added with winsock init/cleanup example functions
authorDaniel Stenberg <daniel@haxx.se>
Tue, 20 Feb 2001 13:56:38 +0000 (13:56 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Feb 2001 13:56:38 +0000 (13:56 +0000)
docs/examples/Makefile.am
docs/examples/curlgtk.c
docs/examples/postit.c
docs/examples/sepheaders.c
docs/examples/simple.c
docs/examples/win32sockets.c [new file with mode: 0644]

index b8e9bc6..35b0a88 100644 (file)
@@ -6,6 +6,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
 
 EXTRA_DIST = 
        README curlgtk.c sepheaders.c simple.c postit.c \
+       win32sockets.c \
        getpageinvar.php simpleget.php simplepost.php
 
 all:
index 48b10e9..7c9ce2a 100644 (file)
@@ -1,4 +1,12 @@
-/* curlgtk.c */
+/*****************************************************************************
+ *                                  _   _ ____  _     
+ *  Project                     ___| | | |  _ \| |    
+ *                             / __| | | | |_) | |    
+ *                            | (__| |_| |  _ <| |___ 
+ *                             \___|\___/|_| \_\_____|
+ *
+ * $Id$
+ */
 /* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
 /* an attempt to use the curl library in concert with a gtk-threaded application */
 
index 710a149..e811aa2 100644 (file)
@@ -21,6 +21,9 @@
  * This exact source code has not been verified to work.
  */
 
+/* to make this work under windows, use the win32-functions from the
+   win32socket.c file as well */
+
 #include <stdio.h>
 
 #include <curl/curl.h>
index 724e141..ead5572 100644 (file)
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ *                                  _   _ ____  _     
+ *  Project                     ___| | | |  _ \| |    
+ *                             / __| | | | |_) | |    
+ *                            | (__| |_| |  _ <| |___ 
+ *                             \___|\___/|_| \_\_____|
+ *
+ * $Id$
+ */
+
+/* to make this work under windows, use the win32-functions from the
+   win32socket.c file as well */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
index e6138c4..907d5e8 100644 (file)
@@ -1,9 +1,22 @@
+/*****************************************************************************
+ *                                  _   _ ____  _     
+ *  Project                     ___| | | |  _ \| |    
+ *                             / __| | | | |_) | |    
+ *                            | (__| |_| |  _ <| |___ 
+ *                             \___|\___/|_| \_\_____|
+ *
+ * $Id$
+ */
+
 #include <stdio.h>
 
 #include <curl/curl.h>
 #include <curl/types.h>
 #include <curl/easy.h>
 
+/* to make this work under windows, use the win32-functions from the
+   win32socket.c file as well */
+
 int main(int argc, char **argv)
 {
   CURL *curl;
diff --git a/docs/examples/win32sockets.c b/docs/examples/win32sockets.c
new file mode 100644 (file)
index 0000000..f052299
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * These are example functions doing socket init that Windows
+ * require. If you don't use windows, you can safely ignore this crap.
+ */
+
+#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
+static void win32_cleanup(void)
+{
+  WSACleanup();
+}
+
+static CURLcode win32_init(void)
+{
+  WORD wVersionRequested;  
+  WSADATA wsaData; 
+  int err; 
+  wVersionRequested = MAKEWORD(1, 1); 
+    
+  err = WSAStartup(wVersionRequested, &wsaData); 
+    
+  if (err != 0) 
+    /* Tell the user that we couldn't find a useable */ 
+    /* winsock.dll.     */ 
+    return 1;
+    
+  /* Confirm that the Windows Sockets DLL supports 1.1.*/ 
+  /* Note that if the DLL supports versions greater */ 
+  /* than 1.1 in addition to 1.1, it will still return */ 
+  /* 1.1 in wVersion since that is the version we */ 
+  /* requested. */ 
+    
+  if ( LOBYTE( wsaData.wVersion ) != 1 || 
+       HIBYTE( wsaData.wVersion ) != 1 ) { 
+    /* Tell the user that we couldn't find a useable */ 
+
+    /* winsock.dll. */ 
+    WSACleanup(); 
+    return 1; 
+  }
+  return 0; /* 0 is ok */
+}