mirror of
https://github.com/curl/curl.git
synced 2026-08-25 20:53:37 +03:00
Moved more generic functions to util.[ch]
Added resolve.c to simply resolve a given host name
This commit is contained in:
parent
ede9fb4fcc
commit
84fd4686e2
6 changed files with 238 additions and 157 deletions
|
|
@ -83,33 +83,6 @@
|
|||
#include "inet_pton.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <process.h>
|
||||
|
||||
#define sleep(sec) Sleep ((sec)*1000)
|
||||
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define EISCONN WSAEISCONN
|
||||
#define ENOTSOCK WSAENOTSOCK
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
|
||||
static void win32_cleanup(void);
|
||||
|
||||
#if defined(ENABLE_IPV6) && defined(__MINGW32__)
|
||||
const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* include memdebug.h last */
|
||||
#include "memdebug.h"
|
||||
|
||||
|
|
@ -157,55 +130,6 @@ static void sigpipe_handler(int sig)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#undef perror
|
||||
#define perror(m) win32_perror(m)
|
||||
|
||||
static void win32_perror(const char *msg)
|
||||
{
|
||||
char buf[256];
|
||||
DWORD err = WSAGetLastError();
|
||||
|
||||
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
|
||||
LANG_NEUTRAL, buf, sizeof(buf), NULL))
|
||||
snprintf(buf, sizeof(buf), "Unknown error %lu (%#lx)", err, err);
|
||||
if (msg)
|
||||
fprintf(stderr, "%s: ", msg);
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
static void win32_init(void)
|
||||
{
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
|
||||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
|
||||
if (err != 0) {
|
||||
perror("Winsock init failed");
|
||||
logmsg("Error initialising winsock -- aborting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( LOBYTE( wsaData.wVersion ) != 2 ||
|
||||
HIBYTE( wsaData.wVersion ) != 0 ) {
|
||||
|
||||
WSACleanup();
|
||||
perror("Winsock init failed");
|
||||
logmsg("No suitable winsock.dll found -- aborting\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
static void win32_cleanup(void)
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#endif
|
||||
|
||||
char use_ipv6=FALSE;
|
||||
unsigned short port = DEFAULT_PORT;
|
||||
unsigned short connectport = 0; /* if non-zero, we activate this mode */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue