diff --git a/configure.ac b/configure.ac index 8de91a0..a764e18 100644 --- a/configure.ac +++ b/configure.ac @@ -238,6 +238,8 @@ if test "x$NCURSES_FOUND" = "xno"; then AC_MSG_ERROR([required library winsock2 was not found on the system, please check your MinGW installation]) ] ) + AC_DEFINE([_WIN32_WINNT], [0x501], + [enable getaddrinfo/freeaddrinfo on XP and higher]) else AC_CHECK_LIB([ncursesw], [wget_wch], [ diff --git a/src/configdir.c b/src/configdir.c index a032546..193b162 100644 --- a/src/configdir.c +++ b/src/configdir.c @@ -49,7 +49,10 @@ char *get_user_config_dir(void) { char *user_config_dir; -#ifdef WIN32 +#ifdef __WIN32__ +#warning Please fix configdir for Win32 + return NULL; +#if 0 char appdata[MAX_PATH]; BOOL ok; @@ -62,6 +65,7 @@ char *get_user_config_dir(void) user_config_dir = strdup(appdata); return user_config_dir; +#endif #else /* WIN32 */ @@ -126,11 +130,10 @@ char *get_user_config_dir(void) */ int create_user_config_dir(char *path) { - - int mkdir_err; - -#ifdef WIN32 - +#ifdef __WIN32__ +#warning Please fix configdir for Win32 + return -1; +#if 0 char *fullpath = malloc(strlen(path) + strlen(CONFIGDIR) + 1); strcpy(fullpath, path); strcat(fullpath, CONFIGDIR); @@ -143,7 +146,11 @@ int create_user_config_dir(char *path) return -1; } + free(fullpath); +#endif + #else + int mkdir_err; mkdir_err = mkdir(path, 0700); struct stat buf; @@ -163,7 +170,7 @@ int create_user_config_dir(char *path) return -1; } -#endif free(fullpath); return 0; +#endif } diff --git a/src/main.c b/src/main.c index dc52753..3d70c7a 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,10 @@ #include "config.h" #endif +#ifndef SIGWINCH + #define SIGWINCH 28 +#endif + #include #include #include @@ -15,11 +19,13 @@ #include #include #include -#include -#ifdef _win32 -#include +#ifdef WIN32 + #include + #include + #include #else +#include #include #include #include @@ -122,16 +128,32 @@ uint32_t resolve_addr(const char *address) hints.ai_family = AF_INET; // IPv4 only right now. hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses. +#ifdef __WIN32__ + int res; + WSADATA wsa_data; + + res = WSAStartup(MAKEWORD(2, 2), &wsa_data); + if (res != 0) + { + return 0; + } +#endif rc = getaddrinfo(address, "echo", &hints, &server); // Lookup failed. if (rc != 0) { +#ifdef __WIN32__ + WSACleanup(); +#endif return 0; } // IPv4 records only.. if (server->ai_family != AF_INET) { freeaddrinfo(server); +#ifdef __WIN32__ + WSACleanup(); +#endif return 0; } @@ -139,6 +161,9 @@ uint32_t resolve_addr(const char *address) addr = ((struct sockaddr_in *)server->ai_addr)->sin_addr.s_addr; freeaddrinfo(server); +#ifdef __WIN32__ + WSACleanup(); +#endif return addr; }