FreeTDS API

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