fix rules for optional plugins.
[galan.git] / src / dllinit.c
blob9cc9ccd6c1f8c1eef242d1fa4d8931edcf8a7324
1 /* dllinit.c -- Portable DLL initialization.
2 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Mumit Khan (khan@xraylith.wisc.edu).
5 I've used DllMain as the DLL "main" since that's the most common
6 usage. MSVC and Mingw32 both default to DllMain as the standard
7 callback from the linker entry point. Cygwin, as of b20.1, also
8 uses DllMain as the default callback from the entry point.
10 The real entry point is typically always defined by the runtime
11 library, and usually never overridden by (casual) user. What you can
12 override however is the callback routine that the entry point calls,
13 and this file provides such a callback function, DllMain.
15 Mingw32: The default entry point for mingw32 is DllMainCRTStartup
16 which is defined in libmingw32.a This in turn calls DllMain which is
17 defined here. If not defined, there is a stub in libmingw32.a which
18 does nothing.
20 Cygwin: The default entry point for Cygwin b20.1 or newer is
21 __cygwin_dll_entry which is defined in libcygwin.a. This in turn
22 calls the routine DllMain. If not defined, there is a stub in
23 libcygwin.a which does nothing.
25 MSVC: MSVC runtime calls DllMain, just like Mingw32.
27 Summary: If you need to do anything special in DllMain, just add it
28 here. Otherwise, the default setup should be just fine for 99%+ of
29 the time. I strongly suggest that you *not* change the entry point,
30 but rather change DllMain as appropriate.
35 #define WIN32_LEAN_AND_MEAN
36 #include <windows.h>
37 #undef WIN32_LEAN_AND_MEAN
38 #include <stdio.h>
40 BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
41 LPVOID reserved /* Not used. */ );
44 *----------------------------------------------------------------------
46 * DllMain --
48 * This routine is called by the Mingw32, Cygwin32 or VC++ C run
49 * time library init code, or the Borland DllEntryPoint routine. It
50 * is responsible for initializing various dynamically loaded
51 * libraries.
53 * Results:
54 * TRUE on sucess, FALSE on failure.
56 * Side effects:
58 *----------------------------------------------------------------------
60 BOOL APIENTRY
61 DllMain (
62 HINSTANCE hInst /* Library instance handle. */ ,
63 DWORD reason /* Reason this function is being called. */ ,
64 LPVOID reserved /* Not used. */ )
66 switch (reason)
68 case DLL_PROCESS_ATTACH:
69 break;
71 case DLL_PROCESS_DETACH:
72 break;
74 case DLL_THREAD_ATTACH:
75 break;
77 case DLL_THREAD_DETACH:
78 break;
80 return TRUE;