mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
win32sockets.c is now added with winsock init/cleanup example functions
This commit is contained in:
parent
43da41e73e
commit
ada9bc2b24
@ -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:
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
41
docs/examples/win32sockets.c
Normal file
41
docs/examples/win32sockets.c
Normal file
@ -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 */
|
||||
}
|
Loading…
Reference in New Issue
Block a user