FreeTDS API: win32/initnet.c Source File

FreeTDS API

Loading...
Searching...
No Matches
initnet.c
1#include <config.h>
2
3#if defined(_MSC_VER) && defined(_DEBUG)
4#define _CRTDBG_MAP_ALLOC
5#include <stdlib.h>
6#include <crtdbg.h>
7#endif
8
9#include <freetds/windows.h>
10#include <freetds/macros.h>
11#include <freetds/sysdep_private.h>
12
13#ifdef DLL_EXPORT
14
15HINSTANCE hinstFreeTDS;
16
17BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
18
19BOOL WINAPI
20DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved TDS_UNUSED)
21{
22 hinstFreeTDS = hinstDLL;
23 switch (fdwReason) {
24 case DLL_PROCESS_ATTACH:
25#if defined(_MSC_VER) && defined(_DEBUG)
26 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
27 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
28 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
29 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
30 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
31 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
32 _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
33#endif
34
35 if (tds_socket_init() != 0)
36 return FALSE;
37
38 DisableThreadLibraryCalls(hinstDLL);
39 break;
40
41 case DLL_PROCESS_DETACH:
42 tds_socket_done();
43#if defined(_MSC_VER) && defined(_DEBUG)
44 _CrtDumpMemoryLeaks();
45#endif
46 break;
47 }
48 return TRUE;
49}
50
51#endif
52