2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 #include <afs/param.h>
18 #include <WINNT/afsapplib.h>
19 #include "al_dynlink.h"
23 * LIBRARIES __________________________________________________________________
27 #define cszLIBRARY_UTIL TEXT("AfsAdminUtil.dll")
28 #define cszLIBRARY_KAS TEXT("AfsKasAdmin.dll")
29 #define cszLIBRARY_CLIENT TEXT("AfsClientAdmin.dll")
33 * ADMIN ______________________________________________________________________
37 static size_t g_cReqUtilLibrary
= 0;
38 static HINSTANCE g_hiUtilLibrary
= NULL
;
40 util_AdminErrorCodeTranslate_t util_AdminErrorCodeTranslateP
= NULL
;
43 BOOL
OpenUtilLibrary (ULONG
*pStatus
)
46 ULONG status
= ERROR_DLL_NOT_FOUND
;
48 if ((++g_cReqUtilLibrary
) == 1)
50 if ( ((g_hiUtilLibrary
= LoadLibrary (cszLIBRARY_UTIL
)) == NULL
) ||
51 ((util_AdminErrorCodeTranslateP
= (util_AdminErrorCodeTranslate_t
)GetProcAddress (g_hiUtilLibrary
, "util_AdminErrorCodeTranslate")) == NULL
) )
53 status
= GetLastError();
68 void CloseUtilLibrary (void)
70 if ((--g_cReqUtilLibrary
) == 0)
73 FreeLibrary (g_hiUtilLibrary
);
74 g_hiUtilLibrary
= NULL
;
80 * KAS ________________________________________________________________________
84 static size_t g_cReqKasLibrary
= 0;
85 static HINSTANCE g_hiKasLibrary
= NULL
;
87 kas_PrincipalGetBegin_t kas_PrincipalGetBeginP
= NULL
;
88 kas_PrincipalGetNext_t kas_PrincipalGetNextP
= NULL
;
89 kas_PrincipalGetDone_t kas_PrincipalGetDoneP
= NULL
;
90 kas_PrincipalGet_t kas_PrincipalGetP
= NULL
;
93 BOOL
OpenKasLibrary (ULONG
*pStatus
)
96 ULONG status
= ERROR_DLL_NOT_FOUND
;
98 if ((++g_cReqKasLibrary
) == 1)
100 if ( ((g_hiKasLibrary
= LoadLibrary (cszLIBRARY_KAS
)) == NULL
) ||
101 ((kas_PrincipalGetBeginP
= (kas_PrincipalGetBegin_t
)GetProcAddress (g_hiKasLibrary
, "kas_PrincipalGetBegin")) == NULL
) ||
102 ((kas_PrincipalGetNextP
= (kas_PrincipalGetNext_t
)GetProcAddress (g_hiKasLibrary
, "kas_PrincipalGetNext")) == NULL
) ||
103 ((kas_PrincipalGetDoneP
= (kas_PrincipalGetDone_t
)GetProcAddress (g_hiKasLibrary
, "kas_PrincipalGetDone")) == NULL
) ||
104 ((kas_PrincipalGetP
= (kas_PrincipalGet_t
)GetProcAddress (g_hiKasLibrary
, "kas_PrincipalGet")) == NULL
) )
106 status
= GetLastError();
121 void CloseKasLibrary (void)
123 if ((--g_cReqKasLibrary
) == 0)
126 FreeLibrary (g_hiKasLibrary
);
127 g_hiKasLibrary
= NULL
;
133 * CLIENT _____________________________________________________________________
137 static size_t g_cReqClientLibrary
= 0;
138 static HINSTANCE g_hiClientLibrary
= NULL
;
140 typedef int (ADMINAPI
*afsclient_Init_t
)(afs_status_p st
);
142 afsclient_TokenGetExisting_t afsclient_TokenGetExistingP
= NULL
;
143 afsclient_TokenGetNew_t afsclient_TokenGetNewP
= NULL
;
144 afsclient_TokenClose_t afsclient_TokenCloseP
= NULL
;
145 afsclient_TokenQuery_t afsclient_TokenQueryP
= NULL
;
146 afsclient_CellOpen_t afsclient_CellOpenP
= NULL
;
147 afsclient_CellClose_t afsclient_CellCloseP
= NULL
;
148 afsclient_LocalCellGet_t afsclient_LocalCellGetP
= NULL
;
149 afsclient_Init_t afsclient_InitP
= NULL
;
152 BOOL
OpenClientLibrary (ULONG
*pStatus
)
155 ULONG status
= ERROR_DLL_NOT_FOUND
;
157 if ((++g_cReqClientLibrary
) == 1)
159 if ( ((g_hiClientLibrary
= LoadLibrary (cszLIBRARY_CLIENT
)) == NULL
) ||
160 ((afsclient_TokenGetExistingP
= (afsclient_TokenGetExisting_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_TokenGetExisting")) == NULL
) ||
161 ((afsclient_TokenGetNewP
= (afsclient_TokenGetNew_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_TokenGetNew")) == NULL
) ||
162 ((afsclient_TokenCloseP
= (afsclient_TokenClose_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_TokenClose")) == NULL
) ||
163 ((afsclient_TokenQueryP
= (afsclient_TokenQuery_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_TokenQuery")) == NULL
) ||
164 ((afsclient_CellOpenP
= (afsclient_CellOpen_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_CellOpen")) == NULL
) ||
165 ((afsclient_CellCloseP
= (afsclient_CellClose_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_CellClose")) == NULL
) ||
166 ((afsclient_LocalCellGetP
= (afsclient_LocalCellGet_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_LocalCellGet")) == NULL
) ||
167 ((afsclient_InitP
= (afsclient_Init_t
)GetProcAddress (g_hiClientLibrary
, "afsclient_Init")) == NULL
) )
169 status
= GetLastError();
170 CloseClientLibrary();
172 else if (!(*afsclient_InitP
)((afs_status_p
)&status
))
174 CloseClientLibrary();
177 if (g_hiClientLibrary
)
188 void CloseClientLibrary (void)
190 if ((--g_cReqClientLibrary
) == 0)
192 if (g_hiClientLibrary
)
193 FreeLibrary (g_hiClientLibrary
);
194 g_hiClientLibrary
= NULL
;