]> git.sur5r.net Git - openldap/blob - libraries/msdos/winsock/wsa.c
Initial revision
[openldap] / libraries / msdos / winsock / wsa.c
1 /*
2  * Microsoft Windows specifics for LIBLDAP DLL
3  */
4 #include "lber.h"
5 #include "ldap.h"
6 #include "msdos.h"
7
8
9 #ifdef _WIN32
10 /* Lifted from Q125688
11  * How to Port a 16-bit DLL to a Win32 DLL
12  * on the MSVC 4.0 CD
13  */
14 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
15 {
16         switch (fdwReason)
17         {
18         case DLL_PROCESS_ATTACH:
19                  /* Code from LibMain inserted here.  Return TRUE to keep the
20                     DLL loaded or return FALSE to fail loading the DLL.
21
22                     You may have to modify the code in your original LibMain to
23                     account for the fact that it may be called more than once.
24                     You will get one DLL_PROCESS_ATTACH for each process that
25                     loads the DLL. This is different from LibMain which gets
26                     called only once when the DLL is loaded. The only time this
27                     is critical is when you are using shared data sections.
28                     If you are using shared data sections for statically
29                     allocated data, you will need to be careful to initialize it
30                     only once. Check your code carefully.
31
32                     Certain one-time initializations may now need to be done for
33                     each process that attaches. You may also not need code from
34                     your original LibMain because the operating system may now
35                     be doing it for you.
36                  */
37                 /*
38                  * 16 bit code calls UnlockData()
39                  * which is mapped to UnlockSegment in windows.h
40                  * in 32 bit world UnlockData is not defined anywhere
41                  * UnlockSegment is mapped to GlobalUnfix in winbase.h
42                  * and the docs for both UnlockSegment and GlobalUnfix say 
43                  * ".. function is oboslete.  Segments have no meaning 
44                  *  in the 32-bit environment".  So we do nothing here.
45                  */
46                 break;
47
48         case DLL_THREAD_ATTACH:
49                 /* Called each time a thread is created in a process that has
50                    already loaded (attached to) this DLL. Does not get called
51                    for each thread that exists in the process before it loaded
52                    the DLL.
53
54                    Do thread-specific initialization here.
55                 */
56                 break;
57
58         case DLL_THREAD_DETACH:
59                 /* Same as above, but called when a thread in the process
60                    exits.
61
62                    Do thread-specific cleanup here.
63                 */
64                 break;
65
66         case DLL_PROCESS_DETACH:
67                 /* Code from _WEP inserted here.  This code may (like the
68                    LibMain) not be necessary.  Check to make certain that the
69                    operating system is not doing it for you.
70                 */
71                 break;
72         }
73         /* The return value is only used for DLL_PROCESS_ATTACH; all other
74         conditions are ignored.  */
75         return TRUE;   // successful DLL_PROCESS_ATTACH
76 }
77 #else
78 int CALLBACK
79 LibMain( HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine )
80 {
81         UnlockData( 0 );
82         return( 1 );
83 }
84 #endif
85
86
87 void
88 ldap_memfree( void *p )
89 {
90         free( p );
91 }