config.c 54 KB

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