mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +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:
23
src/init.c
23
src/init.c
@@ -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 */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
Reference in New Issue
Block a user