krb5_16.def krb5_32.def: Do not export krb5_init_ets/krb5_finish_ets
authorRichard Basch <probe@mit.edu>
Thu, 20 Feb 1997 06:18:05 +0000 (06:18 +0000)
committerRichard Basch <probe@mit.edu>
Thu, 20 Feb 1997 06:18:05 +0000 (06:18 +0000)
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

src/lib/krb5_16.def
src/lib/krb5_32.def
src/lib/win_glue.c

index 7d7fdc7d55ca4affdbde992c4746dec9d5415589..f2410f55ecd1e85108c8099c86ca336535d4cbf9 100644 (file)
@@ -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
index 66b24f6386bf4e311540785861e324c2b5a30271..6c65e43830ef2a81cd1dbd7e8fe5f3bc1e1a2bc8 100644 (file)
@@ -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
index aab6509c14d89bbec45256e1f1eaea87f4756038..c9d4971bb651f27c78db0138c61661da75c62c36 100644 (file)
  * working. 
  */
 
-/* We can't include winsock.h directly because of /Za (stdc) options */
 #ifdef KRB4
 #include <kerberosIV/krb.h>
 #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 <kerberosIV/krb_err.h>
 #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