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
12#ifdef DLL_EXPORT
13
14HINSTANCE hinstFreeTDS;
15
16BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
17
18BOOL WINAPI
19DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved TDS_UNUSED)
20{
21 hinstFreeTDS = hinstDLL;
22 switch (fdwReason) {
23 case DLL_PROCESS_ATTACH:
24#if defined(_MSC_VER) && defined(_DEBUG)
25 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
26 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
27 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
28 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
29 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
30 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
31 _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
32#endif
33
34 if (tds_socket_init() != 0)
35 return FALSE;
36
37 DisableThreadLibraryCalls(hinstDLL);
38 break;
39
40 case DLL_PROCESS_DETACH:
41 tds_socket_done();
42#if defined(_MSC_VER) && defined(_DEBUG)
43 _CrtDumpMemoryLeaks();
44#endif
45 break;
46 }
47 return TRUE;
48}
49
50#endif
51