1*7f2fe78bSCy Schubert #include "k5-int.h"
2*7f2fe78bSCy Schubert
3*7f2fe78bSCy Schubert #ifdef KRB5
4*7f2fe78bSCy Schubert #include "krb5_err.h"
5*7f2fe78bSCy Schubert #include "kv5m_err.h"
6*7f2fe78bSCy Schubert #include "asn1_err.h"
7*7f2fe78bSCy Schubert #include "kdb5_err.h"
8*7f2fe78bSCy Schubert #include "profile.h"
9*7f2fe78bSCy Schubert extern void krb5_stdcc_shutdown();
10*7f2fe78bSCy Schubert #endif
11*7f2fe78bSCy Schubert #ifdef GSSAPI
12*7f2fe78bSCy Schubert #include "gssapi/generic/gssapi_err_generic.h"
13*7f2fe78bSCy Schubert #include "gssapi/krb5/gssapi_err_krb5.h"
14*7f2fe78bSCy Schubert #endif
15*7f2fe78bSCy Schubert
16*7f2fe78bSCy Schubert
17*7f2fe78bSCy Schubert /*
18*7f2fe78bSCy Schubert * #defines for MIT-specific time-based timebombs and/or version
19*7f2fe78bSCy Schubert * server for the Kerberos DLL.
20*7f2fe78bSCy Schubert */
21*7f2fe78bSCy Schubert
22*7f2fe78bSCy Schubert #ifdef SAP_TIMEBOMB
23*7f2fe78bSCy Schubert #define TIMEBOMB 865141200 /* 1-Jun-97 */
24*7f2fe78bSCy Schubert #define TIMEBOMB_PRODUCT "SAPGUI"
25*7f2fe78bSCy Schubert #define TIMEBOMB_WARN 15
26*7f2fe78bSCy Schubert #define TIMEBOMB_INFO " Please see the web page at:\nhttp://web.mit.edu/reeng/www/saphelp for more information"
27*7f2fe78bSCy Schubert #define TIMEBOMB_ERROR KRB5_APPL_EXPIRED
28*7f2fe78bSCy Schubert #endif
29*7f2fe78bSCy Schubert
30*7f2fe78bSCy Schubert #ifdef KRB_TIMEBOMB
31*7f2fe78bSCy Schubert #define TIMEBOMB 865141200 /* 1-Jun-97 */
32*7f2fe78bSCy Schubert #define TIMEBOMB_PRODUCT "Kerberos V5"
33*7f2fe78bSCy Schubert #define TIMEBOMB_WARN 15
34*7f2fe78bSCy Schubert #define TIMEBOMB_INFO " Please see the web page at:\nhttp://web.mit.edu/reeng/www/saphelp for more information"
35*7f2fe78bSCy Schubert #define TIMEBOMB_ERROR KRB5_LIB_EXPIRED
36*7f2fe78bSCy Schubert #endif
37*7f2fe78bSCy Schubert
38*7f2fe78bSCy Schubert /*
39*7f2fe78bSCy Schubert * #defines for using MIT's version server DLL
40*7f2fe78bSCy Schubert */
41*7f2fe78bSCy Schubert #ifdef SAP_VERSERV
42*7f2fe78bSCy Schubert #define APP_TITLE "KRB5-SAP"
43*7f2fe78bSCy Schubert #define APP_VER "3.0f"
44*7f2fe78bSCy Schubert #define APP_INI "krb5sap.ini"
45*7f2fe78bSCy Schubert #define VERSERV_ERROR KRB5_APPL_EXPIRED
46*7f2fe78bSCy Schubert #endif
47*7f2fe78bSCy Schubert
48*7f2fe78bSCy Schubert #ifdef VERSERV
49*7f2fe78bSCy Schubert #define WINDOWS
50*7f2fe78bSCy Schubert #include <ver.h>
51*7f2fe78bSCy Schubert #include <vs.h>
52*7f2fe78bSCy Schubert #include <v.h>
53*7f2fe78bSCy Schubert
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy Schubert /*
56*7f2fe78bSCy Schubert * This function will get the version resource information from the
57*7f2fe78bSCy Schubert * application using the DLL. This allows us to Version Serve
58*7f2fe78bSCy Schubert * arbitrary third party applications. If there is an error, or we
59*7f2fe78bSCy Schubert * decide that we should not version check the calling application
60*7f2fe78bSCy Schubert * then VSflag will be FALSE when the function returns.
61*7f2fe78bSCy Schubert *
62*7f2fe78bSCy Schubert * The buffers passed into this function must be at least
63*7f2fe78bSCy Schubert * APPVERINFO_SIZE bytes long.
64*7f2fe78bSCy Schubert */
65*7f2fe78bSCy Schubert
66*7f2fe78bSCy Schubert #define APPVERINFO_SIZE 256
67*7f2fe78bSCy Schubert
GetCallingAppVerInfo(char * AppTitle,char * AppVer,char * AppIni,BOOL * VSflag)68*7f2fe78bSCy Schubert void GetCallingAppVerInfo( char *AppTitle, char *AppVer, char *AppIni,
69*7f2fe78bSCy Schubert BOOL *VSflag)
70*7f2fe78bSCy Schubert {
71*7f2fe78bSCy Schubert char CallerFilename[_MAX_PATH];
72*7f2fe78bSCy Schubert LONG *lpLangInfo;
73*7f2fe78bSCy Schubert DWORD hVersionInfoID, size;
74*7f2fe78bSCy Schubert GLOBALHANDLE hVersionInfo;
75*7f2fe78bSCy Schubert LPSTR lpVersionInfo;
76*7f2fe78bSCy Schubert int dumint, retval;
77*7f2fe78bSCy Schubert char *cp;
78*7f2fe78bSCy Schubert char *revAppTitle;
79*7f2fe78bSCy Schubert char szVerQ[90];
80*7f2fe78bSCy Schubert LPBYTE locAppTitle;
81*7f2fe78bSCy Schubert LPBYTE locAppVer;
82*7f2fe78bSCy Schubert char locAppIni[_MAX_PATH];
83*7f2fe78bSCy Schubert #ifndef _WIN32
84*7f2fe78bSCy Schubert WORD wStackSeg;
85*7f2fe78bSCy Schubert #endif /* !_WIN32 */
86*7f2fe78bSCy Schubert
87*7f2fe78bSCy Schubert /* first we need to get the calling module's filename */
88*7f2fe78bSCy Schubert #ifndef _WIN32
89*7f2fe78bSCy Schubert _asm {
90*7f2fe78bSCy Schubert mov wStackSeg, ss
91*7f2fe78bSCy Schubert };
92*7f2fe78bSCy Schubert retval = GetModuleFileName((HMODULE)wStackSeg, CallerFilename,
93*7f2fe78bSCy Schubert _MAX_PATH);
94*7f2fe78bSCy Schubert #else
95*7f2fe78bSCy Schubert /*
96*7f2fe78bSCy Schubert * Note: this may only work for single threaded applications,
97*7f2fe78bSCy Schubert * we'll live and learn ...
98*7f2fe78bSCy Schubert */
99*7f2fe78bSCy Schubert retval = GetModuleFileName( NULL, CallerFilename, _MAX_PATH);
100*7f2fe78bSCy Schubert #endif
101*7f2fe78bSCy Schubert
102*7f2fe78bSCy Schubert if ( retval == 0 ) {
103*7f2fe78bSCy Schubert VSflag = FALSE;
104*7f2fe78bSCy Schubert return;
105*7f2fe78bSCy Schubert }
106*7f2fe78bSCy Schubert
107*7f2fe78bSCy Schubert size = GetFileVersionInfoSize( CallerFilename, &hVersionInfoID);
108*7f2fe78bSCy Schubert
109*7f2fe78bSCy Schubert if( size == 0 ) {
110*7f2fe78bSCy Schubert /*
111*7f2fe78bSCy Schubert * hey , I bet we don't have a version resource, let's
112*7f2fe78bSCy Schubert * punt
113*7f2fe78bSCy Schubert */
114*7f2fe78bSCy Schubert *VSflag = FALSE;
115*7f2fe78bSCy Schubert return;
116*7f2fe78bSCy Schubert }
117*7f2fe78bSCy Schubert
118*7f2fe78bSCy Schubert hVersionInfo = GlobalAlloc(GHND, size);
119*7f2fe78bSCy Schubert lpVersionInfo = GlobalLock(hVersionInfo);
120*7f2fe78bSCy Schubert
121*7f2fe78bSCy Schubert retval = GetFileVersionInfo( CallerFilename, hVersionInfoID, size,
122*7f2fe78bSCy Schubert lpVersionInfo);
123*7f2fe78bSCy Schubert
124*7f2fe78bSCy Schubert retval = VerQueryValue(lpVersionInfo, "\\VarFileInfo\\Translation",
125*7f2fe78bSCy Schubert (LPSTR *)&lpLangInfo, &dumint);
126*7f2fe78bSCy Schubert wsprintf(szVerQ,
127*7f2fe78bSCy Schubert "\\StringFileInfo\\%04x%04x\\",
128*7f2fe78bSCy Schubert LOWORD(*lpLangInfo), HIWORD(*lpLangInfo));
129*7f2fe78bSCy Schubert
130*7f2fe78bSCy Schubert cp = szVerQ + lstrlen(szVerQ);
131*7f2fe78bSCy Schubert
132*7f2fe78bSCy Schubert lstrcpy(cp, "ProductName");
133*7f2fe78bSCy Schubert
134*7f2fe78bSCy Schubert
135*7f2fe78bSCy Schubert /* try a localAppTitle and then a strcpy 4/2/97 */
136*7f2fe78bSCy Schubert
137*7f2fe78bSCy Schubert locAppTitle = 0;
138*7f2fe78bSCy Schubert locAppVer = 0;
139*7f2fe78bSCy Schubert
140*7f2fe78bSCy Schubert retval = VerQueryValue(lpVersionInfo, szVerQ, &locAppTitle,
141*7f2fe78bSCy Schubert &dumint);
142*7f2fe78bSCy Schubert
143*7f2fe78bSCy Schubert lstrcpy(cp, "ProductVersion");
144*7f2fe78bSCy Schubert
145*7f2fe78bSCy Schubert
146*7f2fe78bSCy Schubert retval = VerQueryValue(lpVersionInfo, szVerQ, &locAppVer,
147*7f2fe78bSCy Schubert &dumint);
148*7f2fe78bSCy Schubert
149*7f2fe78bSCy Schubert if (!locAppTitle || !locAppVer) {
150*7f2fe78bSCy Schubert /* Punt, we don't have the right version resource records */
151*7f2fe78bSCy Schubert *VSflag = FALSE;
152*7f2fe78bSCy Schubert return;
153*7f2fe78bSCy Schubert }
154*7f2fe78bSCy Schubert
155*7f2fe78bSCy Schubert /*
156*7f2fe78bSCy Schubert * We don't have a way to determine that INI file of the
157*7f2fe78bSCy Schubert * application at the moment so let's just use krb5.ini
158*7f2fe78bSCy Schubert */
159*7f2fe78bSCy Schubert strncpy( locAppIni, KERBEROS_INI, sizeof(locAppIni) - 1 );
160*7f2fe78bSCy Schubert locAppIni[ sizeof(locAppIni) - 1 ] = '\0';
161*7f2fe78bSCy Schubert
162*7f2fe78bSCy Schubert strncpy( AppTitle, locAppTitle, APPVERINFO_SIZE);
163*7f2fe78bSCy Schubert AppTitle[APPVERINFO_SIZE - 1] = '\0';
164*7f2fe78bSCy Schubert strncpy( AppVer, locAppVer, APPVERINFO_SIZE);
165*7f2fe78bSCy Schubert AppVer[APPVERINFO_SIZE - 1] = '\0';
166*7f2fe78bSCy Schubert strncpy( AppIni, locAppIni, APPVERINFO_SIZE);
167*7f2fe78bSCy Schubert AppIni[APPVERINFO_SIZE - 1] = '\0';
168*7f2fe78bSCy Schubert
169*7f2fe78bSCy Schubert /*
170*7f2fe78bSCy Schubert * We also need to determine if we want to suppress version
171*7f2fe78bSCy Schubert * checking of this application. Does the tail of the
172*7f2fe78bSCy Schubert * AppTitle end in a "-v" ?
173*7f2fe78bSCy Schubert */
174*7f2fe78bSCy Schubert revAppTitle = _strrev( _strdup(AppTitle));
175*7f2fe78bSCy Schubert if( revAppTitle[0] == 'v' || revAppTitle[0] == 'V' &&
176*7f2fe78bSCy Schubert revAppTitle[1] == '-' ) {
177*7f2fe78bSCy Schubert VSflag = FALSE;
178*7f2fe78bSCy Schubert }
179*7f2fe78bSCy Schubert return;
180*7f2fe78bSCy Schubert }
181*7f2fe78bSCy Schubert
182*7f2fe78bSCy Schubert
183*7f2fe78bSCy Schubert /*
184*7f2fe78bSCy Schubert * Use the version server to give us some control on distribution and usage
185*7f2fe78bSCy Schubert * We're going to test track as well
186*7f2fe78bSCy Schubert */
CallVersionServer(app_title,app_version,app_ini,code_cover)187*7f2fe78bSCy Schubert static int CallVersionServer(app_title, app_version, app_ini, code_cover)
188*7f2fe78bSCy Schubert char *app_title;
189*7f2fe78bSCy Schubert char *app_version;
190*7f2fe78bSCy Schubert char *app_ini;
191*7f2fe78bSCy Schubert char *code_cover;
192*7f2fe78bSCy Schubert {
193*7f2fe78bSCy Schubert VS_Request vrequest;
194*7f2fe78bSCy Schubert VS_Status vstatus;
195*7f2fe78bSCy Schubert
196*7f2fe78bSCy Schubert SetCursor(LoadCursor(NULL, IDC_WAIT));
197*7f2fe78bSCy Schubert
198*7f2fe78bSCy Schubert /*
199*7f2fe78bSCy Schubert * We should be able to pass in code_cover below, but things
200*7f2fe78bSCy Schubert * are breaking under Windows 16 for no good reason.
201*7f2fe78bSCy Schubert */
202*7f2fe78bSCy Schubert vrequest = VSFormRequest((LPSTR) app_title, (LPSTR) app_version,
203*7f2fe78bSCy Schubert (LPSTR) app_ini,
204*7f2fe78bSCy Schubert NULL /* code_cover */, NULL,
205*7f2fe78bSCy Schubert V_CHECK_AND_LOG);
206*7f2fe78bSCy Schubert
207*7f2fe78bSCy Schubert SetCursor(LoadCursor(NULL, IDC_ARROW));
208*7f2fe78bSCy Schubert /*
209*7f2fe78bSCy Schubert * If the user presses cancel when registering the test
210*7f2fe78bSCy Schubert * tracker, we'll let them continue.
211*7f2fe78bSCy Schubert */
212*7f2fe78bSCy Schubert if (ReqStatus(vrequest) == V_E_CANCEL) {
213*7f2fe78bSCy Schubert VSDestroyRequest(vrequest);
214*7f2fe78bSCy Schubert return 0;
215*7f2fe78bSCy Schubert }
216*7f2fe78bSCy Schubert vstatus = VSProcessRequest(vrequest);
217*7f2fe78bSCy Schubert /*
218*7f2fe78bSCy Schubert * Only complain periodically, if the test tracker isn't
219*7f2fe78bSCy Schubert * working...
220*7f2fe78bSCy Schubert */
221*7f2fe78bSCy Schubert if (v_complain(vstatus, app_ini)) {
222*7f2fe78bSCy Schubert WinVSReportRequest(vrequest, NULL,
223*7f2fe78bSCy Schubert "Version Server Status Report");
224*7f2fe78bSCy Schubert }
225*7f2fe78bSCy Schubert if (vstatus == V_REQUIRED) {
226*7f2fe78bSCy Schubert SetCursor(LoadCursor(NULL, IDC_WAIT));
227*7f2fe78bSCy Schubert VSDestroyRequest(vrequest);
228*7f2fe78bSCy Schubert return( -1 );
229*7f2fe78bSCy Schubert }
230*7f2fe78bSCy Schubert VSDestroyRequest(vrequest);
231*7f2fe78bSCy Schubert return (0);
232*7f2fe78bSCy Schubert }
233*7f2fe78bSCy Schubert #endif
234*7f2fe78bSCy Schubert
235*7f2fe78bSCy Schubert #ifdef TIMEBOMB
do_timebomb()236*7f2fe78bSCy Schubert static krb5_error_code do_timebomb()
237*7f2fe78bSCy Schubert {
238*7f2fe78bSCy Schubert char buf[1024];
239*7f2fe78bSCy Schubert long timeleft;
240*7f2fe78bSCy Schubert static first_time = 1;
241*7f2fe78bSCy Schubert
242*7f2fe78bSCy Schubert timeleft = TIMEBOMB - time(0);
243*7f2fe78bSCy Schubert if (timeleft <= 0) {
244*7f2fe78bSCy Schubert if (first_time) {
245*7f2fe78bSCy Schubert sprintf(buf, "Your version of %s has expired.\n",
246*7f2fe78bSCy Schubert TIMEBOMB_PRODUCT);
247*7f2fe78bSCy Schubert buf[sizeof(buf) - 1] = '\0';
248*7f2fe78bSCy Schubert strncat(buf, "Please upgrade it.", sizeof(buf) - 1 - strlen(buf));
249*7f2fe78bSCy Schubert #ifdef TIMEBOMB_INFO
250*7f2fe78bSCy Schubert strncat(buf, TIMEBOMB_INFO, sizeof(buf) - 1 - strlen(buf));
251*7f2fe78bSCy Schubert #endif
252*7f2fe78bSCy Schubert MessageBox(NULL, buf, "", MB_OK);
253*7f2fe78bSCy Schubert first_time = 0;
254*7f2fe78bSCy Schubert }
255*7f2fe78bSCy Schubert return TIMEBOMB_ERROR;
256*7f2fe78bSCy Schubert }
257*7f2fe78bSCy Schubert timeleft = timeleft / ((long) 60*60*24);
258*7f2fe78bSCy Schubert if (timeleft < TIMEBOMB_WARN) {
259*7f2fe78bSCy Schubert if (first_time) {
260*7f2fe78bSCy Schubert sprintf(buf, "Your version of %s will expire in %ld days.\n",
261*7f2fe78bSCy Schubert TIMEBOMB_PRODUCT, timeleft);
262*7f2fe78bSCy Schubert strncat(buf, "Please upgrade it soon.", sizeof(buf) - 1 - strlen(buf));
263*7f2fe78bSCy Schubert #ifdef TIMEBOMB_INFO
264*7f2fe78bSCy Schubert strncat(buf, TIMEBOMB_INFO, sizeof(buf) - 1 - strlen(buf));
265*7f2fe78bSCy Schubert #endif
266*7f2fe78bSCy Schubert MessageBox(NULL, buf, "", MB_OK);
267*7f2fe78bSCy Schubert first_time = 0;
268*7f2fe78bSCy Schubert }
269*7f2fe78bSCy Schubert }
270*7f2fe78bSCy Schubert return 0;
271*7f2fe78bSCy Schubert }
272*7f2fe78bSCy Schubert #endif
273*7f2fe78bSCy Schubert
274*7f2fe78bSCy Schubert /*
275*7f2fe78bSCy Schubert * This was originally called from LibMain; unfortunately, Windows 3.1
276*7f2fe78bSCy Schubert * doesn't allow you to make messaging calls from LibMain. So, we now
277*7f2fe78bSCy Schubert * do the timebomb/version server stuff from krb5_init_context().
278*7f2fe78bSCy Schubert */
krb5_vercheck()279*7f2fe78bSCy Schubert krb5_error_code krb5_vercheck()
280*7f2fe78bSCy Schubert {
281*7f2fe78bSCy Schubert static int verchecked = 0;
282*7f2fe78bSCy Schubert if (verchecked)
283*7f2fe78bSCy Schubert return 0;
284*7f2fe78bSCy Schubert #ifdef TIMEBOMB
285*7f2fe78bSCy Schubert krb5_error_code retval = do_timebomb();
286*7f2fe78bSCy Schubert if (retval)
287*7f2fe78bSCy Schubert return retval;
288*7f2fe78bSCy Schubert #endif
289*7f2fe78bSCy Schubert #ifdef VERSERV
290*7f2fe78bSCy Schubert {
291*7f2fe78bSCy Schubert #ifdef APP_TITLE
292*7f2fe78bSCy Schubert if (CallVersionServer(APP_TITLE, APP_VER, APP_INI, NULL))
293*7f2fe78bSCy Schubert return VERSERV_ERROR;
294*7f2fe78bSCy Schubert #else
295*7f2fe78bSCy Schubert char AppTitle[APPVERINFO_SIZE];
296*7f2fe78bSCy Schubert char AppVer[APPVERINFO_SIZE];
297*7f2fe78bSCy Schubert char AppIni[APPVERINFO_SIZE];
298*7f2fe78bSCy Schubert BOOL VSflag=TRUE;
299*7f2fe78bSCy Schubert
300*7f2fe78bSCy Schubert GetCallingAppVerInfo( AppTitle, AppVer, AppIni, &VSflag);
301*7f2fe78bSCy Schubert
302*7f2fe78bSCy Schubert if (VSflag) {
303*7f2fe78bSCy Schubert if (CallVersionServer(AppTitle, AppVer, AppIni, NULL))
304*7f2fe78bSCy Schubert return KRB5_APPL_EXPIRED;
305*7f2fe78bSCy Schubert }
306*7f2fe78bSCy Schubert #endif
307*7f2fe78bSCy Schubert
308*7f2fe78bSCy Schubert }
309*7f2fe78bSCy Schubert #endif
310*7f2fe78bSCy Schubert verchecked = 1;
311*7f2fe78bSCy Schubert return 0;
312*7f2fe78bSCy Schubert }
313*7f2fe78bSCy Schubert
314*7f2fe78bSCy Schubert
315*7f2fe78bSCy Schubert static HINSTANCE hlibinstance;
316*7f2fe78bSCy Schubert
get_lib_instance()317*7f2fe78bSCy Schubert HINSTANCE get_lib_instance()
318*7f2fe78bSCy Schubert {
319*7f2fe78bSCy Schubert return hlibinstance;
320*7f2fe78bSCy Schubert }
321*7f2fe78bSCy Schubert
322*7f2fe78bSCy Schubert #define DLL_STARTUP 0
323*7f2fe78bSCy Schubert #define DLL_SHUTDOWN 1
324*7f2fe78bSCy Schubert
325*7f2fe78bSCy Schubert static int
control(int mode)326*7f2fe78bSCy Schubert control(int mode)
327*7f2fe78bSCy Schubert {
328*7f2fe78bSCy Schubert switch(mode) {
329*7f2fe78bSCy Schubert case DLL_STARTUP:
330*7f2fe78bSCy Schubert break;
331*7f2fe78bSCy Schubert
332*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
333*7f2fe78bSCy Schubert #ifdef KRB5
334*7f2fe78bSCy Schubert krb5_stdcc_shutdown();
335*7f2fe78bSCy Schubert #endif
336*7f2fe78bSCy Schubert break;
337*7f2fe78bSCy Schubert
338*7f2fe78bSCy Schubert #if defined(ENABLE_THREADS) && defined(SUPPORTLIB)
339*7f2fe78bSCy Schubert case DLL_THREAD_DETACH:
340*7f2fe78bSCy Schubert krb5int_thread_detach_hook();
341*7f2fe78bSCy Schubert return 0;
342*7f2fe78bSCy Schubert #endif
343*7f2fe78bSCy Schubert
344*7f2fe78bSCy Schubert default:
345*7f2fe78bSCy Schubert return -1;
346*7f2fe78bSCy Schubert }
347*7f2fe78bSCy Schubert
348*7f2fe78bSCy Schubert #if defined KRB5
349*7f2fe78bSCy Schubert switch (mode) {
350*7f2fe78bSCy Schubert case DLL_STARTUP:
351*7f2fe78bSCy Schubert profile_library_initializer__auxinit();
352*7f2fe78bSCy Schubert krb5int_lib_init__auxinit();
353*7f2fe78bSCy Schubert break;
354*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
355*7f2fe78bSCy Schubert krb5int_lib_fini();
356*7f2fe78bSCy Schubert profile_library_finalizer();
357*7f2fe78bSCy Schubert break;
358*7f2fe78bSCy Schubert }
359*7f2fe78bSCy Schubert #elif defined GSSAPI
360*7f2fe78bSCy Schubert switch (mode) {
361*7f2fe78bSCy Schubert case DLL_STARTUP:
362*7f2fe78bSCy Schubert gssint_mechglue_init__auxinit();
363*7f2fe78bSCy Schubert break;
364*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
365*7f2fe78bSCy Schubert gssint_mechglue_fini();
366*7f2fe78bSCy Schubert break;
367*7f2fe78bSCy Schubert }
368*7f2fe78bSCy Schubert #elif defined COMERR
369*7f2fe78bSCy Schubert switch (mode) {
370*7f2fe78bSCy Schubert case DLL_STARTUP:
371*7f2fe78bSCy Schubert com_err_initialize__auxinit();
372*7f2fe78bSCy Schubert break;
373*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
374*7f2fe78bSCy Schubert com_err_terminate();
375*7f2fe78bSCy Schubert break;
376*7f2fe78bSCy Schubert }
377*7f2fe78bSCy Schubert #elif defined PROFILELIB
378*7f2fe78bSCy Schubert switch (mode) {
379*7f2fe78bSCy Schubert case DLL_STARTUP:
380*7f2fe78bSCy Schubert profile_library_initializer__auxinit();
381*7f2fe78bSCy Schubert break;
382*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
383*7f2fe78bSCy Schubert profile_library_finalizer();
384*7f2fe78bSCy Schubert break;
385*7f2fe78bSCy Schubert }
386*7f2fe78bSCy Schubert #elif defined SUPPORTLIB
387*7f2fe78bSCy Schubert switch (mode) {
388*7f2fe78bSCy Schubert case DLL_STARTUP:
389*7f2fe78bSCy Schubert krb5int_thread_support_init__auxinit();
390*7f2fe78bSCy Schubert break;
391*7f2fe78bSCy Schubert case DLL_SHUTDOWN:
392*7f2fe78bSCy Schubert krb5int_thread_support_fini();
393*7f2fe78bSCy Schubert break;
394*7f2fe78bSCy Schubert }
395*7f2fe78bSCy Schubert #else
396*7f2fe78bSCy Schubert # error "Don't know the init/fini functions for this library."
397*7f2fe78bSCy Schubert #endif
398*7f2fe78bSCy Schubert
399*7f2fe78bSCy Schubert return 0;
400*7f2fe78bSCy Schubert }
401*7f2fe78bSCy Schubert
402*7f2fe78bSCy Schubert #ifdef _WIN32
403*7f2fe78bSCy Schubert
DllMain(HANDLE hModule,DWORD fdwReason,LPVOID lpReserved)404*7f2fe78bSCy Schubert BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
405*7f2fe78bSCy Schubert {
406*7f2fe78bSCy Schubert switch (fdwReason)
407*7f2fe78bSCy Schubert {
408*7f2fe78bSCy Schubert case DLL_PROCESS_ATTACH:
409*7f2fe78bSCy Schubert hlibinstance = (HINSTANCE) hModule;
410*7f2fe78bSCy Schubert if (control(DLL_STARTUP))
411*7f2fe78bSCy Schubert return FALSE;
412*7f2fe78bSCy Schubert break;
413*7f2fe78bSCy Schubert
414*7f2fe78bSCy Schubert case DLL_THREAD_ATTACH:
415*7f2fe78bSCy Schubert break;
416*7f2fe78bSCy Schubert
417*7f2fe78bSCy Schubert case DLL_THREAD_DETACH:
418*7f2fe78bSCy Schubert if (control(DLL_THREAD_DETACH))
419*7f2fe78bSCy Schubert return FALSE;
420*7f2fe78bSCy Schubert break;
421*7f2fe78bSCy Schubert
422*7f2fe78bSCy Schubert case DLL_PROCESS_DETACH:
423*7f2fe78bSCy Schubert if (control(DLL_SHUTDOWN))
424*7f2fe78bSCy Schubert return FALSE;
425*7f2fe78bSCy Schubert break;
426*7f2fe78bSCy Schubert
427*7f2fe78bSCy Schubert default:
428*7f2fe78bSCy Schubert return FALSE;
429*7f2fe78bSCy Schubert }
430*7f2fe78bSCy Schubert
431*7f2fe78bSCy Schubert return TRUE; // successful DLL_PROCESS_ATTACH
432*7f2fe78bSCy Schubert }
433*7f2fe78bSCy Schubert
434*7f2fe78bSCy Schubert #else
435*7f2fe78bSCy Schubert
436*7f2fe78bSCy Schubert BOOL CALLBACK
LibMain(hInst,wDataSeg,cbHeap,CmdLine)437*7f2fe78bSCy Schubert LibMain (hInst, wDataSeg, cbHeap, CmdLine)
438*7f2fe78bSCy Schubert HINSTANCE hInst;
439*7f2fe78bSCy Schubert WORD wDataSeg;
440*7f2fe78bSCy Schubert WORD cbHeap;
441*7f2fe78bSCy Schubert LPSTR CmdLine;
442*7f2fe78bSCy Schubert {
443*7f2fe78bSCy Schubert hlibinstance = hInst;
444*7f2fe78bSCy Schubert if (control(DLL_STARTUP))
445*7f2fe78bSCy Schubert return 0;
446*7f2fe78bSCy Schubert else
447*7f2fe78bSCy Schubert return 1;
448*7f2fe78bSCy Schubert }
449*7f2fe78bSCy Schubert
450*7f2fe78bSCy Schubert int CALLBACK __export
WEP(nParam)451*7f2fe78bSCy Schubert WEP(nParam)
452*7f2fe78bSCy Schubert int nParam;
453*7f2fe78bSCy Schubert {
454*7f2fe78bSCy Schubert if (control(DLL_SHUTDOWN))
455*7f2fe78bSCy Schubert return 0;
456*7f2fe78bSCy Schubert else
457*7f2fe78bSCy Schubert return 1;
458*7f2fe78bSCy Schubert }
459*7f2fe78bSCy Schubert
460*7f2fe78bSCy Schubert #endif
461