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