📄 dll.c
字号:
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */
/*
** DLL.C - This is the ODBC sample driver code for
** LIBMAIN processing.
**
*/
#include "myodbc.h"
#ifdef THREAD
#include <my_pthread.h>
#endif
#include <locale.h>
char *default_locale, *decimal_point, *thousands_sep;
uint decimal_point_length,thousands_sep_length;
static bool myodbc_inited=0;
void myodbc_init(void)
{
struct lconv *tmp;
DBUG_ENTER("myodbc_init");
if (!myodbc_inited)
{
myodbc_inited=1;
my_init();
#ifdef LOG_ALL
#ifdef __UNIX__
DBUG_PUSH("d:t:S:O,/tmp/myodbc.log");
#else
DBUG_PUSH("d:t:S:O,c::\\tmp\\myodbc.log");
#endif
#else
if (getenv("MYODBC_LOG") != NULL)
DBUG_PUSH(getenv("MYODBC_LOG"));
#endif
init_getfunctions();
default_locale=my_strdup(setlocale(LC_NUMERIC,NullS),MYF(0));
setlocale(LC_NUMERIC,"");
tmp=localeconv();
decimal_point=my_strdup(tmp->decimal_point,MYF(0));
decimal_point_length=strlen(decimal_point);
thousands_sep=my_strdup(tmp->thousands_sep,MYF(0));
thousands_sep_length=strlen(thousands_sep);
setlocale(LC_NUMERIC,default_locale);
}
DBUG_VOID_RETURN;
}
#ifdef _WIN32
static int inited=0;
HINSTANCE NEAR s_hModule; // Saved module handle.
BOOL APIENTRY LibMain(HANDLE hInst,DWORD ul_reason_being_called,
LPVOID lpReserved)
{
switch (ul_reason_being_called) {
case DLL_PROCESS_ATTACH: // case of libentry call in win 3.x
if (!inited++)
{
WSADATA wsaData;
s_hModule = hInst;
if (WSAStartup(MAKEWORD(1, 1), &wsaData))
return FALSE;
myodbc_init();
}
break;
case DLL_THREAD_ATTACH:
#ifdef THREAD
my_thread_global_init();
#endif
break;
case DLL_PROCESS_DETACH: // case of wep call in win 3.x
if (!--inited)
{
WSACleanup();
}
break;
case DLL_THREAD_DETACH:
break;
default:
break;
} /* switch */
return TRUE;
UNREFERENCED_PARAMETER(lpReserved);
} /* LibMain */
int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved)
{
return LibMain(hInst,ul_reason_being_called,lpReserved);
}
#elif defined(WINDOWS)
// - - - - - - - - -
// This routine is called by LIBSTART.ASM at module load time. All it
// does in this sample is remember the DLL module handle. The module
// handle is needed if you want to do things like load stuff from the
// resource file (for instance string resources).
int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize,
UCHAR FAR *lszCmdLine)
{
s_hModule = hModule;
myodbc_init();
return TRUE;
}
#endif
#ifdef WIN32
void __declspec( dllexport) FAR PASCAL LoadByOrdinal(void);
// Entry point to cause DM to load using ordinals
void __declspec( dllexport) FAR PASCAL LoadByOrdinal(void)
{}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -