corrections-to-MIT-merge-20040306
[openafs.git] / src / WINNT / client_creds / afscreds.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #ifndef AFSCREDS_H
11 #define AFSCREDS_H
12
13
14 /*
15  * INCLUSIONS _________________________________________________________________
16  *
17  */
18
19 #include <WINNT/TaLocale.h>
20 #undef REALLOC /* RT ticket 2120; So we can redefine it later */
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <regstr.h>
24 #include <time.h>
25 #include <shellapi.h>
26 #include <WINNT/al_wizard.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 #include <osithrdnt.h>
31 #include <osisleep.h>
32 #include <osibasel.h>
33 #ifdef __cplusplus
34 }
35 #endif
36 #include "resource.h"
37 #include "checklist.h"
38 #include "window.h"
39 #include "shortcut.h"
40 #include "trayicon.h"
41 #include "creds.h"
42 #include "credstab.h"
43 #include "advtab.h"
44 #include "mounttab.h"
45 #include "afswiz.h"
46 #include "drivemap.h"
47 #include "help.hid"
48
49
50 /*
51  * REG PATHS __________________________________________________________________
52  *
53  */
54
55 #define REGSTR_BASE          HKEY_LOCAL_MACHINE
56 #define REGSTR_PATH_AFS      TEXT("Software\\TransarcCorporation\\AFS Client\\CurrentVersion")
57 #define REGSTR_PATH_AFSCREDS TEXT("Software\\TransarcCorporation\\AFS Client\\AfsCreds")
58
59 #define REGVAL_AFS_TITLE     TEXT("Title")
60 #define REGVAL_AFS_VERSION   TEXT("VersionString")
61 #define REGVAL_AFS_PATCH     TEXT("PatchLevel")
62 #define REGVAL_AFS_PATH      TEXT("PathName")
63
64 #define cszSHORTCUT_NAME     TEXT("AFS Credentials.lnk")
65
66 #define AFSCREDS_SHORTCUT_OPTIONS  TEXT("-A -M -N -Q")
67
68 /*
69  * VARIABLES __________________________________________________________________
70  *
71  */
72
73 typedef struct
74    {
75    TCHAR szCell[ MAX_PATH ];
76    TCHAR szUser[ MAX_PATH ];
77    SYSTEMTIME stExpires;
78    BOOL fRemind;
79    } CREDS, *LPCREDS;
80
81 typedef struct
82    {
83    HWND hMain;
84    CREDS *aCreds;
85    size_t cCreds;
86    DWORD tickLastRetest;
87    LONG fShowingMessage;
88    LPWIZARD pWizard;
89    BOOL fStartup;
90    BOOL fIsWinNT;
91    TCHAR szHelpFile[ MAX_PATH ];
92    osi_mutex_t expirationCheckLock;
93    osi_mutex_t credsLock;
94    } GLOBALS;
95
96 extern GLOBALS g;
97
98
99 /*
100  * TIMING _____________________________________________________________________
101  *
102  */
103
104 #define cminREMIND_TEST      1    // test every minute for expired creds
105 #define cminREMIND_WARN      15   // warn if creds expire in 15 minutes
106 #define cminRENEW            20   // renew creds when there are 20 minutes remaining
107 #define cminMINLIFE          30   // minimum life of Kerberos creds
108
109 #define cmsecMOUSEOVER       1000 // retest freq when mouse is over tray icon
110 #define cmsecSERVICE         2000 // retest freq when starting/stopping service
111
112 #define c100ns1SECOND        (LONGLONG)10000000
113 #define cmsec1SECOND         1000
114 #define cmsec1MINUTE         60000
115 #define csec1MINUTE          60
116
117
118 #define ID_REMIND_TIMER      1000
119 #define ID_SERVICE_TIMER     1001
120 #define ID_WIZARD_TIMER      1002
121
122
123 /*
124  * MACROS _____________________________________________________________________
125  *
126  */
127
128 #ifndef FileExists
129 #define FileExists(_psz)  ((GetFileAttributes (_psz) == 0xFFFFFFFF) ? FALSE : TRUE)
130 #endif
131
132 #ifndef THIS_HINST
133 #define THIS_HINST  (HINSTANCE)GetModuleHandle(NULL)
134 #endif
135
136 #ifndef iswhite
137 #define iswhite(_ch) ( ((_ch)==TEXT(' ')) || ((_ch)==TEXT('\t')) || ((_ch)==TEXT('\r')) || ((_ch)==TEXT('\n')) )
138 #endif
139
140 #ifndef cxRECT
141 #define cxRECT(_r) ((_r).right - (_r).left)
142 #endif
143
144 #ifndef cyRECT
145 #define cyRECT(_r) ((_r).bottom - (_r).top)
146 #endif
147
148 #ifndef REALLOC
149 #define REALLOC(_a,_c,_r,_i) AfsCredsReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
150 #endif
151
152
153 /*
154  * PROTOTYPES _________________________________________________________________
155  *
156  */
157
158 void Quit (void);
159
160 BOOL AfsCredsReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc);
161
162 void LoadRemind (size_t iCreds);
163 void SaveRemind (size_t iCreds);
164
165 void TimeToSystemTime (SYSTEMTIME *pst, time_t TimeT);
166
167 LPARAM GetTabParam (HWND hTab, int iTab);
168 HWND GetTabChild (HWND hTab);
169
170
171 #endif
172