X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fwin.c;h=fe06f126593c4dda9b7352f3f26b73df2aed191b;hb=65f518e8036699fa3c574266d39e3cd1263af9e8;hp=5cbe5c6728b536c8cbe8d24c9f27e1ea5fd4b1eb;hpb=88e70911ee4a023f3e3a442f22f7a7693fe642a7;p=oweals%2Fgnunet.git diff --git a/src/util/win.c b/src/util/win.c index 5cbe5c672..fe06f1265 100644 --- a/src/util/win.c +++ b/src/util/win.c @@ -1,10 +1,10 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors) + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your + by the Free Software Foundation; either version 3, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but @@ -29,6 +29,7 @@ #include "winproc.h" #include "platform.h" +#include "gnunet_crypto_lib.h" #include "gnunet_common.h" #include "gnunet_connection_lib.h" @@ -45,7 +46,7 @@ int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows); ULONG Length; \ DWORD Flags; \ }; \ - }; + }; #define _IP_ADAPTER_UNICAST_ADDRESS_BASE \ SOCKET_ADDRESS Address; \ @@ -106,7 +107,7 @@ typedef enum _NET_IF_CONNECTION_TYPE { NET_IF_CONNECTION_DEDICATED = 1, NET_IF_CONNECTION_PASSIVE, NET_IF_CONNECTION_DEMAND, - NET_IF_CONNECTION_MAXIMUM + NET_IF_CONNECTION_MAXIMUM } NET_IF_CONNECTION_TYPE, *PNET_IF_CONNECTION_TYPE; typedef enum { @@ -116,7 +117,7 @@ typedef enum { TUNNEL_TYPE_6TO4, TUNNEL_TYPE_ISATAP, TUNNEL_TYPE_TEREDO, - TUNNEL_TYPE_IPHTTPS + TUNNEL_TYPE_IPHTTPS } TUNNEL_TYPE, *PTUNNEL_TYPE; #endif @@ -209,7 +210,7 @@ typedef struct _IP_ADAPTER_ADDRESSES##suffix { \ _IP_ADAPTER_ADDRESSES_BASE \ addition \ } IP_ADAPTER_ADDRESSES##suffix, *PIP_ADAPTER_ADDRESSES##suffix; - + /* _IP_ADAPTER_ADDRESSES_DEFINE(,) defined in w32api headers */ _IP_ADAPTER_ADDRESSES_DEFINE(_XPSP1,_IP_ADAPTER_ADDRESSES_ADD_XPSP1) @@ -299,18 +300,19 @@ int EnumNICs2 (INTERFACE_INFO **ifs4, int *ifs4_len, SOCKET_ADDRESS_LIST **ifs6) { int result = 0; - SOCKET s4 = INVALID_SOCKET, s6 = INVALID_SOCKET; - DWORD dwret1 = 0, dwret2; - DWORD err1, err2; - int ifs4len = 0, ifs6len = 0; + SOCKET s4; + SOCKET s6; + int ifs4len = 0; + int ifs6len = 0; INTERFACE_INFO *interfaces4 = NULL; SOCKET_ADDRESS_LIST *interfaces6 = NULL; + SetLastError (0); s4 = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - err1 = GetLastError (); + (void) GetLastError (); SetLastError (0); s6 = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP); - err2 = GetLastError (); + (void) GetLastError (); if (s6 != INVALID_SOCKET) { ifs6len = EnumNICs_IPv6_get_ifs_count (s6); @@ -351,8 +353,9 @@ error: return GNUNET_SYSERR; } + /** - * Returns GNUNET_OK on OK, GNUNET_SYSERR on error + * @returns #GNUNET_OK on success, #GNUNET_SYSERR on error */ int EnumNICs3 (struct EnumNICs3_results **results, int *results_count) @@ -696,6 +699,7 @@ int InstallAsService(char *servicename, char *application, char *username) return 0; } + /** * @brief Uninstall Windows service * @param servicename name of the service to delete @@ -705,7 +709,8 @@ int InstallAsService(char *servicename, char *application, char *username) * 3 if the service cannot be accessed * 4 if the service cannot be deleted */ -int UninstallService(char *servicename) +int +UninstallService(char *servicename) { SC_HANDLE hManager, hService; @@ -739,7 +744,8 @@ closeSCM: * @see http://support.microsoft.com/?scid=kb;en-us;132958 * @date 12-Jul-95 */ -void _InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String) +void +_InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String) { DWORD StringLength; @@ -763,7 +769,8 @@ void _InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String) * @see http://support.microsoft.com/?scid=kb;en-us;132958 * @date 12-Jul-95 */ -NTSTATUS _OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle) +NTSTATUS +_OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle) { LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_UNICODE_STRING ServerString; @@ -796,7 +803,8 @@ 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(LPCTSTR SystemName, LPCTSTR AccountName, PSID * Sid) +BOOL +_GetAccountSid(LPCTSTR SystemName, LPCTSTR AccountName, PSID * Sid) { LPTSTR ReferencedDomain = NULL; DWORD cbSid = 128; /* initial allocation attempt */ @@ -863,10 +871,11 @@ end: * @see http://support.microsoft.com/?scid=kb;en-us;132958 * @date 12-Jul-95 */ -NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */ - PSID AccountSid, /* SID to grant privilege to */ - LPWSTR PrivilegeName, /* privilege to grant (Unicode) */ - BOOL bEnable /* enable or disable */ +NTSTATUS +_SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */ + PSID AccountSid, /* SID to grant privilege to */ + LPWSTR PrivilegeName, /* privilege to grant (Unicode) */ + BOOL bEnable /* enable or disable */ ) { LSA_UNICODE_STRING PrivilegeString; @@ -903,13 +912,14 @@ NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */ * @param pszName the name of the account * @param pszDesc description of the account */ -int CreateServiceAccount(const char *pszName, const char *pszDesc) +int +CreateServiceAccount(const char *pszName, + const char *pszDesc) { USER_INFO_1 ui; USER_INFO_1008 ui2; NET_API_STATUS nStatus; wchar_t wszName[MAX_NAME_LENGTH], wszDesc[MAX_NAME_LENGTH]; - DWORD dwErr; LSA_HANDLE hPolicy; PSID pSID;