]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/uxcfg.c
Inhibit the Serial configuration panel in mid-session if the session
[PuTTY.git] / unix / uxcfg.c
1 /*
2  * uxcfg.c - the Unix-specific parts of the PuTTY configuration
3  * 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 void unix_setup_config_box(struct controlbox *b, int midsession, int protocol)
14 {
15     struct controlset *s;
16     union control *c;
17
18     /*
19      * The Config structure contains two Unix-specific elements
20      * which are not configured in here: stamp_utmp and
21      * login_shell. This is because pterm does not put up a
22      * configuration box right at the start, which is the only time
23      * when these elements would be useful to configure.
24      */
25
26     /*
27      * On Unix, we don't have a drop-down list for the printer
28      * control.
29      */
30     s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
31     assert(s->ncontrols == 1 && s->ctrls[0]->generic.type == CTRL_EDITBOX);
32     s->ctrls[0]->editbox.has_list = 0;
33
34     /*
35      * Unix supports a local-command proxy. This also means we must
36      * adjust the text on the `Telnet command' control.
37      */
38     if (!midsession) {
39         int i;
40         s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
41         for (i = 0; i < s->ncontrols; i++) {
42             c = s->ctrls[i];
43             if (c->generic.type == CTRL_RADIO &&
44                 c->generic.context.i == offsetof(Config, proxy_type)) {
45                 assert(c->generic.handler == dlg_stdradiobutton_handler);
46                 c->radio.nbuttons++;
47                 c->radio.buttons =
48                     sresize(c->radio.buttons, c->radio.nbuttons, char *);
49                 c->radio.buttons[c->radio.nbuttons-1] =
50                     dupstr("Local");
51                 c->radio.buttondata =
52                     sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
53                 c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
54                 break;
55             }
56         }
57
58         for (i = 0; i < s->ncontrols; i++) {
59             c = s->ctrls[i];
60             if (c->generic.type == CTRL_EDITBOX &&
61                 c->generic.context.i ==
62                 offsetof(Config, proxy_telnet_command)) {
63                 assert(c->generic.handler == dlg_stdeditbox_handler);
64                 sfree(c->generic.label);
65                 c->generic.label = dupstr("Telnet command, or local"
66                                           " proxy command");
67                 break;
68             }
69         }
70     }
71
72     /*
73      * Serial back end is available on Unix. However, we have to
74      * mask out a couple of the configuration options: mark and
75      * space parity are not conveniently supported, and neither is
76      * DSR/DTR flow control.
77      */
78     if (!midsession || (protocol == PROT_SERIAL))
79         ser_setup_config_box(b, midsession, 0x07, 0x07);
80 }