1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-08 23:03:12 +02:00

Windows code cleanup: WSAStartup() -> init_winsock()

This commit is contained in:
Bram Matthys
2022-01-03 13:18:51 +01:00
parent 98c0e786b5
commit c02eb3f16c
6 changed files with 23 additions and 22 deletions
+3
View File
@@ -948,6 +948,9 @@ extern int unreal_bind(int fd, const char *ip, int port, SocketType socket_type)
extern int unreal_connect(int fd, const char *ip, int port, int ipv6);
extern int is_valid_ip(const char *str);
extern int ipv6_capable(void);
#ifdef _WIN32
extern void init_winsock(void);
#endif
extern MODVAR Client *remote_rehash_client;
extern MODVAR int debugfd;
extern void convert_to_absolute_path(char **path, const char *reldir);
+2 -5
View File
@@ -500,10 +500,7 @@ int main(int argc, char *argv[])
int InitUnrealIRCd(int argc, char *argv[])
#endif
{
#ifdef _WIN32
WORD wVersionRequested = MAKEWORD(1, 1);
WSADATA wsaData;
#else
#ifndef _WIN32
uid_t uid, euid;
gid_t gid, egid;
#endif
@@ -573,7 +570,7 @@ int InitUnrealIRCd(int argc, char *argv[])
#ifndef _WIN32
(void)umask(077); /* better safe than sorry --SRB */
#else
WSAStartup(wVersionRequested, &wsaData);
init_winsock();
#endif
setup_signals();
+13
View File
@@ -1365,3 +1365,16 @@ int unreal_bind(int fd, const char *ip, int port, SocketType socket_type)
return ret;
}
}
#ifdef _WIN32
void init_winsock(void)
{
WSADATA WSAData;
if (WSAStartup(MAKEWORD(1, 1), &WSAData) != 0)
{
MessageBox(NULL, "Unable to initialize WinSock", "UnrealIRCD Initalization Error", MB_OK);
fprintf(stderr, "Unable to initialize WinSock\n");
exit(1);
}
}
#endif
+3 -2
View File
@@ -73,9 +73,10 @@ void unrealircdctl_status(void)
int main(int argc, char *argv[])
{
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1), &wsaData);
dbuf_init();
#ifdef _WIN32
init_winsock();
#endif
if (argc == 1)
unrealircdctl_usage(argv[0]);
+1 -7
View File
@@ -188,7 +188,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
MSG msg;
unsigned char *s;
HWND hWnd;
WSADATA WSAData;
HICON hIcon;
SC_HANDLE hService, hSCManager;
SERVICE_TABLE_ENTRY DispatchTable[] =
@@ -250,12 +249,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
if (!LoadLibrary("riched20.dll"))
LoadLibrary("riched32.dll");
InitDebug();
if (WSAStartup(MAKEWORD(1, 1), &WSAData) != 0)
{
MessageBox(NULL, "Unable to initialize WinSock", "UnrealIRCD Initalization Error", MB_OK);
return FALSE;
}
init_winsock();
hInst = hInstance;
MainDlgBackground = CreateSolidBrush(RGB(75, 134, 238)); /* Background of main dialog */
+1 -8
View File
@@ -90,7 +90,6 @@ VOID WINAPI IRCDCtrlHandler(DWORD opcode)
*/
VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
WSADATA WSAData;
DWORD error = 0;
char path[MAX_PATH], *folder;
@@ -121,13 +120,7 @@ VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
GetOSName(OSName);
InitDebug();
/* Initialize Winsocks */
if ((error = WSAStartup(MAKEWORD(1, 1), &WSAData)) != 0)
{
SetServiceStop(error);
return;
}
init_winsock();
/* Initialize the IRCd */
if ((error = InitUnrealIRCd(dwArgc, lpszArgv)) != 1)