1 | /* $Id: initterm.cpp,v 1.17 2001-09-05 10:26:30 bird Exp $
|
---|
2 | *
|
---|
3 | * WSOCK32 DLL entry point
|
---|
4 | *
|
---|
5 | * Copyright 1998 Sander van Leeuwen
|
---|
6 | * Copyright 1998 Peter Fitzsimmons
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | */
|
---|
10 |
|
---|
11 | #define INCL_DOSMODULEMGR
|
---|
12 | #define INCL_DOSPROCESS
|
---|
13 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <stdio.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <odin.h>
|
---|
18 | #include <win32type.h>
|
---|
19 | #include <winconst.h>
|
---|
20 | #include <odinlx.h>
|
---|
21 | #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
|
---|
22 | #include <initdll.h>
|
---|
23 |
|
---|
24 | #define DBG_LOCALLOG DBG_initterm
|
---|
25 | #include "dbglocal.h"
|
---|
26 |
|
---|
27 | // Win32 resource table (produced by wrc)
|
---|
28 | extern DWORD wsock32_PEResTab;
|
---|
29 |
|
---|
30 | static HMODULE dllHandle = 0;
|
---|
31 |
|
---|
32 | INT WIN32API WSACleanup();
|
---|
33 |
|
---|
34 | BOOL WINAPI WinsockLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
35 | {
|
---|
36 | switch (fdwReason)
|
---|
37 | {
|
---|
38 | case DLL_PROCESS_ATTACH:
|
---|
39 | return TRUE;
|
---|
40 |
|
---|
41 | case DLL_THREAD_ATTACH:
|
---|
42 | case DLL_THREAD_DETACH:
|
---|
43 | return TRUE;
|
---|
44 |
|
---|
45 | case DLL_PROCESS_DETACH:
|
---|
46 | WSACleanup();
|
---|
47 | return TRUE;
|
---|
48 | }
|
---|
49 | return FALSE;
|
---|
50 | }
|
---|
51 |
|
---|
52 | ULONG SYSTEM DLL_InitWSock32(ULONG hModule)
|
---|
53 | {
|
---|
54 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
55 |
|
---|
56 | ParseLogStatusWSOCK32();
|
---|
57 |
|
---|
58 | dllHandle = RegisterLxDll(hModule, WinsockLibMain, (PVOID)&wsock32_PEResTab);
|
---|
59 | if (dllHandle == 0)
|
---|
60 | return -1;
|
---|
61 |
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 | void SYSTEM DLL_TermWSock32(ULONG hModule)
|
---|
66 | {
|
---|
67 | if (dllHandle)
|
---|
68 | UnregisterLxDll(dllHandle);
|
---|
69 | }
|
---|
70 |
|
---|
71 | ULONG SYSTEM DLL_Init(ULONG hModule)
|
---|
72 | {
|
---|
73 | if (DLL_InitDefault(hModule) == -1)
|
---|
74 | return -1;
|
---|
75 | return DLL_InitWSock32(hModule);
|
---|
76 | }
|
---|
77 |
|
---|
78 | void SYSTEM DLL_Term(ULONG hModule)
|
---|
79 | {
|
---|
80 | DLL_TermWSock32(hModule);
|
---|
81 | DLL_TermDefault(hModule);
|
---|
82 | }
|
---|