1
/* Copyright (C) 2000-2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation.
7
There are special exceptions to the terms and conditions of the GPL as it
8
is applied to this software. View the full text of the exception in file
9
EXCEPTIONS-CLIENT in the directory of this software distribution.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
** Handling initialization of the dll library
24
#include <my_global.h>
26
#include <my_pthread.h>
28
static my_bool libmysql_inited=0;
30
void libmysql_init(void)
37
DBUG_ENTER("libmysql_init");
39
DBUG_PUSH("d:t:S:O,c::\\tmp\\libmysql.log");
41
if (getenv("LIBMYSQL_LOG") != NULL)
42
DBUG_PUSH(getenv("LIBMYSQL_LOG"));
50
static int inited=0,threads=0;
51
HINSTANCE NEAR s_hModule; /* Saved module handle */
54
BOOL APIENTRY LibMain(HANDLE hInst,DWORD ul_reason_being_called,
57
switch (ul_reason_being_called) {
58
case DLL_PROCESS_ATTACH: /* case of libentry call in win 3.x */
63
main_thread=GetCurrentThreadId();
66
case DLL_THREAD_ATTACH:
70
case DLL_PROCESS_DETACH: /* case of wep call in win 3.x */
71
if (!--inited) /* Safety */
73
/* my_thread_init() */ /* This may give extra safety */
77
case DLL_THREAD_DETACH:
78
/* Main thread will free by my_end() */
80
if (main_thread != GetCurrentThreadId())
89
UNREFERENCED_PARAMETER(lpReserved);
92
int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved)
94
return LibMain(hInst,ul_reason_being_called,lpReserved);
97
#elif defined(WINDOWS)
99
/****************************************************************************
100
** This routine is called by LIBSTART.ASM at module load time. All it
101
** does in this sample is remember the DLL module handle. The module
102
** handle is needed if you want to do things like load stuff from the
103
** resource file (for instance string resources).
104
****************************************************************************/
106
int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize,
107
UCHAR FAR *lszCmdLine)