From 640d73877e44394a3c12c0aa2cf023c543933032 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 28 Aug 2006 13:08:15 +0000 Subject: [PATCH] Because not all OSes will support the same set of serial port options, here's a slight change to the API of ser_setup_config_box() to make it filter its parity and flow control options using platform-supplied bit masks. git-svn-id: svn://svn.tartarus.org/sgt/putty@6820 cda61777-01e9-0310-a592-d414129be87e --- sercfg.c | 42 +++++++++++++++++++++++++++--------------- windows/wincfg.c | 2 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/sercfg.c b/sercfg.c index 10b582f0..752953e5 100644 --- a/sercfg.c +++ b/sercfg.c @@ -29,18 +29,24 @@ static void serial_parity_handler(union control *ctrl, void *dlg, {"Mark", SER_PAR_MARK}, {"Space", SER_PAR_SPACE}, }; - int i; + int mask = ctrl->listbox.context.i; + int i, j; Config *cfg = (Config *)data; if (event == EVENT_REFRESH) { dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); - for (i = 0; i < lenof(parities); i++) - dlg_listbox_addwithid(ctrl, dlg, parities[i].name, - parities[i].val); - for (i = 0; i < lenof(parities); i++) + for (i = 0; i < lenof(parities); i++) { + if (mask & (1 << i)) + dlg_listbox_addwithid(ctrl, dlg, parities[i].name, + parities[i].val); + } + for (i = j = 0; i < lenof(parities); i++) { if (cfg->serparity == parities[i].val) - dlg_listbox_select(ctrl, dlg, i); + dlg_listbox_select(ctrl, dlg, j); + if (mask & (1 << i)) + j++; + } dlg_update_done(ctrl, dlg); } else if (event == EVENT_SELCHANGE) { int i = dlg_listbox_index(ctrl, dlg); @@ -64,18 +70,23 @@ static void serial_flow_handler(union control *ctrl, void *dlg, {"RTS/CTS", SER_FLOW_RTSCTS}, {"DSR/DTR", SER_FLOW_DSRDTR}, }; - int i; + int mask = ctrl->listbox.context.i; + int i, j; Config *cfg = (Config *)data; if (event == EVENT_REFRESH) { dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); - for (i = 0; i < lenof(flows); i++) - dlg_listbox_addwithid(ctrl, dlg, flows[i].name, - flows[i].val); - for (i = 0; i < lenof(flows); i++) + for (i = 0; i < lenof(flows); i++) { + if (mask & (1 << i)) + dlg_listbox_addwithid(ctrl, dlg, flows[i].name, flows[i].val); + } + for (i = j = 0; i < lenof(flows); i++) { if (cfg->serflow == flows[i].val) - dlg_listbox_select(ctrl, dlg, i); + dlg_listbox_select(ctrl, dlg, j); + if (mask & (1 << i)) + j++; + } dlg_update_done(ctrl, dlg); } else if (event == EVENT_SELCHANGE) { int i = dlg_listbox_index(ctrl, dlg); @@ -87,7 +98,8 @@ static void serial_flow_handler(union control *ctrl, void *dlg, } } -void ser_setup_config_box(struct controlbox *b, int midsession) +void ser_setup_config_box(struct controlbox *b, int midsession, + int parity_mask, int flow_mask) { struct controlset *s; union control *c; @@ -160,8 +172,8 @@ void ser_setup_config_box(struct controlbox *b, int midsession) dlg_stdeditbox_handler,I(offsetof(Config,serstopbits)),I(-2)); ctrl_droplist(s, "Parity", 'p', 40, HELPCTX(serial_parity), - serial_parity_handler, I(0)); + serial_parity_handler, I(parity_mask)); ctrl_droplist(s, "Flow control", 'f', 40, HELPCTX(serial_flow), - serial_flow_handler, I(0)); + serial_flow_handler, I(flow_mask)); } diff --git a/windows/wincfg.c b/windows/wincfg.c index ff5739be..574e1e8f 100644 --- a/windows/wincfg.c +++ b/windows/wincfg.c @@ -375,5 +375,5 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help, /* * Serial back end is available on Windows. */ - ser_setup_config_box(b, midsession); + ser_setup_config_box(b, midsession, 0x1F, 0x0F); } -- 2.11.0