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 WSADATA wsaData;
22
23 hinstFreeTDS = hinstDLL;
24 switch (fdwReason) {
25 case DLL_PROCESS_ATTACH:
26#if defined(_MSC_VER) && defined(_DEBUG)
27 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
28 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
29 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
30 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
31 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
32 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
33 _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
34#endif
35
36 if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
37 return FALSE;
38
39 DisableThreadLibraryCalls(hinstDLL);
40 break;
41
42 case DLL_PROCESS_DETACH:
43#if defined(_MSC_VER) && defined(_DEBUG)
44 _CrtDumpMemoryLeaks();
45#endif
46 break;
47 }
48 return TRUE;
49}
50
51#endif
52