1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

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>
This commit is contained in:
Andreas Schneider
2018-08-13 09:30:51 +02:00
parent 6aa9392699
commit 4d87256ca7

View File

@@ -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 */
/** @} */