From 6ce4b96f6b6d572e95e8a82b84970bd58dcd76e0 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 3 Apr 2005 15:00:44 +0000 Subject: [PATCH] - parsing of comX, parportX and usbX options simplified similar to ataX options --- bochs/config.cc | 199 ++++++++++++++++-------------------------------- 1 file changed, 67 insertions(+), 132 deletions(-) diff --git a/bochs/config.cc b/bochs/config.cc index 5553bab68..8013c3451 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.33 2005-03-16 16:36:31 vruppert Exp $ +// $Id: config.cc,v 1.34 2005-04-03 15:00:44 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -2186,6 +2186,7 @@ int get_floppy_type_from_image(const char *filename) parse_line_formatted(char *context, int num_params, char *params[]) { int i, slot, t; + Bit8u idx; if (num_params < 1) return 0; if (num_params < 2) { @@ -2518,7 +2519,6 @@ parse_line_formatted(char *context, int num_params, char *params[]) } } } - else if (!strcmp(params[0], "boot")) { if (num_params < 2) { PARSE_ERR(("%s: boot directive malformed.", context)); @@ -2550,109 +2550,6 @@ parse_line_formatted(char *context, int num_params, char *params[]) PARSE_ERR(("%s: a boot drive appears twice in boot sequence.", context)); } } - - else if (!strcmp(params[0], "com1")) { - for (i=1; iset (1); - } - else if (!strncmp(params[i], "dev=", 4)) { - bx_options.com[0].Odev->set (¶ms[i][4]); - bx_options.com[0].Oenabled->set (1); - } - else { - PARSE_ERR(("%s: unknown parameter for com1 ignored.", context)); - } - } - } - else if (!strcmp(params[0], "com2")) { - for (i=1; iset (1); - } - else if (!strncmp(params[i], "dev=", 4)) { - bx_options.com[1].Odev->set (¶ms[i][4]); - bx_options.com[1].Oenabled->set (1); - } - else { - PARSE_ERR(("%s: unknown parameter for com2 ignored.", context)); - } - } - } - else if (!strcmp(params[0], "com3")) { - for (i=1; iset (1); - } - else if (!strncmp(params[i], "dev=", 4)) { - bx_options.com[2].Odev->set (¶ms[i][4]); - bx_options.com[2].Oenabled->set (1); - } - else { - PARSE_ERR(("%s: unknown parameter for com3 ignored.", context)); - } - } - } - else if (!strcmp(params[0], "com4")) { - for (i=1; iset (1); - } - else if (!strncmp(params[i], "dev=", 4)) { - bx_options.com[3].Odev->set (¶ms[i][4]); - bx_options.com[3].Oenabled->set (1); - } - else { - PARSE_ERR(("%s: unknown parameter for com4 ignored.", context)); - } - } - } - else if (!strcmp(params[0], "usb1")) { - for (i=1; iset (strdup(¶ms[1][5])); #endif } - else if (!strcmp(params[0], "sb16")) { int enable = 1; for (i=1; iset (0); } - - else if (!strcmp(params[0], "parport1")) { + else if ((!strncmp(params[0], "com", 3)) && (strlen(params[0]) == 4)) { + idx = params[0][3]; + if ((idx < '1') || (idx > '9')) { + PARSE_ERR(("%s: comX directive malformed.", context)); + } + idx -= '1'; + if (idx >= BX_N_SERIAL_PORTS) { + PARSE_ERR(("%s: comX port number out of range.", context)); + } for (i=1; iset (atol(¶ms[i][8])); + } else if (!strncmp(params[i], "mode=", 5)) { + if (!bx_options.com[idx].Omode->set_by_name (strdup(¶ms[i][5]))) + PARSE_ERR(("%s: com%d serial port mode '%s' not available", context, idx+1, strdup(¶ms[i][5]))); + bx_options.com[idx].Oenabled->set (1); + } else if (!strncmp(params[i], "dev=", 4)) { + bx_options.com[idx].Odev->set (¶ms[i][4]); + bx_options.com[idx].Oenabled->set (1); + } else { + PARSE_ERR(("%s: unknown parameter for com%d ignored.", context, idx+1)); + } + } + } else if ((!strncmp(params[0], "parport", 7)) && (strlen(params[0]) == 8)) { + idx = params[0][7]; + if ((idx < '1') || (idx > '9')) { + PARSE_ERR(("%s: parportX directive malformed.", context)); + } + idx -= '1'; + if (idx >= BX_N_PARALLEL_PORTS) { + PARSE_ERR(("%s: parportX port number out of range.", context)); } - } - - else if (!strcmp(params[0], "parport2")) { for (i=1; iset (atol(¶ms[i][8])); + } else if (!strncmp(params[i], "file=", 5)) { + bx_options.par[idx].Ooutfile->set (strdup(¶ms[i][5])); + bx_options.par[idx].Oenabled->set (1); + } else { + BX_ERROR(("%s: unknown parameter for parport%d ignored.", context, idx+1)); + } } - } - - else if (!strcmp(params[0], "i440fxsupport")) { + } else if ((!strncmp(params[0], "usb", 3)) && (strlen(params[0]) == 4)) { + idx = params[0][3]; + if ((idx < '1') || (idx > '9')) { + PARSE_ERR(("%s: usbX directive malformed.", context)); + } + idx -= '1'; + if (idx >= BX_N_USB_HUBS) { + PARSE_ERR(("%s: usbX hub number out of range.", context)); + } + for (i=1; i