Mention plink's new -N option in usage and man page.
[u/mdw/putty] / config.c
CommitLineData
fe8abbf4 1/*
2 * config.c - the platform-independent parts of the PuTTY
3 * configuration box.
4 */
5
6#include <assert.h>
7#include <stdlib.h>
8
9#include "putty.h"
10#include "dialog.h"
11#include "storage.h"
12
13#define PRINTER_DISABLED_STRING "None (printing disabled)"
14
15static void protocolbuttons_handler(union control *ctrl, void *dlg,
16 void *data, int event)
17{
18 int button, defport;
19 Config *cfg = (Config *)data;
20 /*
21 * This function works just like the standard radio-button
22 * handler, except that it also has to change the setting of
23 * the port box. We expect the context parameter to point at
24 * the `union control' structure for the port box.
25 */
26 if (event == EVENT_REFRESH) {
27 for (button = 0; button < ctrl->radio.nbuttons; button++)
28 if (cfg->protocol == ctrl->radio.buttondata[button].i)
29 break;
30 /* We expected that `break' to happen, in all circumstances. */
31 assert(button < ctrl->radio.nbuttons);
32 dlg_radiobutton_set(ctrl, dlg, button);
33 } else if (event == EVENT_VALCHANGE) {
34 int oldproto = cfg->protocol;
35 button = dlg_radiobutton_get(ctrl, dlg);
36 assert(button >= 0 && button < ctrl->radio.nbuttons);
37 cfg->protocol = ctrl->radio.buttondata[button].i;
38 if (oldproto != cfg->protocol) {
39 defport = -1;
40 switch (cfg->protocol) {
41 case PROT_SSH: defport = 22; break;
42 case PROT_TELNET: defport = 23; break;
43 case PROT_RLOGIN: defport = 513; break;
44 }
45 if (defport > 0 && cfg->port != defport) {
46 cfg->port = defport;
47 dlg_refresh((union control *)ctrl->radio.context.p, dlg);
48 }
49 }
50 }
51}
52
53static void numeric_keypad_handler(union control *ctrl, void *dlg,
54 void *data, int event)
55{
56 int button;
57 Config *cfg = (Config *)data;
58 /*
59 * This function works much like the standard radio button
60 * handler, but it has to handle two fields in Config.
61 */
62 if (event == EVENT_REFRESH) {
63 if (cfg->nethack_keypad)
64 button = 2;
65 else if (cfg->app_keypad)
66 button = 1;
67 else
68 button = 0;
69 assert(button < ctrl->radio.nbuttons);
70 dlg_radiobutton_set(ctrl, dlg, button);
71 } else if (event == EVENT_VALCHANGE) {
72 button = dlg_radiobutton_get(ctrl, dlg);
73 assert(button >= 0 && button < ctrl->radio.nbuttons);
74 if (button == 2) {
75 cfg->app_keypad = FALSE;
76 cfg->nethack_keypad = TRUE;
77 } else {
78 cfg->app_keypad = (button != 0);
79 cfg->nethack_keypad = FALSE;
80 }
81 }
82}
83
84static void cipherlist_handler(union control *ctrl, void *dlg,
85 void *data, int event)
86{
87 Config *cfg = (Config *)data;
88 if (event == EVENT_REFRESH) {
89 int i;
90
91 static const struct { char *s; int c; } ciphers[] = {
92 { "3DES", CIPHER_3DES },
93 { "Blowfish", CIPHER_BLOWFISH },
94 { "DES", CIPHER_DES },
95 { "AES (SSH 2 only)", CIPHER_AES },
96 { "-- warn below here --", CIPHER_WARN }
97 };
98
99 /* Set up the "selected ciphers" box. */
100 /* (cipherlist assumed to contain all ciphers) */
101 dlg_update_start(ctrl, dlg);
102 dlg_listbox_clear(ctrl, dlg);
103 for (i = 0; i < CIPHER_MAX; i++) {
104 int c = cfg->ssh_cipherlist[i];
105 int j;
106 char *cstr = NULL;
107 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
108 if (ciphers[j].c == c) {
109 cstr = ciphers[j].s;
110 break;
111 }
112 }
4eaff8d4 113 dlg_listbox_addwithid(ctrl, dlg, cstr, c);
fe8abbf4 114 }
115 dlg_update_done(ctrl, dlg);
116
117 } else if (event == EVENT_VALCHANGE) {
118 int i;
119
120 /* Update array to match the list box. */
121 for (i=0; i < CIPHER_MAX; i++)
122 cfg->ssh_cipherlist[i] = dlg_listbox_getid(ctrl, dlg, i);
123
124 }
125}
126
127static void printerbox_handler(union control *ctrl, void *dlg,
128 void *data, int event)
129{
130 Config *cfg = (Config *)data;
131 if (event == EVENT_REFRESH) {
132 int nprinters, i;
133 printer_enum *pe;
134
135 dlg_update_start(ctrl, dlg);
0f915619 136 /*
137 * Some backends may wish to disable the drop-down list on
138 * this edit box. Be prepared for this.
139 */
140 if (ctrl->editbox.has_list) {
141 dlg_listbox_clear(ctrl, dlg);
142 dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING);
143 pe = printer_start_enum(&nprinters);
144 for (i = 0; i < nprinters; i++)
145 dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i));
146 printer_finish_enum(pe);
147 }
fe8abbf4 148 dlg_editbox_set(ctrl, dlg,
149 (*cfg->printer ? cfg->printer :
150 PRINTER_DISABLED_STRING));
151 dlg_update_done(ctrl, dlg);
152 } else if (event == EVENT_VALCHANGE) {
153 dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
154 if (!strcmp(cfg->printer, PRINTER_DISABLED_STRING))
155 *cfg->printer = '\0';
156 }
157}
158
159static void codepage_handler(union control *ctrl, void *dlg,
160 void *data, int event)
161{
162 Config *cfg = (Config *)data;
163 if (event == EVENT_REFRESH) {
164 int i;
d4413bd2 165 const char *cp;
fe8abbf4 166 dlg_update_start(ctrl, dlg);
167 strcpy(cfg->line_codepage,
168 cp_name(decode_codepage(cfg->line_codepage)));
169 dlg_listbox_clear(ctrl, dlg);
170 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++)
171 dlg_listbox_add(ctrl, dlg, cp);
172 dlg_editbox_set(ctrl, dlg, cfg->line_codepage);
173 dlg_update_done(ctrl, dlg);
174 } else if (event == EVENT_VALCHANGE) {
175 dlg_editbox_get(ctrl, dlg, cfg->line_codepage,
176 sizeof(cfg->line_codepage));
177 strcpy(cfg->line_codepage,
178 cp_name(decode_codepage(cfg->line_codepage)));
179 }
180}
181
182static void sshbug_handler(union control *ctrl, void *dlg,
183 void *data, int event)
184{
185 if (event == EVENT_REFRESH) {
186 dlg_update_start(ctrl, dlg);
187 dlg_listbox_clear(ctrl, dlg);
4eaff8d4 188 dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO);
189 dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF);
190 dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON);
fe8abbf4 191 switch (*(int *)ATOFFSET(data, ctrl->listbox.context.i)) {
192 case AUTO: dlg_listbox_select(ctrl, dlg, 0); break;
193 case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break;
194 case FORCE_ON: dlg_listbox_select(ctrl, dlg, 2); break;
195 }
196 dlg_update_done(ctrl, dlg);
197 } else if (event == EVENT_SELCHANGE) {
198 int i = dlg_listbox_index(ctrl, dlg);
199 if (i < 0)
200 i = AUTO;
201 else
202 i = dlg_listbox_getid(ctrl, dlg, i);
203 *(int *)ATOFFSET(data, ctrl->listbox.context.i) = i;
204 }
205}
206
4e6d4091 207#define SAVEDSESSION_LEN 2048
208
fe8abbf4 209struct sessionsaver_data {
210 union control *editbox, *listbox, *loadbutton, *savebutton, *delbutton;
211 union control *okbutton, *cancelbutton;
fe8abbf4 212 struct sesslist *sesslist;
213};
214
215/*
216 * Helper function to load the session selected in the list box, if
217 * any, as this is done in more than one place below. Returns 0 for
218 * failure.
219 */
220static int load_selected_session(struct sessionsaver_data *ssd,
4e6d4091 221 char *savedsession,
fe8abbf4 222 void *dlg, Config *cfg)
223{
224 int i = dlg_listbox_index(ssd->listbox, dlg);
225 int isdef;
226 if (i < 0) {
227 dlg_beep(dlg);
228 return 0;
229 }
230 isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
231 load_settings(ssd->sesslist->sessions[i], !isdef, cfg);
232 if (!isdef) {
4e6d4091 233 strncpy(savedsession, ssd->sesslist->sessions[i],
234 SAVEDSESSION_LEN);
235 savedsession[SAVEDSESSION_LEN-1] = '\0';
fe8abbf4 236 } else {
4e6d4091 237 savedsession[0] = '\0';
fe8abbf4 238 }
239 dlg_refresh(NULL, dlg);
240 /* Restore the selection, which might have been clobbered by
241 * changing the value of the edit box. */
242 dlg_listbox_select(ssd->listbox, dlg, i);
243 return 1;
244}
245
246static void sessionsaver_handler(union control *ctrl, void *dlg,
247 void *data, int event)
248{
249 Config *cfg = (Config *)data;
250 struct sessionsaver_data *ssd =
251 (struct sessionsaver_data *)ctrl->generic.context.p;
4e6d4091 252 char *savedsession;
253
254 /*
255 * The first time we're called in a new dialog, we must
256 * allocate space to store the current contents of the saved
257 * session edit box (since it must persist even when we switch
258 * panels, but is not part of the Config).
56b9b9a7 259 *
260 * Of course, this doesn't need to be done mid-session.
4e6d4091 261 */
56b9b9a7 262 if (!ssd->editbox) {
263 savedsession = NULL;
264 } else if (!dlg_get_privdata(ssd->editbox, dlg)) {
4e6d4091 265 savedsession = (char *)
266 dlg_alloc_privdata(ssd->editbox, dlg, SAVEDSESSION_LEN);
267 savedsession[0] = '\0';
268 } else {
269 savedsession = dlg_get_privdata(ssd->editbox, dlg);
270 }
fe8abbf4 271
272 if (event == EVENT_REFRESH) {
273 if (ctrl == ssd->editbox) {
4e6d4091 274 dlg_editbox_set(ctrl, dlg, savedsession);
fe8abbf4 275 } else if (ctrl == ssd->listbox) {
276 int i;
277 dlg_update_start(ctrl, dlg);
278 dlg_listbox_clear(ctrl, dlg);
279 for (i = 0; i < ssd->sesslist->nsessions; i++)
280 dlg_listbox_add(ctrl, dlg, ssd->sesslist->sessions[i]);
281 dlg_update_done(ctrl, dlg);
282 }
283 } else if (event == EVENT_VALCHANGE) {
284 if (ctrl == ssd->editbox) {
4e6d4091 285 dlg_editbox_get(ctrl, dlg, savedsession,
286 SAVEDSESSION_LEN);
fe8abbf4 287 }
288 } else if (event == EVENT_ACTION) {
289 if (ctrl == ssd->listbox || ctrl == ssd->loadbutton) {
290 /*
291 * The user has double-clicked a session, or hit Load.
292 * We must load the selected session, and then
293 * terminate the configuration dialog _if_ there was a
294 * double-click on the list box _and_ that session
295 * contains a hostname.
296 */
4e6d4091 297 if (load_selected_session(ssd, savedsession, dlg, cfg) &&
fe8abbf4 298 (ctrl == ssd->listbox && cfg->host[0])) {
299 dlg_end(dlg, 1); /* it's all over, and succeeded */
300 }
301 } else if (ctrl == ssd->savebutton) {
4e6d4091 302 int isdef = !strcmp(savedsession, "Default Settings");
303 if (!savedsession[0]) {
8b0cb5aa 304 int i = dlg_listbox_index(ssd->listbox, dlg);
fe8abbf4 305 if (i < 0) {
306 dlg_beep(dlg);
307 return;
308 }
309 isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
310 if (!isdef) {
4e6d4091 311 strncpy(savedsession, ssd->sesslist->sessions[i],
312 SAVEDSESSION_LEN);
313 savedsession[SAVEDSESSION_LEN-1] = '\0';
fe8abbf4 314 } else {
4e6d4091 315 savedsession[0] = '\0';
fe8abbf4 316 }
317 }
3f935d5b 318 {
319 char *errmsg = save_settings(savedsession, !isdef, cfg);
320 if (errmsg) {
321 dlg_error_msg(dlg, errmsg);
322 sfree(errmsg);
323 }
324 }
fe8abbf4 325 get_sesslist(ssd->sesslist, FALSE);
326 get_sesslist(ssd->sesslist, TRUE);
327 dlg_refresh(ssd->editbox, dlg);
328 dlg_refresh(ssd->listbox, dlg);
329 } else if (ctrl == ssd->delbutton) {
6f87d111 330 int i = dlg_listbox_index(ssd->listbox, dlg);
fe8abbf4 331 if (i <= 0) {
332 dlg_beep(dlg);
333 } else {
334 del_settings(ssd->sesslist->sessions[i]);
335 get_sesslist(ssd->sesslist, FALSE);
336 get_sesslist(ssd->sesslist, TRUE);
337 dlg_refresh(ssd->listbox, dlg);
338 }
339 } else if (ctrl == ssd->okbutton) {
56b9b9a7 340 if (!savedsession) {
341 /* In a mid-session Change Settings, Apply is always OK. */
342 dlg_end(dlg, 1);
343 return;
344 }
fe8abbf4 345 /*
346 * Annoying special case. If the `Open' button is
347 * pressed while no host name is currently set, _and_
348 * the session list previously had the focus, _and_
349 * there was a session selected in that which had a
350 * valid host name in it, then load it and go.
351 */
0bd8d76d 352 if (dlg_last_focused(ctrl, dlg) == ssd->listbox && !*cfg->host) {
fe8abbf4 353 Config cfg2;
4e6d4091 354 if (!load_selected_session(ssd, savedsession, dlg, &cfg2)) {
fe8abbf4 355 dlg_beep(dlg);
356 return;
357 }
358 /* If at this point we have a valid session, go! */
359 if (*cfg2.host) {
360 *cfg = cfg2; /* structure copy */
6eaa8806 361 cfg->remote_cmd_ptr = cfg->remote_cmd; /* nasty */
fe8abbf4 362 dlg_end(dlg, 1);
363 } else
364 dlg_beep(dlg);
365 }
366
367 /*
368 * Otherwise, do the normal thing: if we have a valid
369 * session, get going.
370 */
371 if (*cfg->host) {
372 dlg_end(dlg, 1);
373 } else
374 dlg_beep(dlg);
375 } else if (ctrl == ssd->cancelbutton) {
376 dlg_end(dlg, 0);
377 }
378 }
379}
380
381struct charclass_data {
382 union control *listbox, *editbox, *button;
383};
384
385static void charclass_handler(union control *ctrl, void *dlg,
386 void *data, int event)
387{
388 Config *cfg = (Config *)data;
389 struct charclass_data *ccd =
390 (struct charclass_data *)ctrl->generic.context.p;
391
392 if (event == EVENT_REFRESH) {
393 if (ctrl == ccd->listbox) {
394 int i;
395 dlg_update_start(ctrl, dlg);
396 dlg_listbox_clear(ctrl, dlg);
397 for (i = 0; i < 128; i++) {
398 char str[100];
399 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
400 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg->wordness[i]);
401 dlg_listbox_add(ctrl, dlg, str);
402 }
403 dlg_update_done(ctrl, dlg);
404 }
405 } else if (event == EVENT_ACTION) {
406 if (ctrl == ccd->button) {
407 char str[100];
408 int i, n;
409 dlg_editbox_get(ccd->editbox, dlg, str, sizeof(str));
410 n = atoi(str);
411 for (i = 0; i < 128; i++) {
412 if (dlg_listbox_issel(ccd->listbox, dlg, i))
413 cfg->wordness[i] = n;
414 }
415 dlg_refresh(ccd->listbox, dlg);
416 }
417 }
418}
419
420struct colour_data {
18c2f87c 421 union control *listbox, *redit, *gedit, *bedit, *button;
fe8abbf4 422};
423
424static const char *const colours[] = {
425 "Default Foreground", "Default Bold Foreground",
426 "Default Background", "Default Bold Background",
427 "Cursor Text", "Cursor Colour",
428 "ANSI Black", "ANSI Black Bold",
429 "ANSI Red", "ANSI Red Bold",
430 "ANSI Green", "ANSI Green Bold",
431 "ANSI Yellow", "ANSI Yellow Bold",
432 "ANSI Blue", "ANSI Blue Bold",
433 "ANSI Magenta", "ANSI Magenta Bold",
434 "ANSI Cyan", "ANSI Cyan Bold",
435 "ANSI White", "ANSI White Bold"
436};
437
438static void colour_handler(union control *ctrl, void *dlg,
439 void *data, int event)
440{
441 Config *cfg = (Config *)data;
442 struct colour_data *cd =
443 (struct colour_data *)ctrl->generic.context.p;
444 int update = FALSE, r, g, b;
445
446 if (event == EVENT_REFRESH) {
447 if (ctrl == cd->listbox) {
448 int i;
449 dlg_update_start(ctrl, dlg);
450 dlg_listbox_clear(ctrl, dlg);
451 for (i = 0; i < lenof(colours); i++)
452 dlg_listbox_add(ctrl, dlg, colours[i]);
453 dlg_update_done(ctrl, dlg);
18c2f87c 454 dlg_editbox_set(cd->redit, dlg, "");
455 dlg_editbox_set(cd->gedit, dlg, "");
456 dlg_editbox_set(cd->bedit, dlg, "");
fe8abbf4 457 }
458 } else if (event == EVENT_SELCHANGE) {
459 if (ctrl == cd->listbox) {
460 /* The user has selected a colour. Update the RGB text. */
461 int i = dlg_listbox_index(ctrl, dlg);
462 if (i < 0) {
463 dlg_beep(dlg);
464 return;
465 }
466 r = cfg->colours[i][0];
467 g = cfg->colours[i][1];
468 b = cfg->colours[i][2];
469 update = TRUE;
470 }
18c2f87c 471 } else if (event == EVENT_VALCHANGE) {
472 if (ctrl == cd->redit || ctrl == cd->gedit || ctrl == cd->bedit) {
473 /* The user has changed the colour using the edit boxes. */
474 char buf[80];
475 int i, cval;
476
477 dlg_editbox_get(ctrl, dlg, buf, lenof(buf));
478 cval = atoi(buf) & 255;
479
480 i = dlg_listbox_index(cd->listbox, dlg);
481 if (i >= 0) {
482 if (ctrl == cd->redit)
483 cfg->colours[i][0] = cval;
484 else if (ctrl == cd->gedit)
485 cfg->colours[i][1] = cval;
486 else if (ctrl == cd->bedit)
487 cfg->colours[i][2] = cval;
488 }
489 }
fe8abbf4 490 } else if (event == EVENT_ACTION) {
491 if (ctrl == cd->button) {
492 int i = dlg_listbox_index(cd->listbox, dlg);
493 if (i < 0) {
494 dlg_beep(dlg);
495 return;
496 }
497 /*
498 * Start a colour selector, which will send us an
499 * EVENT_CALLBACK when it's finished and allow us to
500 * pick up the results.
501 */
502 dlg_coloursel_start(ctrl, dlg,
503 cfg->colours[i][0],
504 cfg->colours[i][1],
505 cfg->colours[i][2]);
506 }
507 } else if (event == EVENT_CALLBACK) {
508 if (ctrl == cd->button) {
509 int i = dlg_listbox_index(cd->listbox, dlg);
510 /*
511 * Collect the results of the colour selector. Will
512 * return nonzero on success, or zero if the colour
513 * selector did nothing (user hit Cancel, for example).
514 */
515 if (dlg_coloursel_results(ctrl, dlg, &r, &g, &b)) {
516 cfg->colours[i][0] = r;
517 cfg->colours[i][1] = g;
518 cfg->colours[i][2] = b;
519 update = TRUE;
520 }
521 }
522 }
523
524 if (update) {
525 char buf[40];
18c2f87c 526 sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf);
527 sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf);
528 sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf);
fe8abbf4 529 }
530}
531
532struct environ_data {
533 union control *varbox, *valbox, *addbutton, *rembutton, *listbox;
534};
535
536static void environ_handler(union control *ctrl, void *dlg,
537 void *data, int event)
538{
539 Config *cfg = (Config *)data;
540 struct environ_data *ed =
541 (struct environ_data *)ctrl->generic.context.p;
542
543 if (event == EVENT_REFRESH) {
544 if (ctrl == ed->listbox) {
545 char *p = cfg->environmt;
546 dlg_update_start(ctrl, dlg);
547 dlg_listbox_clear(ctrl, dlg);
548 while (*p) {
549 dlg_listbox_add(ctrl, dlg, p);
550 p += strlen(p) + 1;
551 }
552 dlg_update_done(ctrl, dlg);
553 }
554 } else if (event == EVENT_ACTION) {
555 if (ctrl == ed->addbutton) {
556 char str[sizeof(cfg->environmt)];
557 char *p;
558 dlg_editbox_get(ed->varbox, dlg, str, sizeof(str)-1);
559 if (!*str) {
560 dlg_beep(dlg);
561 return;
562 }
563 p = str + strlen(str);
564 *p++ = '\t';
565 dlg_editbox_get(ed->valbox, dlg, p, sizeof(str)-1 - (p - str));
566 if (!*p) {
567 dlg_beep(dlg);
568 return;
569 }
570 p = cfg->environmt;
571 while (*p) {
572 while (*p)
573 p++;
574 p++;
575 }
576 if ((p - cfg->environmt) + strlen(str) + 2 <
577 sizeof(cfg->environmt)) {
578 strcpy(p, str);
579 p[strlen(str) + 1] = '\0';
580 dlg_listbox_add(ed->listbox, dlg, str);
581 dlg_editbox_set(ed->varbox, dlg, "");
582 dlg_editbox_set(ed->valbox, dlg, "");
583 } else {
584 dlg_error_msg(dlg, "Environment too big");
585 }
586 } else if (ctrl == ed->rembutton) {
587 int i = dlg_listbox_index(ed->listbox, dlg);
588 if (i < 0) {
589 dlg_beep(dlg);
590 } else {
591 char *p, *q;
592
593 dlg_listbox_del(ed->listbox, dlg, i);
594 p = cfg->environmt;
595 while (i > 0) {
596 if (!*p)
597 goto disaster;
598 while (*p)
599 p++;
600 p++;
601 i--;
602 }
603 q = p;
604 if (!*p)
605 goto disaster;
606 while (*p)
607 p++;
608 p++;
609 while (*p) {
610 while (*p)
611 *q++ = *p++;
612 *q++ = *p++;
613 }
614 *q = '\0';
615 disaster:;
616 }
617 }
618 }
619}
620
621struct portfwd_data {
622 union control *addbutton, *rembutton, *listbox;
623 union control *sourcebox, *destbox, *direction;
624};
625
626static void portfwd_handler(union control *ctrl, void *dlg,
627 void *data, int event)
628{
629 Config *cfg = (Config *)data;
630 struct portfwd_data *pfd =
631 (struct portfwd_data *)ctrl->generic.context.p;
632
633 if (event == EVENT_REFRESH) {
634 if (ctrl == pfd->listbox) {
635 char *p = cfg->portfwd;
636 dlg_update_start(ctrl, dlg);
637 dlg_listbox_clear(ctrl, dlg);
638 while (*p) {
639 dlg_listbox_add(ctrl, dlg, p);
640 p += strlen(p) + 1;
641 }
642 dlg_update_done(ctrl, dlg);
07e4d76d 643 } else if (ctrl == pfd->direction) {
644 /*
645 * Default is Local.
646 */
647 dlg_radiobutton_set(ctrl, dlg, 0);
fe8abbf4 648 }
649 } else if (event == EVENT_ACTION) {
650 if (ctrl == pfd->addbutton) {
651 char str[sizeof(cfg->portfwd)];
652 char *p;
820ebe3b 653 int whichbutton = dlg_radiobutton_get(pfd->direction, dlg);
654 if (whichbutton == 0)
fe8abbf4 655 str[0] = 'L';
820ebe3b 656 else if (whichbutton == 1)
fe8abbf4 657 str[0] = 'R';
820ebe3b 658 else
659 str[0] = 'D';
fe8abbf4 660 dlg_editbox_get(pfd->sourcebox, dlg, str+1, sizeof(str) - 2);
661 if (!str[1]) {
662 dlg_error_msg(dlg, "You need to specify a source port number");
663 return;
664 }
665 p = str + strlen(str);
820ebe3b 666 if (str[0] != 'D') {
667 *p++ = '\t';
668 dlg_editbox_get(pfd->destbox, dlg, p,
669 sizeof(str)-1 - (p - str));
670 if (!*p || !strchr(p, ':')) {
671 dlg_error_msg(dlg,
672 "You need to specify a destination address\n"
673 "in the form \"host.name:port\"");
674 return;
675 }
676 } else
677 *p = '\0';
fe8abbf4 678 p = cfg->portfwd;
679 while (*p) {
680 while (*p)
681 p++;
682 p++;
683 }
684 if ((p - cfg->portfwd) + strlen(str) + 2 <
685 sizeof(cfg->portfwd)) {
686 strcpy(p, str);
687 p[strlen(str) + 1] = '\0';
688 dlg_listbox_add(pfd->listbox, dlg, str);
689 dlg_editbox_set(pfd->sourcebox, dlg, "");
690 dlg_editbox_set(pfd->destbox, dlg, "");
691 } else {
692 dlg_error_msg(dlg, "Too many forwardings");
693 }
694 } else if (ctrl == pfd->rembutton) {
695 int i = dlg_listbox_index(pfd->listbox, dlg);
696 if (i < 0)
697 dlg_beep(dlg);
698 else {
699 char *p, *q;
700
701 dlg_listbox_del(pfd->listbox, dlg, i);
702 p = cfg->portfwd;
703 while (i > 0) {
704 if (!*p)
705 goto disaster2;
706 while (*p)
707 p++;
708 p++;
709 i--;
710 }
711 q = p;
712 if (!*p)
713 goto disaster2;
714 while (*p)
715 p++;
716 p++;
717 while (*p) {
718 while (*p)
719 *q++ = *p++;
720 *q++ = *p++;
721 }
722 *q = '\0';
723 disaster2:;
724 }
725 }
726 }
727}
728
729void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
730 int midsession, int protocol)
731{
732 struct controlset *s;
733 struct sessionsaver_data *ssd;
734 struct charclass_data *ccd;
735 struct colour_data *cd;
736 struct environ_data *ed;
737 struct portfwd_data *pfd;
738 union control *c;
f6f450e2 739 char *str;
fe8abbf4 740
741 ssd = (struct sessionsaver_data *)
742 ctrl_alloc(b, sizeof(struct sessionsaver_data));
56b9b9a7 743 memset(ssd, 0, sizeof(*ssd));
fe8abbf4 744 ssd->sesslist = (midsession ? NULL : sesslist);
745
746 /*
747 * The standard panel that appears at the bottom of all panels:
748 * Open, Cancel, Apply etc.
749 */
750 s = ctrl_getset(b, "", "", "");
751 ctrl_columns(s, 5, 20, 20, 20, 20, 20);
752 ssd->okbutton = ctrl_pushbutton(s,
753 (midsession ? "Apply" : "Open"),
754 (char)(midsession ? 'a' : 'o'),
755 HELPCTX(no_help),
756 sessionsaver_handler, P(ssd));
757 ssd->okbutton->button.isdefault = TRUE;
758 ssd->okbutton->generic.column = 3;
759 ssd->cancelbutton = ctrl_pushbutton(s, "Cancel", 'c', HELPCTX(no_help),
760 sessionsaver_handler, P(ssd));
0bd8d76d 761 ssd->cancelbutton->button.iscancel = TRUE;
fe8abbf4 762 ssd->cancelbutton->generic.column = 4;
763 /* We carefully don't close the 5-column part, so that platform-
764 * specific add-ons can put extra buttons alongside Open and Cancel. */
765
766 /*
767 * The Session panel.
768 */
f6f450e2 769 str = dupprintf("Basic options for your %s session", appname);
770 ctrl_settitle(b, "Session", str);
771 sfree(str);
fe8abbf4 772
773 if (!midsession) {
774 s = ctrl_getset(b, "Session", "hostport",
775 "Specify your connection by host name or IP address");
776 ctrl_columns(s, 2, 75, 25);
777 c = ctrl_editbox(s, "Host Name (or IP address)", 'n', 100,
778 HELPCTX(session_hostname),
779 dlg_stdeditbox_handler, I(offsetof(Config,host)),
780 I(sizeof(((Config *)0)->host)));
781 c->generic.column = 0;
782 c = ctrl_editbox(s, "Port", 'p', 100, HELPCTX(session_hostname),
783 dlg_stdeditbox_handler,
784 I(offsetof(Config,port)), I(-1));
785 c->generic.column = 1;
786 ctrl_columns(s, 1, 100);
d9b15094 787 if (backends[3].name == NULL) {
fe8abbf4 788 ctrl_radiobuttons(s, "Protocol:", NO_SHORTCUT, 3,
789 HELPCTX(session_hostname),
790 protocolbuttons_handler, P(c),
791 "Raw", 'r', I(PROT_RAW),
792 "Telnet", 't', I(PROT_TELNET),
793 "Rlogin", 'i', I(PROT_RLOGIN),
794 NULL);
795 } else {
796 ctrl_radiobuttons(s, "Protocol:", NO_SHORTCUT, 4,
797 HELPCTX(session_hostname),
798 protocolbuttons_handler, P(c),
799 "Raw", 'r', I(PROT_RAW),
800 "Telnet", 't', I(PROT_TELNET),
801 "Rlogin", 'i', I(PROT_RLOGIN),
802 "SSH", 's', I(PROT_SSH),
803 NULL);
804 }
805
806 s = ctrl_getset(b, "Session", "savedsessions",
807 "Load, save or delete a stored session");
808 ctrl_columns(s, 2, 75, 25);
fe8abbf4 809 ssd->sesslist = sesslist;
810 ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100,
811 HELPCTX(session_saved),
812 sessionsaver_handler, P(ssd), P(NULL));
813 ssd->editbox->generic.column = 0;
814 /* Reset columns so that the buttons are alongside the list, rather
815 * than alongside that edit box. */
816 ctrl_columns(s, 1, 100);
817 ctrl_columns(s, 2, 75, 25);
0bd8d76d 818 ssd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
819 HELPCTX(session_saved),
820 sessionsaver_handler, P(ssd));
821 ssd->listbox->generic.column = 0;
822 ssd->listbox->listbox.height = 7;
fe8abbf4 823 ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l',
824 HELPCTX(session_saved),
825 sessionsaver_handler, P(ssd));
826 ssd->loadbutton->generic.column = 1;
827 ssd->savebutton = ctrl_pushbutton(s, "Save", 'v',
828 HELPCTX(session_saved),
829 sessionsaver_handler, P(ssd));
830 ssd->savebutton->generic.column = 1;
831 ssd->delbutton = ctrl_pushbutton(s, "Delete", 'd',
832 HELPCTX(session_saved),
833 sessionsaver_handler, P(ssd));
834 ssd->delbutton->generic.column = 1;
fe8abbf4 835 ctrl_columns(s, 1, 100);
836 }
837
838 s = ctrl_getset(b, "Session", "otheropts", NULL);
839 c = ctrl_radiobuttons(s, "Close window on exit:", 'w', 4,
840 HELPCTX(session_coe),
841 dlg_stdradiobutton_handler,
842 I(offsetof(Config, close_on_exit)),
843 "Always", I(FORCE_ON),
844 "Never", I(FORCE_OFF),
845 "Only on clean exit", I(AUTO), NULL);
846
847 /*
848 * The Session/Logging panel.
849 */
850 ctrl_settitle(b, "Session/Logging", "Options controlling session logging");
851
852 s = ctrl_getset(b, "Session/Logging", "main", NULL);
3e547dd8 853 /*
854 * The logging buttons change depending on whether SSH packet
855 * logging can sensibly be available.
856 */
857 {
858 char *sshlogname;
859 if ((midsession && protocol == PROT_SSH) ||
860 (!midsession && backends[3].name != NULL))
861 sshlogname = "Log SSH packet data";
862 else
863 sshlogname = NULL; /* this will disable the button */
864 ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 1,
865 HELPCTX(logging_main),
866 dlg_stdradiobutton_handler,
867 I(offsetof(Config, logtype)),
868 "Logging turned off completely", 't', I(LGTYP_NONE),
869 "Log printable output only", 'p', I(LGTYP_ASCII),
870 "Log all session output", 'l', I(LGTYP_DEBUG),
871 sshlogname, 's', I(LGTYP_PACKETS),
872 NULL);
873 }
fe8abbf4 874 ctrl_filesel(s, "Log file name:", 'f',
875 NULL, TRUE, "Select session log file name",
876 HELPCTX(logging_filename),
877 dlg_stdfilesel_handler, I(offsetof(Config, logfilename)));
878 ctrl_text(s, "(Log file name can contain &Y, &M, &D for date,"
879 " &T for time, and &H for host name)",
880 HELPCTX(logging_filename));
881 ctrl_radiobuttons(s, "What to do if the log file already exists:", 'e', 1,
882 HELPCTX(logging_exists),
883 dlg_stdradiobutton_handler, I(offsetof(Config,logxfovr)),
884 "Always overwrite it", I(LGXF_OVR),
885 "Always append to the end of it", I(LGXF_APN),
886 "Ask the user every time", I(LGXF_ASK), NULL);
887
9a10ecf4 888 if ((midsession && protocol == PROT_SSH) ||
889 (!midsession && backends[3].name != NULL)) {
890 s = ctrl_getset(b, "Session/Logging", "ssh",
891 "Options specific to SSH packet logging");
892 ctrl_checkbox(s, "Omit known password fields", 'k',
893 HELPCTX(logging_ssh_omit_password),
894 dlg_stdcheckbox_handler, I(offsetof(Config,logomitpass)));
895 ctrl_checkbox(s, "Omit session data", 'd',
896 HELPCTX(logging_ssh_omit_data),
897 dlg_stdcheckbox_handler, I(offsetof(Config,logomitdata)));
898 }
899
fe8abbf4 900 /*
901 * The Terminal panel.
902 */
903 ctrl_settitle(b, "Terminal", "Options controlling the terminal emulation");
904
905 s = ctrl_getset(b, "Terminal", "general", "Set various terminal options");
906 ctrl_checkbox(s, "Auto wrap mode initially on", 'w',
907 HELPCTX(terminal_autowrap),
908 dlg_stdcheckbox_handler, I(offsetof(Config,wrap_mode)));
909 ctrl_checkbox(s, "DEC Origin Mode initially on", 'd',
910 HELPCTX(terminal_decom),
911 dlg_stdcheckbox_handler, I(offsetof(Config,dec_om)));
912 ctrl_checkbox(s, "Implicit CR in every LF", 'r',
913 HELPCTX(terminal_lfhascr),
914 dlg_stdcheckbox_handler, I(offsetof(Config,lfhascr)));
915 ctrl_checkbox(s, "Use background colour to erase screen", 'e',
916 HELPCTX(terminal_bce),
917 dlg_stdcheckbox_handler, I(offsetof(Config,bce)));
918 ctrl_checkbox(s, "Enable blinking text", 'n',
919 HELPCTX(terminal_blink),
920 dlg_stdcheckbox_handler, I(offsetof(Config,blinktext)));
921 ctrl_editbox(s, "Answerback to ^E:", 's', 100,
922 HELPCTX(terminal_answerback),
923 dlg_stdeditbox_handler, I(offsetof(Config,answerback)),
924 I(sizeof(((Config *)0)->answerback)));
925
926 s = ctrl_getset(b, "Terminal", "ldisc", "Line discipline options");
927 ctrl_radiobuttons(s, "Local echo:", 'l', 3,
928 HELPCTX(terminal_localecho),
929 dlg_stdradiobutton_handler,I(offsetof(Config,localecho)),
930 "Auto", I(AUTO),
931 "Force on", I(FORCE_ON),
932 "Force off", I(FORCE_OFF), NULL);
933 ctrl_radiobuttons(s, "Local line editing:", 't', 3,
934 HELPCTX(terminal_localedit),
935 dlg_stdradiobutton_handler,I(offsetof(Config,localedit)),
936 "Auto", I(AUTO),
937 "Force on", I(FORCE_ON),
938 "Force off", I(FORCE_OFF), NULL);
939
940 s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
941 ctrl_combobox(s, "Printer to send ANSI printer output to:", 'p', 100,
942 HELPCTX(terminal_printing),
943 printerbox_handler, P(NULL), P(NULL));
944
945 /*
946 * The Terminal/Keyboard panel.
947 */
948 ctrl_settitle(b, "Terminal/Keyboard",
949 "Options controlling the effects of keys");
950
951 s = ctrl_getset(b, "Terminal/Keyboard", "mappings",
952 "Change the sequences sent by:");
953 ctrl_radiobuttons(s, "The Backspace key", 'b', 2,
954 HELPCTX(keyboard_backspace),
955 dlg_stdradiobutton_handler,
956 I(offsetof(Config, bksp_is_delete)),
957 "Control-H", I(0), "Control-? (127)", I(1), NULL);
958 ctrl_radiobuttons(s, "The Home and End keys", 'e', 2,
959 HELPCTX(keyboard_homeend),
960 dlg_stdradiobutton_handler,
961 I(offsetof(Config, rxvt_homeend)),
962 "Standard", I(0), "rxvt", I(1), NULL);
963 ctrl_radiobuttons(s, "The Function keys and keypad", 'f', 3,
964 HELPCTX(keyboard_funkeys),
965 dlg_stdradiobutton_handler,
966 I(offsetof(Config, funky_type)),
967 "ESC[n~", I(0), "Linux", I(1), "Xterm R6", I(2),
968 "VT400", I(3), "VT100+", I(4), "SCO", I(5), NULL);
969
970 s = ctrl_getset(b, "Terminal/Keyboard", "appkeypad",
971 "Application keypad settings:");
972 ctrl_radiobuttons(s, "Initial state of cursor keys:", 'r', 3,
973 HELPCTX(keyboard_appcursor),
974 dlg_stdradiobutton_handler,
975 I(offsetof(Config, app_cursor)),
976 "Normal", I(0), "Application", I(1), NULL);
977 ctrl_radiobuttons(s, "Initial state of numeric keypad:", 'n', 3,
978 HELPCTX(keyboard_appkeypad),
979 numeric_keypad_handler, P(NULL),
980 "Normal", I(0), "Application", I(1), "NetHack", I(2),
981 NULL);
982
983 /*
984 * The Terminal/Bell panel.
985 */
986 ctrl_settitle(b, "Terminal/Bell",
987 "Options controlling the terminal bell");
988
989 s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
990 ctrl_radiobuttons(s, "Action to happen when a bell occurs:", 'b', 1,
991 HELPCTX(bell_style),
992 dlg_stdradiobutton_handler, I(offsetof(Config, beep)),
993 "None (bell disabled)", I(BELL_DISABLED),
994 "Make default system alert sound", I(BELL_DEFAULT),
995 "Visual bell (flash window)", I(BELL_VISUAL), NULL);
996
997 s = ctrl_getset(b, "Terminal/Bell", "overload",
998 "Control the bell overload behaviour");
999 ctrl_checkbox(s, "Bell is temporarily disabled when over-used", 'd',
1000 HELPCTX(bell_overload),
1001 dlg_stdcheckbox_handler, I(offsetof(Config,bellovl)));
1002 ctrl_editbox(s, "Over-use means this many bells...", 'm', 20,
1003 HELPCTX(bell_overload),
1004 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_n)), I(-1));
1005 ctrl_editbox(s, "... in this many seconds", 't', 20,
1006 HELPCTX(bell_overload),
1007 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_t)),
62697e04 1008 I(-TICKSPERSEC));
fe8abbf4 1009 ctrl_text(s, "The bell is re-enabled after a few seconds of silence.",
1010 HELPCTX(bell_overload));
1011 ctrl_editbox(s, "Seconds of silence required", 's', 20,
1012 HELPCTX(bell_overload),
1013 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_s)),
62697e04 1014 I(-TICKSPERSEC));
fe8abbf4 1015
1016 /*
1017 * The Terminal/Features panel.
1018 */
1019 ctrl_settitle(b, "Terminal/Features",
1020 "Enabling and disabling advanced terminal features");
1021
1022 s = ctrl_getset(b, "Terminal/Features", "main", NULL);
1023 ctrl_checkbox(s, "Disable application cursor keys mode", 'u',
1024 HELPCTX(features_application),
1025 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_c)));
1026 ctrl_checkbox(s, "Disable application keypad mode", 'k',
1027 HELPCTX(features_application),
1028 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_k)));
1029 ctrl_checkbox(s, "Disable xterm-style mouse reporting", 'x',
1030 HELPCTX(features_mouse),
1031 dlg_stdcheckbox_handler, I(offsetof(Config,no_mouse_rep)));
1032 ctrl_checkbox(s, "Disable remote-controlled terminal resizing", 's',
1033 HELPCTX(features_resize),
1034 dlg_stdcheckbox_handler,
1035 I(offsetof(Config,no_remote_resize)));
1036 ctrl_checkbox(s, "Disable switching to alternate terminal screen", 'w',
1037 HELPCTX(features_altscreen),
1038 dlg_stdcheckbox_handler, I(offsetof(Config,no_alt_screen)));
1039 ctrl_checkbox(s, "Disable remote-controlled window title changing", 't',
1040 HELPCTX(features_retitle),
1041 dlg_stdcheckbox_handler,
1042 I(offsetof(Config,no_remote_wintitle)));
7fcdebd3 1043 ctrl_checkbox(s, "Disable remote window title querying (SECURITY)",
1044 'q', HELPCTX(features_qtitle), dlg_stdcheckbox_handler,
1045 I(offsetof(Config,no_remote_qtitle)));
fe8abbf4 1046 ctrl_checkbox(s, "Disable destructive backspace on server sending ^?",'b',
1047 HELPCTX(features_dbackspace),
1048 dlg_stdcheckbox_handler, I(offsetof(Config,no_dbackspace)));
1049 ctrl_checkbox(s, "Disable remote-controlled character set configuration",
1050 'r', HELPCTX(features_charset), dlg_stdcheckbox_handler,
1051 I(offsetof(Config,no_remote_charset)));
f0fccd51 1052 ctrl_checkbox(s, "Disable Arabic text shaping",
f4ec0818 1053 'l', HELPCTX(features_arabicshaping), dlg_stdcheckbox_handler,
f0fccd51 1054 I(offsetof(Config, arabicshaping)));
1055 ctrl_checkbox(s, "Disable bidirectional text display",
f4ec0818 1056 'd', HELPCTX(features_bidi), dlg_stdcheckbox_handler,
f0fccd51 1057 I(offsetof(Config, bidi)));
fe8abbf4 1058
1059 /*
1060 * The Window panel.
1061 */
f6f450e2 1062 str = dupprintf("Options controlling %s's window", appname);
1063 ctrl_settitle(b, "Window", str);
1064 sfree(str);
fe8abbf4 1065
1066 s = ctrl_getset(b, "Window", "size", "Set the size of the window");
1067 ctrl_columns(s, 2, 50, 50);
1068 c = ctrl_editbox(s, "Rows", 'r', 100,
1069 HELPCTX(window_size),
1070 dlg_stdeditbox_handler, I(offsetof(Config,height)),I(-1));
1071 c->generic.column = 0;
1072 c = ctrl_editbox(s, "Columns", 'm', 100,
1073 HELPCTX(window_size),
1074 dlg_stdeditbox_handler, I(offsetof(Config,width)), I(-1));
1075 c->generic.column = 1;
1076 ctrl_columns(s, 1, 100);
1077
1078 s = ctrl_getset(b, "Window", "scrollback",
1079 "Control the scrollback in the window");
1080 ctrl_editbox(s, "Lines of scrollback", 's', 50,
1081 HELPCTX(window_scrollback),
1082 dlg_stdeditbox_handler, I(offsetof(Config,savelines)), I(-1));
1083 ctrl_checkbox(s, "Display scrollbar", 'd',
1084 HELPCTX(window_scrollback),
1085 dlg_stdcheckbox_handler, I(offsetof(Config,scrollbar)));
fe8abbf4 1086 ctrl_checkbox(s, "Reset scrollback on keypress", 'k',
1087 HELPCTX(window_scrollback),
1088 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_key)));
1089 ctrl_checkbox(s, "Reset scrollback on display activity", 'p',
1090 HELPCTX(window_scrollback),
1091 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_disp)));
876e5d5e 1092 ctrl_checkbox(s, "Push erased text into scrollback", 'e',
1093 HELPCTX(window_erased),
1094 dlg_stdcheckbox_handler,
1095 I(offsetof(Config,erase_to_scrollback)));
fe8abbf4 1096
1097 /*
1098 * The Window/Appearance panel.
1099 */
f6f450e2 1100 str = dupprintf("Configure the appearance of %s's window", appname);
1101 ctrl_settitle(b, "Window/Appearance", str);
1102 sfree(str);
fe8abbf4 1103
1104 s = ctrl_getset(b, "Window/Appearance", "cursor",
1105 "Adjust the use of the cursor");
1106 ctrl_radiobuttons(s, "Cursor appearance:", NO_SHORTCUT, 3,
1107 HELPCTX(appearance_cursor),
1108 dlg_stdradiobutton_handler,
1109 I(offsetof(Config, cursor_type)),
1110 "Block", 'l', I(0),
1111 "Underline", 'u', I(1),
1112 "Vertical line", 'v', I(2), NULL);
1113 ctrl_checkbox(s, "Cursor blinks", 'b',
1114 HELPCTX(appearance_cursor),
1115 dlg_stdcheckbox_handler, I(offsetof(Config,blink_cur)));
1116
1117 s = ctrl_getset(b, "Window/Appearance", "font",
1118 "Font settings");
1119 ctrl_fontsel(s, "Font used in the terminal window", 'n',
1120 HELPCTX(appearance_font),
1121 dlg_stdfontsel_handler, I(offsetof(Config, font)));
1122
1123 s = ctrl_getset(b, "Window/Appearance", "mouse",
1124 "Adjust the use of the mouse pointer");
1125 ctrl_checkbox(s, "Hide mouse pointer when typing in window", 'p',
1126 HELPCTX(appearance_hidemouse),
1127 dlg_stdcheckbox_handler, I(offsetof(Config,hide_mouseptr)));
1128
1129 s = ctrl_getset(b, "Window/Appearance", "border",
1130 "Adjust the window border");
1131 ctrl_editbox(s, "Gap between text and window edge:", NO_SHORTCUT, 20,
1132 HELPCTX(appearance_border),
1133 dlg_stdeditbox_handler,
1134 I(offsetof(Config,window_border)), I(-1));
1135
1136 /*
1137 * The Window/Behaviour panel.
1138 */
f6f450e2 1139 str = dupprintf("Configure the behaviour of %s's window", appname);
1140 ctrl_settitle(b, "Window/Behaviour", str);
1141 sfree(str);
fe8abbf4 1142
1143 s = ctrl_getset(b, "Window/Behaviour", "title",
1144 "Adjust the behaviour of the window title");
1145 ctrl_editbox(s, "Window title:", 't', 100,
1146 HELPCTX(appearance_title),
1147 dlg_stdeditbox_handler, I(offsetof(Config,wintitle)),
1148 I(sizeof(((Config *)0)->wintitle)));
1149 ctrl_checkbox(s, "Separate window and icon titles", 'i',
1150 HELPCTX(appearance_title),
1151 dlg_stdcheckbox_handler,
1152 I(CHECKBOX_INVERT | offsetof(Config,win_name_always)));
1153
1154 s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
1155 ctrl_checkbox(s, "Warn before closing window", 'w',
1156 HELPCTX(behaviour_closewarn),
1157 dlg_stdcheckbox_handler, I(offsetof(Config,warn_on_close)));
1158
1159 /*
1160 * The Window/Translation panel.
1161 */
1162 ctrl_settitle(b, "Window/Translation",
1163 "Options controlling character set translation");
1164
1165 s = ctrl_getset(b, "Window/Translation", "trans",
1166 "Character set translation on received data");
1167 ctrl_combobox(s, "Received data assumed to be in which character set:",
1168 'r', 100, HELPCTX(translation_codepage),
1169 codepage_handler, P(NULL), P(NULL));
1170
00381fc7 1171 str = dupprintf("Adjust how %s handles line drawing characters", appname);
f6f450e2 1172 s = ctrl_getset(b, "Window/Translation", "linedraw", str);
1173 sfree(str);
fe8abbf4 1174 ctrl_radiobuttons(s, "Handling of line drawing characters:", NO_SHORTCUT,1,
1175 HELPCTX(translation_linedraw),
1176 dlg_stdradiobutton_handler,
1177 I(offsetof(Config, vtmode)),
3900c2d6 1178 "Use Unicode line drawing code points",'u',I(VT_UNICODE),
fe8abbf4 1179 "Poor man's line drawing (+, - and |)",'p',I(VT_POORMAN),
3900c2d6 1180 NULL);
00381fc7 1181 ctrl_checkbox(s, "Copy and paste line drawing characters as lqqqk",'d',
1182 HELPCTX(selection_linedraw),
1183 dlg_stdcheckbox_handler, I(offsetof(Config,rawcnp)));
fe8abbf4 1184
1185 /*
1186 * The Window/Selection panel.
1187 */
1188 ctrl_settitle(b, "Window/Selection", "Options controlling copy and paste");
fe8abbf4 1189
1190 s = ctrl_getset(b, "Window/Selection", "mouse",
1191 "Control use of mouse");
1192 ctrl_checkbox(s, "Shift overrides application's use of mouse", 'p',
1193 HELPCTX(selection_shiftdrag),
1194 dlg_stdcheckbox_handler, I(offsetof(Config,mouse_override)));
1195 ctrl_radiobuttons(s,
1196 "Default selection mode (Alt+drag does the other one):",
1197 NO_SHORTCUT, 2,
1198 HELPCTX(selection_rect),
1199 dlg_stdradiobutton_handler,
1200 I(offsetof(Config, rect_select)),
1201 "Normal", 'n', I(0),
1202 "Rectangular block", 'r', I(1), NULL);
1203
1204 s = ctrl_getset(b, "Window/Selection", "charclass",
1205 "Control the select-one-word-at-a-time mode");
1206 ccd = (struct charclass_data *)
1207 ctrl_alloc(b, sizeof(struct charclass_data));
1208 ccd->listbox = ctrl_listbox(s, "Character classes:", 'e',
1209 HELPCTX(selection_charclasses),
1210 charclass_handler, P(ccd));
1211 ccd->listbox->listbox.multisel = 1;
1212 ccd->listbox->listbox.ncols = 4;
3d88e64d 1213 ccd->listbox->listbox.percentages = snewn(4, int);
fe8abbf4 1214 ccd->listbox->listbox.percentages[0] = 15;
1215 ccd->listbox->listbox.percentages[1] = 25;
1216 ccd->listbox->listbox.percentages[2] = 20;
1217 ccd->listbox->listbox.percentages[3] = 40;
1218 ctrl_columns(s, 2, 67, 33);
1219 ccd->editbox = ctrl_editbox(s, "Set to class", 't', 50,
1220 HELPCTX(selection_charclasses),
1221 charclass_handler, P(ccd), P(NULL));
1222 ccd->editbox->generic.column = 0;
1223 ccd->button = ctrl_pushbutton(s, "Set", 's',
1224 HELPCTX(selection_charclasses),
1225 charclass_handler, P(ccd));
1226 ccd->button->generic.column = 1;
1227 ctrl_columns(s, 1, 100);
1228
1229 /*
1230 * The Window/Colours panel.
1231 */
1232 ctrl_settitle(b, "Window/Colours", "Options controlling use of colours");
1233
1234 s = ctrl_getset(b, "Window/Colours", "general",
1235 "General options for colour usage");
1236 ctrl_checkbox(s, "Bolded text is a different colour", 'b',
1237 HELPCTX(colours_bold),
1238 dlg_stdcheckbox_handler, I(offsetof(Config,bold_colour)));
1239
f6f450e2 1240 str = dupprintf("Adjust the precise colours %s displays", appname);
1241 s = ctrl_getset(b, "Window/Colours", "adjust", str);
1242 sfree(str);
fe8abbf4 1243 ctrl_text(s, "Select a colour from the list, and then click the"
1244 " Modify button to change its appearance.",
1245 HELPCTX(colours_config));
1246 ctrl_columns(s, 2, 67, 33);
1247 cd = (struct colour_data *)ctrl_alloc(b, sizeof(struct colour_data));
1248 cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u',
1249 HELPCTX(colours_config), colour_handler, P(cd));
1250 cd->listbox->generic.column = 0;
18c2f87c 1251 cd->listbox->listbox.height = 7;
fe8abbf4 1252 c = ctrl_text(s, "RGB value:", HELPCTX(colours_config));
1253 c->generic.column = 1;
18c2f87c 1254 cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config),
1255 colour_handler, P(cd), P(NULL));
1256 cd->redit->generic.column = 1;
1257 cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config),
1258 colour_handler, P(cd), P(NULL));
1259 cd->gedit->generic.column = 1;
1260 cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config),
1261 colour_handler, P(cd), P(NULL));
1262 cd->bedit->generic.column = 1;
fe8abbf4 1263 cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config),
1264 colour_handler, P(cd));
1265 cd->button->generic.column = 1;
1266 ctrl_columns(s, 1, 100);
1267
1268 /*
3e547dd8 1269 * The Connection panel. This doesn't show up if we're in a
1270 * non-network utility such as pterm. We tell this by being
1271 * passed a protocol < 0.
fe8abbf4 1272 */
3e547dd8 1273 if (protocol >= 0) {
1274 ctrl_settitle(b, "Connection", "Options controlling the connection");
1275
1276 if (!midsession) {
1277 s = ctrl_getset(b, "Connection", "data",
1278 "Data to send to the server");
1279 ctrl_editbox(s, "Terminal-type string", 't', 50,
1280 HELPCTX(connection_termtype),
1281 dlg_stdeditbox_handler, I(offsetof(Config,termtype)),
1282 I(sizeof(((Config *)0)->termtype)));
a5dd8467 1283 ctrl_editbox(s, "Terminal speeds", 's', 50,
1284 HELPCTX(connection_termspeed),
1285 dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
1286 I(sizeof(((Config *)0)->termspeed)));
3e547dd8 1287 ctrl_editbox(s, "Auto-login username", 'u', 50,
1288 HELPCTX(connection_username),
1289 dlg_stdeditbox_handler, I(offsetof(Config,username)),
1290 I(sizeof(((Config *)0)->username)));
1291 }
fe8abbf4 1292
3e547dd8 1293 s = ctrl_getset(b, "Connection", "keepalive",
1294 "Sending of null packets to keep session active");
1295 ctrl_editbox(s, "Seconds between keepalives (0 to turn off)", 'k', 20,
1296 HELPCTX(connection_keepalive),
1297 dlg_stdeditbox_handler, I(offsetof(Config,ping_interval)),
1298 I(-1));
1299
1300 if (!midsession) {
1301 s = ctrl_getset(b, "Connection", "tcp",
1302 "Low-level TCP connection options");
1303 ctrl_checkbox(s, "Disable Nagle's algorithm (TCP_NODELAY option)",
1304 'n', HELPCTX(connection_nodelay),
1305 dlg_stdcheckbox_handler,
1306 I(offsetof(Config,tcp_nodelay)));
79bf227b 1307 ctrl_checkbox(s, "Enable TCP keepalives (SO_KEEPALIVE option)",
1308 'p', HELPCTX(connection_tcpkeepalive),
1309 dlg_stdcheckbox_handler,
1310 I(offsetof(Config,tcp_keepalives)));
3e547dd8 1311 }
fe8abbf4 1312
fe8abbf4 1313 }
1314
1315 if (!midsession) {
1316 /*
1317 * The Connection/Proxy panel.
1318 */
1319 ctrl_settitle(b, "Connection/Proxy",
1320 "Options controlling proxy usage");
1321
10068a0b 1322 s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
1323 ctrl_radiobuttons(s, "Proxy type:", 't', 3,
fe8abbf4 1324 HELPCTX(proxy_type),
1325 dlg_stdradiobutton_handler,
1326 I(offsetof(Config, proxy_type)),
0f0a2507 1327 "None", I(PROXY_NONE),
10068a0b 1328 "SOCKS 4", I(PROXY_SOCKS4),
1329 "SOCKS 5", I(PROXY_SOCKS5),
0f0a2507 1330 "HTTP", I(PROXY_HTTP),
0f0a2507 1331 "Telnet", I(PROXY_TELNET),
fe8abbf4 1332 NULL);
1333 ctrl_columns(s, 2, 80, 20);
1334 c = ctrl_editbox(s, "Proxy hostname", 'y', 100,
1335 HELPCTX(proxy_main),
1336 dlg_stdeditbox_handler,
1337 I(offsetof(Config,proxy_host)),
1338 I(sizeof(((Config *)0)->proxy_host)));
1339 c->generic.column = 0;
1340 c = ctrl_editbox(s, "Port", 'p', 100,
1341 HELPCTX(proxy_main),
1342 dlg_stdeditbox_handler,
1343 I(offsetof(Config,proxy_port)),
1344 I(-1));
1345 c->generic.column = 1;
1346 ctrl_columns(s, 1, 100);
1347 ctrl_editbox(s, "Exclude Hosts/IPs", 'e', 100,
1348 HELPCTX(proxy_exclude),
1349 dlg_stdeditbox_handler,
1350 I(offsetof(Config,proxy_exclude_list)),
1351 I(sizeof(((Config *)0)->proxy_exclude_list)));
1352 ctrl_checkbox(s, "Consider proxying local host connections", 'x',
1353 HELPCTX(proxy_exclude),
1354 dlg_stdcheckbox_handler,
1355 I(offsetof(Config,even_proxy_localhost)));
1356 ctrl_radiobuttons(s, "Do DNS name lookup at proxy end:", 'd', 3,
1357 HELPCTX(proxy_dns),
1358 dlg_stdradiobutton_handler,
1359 I(offsetof(Config, proxy_dns)),
1360 "No", I(FORCE_OFF),
1361 "Auto", I(AUTO),
1362 "Yes", I(FORCE_ON), NULL);
1363 ctrl_editbox(s, "Username", 'u', 60,
1364 HELPCTX(proxy_auth),
1365 dlg_stdeditbox_handler,
1366 I(offsetof(Config,proxy_username)),
1367 I(sizeof(((Config *)0)->proxy_username)));
1368 c = ctrl_editbox(s, "Password", 'w', 60,
1369 HELPCTX(proxy_auth),
1370 dlg_stdeditbox_handler,
1371 I(offsetof(Config,proxy_password)),
1372 I(sizeof(((Config *)0)->proxy_password)));
1373 c->editbox.password = 1;
fe8abbf4 1374 ctrl_editbox(s, "Telnet command", 'm', 100,
1375 HELPCTX(proxy_command),
1376 dlg_stdeditbox_handler,
1377 I(offsetof(Config,proxy_telnet_command)),
1378 I(sizeof(((Config *)0)->proxy_telnet_command)));
fe8abbf4 1379 }
1380
1381 /*
1382 * The Telnet panel exists in the base config box, and in a
1383 * mid-session reconfig box _if_ we're using Telnet.
1384 */
1385 if (!midsession || protocol == PROT_TELNET) {
1386 /*
1387 * The Connection/Telnet panel.
1388 */
1389 ctrl_settitle(b, "Connection/Telnet",
1390 "Options controlling Telnet connections");
1391
1392 if (!midsession) {
1393 s = ctrl_getset(b, "Connection/Telnet", "data",
1394 "Data to send to the server");
fe8abbf4 1395 ctrl_text(s, "Environment variables:", HELPCTX(telnet_environ));
1396 ctrl_columns(s, 2, 80, 20);
1397 ed = (struct environ_data *)
1398 ctrl_alloc(b, sizeof(struct environ_data));
1399 ed->varbox = ctrl_editbox(s, "Variable", 'v', 60,
1400 HELPCTX(telnet_environ),
1401 environ_handler, P(ed), P(NULL));
1402 ed->varbox->generic.column = 0;
1403 ed->valbox = ctrl_editbox(s, "Value", 'l', 60,
1404 HELPCTX(telnet_environ),
1405 environ_handler, P(ed), P(NULL));
1406 ed->valbox->generic.column = 0;
1407 ed->addbutton = ctrl_pushbutton(s, "Add", 'd',
1408 HELPCTX(telnet_environ),
1409 environ_handler, P(ed));
1410 ed->addbutton->generic.column = 1;
1411 ed->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1412 HELPCTX(telnet_environ),
1413 environ_handler, P(ed));
1414 ed->rembutton->generic.column = 1;
1415 ctrl_columns(s, 1, 100);
1416 ed->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1417 HELPCTX(telnet_environ),
1418 environ_handler, P(ed));
1419 ed->listbox->listbox.height = 3;
d437fc9d 1420 ed->listbox->listbox.ncols = 2;
3d88e64d 1421 ed->listbox->listbox.percentages = snewn(2, int);
d437fc9d 1422 ed->listbox->listbox.percentages[0] = 30;
1423 ed->listbox->listbox.percentages[1] = 70;
fe8abbf4 1424 }
1425
1426 s = ctrl_getset(b, "Connection/Telnet", "protocol",
1427 "Telnet protocol adjustments");
1428
1429 if (!midsession) {
1430 ctrl_radiobuttons(s, "Handling of OLD_ENVIRON ambiguity:",
1431 NO_SHORTCUT, 2,
1432 HELPCTX(telnet_oldenviron),
1433 dlg_stdradiobutton_handler,
1434 I(offsetof(Config, rfc_environ)),
1435 "BSD (commonplace)", 'b', I(0),
1436 "RFC 1408 (unusual)", 'f', I(1), NULL);
1437 ctrl_radiobuttons(s, "Telnet negotiation mode:", 't', 2,
1438 HELPCTX(telnet_passive),
1439 dlg_stdradiobutton_handler,
1440 I(offsetof(Config, passive_telnet)),
1441 "Passive", I(1), "Active", I(0), NULL);
1442 }
76d3d354 1443 ctrl_checkbox(s, "Keyboard sends Telnet special commands", 'k',
fe8abbf4 1444 HELPCTX(telnet_specialkeys),
1445 dlg_stdcheckbox_handler,
1446 I(offsetof(Config,telnet_keyboard)));
76d3d354 1447 ctrl_checkbox(s, "Return key sends Telnet New Line instead of ^M",
1448 'm', HELPCTX(telnet_newline),
fe8abbf4 1449 dlg_stdcheckbox_handler,
1450 I(offsetof(Config,telnet_newline)));
1451 }
1452
1453 if (!midsession) {
1454
1455 /*
1456 * The Connection/Rlogin panel.
1457 */
1458 ctrl_settitle(b, "Connection/Rlogin",
1459 "Options controlling Rlogin connections");
1460
1461 s = ctrl_getset(b, "Connection/Rlogin", "data",
1462 "Data to send to the server");
fe8abbf4 1463 ctrl_editbox(s, "Local username:", 'l', 50,
1464 HELPCTX(rlogin_localuser),
1465 dlg_stdeditbox_handler, I(offsetof(Config,localusername)),
1466 I(sizeof(((Config *)0)->localusername)));
1467
1468 }
1469
1470 /*
1471 * All the SSH stuff is omitted in PuTTYtel.
1472 */
1473
d9b15094 1474 if (!midsession && backends[3].name != NULL) {
fe8abbf4 1475
1476 /*
1477 * The Connection/SSH panel.
1478 */
1479 ctrl_settitle(b, "Connection/SSH",
1480 "Options controlling SSH connections");
1481
1482 s = ctrl_getset(b, "Connection/SSH", "data",
1483 "Data to send to the server");
1484 ctrl_editbox(s, "Remote command:", 'r', 100,
1485 HELPCTX(ssh_command),
1486 dlg_stdeditbox_handler, I(offsetof(Config,remote_cmd)),
1487 I(sizeof(((Config *)0)->remote_cmd)));
1488
1489 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
1490 ctrl_checkbox(s, "Don't allocate a pseudo-terminal", 'p',
1491 HELPCTX(ssh_nopty),
1492 dlg_stdcheckbox_handler,
1493 I(offsetof(Config,nopty)));
0ed48730 1494 ctrl_checkbox(s, "Don't start a shell or command at all", 'n',
1495 HELPCTX(ssh_noshell),
1496 dlg_stdcheckbox_handler,
1497 I(offsetof(Config,ssh_no_shell)));
fe8abbf4 1498 ctrl_checkbox(s, "Enable compression", 'e',
1499 HELPCTX(ssh_compress),
1500 dlg_stdcheckbox_handler,
1501 I(offsetof(Config,compression)));
1502 ctrl_radiobuttons(s, "Preferred SSH protocol version:", NO_SHORTCUT, 4,
1503 HELPCTX(ssh_protocol),
1504 dlg_stdradiobutton_handler,
1505 I(offsetof(Config, sshprot)),
1506 "1 only", 'l', I(0),
1507 "1", '1', I(1),
1508 "2", '2', I(2),
0ed48730 1509 "2 only", 'y', I(3), NULL);
fe8abbf4 1510
1511 s = ctrl_getset(b, "Connection/SSH", "encryption", "Encryption options");
bb524800 1512 c = ctrl_draglist(s, "Encryption cipher selection policy:", 's',
1513 HELPCTX(ssh_ciphers),
1514 cipherlist_handler, P(NULL));
1515 c->listbox.height = 6;
1516
8f161275 1517 ctrl_checkbox(s, "Enable legacy use of single-DES in SSH 2", 'i',
fe8abbf4 1518 HELPCTX(ssh_ciphers),
1519 dlg_stdcheckbox_handler,
1520 I(offsetof(Config,ssh2_des_cbc)));
1521
1522 /*
1523 * The Connection/SSH/Auth panel.
1524 */
1525 ctrl_settitle(b, "Connection/SSH/Auth",
1526 "Options controlling SSH authentication");
1527
1528 s = ctrl_getset(b, "Connection/SSH/Auth", "methods",
1529 "Authentication methods");
1530 ctrl_checkbox(s, "Attempt TIS or CryptoCard auth (SSH1)", 'm',
1531 HELPCTX(ssh_auth_tis),
1532 dlg_stdcheckbox_handler,
1533 I(offsetof(Config,try_tis_auth)));
1534 ctrl_checkbox(s, "Attempt \"keyboard-interactive\" auth (SSH2)",
1535 'i', HELPCTX(ssh_auth_ki),
1536 dlg_stdcheckbox_handler,
1537 I(offsetof(Config,try_ki_auth)));
1538
1539 s = ctrl_getset(b, "Connection/SSH/Auth", "params",
1540 "Authentication parameters");
1541 ctrl_checkbox(s, "Allow agent forwarding", 'f',
1542 HELPCTX(ssh_auth_agentfwd),
1543 dlg_stdcheckbox_handler, I(offsetof(Config,agentfwd)));
1544 ctrl_checkbox(s, "Allow attempted changes of username in SSH2", 'u',
1545 HELPCTX(ssh_auth_changeuser),
1546 dlg_stdcheckbox_handler,
1547 I(offsetof(Config,change_username)));
1548 ctrl_filesel(s, "Private key file for authentication:", 'k',
1549 FILTER_KEY_FILES, FALSE, "Select private key file",
1550 HELPCTX(ssh_auth_privkey),
1551 dlg_stdfilesel_handler, I(offsetof(Config, keyfile)));
1552
1553 /*
1554 * The Connection/SSH/Tunnels panel.
1555 */
1556 ctrl_settitle(b, "Connection/SSH/Tunnels",
1557 "Options controlling SSH tunnelling");
1558
1559 s = ctrl_getset(b, "Connection/SSH/Tunnels", "x11", "X11 forwarding");
1560 ctrl_checkbox(s, "Enable X11 forwarding", 'e',
1561 HELPCTX(ssh_tunnels_x11),
1562 dlg_stdcheckbox_handler,I(offsetof(Config,x11_forward)));
1563 ctrl_editbox(s, "X display location", 'x', 50,
1564 HELPCTX(ssh_tunnels_x11),
1565 dlg_stdeditbox_handler, I(offsetof(Config,x11_display)),
1566 I(sizeof(((Config *)0)->x11_display)));
1567 ctrl_radiobuttons(s, "Remote X11 authentication protocol", 'u', 2,
1568 HELPCTX(ssh_tunnels_x11auth),
1569 dlg_stdradiobutton_handler,
1570 I(offsetof(Config, x11_auth)),
1571 "MIT-Magic-Cookie-1", I(X11_MIT),
1572 "XDM-Authorization-1", I(X11_XDM), NULL);
1573
1574 s = ctrl_getset(b, "Connection/SSH/Tunnels", "portfwd",
1575 "Port forwarding");
1576 ctrl_checkbox(s, "Local ports accept connections from other hosts",'t',
1577 HELPCTX(ssh_tunnels_portfwd_localhost),
1578 dlg_stdcheckbox_handler,
1579 I(offsetof(Config,lport_acceptall)));
1580 ctrl_checkbox(s, "Remote ports do the same (SSH v2 only)", 'p',
1581 HELPCTX(ssh_tunnels_portfwd_localhost),
1582 dlg_stdcheckbox_handler,
1583 I(offsetof(Config,rport_acceptall)));
1584
1585 ctrl_columns(s, 3, 55, 20, 25);
1586 c = ctrl_text(s, "Forwarded ports:", HELPCTX(ssh_tunnels_portfwd));
1587 c->generic.column = COLUMN_FIELD(0,2);
1588 /* You want to select from the list, _then_ hit Remove. So tab order
1589 * should be that way round. */
1590 pfd = (struct portfwd_data *)ctrl_alloc(b,sizeof(struct portfwd_data));
1591 pfd->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1592 HELPCTX(ssh_tunnels_portfwd),
1593 portfwd_handler, P(pfd));
1594 pfd->rembutton->generic.column = 2;
1595 pfd->rembutton->generic.tabdelay = 1;
1596 pfd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1597 HELPCTX(ssh_tunnels_portfwd),
1598 portfwd_handler, P(pfd));
1599 pfd->listbox->listbox.height = 3;
37dbf11c 1600 pfd->listbox->listbox.ncols = 2;
3d88e64d 1601 pfd->listbox->listbox.percentages = snewn(2, int);
37dbf11c 1602 pfd->listbox->listbox.percentages[0] = 20;
1603 pfd->listbox->listbox.percentages[1] = 80;
fe8abbf4 1604 ctrl_tabdelay(s, pfd->rembutton);
1605 ctrl_text(s, "Add new forwarded port:", HELPCTX(ssh_tunnels_portfwd));
1606 /* You want to enter source, destination and type, _then_ hit Add.
1607 * Again, we adjust the tab order to reflect this. */
1608 pfd->addbutton = ctrl_pushbutton(s, "Add", 'd',
1609 HELPCTX(ssh_tunnels_portfwd),
1610 portfwd_handler, P(pfd));
1611 pfd->addbutton->generic.column = 2;
1612 pfd->addbutton->generic.tabdelay = 1;
1613 pfd->sourcebox = ctrl_editbox(s, "Source port", 's', 40,
1614 HELPCTX(ssh_tunnels_portfwd),
1615 portfwd_handler, P(pfd), P(NULL));
1616 pfd->sourcebox->generic.column = 0;
1617 pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67,
1618 HELPCTX(ssh_tunnels_portfwd),
1619 portfwd_handler, P(pfd), P(NULL));
820ebe3b 1620 pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
fe8abbf4 1621 HELPCTX(ssh_tunnels_portfwd),
1622 portfwd_handler, P(pfd),
1623 "Local", 'l', P(NULL),
820ebe3b 1624 "Remote", 'm', P(NULL),
1625 "Dynamic", 'y', P(NULL),
1626 NULL);
fe8abbf4 1627 ctrl_tabdelay(s, pfd->addbutton);
1628 ctrl_columns(s, 1, 100);
1629
1630 /*
1631 * The Connection/SSH/Bugs panel.
1632 */
1633 ctrl_settitle(b, "Connection/SSH/Bugs",
1634 "Workarounds for SSH server bugs");
1635
1636 s = ctrl_getset(b, "Connection/SSH/Bugs", "main",
1637 "Detection of known bugs in SSH servers");
1638 ctrl_droplist(s, "Chokes on SSH1 ignore messages", 'i', 20,
1639 HELPCTX(ssh_bugs_ignore1),
1640 sshbug_handler, I(offsetof(Config,sshbug_ignore1)));
1641 ctrl_droplist(s, "Refuses all SSH1 password camouflage", 's', 20,
1642 HELPCTX(ssh_bugs_plainpw1),
1643 sshbug_handler, I(offsetof(Config,sshbug_plainpw1)));
1644 ctrl_droplist(s, "Chokes on SSH1 RSA authentication", 'r', 20,
1645 HELPCTX(ssh_bugs_rsa1),
1646 sshbug_handler, I(offsetof(Config,sshbug_rsa1)));
1647 ctrl_droplist(s, "Miscomputes SSH2 HMAC keys", 'm', 20,
1648 HELPCTX(ssh_bugs_hmac2),
1649 sshbug_handler, I(offsetof(Config,sshbug_hmac2)));
1650 ctrl_droplist(s, "Miscomputes SSH2 encryption keys", 'e', 20,
1651 HELPCTX(ssh_bugs_derivekey2),
1652 sshbug_handler, I(offsetof(Config,sshbug_derivekey2)));
1653 ctrl_droplist(s, "Requires padding on SSH2 RSA signatures", 'p', 20,
1654 HELPCTX(ssh_bugs_rsapad2),
1655 sshbug_handler, I(offsetof(Config,sshbug_rsapad2)));
1656 ctrl_droplist(s, "Chokes on Diffie-Hellman group exchange", 'd', 20,
1657 HELPCTX(ssh_bugs_dhgex2),
1658 sshbug_handler, I(offsetof(Config,sshbug_dhgex2)));
1659 ctrl_droplist(s, "Misuses the session ID in PK auth", 'n', 20,
1660 HELPCTX(ssh_bugs_pksessid2),
1661 sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));
1662 }
1663}