OSDN Git Service

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