windows: Add utils_init/deinit functions to initialize Winsock2
This commit is contained in:
@@ -112,6 +112,8 @@ AM_YFLAGS = -v -d
|
||||
|
||||
if USE_WINDOWS
|
||||
libstrongswan_la_LIBADD += -lws2_32
|
||||
libstrongswan_la_SOURCES += \
|
||||
utils/windows.c
|
||||
endif
|
||||
|
||||
if USE_DBGHELP
|
||||
|
||||
@@ -146,6 +146,7 @@ void library_deinit()
|
||||
arrays_deinit();
|
||||
threads_deinit();
|
||||
backtrace_deinit();
|
||||
utils_deinit();
|
||||
|
||||
free((void*)this->public.ns);
|
||||
free(this);
|
||||
@@ -259,6 +260,7 @@ bool library_init(char *settings, const char *namespace)
|
||||
);
|
||||
lib = &this->public;
|
||||
|
||||
utils_init();
|
||||
backtrace_init();
|
||||
threads_init();
|
||||
arrays_init();
|
||||
|
||||
@@ -47,6 +47,26 @@ ENUM(status_names, SUCCESS, NEED_MORE,
|
||||
"NEED_MORE",
|
||||
);
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
void utils_init()
|
||||
{
|
||||
#ifdef WIN32
|
||||
windows_init();
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
void utils_deinit()
|
||||
{
|
||||
#ifdef WIN32
|
||||
windows_deinit();
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
|
||||
@@ -82,6 +82,16 @@
|
||||
#include "enum.h"
|
||||
#include "utils/strerror.h"
|
||||
|
||||
/**
|
||||
* Initialize utility functions
|
||||
*/
|
||||
void utils_init();
|
||||
|
||||
/**
|
||||
* Deinitialize utility functions
|
||||
*/
|
||||
void utils_deinit();
|
||||
|
||||
/**
|
||||
* Helper function that compares two strings for equality
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Martin Willi
|
||||
* Copyright (C) 2013 revosec AG
|
||||
*
|
||||
* This program 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 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
void windows_init()
|
||||
{
|
||||
WSADATA wsad;
|
||||
|
||||
/* initialize winsock2 */
|
||||
WSAStartup(MAKEWORD(2, 2), &wsad);
|
||||
}
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
void windows_deinit()
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
@@ -41,6 +41,16 @@
|
||||
typedef u_int uid_t;
|
||||
typedef u_int gid_t;
|
||||
|
||||
/**
|
||||
* Initialize Windows libraries
|
||||
*/
|
||||
void windows_init();
|
||||
|
||||
/**
|
||||
* Deinitialize windows libraries
|
||||
*/
|
||||
void windows_deinit();
|
||||
|
||||
/**
|
||||
* Replacement for random(3)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user