aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-02-20 13:56:38 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-02-20 13:56:38 +0000
commitada9bc2b24ecb73c78e07aed933dc99f1d44ed3c (patch)
tree2a404577e750f7986496a30da657d180b219705c
parent43da41e73ea600e26916ac45833e06145251087f (diff)
win32sockets.c is now added with winsock init/cleanup example functions
-rw-r--r--docs/examples/Makefile.am1
-rw-r--r--docs/examples/curlgtk.c10
-rw-r--r--docs/examples/postit.c3
-rw-r--r--docs/examples/sepheaders.c13
-rw-r--r--docs/examples/simple.c13
-rw-r--r--docs/examples/win32sockets.c41
6 files changed, 80 insertions, 1 deletions
diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am
index b8e9bc6a2..35b0a8817 100644
--- a/docs/examples/Makefile.am
+++ b/docs/examples/Makefile.am
@@ -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:
diff --git a/docs/examples/curlgtk.c b/docs/examples/curlgtk.c
index 48b10e9c7..7c9ce2a1b 100644
--- a/docs/examples/curlgtk.c
+++ b/docs/examples/curlgtk.c
@@ -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 */
diff --git a/docs/examples/postit.c b/docs/examples/postit.c
index 710a14967..e811aa24a 100644
--- a/docs/examples/postit.c
+++ b/docs/examples/postit.c
@@ -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>
diff --git a/docs/examples/sepheaders.c b/docs/examples/sepheaders.c
index 724e14157..ead557214 100644
--- a/docs/examples/sepheaders.c
+++ b/docs/examples/sepheaders.c
@@ -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>
diff --git a/docs/examples/simple.c b/docs/examples/simple.c
index e6138c4e1..907d5e8e4 100644
--- a/docs/examples/simple.c
+++ b/docs/examples/simple.c
@@ -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
index 000000000..f052299d6
--- /dev/null
+++ b/docs/examples/win32sockets.c
@@ -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 */
+}