From: Richard Basch Date: Thu, 20 Feb 1997 06:18:05 +0000 (+0000) Subject: krb5_16.def krb5_32.def: Do not export krb5_init_ets/krb5_finish_ets X-Git-Tag: krb5-1.1-beta1~1266 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a4f02f3eb5b0bb1749a219cc57ec92a1b9cf9318;p=krb5.git krb5_16.def krb5_32.def: Do not export krb5_init_ets/krb5_finish_ets win_glue.c: Re-arranged code to avoid duplication. Initialize kadm and prof error tables for krb5. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9925 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5_16.def b/src/lib/krb5_16.def index 7d7fdc7d5..f2410f55e 100644 --- a/src/lib/krb5_16.def +++ b/src/lib/krb5_16.def @@ -75,7 +75,6 @@ EXPORTS krb5_get_in_tkt_with_skey krb5_get_notification_message krb5_init_context - krb5_init_ets krb5_mk_error krb5_mk_priv krb5_mk_rep diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def index 66b24f638..6c65e4383 100644 --- a/src/lib/krb5_32.def +++ b/src/lib/krb5_32.def @@ -72,7 +72,6 @@ EXPORTS krb5_get_in_tkt_with_skey krb5_get_notification_message krb5_init_context - krb5_init_ets krb5_mk_error krb5_mk_priv krb5_mk_rep diff --git a/src/lib/win_glue.c b/src/lib/win_glue.c index aab6509c1..c9d4971bb 100644 --- a/src/lib/win_glue.c +++ b/src/lib/win_glue.c @@ -16,24 +16,29 @@ * working. */ -/* We can't include winsock.h directly because of /Za (stdc) options */ #ifdef KRB4 #include #endif - #define NEED_SOCKETS #include "k5-int.h" -#if defined(GSSAPI) && !defined(KRB5) -#define KRB5 1 -#endif -#if (defined(KRB4) || defined(KRB5)) && !defined(NEED_WINSOCK) +#ifndef NEED_WINSOCK +#if defined(KRB4) || defined(KRB5) || defined(GSSAPI) #define NEED_WINSOCK 1 #endif +#endif #ifdef KRB4 #include #endif +#ifdef KRB5 +#include "krb5_err.h" +#include "kv5m_err.h" +#include "asn1_err.h" +#include "kdb5_err.h" +#include "profile.h" +#include "adm_err.h" +#endif #ifdef GSSAPI #include "gssapi/generic/gssapi_err_generic.h" #include "gssapi/krb5/gssapi_err_krb5.h" @@ -181,38 +186,74 @@ krb5_error_code krb5_vercheck() return 0; } -#ifdef NEED_WINSOCK -int -win_socket_initialize() + +static HINSTANCE hlibinstance; + +HINSTANCE get_lib_instance() { + return hlibinstance; +} + +#define DLL_STARTUP 0 +#define DLL_SHUTDOWN 1 + +static int +control(int mode) +{ + void ((KRB5_CALLCONV *et_func)(struct error_table FAR *)); +#ifdef NEED_WINSOCK WORD wVersionRequested; WSADATA wsaData; int err; +#endif - wVersionRequested = 0x0101; /* We need version 1.1 */ + switch(mode) { + case DLL_STARTUP: + et_func = add_error_table; - err = WSAStartup (wVersionRequested, &wsaData); - if (err != 0) - return err; /* Library can't initialize */ +#ifdef NEED_WINSOCK + wVersionRequested = 0x0101; /* We need version 1.1 */ + if ((err = WSAStartup (wVersionRequested, &wsaData))) + return err; + if (wVersionRequested != wsaData.wVersion) { + /* DLL couldn't support our version of the spec */ + WSACleanup (); + return -104; /* FIXME -- better error? */ + } +#endif + + break; - if (wVersionRequested != wsaData.wVersion) { - /* DLL couldn't support our version of the spec */ + case DLL_SHUTDOWN: + et_func = remove_error_table; +#ifdef NEED_WINSOCK WSACleanup (); - return -104; /* FIXME -- better error? */ +#endif + break; + + default: + return -1; } - return 0; -} +#ifdef KRB4 + (*et_func)(&et_krb_error_table); +#endif +#ifdef KRB5 + (*et_func)(&et_krb5_error_table); + (*et_func)(&et_kv5m_error_table); + (*et_func)(&et_kdb5_error_table); + (*et_func)(&et_asn1_error_table); + (*et_func)(&et_prof_error_table); + (*et_func)(&et_kadm_error_table); +#endif +#ifdef GSSAPI + (*et_func)(&et_k5g_error_table); + (*et_func)(&et_ggss_error_table); #endif -static HINSTANCE hlibinstance; - -HINSTANCE get_lib_instance() -{ - return hlibinstance; + return 0; } - #ifdef _WIN32 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved) @@ -221,19 +262,8 @@ BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved) { case DLL_PROCESS_ATTACH: hlibinstance = (HINSTANCE) hModule; -#ifdef NEED_WINSOCK - win_socket_initialize (); -#endif -#ifdef KRB4 - initialize_krb_error_table(); -#endif -#ifdef KRB5 - krb5_init_ets((krb5_context)0); -#endif -#ifdef GSSAPI - initialize_k5g_error_table(); - initialize_ggss_error_table(); -#endif + if (control(DLL_STARTUP)) + return FALSE; break; case DLL_THREAD_ATTACH: @@ -243,19 +273,8 @@ BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved) break; case DLL_PROCESS_DETACH: -#ifdef GSSAPI - cleanup_k5g_error_table(); - cleanup_ggss_error_table(); -#endif -#ifdef KRB5 - krb5_finish_ets((krb5_context)0); -#endif -#ifdef KRB4 - cleanup_krb_error_table(); -#endif -#ifdef NEED_WINSOCK - WSACleanup (); -#endif + if (control(DLL_SHUTDOWN)) + return FALSE; break; default: @@ -275,40 +294,20 @@ WORD cbHeap; LPSTR CmdLine; { hlibinstance = hInst; -#ifdef NEED_WINSOCK - win_socket_initialize (); -#endif -#ifdef KRB4 - initialize_krb_error_table(); -#endif -#ifdef KRB5 - krb5_init_ets((krb5_context)0); -#endif -#ifdef GSSAPI - initialize_k5g_error_table(); - initialize_ggss_error_table(); -#endif - return 1; + if (control(DLL_STARTUP)) + return 0; + else + return 1; } int CALLBACK __export WEP(nParam) int nParam; { -#ifdef GSSAPI - cleanup_k5g_error_table(); - cleanup_ggss_error_table(); -#endif -#ifdef KRB5 - krb5_finish_ets((krb5_context)0); -#endif -#ifdef KRB4 - cleanup_krb_error_table(); -#endif -#ifdef NEED_WINSOCK - WSACleanup(); -#endif - return 1; + if (control(DLL_SHUTDOWN)) + return 0; + else + return 1; } #endif