8c3cd914 |
1 | /* |
2 | * winstuff.h: Windows-specific inter-module stuff. |
3 | */ |
4 | |
f7f27309 |
5 | #ifndef PUTTY_WINSTUFF_H |
6 | #define PUTTY_WINSTUFF_H |
7 | |
9a30e26b |
8 | #include <stdio.h> /* for FILENAME_MAX */ |
9 | |
fe8abbf4 |
10 | #include "tree234.h" |
11 | |
12 | #include "winhelp.h" |
13 | |
9a30e26b |
14 | struct Filename { |
15 | char path[FILENAME_MAX]; |
16 | }; |
17 | #define f_open(filename, mode) ( fopen((filename).path, (mode)) ) |
18 | |
19 | struct FontSpec { |
20 | char name[64]; |
21 | int isbold; |
22 | int height; |
23 | int charset; |
24 | }; |
25 | |
8ee3ff16 |
26 | struct dlgboxinfo { |
27 | int result; |
28 | int flags; |
29 | }; |
30 | |
31 | #define DF_END 0x0001 |
32 | |
8c3cd914 |
33 | /* |
34 | * Global variables. Most modules declare these `extern', but |
35 | * window.c will do `#define PUTTY_DO_GLOBALS' before including this |
36 | * module, and so will get them properly defined. |
37 | */ |
f7f27309 |
38 | #ifndef GLOBAL |
8c3cd914 |
39 | #ifdef PUTTY_DO_GLOBALS |
40 | #define GLOBAL |
41 | #else |
42 | #define GLOBAL extern |
43 | #endif |
f7f27309 |
44 | #endif |
45 | |
a8327734 |
46 | #ifndef DONE_TYPEDEFS |
47 | #define DONE_TYPEDEFS |
48 | typedef struct config_tag Config; |
49 | typedef struct backend_tag Backend; |
50 | typedef struct terminal_tag Terminal; |
51 | #endif |
52 | |
f7f27309 |
53 | #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY" |
54 | #define PUTTY_REG_PARENT "Software\\SimonTatham" |
55 | #define PUTTY_REG_PARENT_CHILD "PuTTY" |
56 | #define PUTTY_REG_GPARENT "Software" |
57 | #define PUTTY_REG_GPARENT_CHILD "SimonTatham" |
58 | |
59 | #define GETTICKCOUNT GetTickCount |
60 | #define CURSORBLINK GetCaretBlinkTime() |
61 | #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */ |
62 | |
63 | #define DEFAULT_CODEPAGE CP_ACP |
64 | |
65 | typedef HDC Context; |
8c3cd914 |
66 | |
f7f27309 |
67 | /* |
68 | * Window handles for the dialog boxes that can be running during a |
69 | * PuTTY session. |
70 | */ |
71 | GLOBAL HWND logbox; |
72 | |
73 | /* |
8ee3ff16 |
74 | * Global structure to hold return values from the config box. |
75 | */ |
76 | GLOBAL struct dlgboxinfo boxinfo; |
77 | |
78 | /* |
f7f27309 |
79 | * The all-important instance handle. |
80 | */ |
8c3cd914 |
81 | GLOBAL HINSTANCE hinst; |
82 | |
83 | /* |
6b78788a |
84 | * Details of the help file. |
85 | */ |
86 | GLOBAL char *help_path; |
87 | GLOBAL int help_has_contents; |
88 | |
89 | /* |
a8327734 |
90 | * The terminal and logging context are notionally local to the |
91 | * Windows front end, but they must be shared between window.c and |
0b4f0bc0 |
92 | * windlg.c. Likewise the saved-sessions list. |
a8327734 |
93 | */ |
94 | GLOBAL Terminal *term; |
95 | GLOBAL void *logctx; |
96 | |
97 | /* |
f7f27309 |
98 | * I've just looked in the windows standard headr files for WM_USER, there |
99 | * are hundreds of flags defined using the form WM_USER+123 so I've |
100 | * renumbered this NETEVENT value and the two in window.c |
101 | */ |
102 | #define WM_XUSER (WM_USER + 0x2000) |
103 | #define WM_NETEVENT (WM_XUSER + 5) |
104 | |
105 | /* |
e6346999 |
106 | * On Windows, we send MA_2CLK as the only event marking the second |
107 | * press of a mouse button. Compare unix.h. |
108 | */ |
109 | #define MULTICLICK_ONLY_EVENT 1 |
110 | |
111 | /* |
112 | * On Windows, data written to the clipboard must be NUL-terminated. |
113 | */ |
114 | #define SELECTION_NUL_TERMINATED 1 |
115 | |
116 | /* |
0f351587 |
117 | * On Windows, copying to the clipboard terminates lines with CRLF. |
118 | */ |
119 | #define SEL_NL { 13, 10 } |
120 | |
121 | /* |
2f92b717 |
122 | * sk_getxdmdata() does not exist under Windows (not that I |
123 | * couldn't write it if I wanted to, but I haven't bothered), so |
124 | * it's a macro which always returns FALSE. With any luck this will |
125 | * cause the compiler to notice it can optimise away the |
126 | * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-) |
127 | */ |
128 | #define sk_getxdmdata(socket, ip, port) (0) |
129 | |
130 | /* |
fe8abbf4 |
131 | * File-selector filter strings used in the config box. On Windows, |
132 | * these strings are of exactly the type needed to go in |
133 | * `lpstrFilter' in an OPENFILENAME structure. |
134 | */ |
135 | #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \ |
136 | "All Files (*.*)\0*\0\0\0") |
137 | #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \ |
138 | "All Files (*.*)\0*\0\0\0") |
139 | |
140 | /* |
8c3cd914 |
141 | * Exports from winctrls.c. |
142 | */ |
143 | |
144 | struct ctlpos { |
145 | HWND hwnd; |
146 | WPARAM font; |
147 | int dlu4inpix; |
148 | int ypos, width; |
149 | int xoff; |
3ac9cd9f |
150 | int boxystart, boxid; |
8c3cd914 |
151 | char *boxtext; |
152 | }; |
153 | |
ca20bfcf |
154 | /* |
c0a81592 |
155 | * Exports from winutils.c. |
156 | */ |
d3a1a808 |
157 | void split_into_argv(char *, int *, char ***, char ***); |
c0a81592 |
158 | |
159 | /* |
ca20bfcf |
160 | * Private structure for prefslist state. Only in the header file |
161 | * so that we can delegate allocation to callers. |
162 | */ |
163 | struct prefslist { |
164 | int listid, upbid, dnbid; |
165 | int srcitem; |
166 | int dummyitem; |
167 | int dragging; |
168 | }; |
169 | |
f7f27309 |
170 | /* |
fe8abbf4 |
171 | * This structure is passed to event handler functions as the `dlg' |
172 | * parameter, and hence is passed back to winctrls access functions. |
173 | */ |
174 | struct dlgparam { |
175 | HWND hwnd; /* the hwnd of the dialog box */ |
176 | struct winctrls *controltrees[8]; /* can have several of these */ |
177 | int nctrltrees; |
f6f450e2 |
178 | char *wintitle; /* title of actual window */ |
fe8abbf4 |
179 | char *errtitle; /* title of error sub-messageboxes */ |
180 | void *data; /* data to pass in refresh events */ |
181 | union control *focused, *lastfocused; /* which ctrl has focus now/before */ |
4e6d4091 |
182 | char shortcuts[128]; /* track which shortcuts in use */ |
fe8abbf4 |
183 | int coloursel_wanted; /* has an event handler asked for |
184 | * a colour selector? */ |
fe8abbf4 |
185 | struct { unsigned char r, g, b, ok; } coloursel_result; /* 0-255 */ |
4e6d4091 |
186 | tree234 *privdata; /* stores per-control private data */ |
fe8abbf4 |
187 | int ended, endresult; /* has the dialog been ended? */ |
188 | }; |
189 | |
190 | /* |
f7f27309 |
191 | * Exports from winctrls.c. |
192 | */ |
8c3cd914 |
193 | void ctlposinit(struct ctlpos *cp, HWND hwnd, |
32874aea |
194 | int leftborder, int rightborder, int topborder); |
ca20bfcf |
195 | HWND doctl(struct ctlpos *cp, RECT r, |
32874aea |
196 | char *wclass, int wstyle, int exstyle, char *wtext, int wid); |
8c3cd914 |
197 | void bartitle(struct ctlpos *cp, char *name, int id); |
3ac9cd9f |
198 | void beginbox(struct ctlpos *cp, char *name, int idbox); |
8c3cd914 |
199 | void endbox(struct ctlpos *cp); |
fe8abbf4 |
200 | void multiedit(struct ctlpos *cp, int password, ...); |
32874aea |
201 | void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...); |
d74d141c |
202 | void bareradioline(struct ctlpos *cp, int nacross, ...); |
8c3cd914 |
203 | void radiobig(struct ctlpos *cp, char *text, int id, ...); |
204 | void checkbox(struct ctlpos *cp, char *text, int id); |
66ee282a |
205 | void statictext(struct ctlpos *cp, char *text, int lines, int id); |
8c3cd914 |
206 | void staticbtn(struct ctlpos *cp, char *stext, int sid, |
32874aea |
207 | char *btext, int bid); |
af282e3b |
208 | void static2btn(struct ctlpos *cp, char *stext, int sid, |
209 | char *btext1, int bid1, char *btext2, int bid2); |
8c3cd914 |
210 | void staticedit(struct ctlpos *cp, char *stext, |
32874aea |
211 | int sid, int eid, int percentedit); |
2c9c6388 |
212 | void staticddl(struct ctlpos *cp, char *stext, |
213 | int sid, int lid, int percentlist); |
b8ae1f0f |
214 | void combobox(struct ctlpos *cp, char *text, int staticid, int listid); |
6e522441 |
215 | void staticpassedit(struct ctlpos *cp, char *stext, |
32874aea |
216 | int sid, int eid, int percentedit); |
6e522441 |
217 | void bigeditctrl(struct ctlpos *cp, char *stext, |
32874aea |
218 | int sid, int eid, int lines); |
219 | void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id); |
8c3cd914 |
220 | void editbutton(struct ctlpos *cp, char *stext, int sid, |
32874aea |
221 | int eid, char *btext, int bid); |
8c3cd914 |
222 | void sesssaver(struct ctlpos *cp, char *text, |
32874aea |
223 | int staticid, int editid, int listid, ...); |
8c3cd914 |
224 | void envsetter(struct ctlpos *cp, char *stext, int sid, |
32874aea |
225 | char *e1stext, int e1sid, int e1id, |
226 | char *e2stext, int e2sid, int e2id, |
227 | int listid, char *b1text, int b1id, char *b2text, int b2id); |
8c3cd914 |
228 | void charclass(struct ctlpos *cp, char *stext, int sid, int listid, |
32874aea |
229 | char *btext, int bid, int eid, char *s2text, int s2id); |
8c3cd914 |
230 | void colouredit(struct ctlpos *cp, char *stext, int sid, int listid, |
32874aea |
231 | char *btext, int bid, ...); |
fe8abbf4 |
232 | void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines, |
233 | char *stext, int sid, int listid, int upbid, int dnbid); |
ca20bfcf |
234 | int handle_prefslist(struct prefslist *hdl, |
235 | int *array, int maxmemb, |
236 | int is_dlmsg, HWND hwnd, |
237 | WPARAM wParam, LPARAM lParam); |
6e522441 |
238 | void progressbar(struct ctlpos *cp, int id); |
d74d141c |
239 | void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid, |
240 | char *e1stext, int e1sid, int e1id, |
241 | char *e2stext, int e2sid, int e2id, |
a4b92c62 |
242 | char *btext, int bid, |
243 | char *r1text, int r1id, char *r2text, int r2id); |
f7f27309 |
244 | |
fe8abbf4 |
245 | #define MAX_SHORTCUTS_PER_CTRL 16 |
246 | |
247 | /* |
248 | * This structure is what's stored for each `union control' in the |
249 | * portable-dialog interface. |
250 | */ |
251 | struct winctrl { |
252 | union control *ctrl; |
253 | /* |
254 | * The control may have several components at the Windows |
255 | * level, with different dialog IDs. To avoid needing N |
256 | * separate platformsidectrl structures (which could be stored |
257 | * separately in a tree234 so that lookup by ID worked), we |
258 | * impose the constraint that those IDs must be in a contiguous |
259 | * block. |
260 | */ |
261 | int base_id; |
262 | int num_ids; |
263 | /* |
264 | * Remember what keyboard shortcuts were used by this control, |
265 | * so that when we remove it again we can take them out of the |
266 | * list in the dlgparam. |
267 | */ |
268 | char shortcuts[MAX_SHORTCUTS_PER_CTRL]; |
269 | /* |
270 | * Some controls need a piece of allocated memory in which to |
271 | * store temporary data about the control. |
272 | */ |
273 | void *data; |
274 | }; |
275 | /* |
276 | * And this structure holds a set of the above, in two separate |
277 | * tree234s so that it can find an item by `union control' or by |
278 | * dialog ID. |
279 | */ |
280 | struct winctrls { |
281 | tree234 *byctrl, *byid; |
282 | }; |
d1582b2e |
283 | struct controlset; |
284 | struct controlbox; |
285 | |
fe8abbf4 |
286 | void winctrl_init(struct winctrls *); |
287 | void winctrl_cleanup(struct winctrls *); |
288 | void winctrl_add(struct winctrls *, struct winctrl *); |
289 | void winctrl_remove(struct winctrls *, struct winctrl *); |
290 | struct winctrl *winctrl_findbyctrl(struct winctrls *, union control *); |
291 | struct winctrl *winctrl_findbyid(struct winctrls *, int); |
292 | struct winctrl *winctrl_findbyindex(struct winctrls *, int); |
293 | void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, |
294 | struct ctlpos *cp, struct controlset *s, int *id); |
295 | int winctrl_handle_command(struct dlgparam *dp, UINT msg, |
296 | WPARAM wParam, LPARAM lParam); |
d1582b2e |
297 | void winctrl_rem_shortcuts(struct dlgparam *dp, struct winctrl *c); |
298 | int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id); |
299 | |
4e6d4091 |
300 | void dp_init(struct dlgparam *dp); |
301 | void dp_add_tree(struct dlgparam *dp, struct winctrls *tree); |
302 | void dp_cleanup(struct dlgparam *dp); |
303 | |
d1582b2e |
304 | /* |
305 | * Exports from wincfg.c. |
306 | */ |
307 | void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help, |
308 | int midsession); |
fe8abbf4 |
309 | |
f7f27309 |
310 | /* |
311 | * Exports from windlg.c. |
312 | */ |
313 | void defuse_showwindow(void); |
314 | int do_config(void); |
315 | int do_reconfig(HWND); |
f7f27309 |
316 | void showeventlog(HWND); |
317 | void showabout(HWND); |
f7f27309 |
318 | void force_normal(HWND hwnd); |
d1582b2e |
319 | void modal_about_box(HWND hwnd); |
320 | void show_help(HWND hwnd); |
f7f27309 |
321 | |
f7f27309 |
322 | /* |
8ee3ff16 |
323 | * Exports from winmisc.c. |
324 | */ |
325 | |
326 | int SaneDialogBox(HINSTANCE hinst, |
327 | LPCTSTR tmpl, |
328 | HWND hwndparent, |
329 | DLGPROC lpDialogFunc); |
330 | |
331 | void SaneEndDialog(HWND hwnd, int ret); |
332 | |
333 | /* |
f7f27309 |
334 | * Exports from sizetip.c. |
335 | */ |
336 | void UpdateSizeTip(HWND src, int cx, int cy); |
337 | void EnableSizeTip(int bEnable); |
338 | |
facd762c |
339 | /* |
340 | * Exports from unicode.c. |
341 | */ |
07b2a9cd |
342 | struct unicode_data; |
21d2b241 |
343 | void init_ucs(Config *, struct unicode_data *); |
facd762c |
344 | |
c44bf5bd |
345 | /* |
346 | * pageantc.c needs to schedule callbacks for asynchronous agent |
347 | * requests. This has to be done differently in GUI and console, so |
348 | * there's an exported function used for the purpose. |
349 | * |
350 | * Also, we supply FLAG_SYNCAGENT to force agent requests to be |
351 | * synchronous in pscp and psftp. |
352 | */ |
353 | void agent_schedule_callback(void (*callback)(void *, void *, int), |
354 | void *callback_ctx, void *data, int len); |
355 | #define FLAG_SYNCAGENT 0x1000 |
356 | |
f7f27309 |
357 | #endif |