From bc83770144cc547a917fc27f0f572859ae203fce Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 5 Nov 2010 11:26:18 +0000 Subject: [PATCH] LRN patch from Mantis #1615 --- configure.ac | 2 ++ src/include/gnunet_common.h | 1 + src/include/platform.h | 4 ++++ src/include/plibc.h | 5 +++-- src/include/winproc.h | 5 +++-- src/transport/gnunet-nat-client-windows.c | 2 +- src/util/common_logging.c | 2 ++ src/util/connection.c | 2 +- src/util/os_priority.c | 1 - src/util/scheduler.c | 3 ++- src/util/signal.c | 2 +- src/util/strings.c | 2 +- src/util/win.cc | 16 ++++++++-------- src/vpn/gnunet-service-dns.c | 2 +- src/vpn/gnunet-vpn-pretty-print.c | 1 + 15 files changed, 31 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 1176ff5fb..eddb10ff0 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,7 @@ AC_PREREQ(2.61) AC_INIT([gnunet], [0.9.0pre1],[bug-gnunet@gnu.org]) AM_INIT_AUTOMAKE([gnunet], [0.9.0pre1]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CONFIG_HEADERS([gnunet_config.h]) AH_TOP([#define _GNU_SOURCE 1]) @@ -141,6 +142,7 @@ netbsd*) LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols" LIBS="$LIBS -lws2_32 -lplibc" CFLAGS="-mms-bitfields $CFLAGS" + CPPFLAGS="-D_WIN32_WINNT=0x0501 $CPPFLAGS" build_target="mingw" AC_PROG_CXX LIBPREFIX=lib diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 57008fa08..badb52880 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -138,6 +138,7 @@ typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename); */ enum GNUNET_ErrorType { + GNUNET_ERROR_TYPE_NONE = 0, GNUNET_ERROR_TYPE_ERROR = 1, GNUNET_ERROR_TYPE_WARNING = 2, GNUNET_ERROR_TYPE_INFO = 4, diff --git a/src/include/platform.h b/src/include/platform.h index 1b279d123..cc2aa03ae 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -78,6 +78,7 @@ #ifdef _MSC_VER #include +#include #else #ifndef MINGW #include @@ -108,6 +109,9 @@ #include #include #include +#ifdef WINDOWS +#include /* for alloca(), on other OSes it's in stdlib.h */ +#endif #ifndef _MSC_VER #include /* KLB_FIX */ #endif diff --git a/src/include/plibc.h b/src/include/plibc.h index 4e3204c98..a59e53de9 100644 --- a/src/include/plibc.h +++ b/src/include/plibc.h @@ -50,8 +50,9 @@ extern "C" { #include "langinfo.h" #endif -#include +#include #include +#include #include #include #include @@ -334,7 +335,7 @@ BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest); BOOL _plibc_DereferenceShortcut(char *pszShortcut); char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags); char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags); -long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey, +long QueryRegistry(HKEY hMainKey, const char *pszKey, const char *pszSubKey, char *pszBuffer, long *pdLength); BOOL __win_IsHandleMarkedAsBlocking(int hHandle); diff --git a/src/include/winproc.h b/src/include/winproc.h index 0298c2d59..595180a96 100644 --- a/src/include/winproc.h +++ b/src/include/winproc.h @@ -34,8 +34,9 @@ #include #include #include +#include +#include #include -#include #include #include #include @@ -198,7 +199,7 @@ extern "C" BOOL CreateShortcut (const char *pszSrc, const char *pszDest); BOOL DereferenceShortcut (char *pszShortcut); - long QueryRegistry (HKEY hMainKey, char *pszKey, char *pszSubKey, + long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey, char *pszBuffer, long *pdLength); int ListNICs (void (*callback) (void *, const char *, int), void *cls); BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName, diff --git a/src/transport/gnunet-nat-client-windows.c b/src/transport/gnunet-nat-client-windows.c index 911f4962a..2e7c8a86e 100644 --- a/src/transport/gnunet-nat-client-windows.c +++ b/src/transport/gnunet-nat-client-windows.c @@ -43,8 +43,8 @@ */ #define _GNU_SOURCE -#include #include +#include #include #include #include diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 223c92218..74f28ff76 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -152,6 +152,8 @@ get_type (const char *log) return GNUNET_ERROR_TYPE_WARNING; if (0 == strcasecmp (log, _("ERROR"))) return GNUNET_ERROR_TYPE_ERROR; + if (0 == strcasecmp (log, _("NONE"))) + return GNUNET_ERROR_TYPE_NONE; return GNUNET_ERROR_TYPE_INVALID; } diff --git a/src/util/connection.c b/src/util/connection.c index efab4edd8..04d0c864d 100644 --- a/src/util/connection.c +++ b/src/util/connection.c @@ -719,7 +719,7 @@ connect_probe_continuation (void *cls, struct GNUNET_CONNECTION_Handle *h = ap->h; struct AddressProbe *pos; int error; - unsigned int len; + socklen_t len; GNUNET_assert (ap->sock != NULL); GNUNET_CONTAINER_DLL_remove (h->ap_head, h->ap_tail, ap); diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 8bb7757f4..baeeb2d9a 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -551,7 +551,6 @@ GNUNET_OS_start_process_v (const int *lsocks, PROCESS_INFORMATION proc; int argcount = 0; char non_const_filename[MAX_PATH +1]; - int filenamelen = 0; struct GNUNET_OS_Process *gnunet_proc = NULL; GNUNET_assert (lsocks == NULL); diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 6e5a06db5..9b8ab4b29 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -692,12 +692,13 @@ static struct GNUNET_DISK_PipeHandle *shutdown_pipe_handle; /** * Signal handler called for SIGPIPE. */ +#ifndef MINGW static void sighandler_pipe () { return; } - +#endif /** * Signal handler called for signals that should cause us to shutdown. */ diff --git a/src/util/signal.c b/src/util/signal.c index 1fc3cf68f..0fe4bfc96 100644 --- a/src/util/signal.c +++ b/src/util/signal.c @@ -68,7 +68,7 @@ GNUNET_SIGNAL_handler_install (int signum, GNUNET_SIGNAL_Handler handler) w32_sigchld_handler = handler; else { - __p_sig_fn_t sigret = signal (signum, handler); + __p_sig_fn_t sigret = signal (signum, (__p_sig_fn_t) handler); if (sigret == SIG_ERR) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/util/strings.c b/src/util/strings.c index c8e5191bf..fa445f694 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -199,7 +199,7 @@ GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset) itmp = tmp; finSize = tmpSize; if (iconv (cd, -#if FREEBSD || DARWIN +#if FREEBSD || DARWIN || WINDOWS (const char **) &input, #else (char **) &input, diff --git a/src/util/win.cc b/src/util/win.cc index 2cc3b8f71..b462033b9 100644 --- a/src/util/win.cc +++ b/src/util/win.cc @@ -346,7 +346,7 @@ NTSTATUS _OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyH * @remarks Call GetLastError() to obtain extended error information. * @see http://support.microsoft.com/?scid=kb;en-us;132958 */ -BOOL _GetAccountSid(LPTSTR SystemName, LPTSTR AccountName, PSID * Sid) +BOOL _GetAccountSid(LPCTSTR SystemName, LPCTSTR AccountName, PSID * Sid) { LPTSTR ReferencedDomain = NULL; DWORD cbSid = 128; /* initial allocation attempt */ @@ -452,7 +452,7 @@ NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */ * @param pszName the name of the account * @param pszDesc description of the account */ -int CreateServiceAccount(char *pszName, char *pszDesc) +int CreateServiceAccount(const char *pszName, const char *pszDesc) { USER_INFO_1 ui; USER_INFO_1008 ui2; @@ -486,14 +486,14 @@ int CreateServiceAccount(char *pszName, char *pszDesc) STATUS_SUCCESS) return 3; - _GetAccountSid(NULL, (LPTSTR) pszName, &pSID); + _GetAccountSid(NULL, (LPCTSTR) pszName, &pSID); - if (_SetPrivilegeOnAccount(hPolicy, pSID, L"SeServiceLogonRight", TRUE) != STATUS_SUCCESS) + if (_SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeServiceLogonRight", TRUE) != STATUS_SUCCESS) return 4; - _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyInteractiveLogonRight", TRUE); - _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyBatchLogonRight", TRUE); - _SetPrivilegeOnAccount(hPolicy, pSID, L"SeDenyNetworkLogonRight", TRUE); + _SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeDenyInteractiveLogonRight", TRUE); + _SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeDenyBatchLogonRight", TRUE); + _SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeDenyNetworkLogonRight", TRUE); GNLsaClose(hPolicy); @@ -801,7 +801,7 @@ char *winErrorStr(const char *prefix, int dwErr) NULL, (DWORD) dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &err, 0, NULL )) { - err = ""; + err = (char *) LocalAlloc (LMEM_FIXED | LMEM_ZEROINIT, 1); } mem = strlen(err) + strlen(prefix) + 20; diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 151561fe4..7997112c4 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -452,7 +452,7 @@ read_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct sockaddr_in addr; memset(&addr, 0, sizeof addr); - unsigned int addrlen = sizeof addr; + socklen_t addrlen = sizeof addr; int r; r = GNUNET_NETWORK_socket_recvfrom(dnsout, diff --git a/src/vpn/gnunet-vpn-pretty-print.c b/src/vpn/gnunet-vpn-pretty-print.c index 1aeb167f1..09aa05b0d 100644 --- a/src/vpn/gnunet-vpn-pretty-print.c +++ b/src/vpn/gnunet-vpn-pretty-print.c @@ -5,6 +5,7 @@ #ifndef _WIN32 #include #else +#include #include #endif -- 2.25.1