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:
@@ -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
@@ -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();
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user