1
1

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>
Этот коммит содержится в:
Andreas Schneider 2018-08-13 09:30:51 +02:00
родитель 6aa9392699
Коммит 4d87256ca7

Просмотреть файл

@ -222,4 +222,27 @@ int ssh_finalize(void) {
return _ssh_finalize(0); 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 */
/** @} */ /** @} */