init: Add a library constructor and destructor for VC
If we compile with Visual Studio, we need a DllMain() for running init and finialize which is the same as a constructor and destructor. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
6aa9392699
Коммит
4d87256ca7
23
src/init.c
23
src/init.c
@ -222,4 +222,27 @@ int ssh_finalize(void) {
|
||||
return _ssh_finalize(0);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* Library constructor and destructor */
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) {
|
||||
rc = ssh_init();
|
||||
} else if (fdwReason == DLL_PROCESS_DETACH) {
|
||||
rc = ssh_finalize();
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/** @} */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user