mirror of
https://github.com/Wind4/vlmcsd
synced 2025-12-20 15:35:51 +00:00
vlmcsd-svn906-2016-06-05-Hotbird64
This commit is contained in:
54
libkms.c
54
libkms.c
@@ -7,9 +7,13 @@
|
||||
#endif // CONFIG
|
||||
#include CONFIG
|
||||
|
||||
#ifdef EXTERNAL
|
||||
#undef EXTERNAL
|
||||
#endif
|
||||
|
||||
#define EXTERNAL dllexport
|
||||
|
||||
#define DLLVERSION 0x30000
|
||||
#define DLLVERSION 0x30001
|
||||
|
||||
#include "libkms.h"
|
||||
#include "shared_globals.h"
|
||||
@@ -24,6 +28,10 @@
|
||||
#include <netinet/in.h>
|
||||
#endif // WIN32
|
||||
|
||||
#ifdef IS_LIBRARY
|
||||
char ErrorMessage[MESSAGE_BUFFER_SIZE];
|
||||
#endif // IS_LIBRARY
|
||||
|
||||
static int_fast8_t IsServerStarted = FALSE;
|
||||
|
||||
|
||||
@@ -42,6 +50,7 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl SendActivationRequest
|
||||
|
||||
EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, RequestCallback_t requestCallback)
|
||||
{
|
||||
#ifndef SIMPLE_SOCKETS
|
||||
char listenAddress[64];
|
||||
|
||||
if (IsServerStarted) return !0;
|
||||
@@ -97,6 +106,39 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl StartKmsServer(const int port, Reques
|
||||
|
||||
IsServerStarted = FALSE;
|
||||
return 0;
|
||||
|
||||
# else // SIMPLE_SOCKETS
|
||||
|
||||
if (IsServerStarted) return !0;
|
||||
int error;
|
||||
|
||||
# ifdef _WIN32
|
||||
# ifndef USE_MSRPC
|
||||
// Windows Sockets must be initialized
|
||||
WSADATA wsadata;
|
||||
|
||||
if ((error = WSAStartup(0x0202, &wsadata)))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
# endif // USE_MSRPC
|
||||
# endif // _WIN32
|
||||
|
||||
defaultport = vlmcsd_malloc(16);
|
||||
snprintf((char*)defaultport, (size_t)16, "%i", port);
|
||||
|
||||
CreateResponseBase = requestCallback;
|
||||
error = listenOnAllAddresses();
|
||||
if (error) return error;
|
||||
|
||||
IsServerStarted = TRUE;
|
||||
runServer();
|
||||
IsServerStarted = FALSE;
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
# endif // SIMPLE_SOCKETS
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +147,11 @@ EXTERNC __declspec(EXTERNAL) DWORD __cdecl StopKmsServer()
|
||||
if (!IsServerStarted) return !0;
|
||||
|
||||
closeAllListeningSockets();
|
||||
|
||||
# ifndef SIMPLE_SOCKETS
|
||||
if (SocketList) free(SocketList);
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,3 +161,9 @@ EXTERNC __declspec(EXTERNAL) int __cdecl GetLibKmsVersion()
|
||||
return DLLVERSION;
|
||||
}
|
||||
|
||||
|
||||
EXTERNC __declspec(EXTERNAL) const char* const __cdecl GetEmulatorVersion()
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user