/* Driver menu. Choose drivers.. */ int drivermenu(void) { struct keyvalue *kv = initkeyvalues(); char message[STRING_SIZE]; char temp[STRING_SIZE] = "1"; int configtype; int i, rc, kcount = 0, neednics; if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings"))) { freekeyvalues(kv); errorbox(_("Unable to open settings file")); return 0; } if (findkey(kv, "CONFIG_TYPE", temp)) configtype = atol(temp); else { fprintf(flog,"setting CONFIG_TYPE = %s\n",temp); configtype = atol(temp); replacekeyvalue(kv, "CONFIG_TYPE", temp); writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings"); } strcpy(message, _("Configure network drivers, and which interface each card is assigned to. " "The current configuration is as follows:\n\n")); kcount = 0; neednics = 0; if (HAS_GREEN) { sprintf(temp, "%-6s: %s\n", "GREEN", knics[_GREEN_CARD_].description); strcat(message, temp); if (strlen(knics[_GREEN_CARD_].macaddr) ) { sprintf(temp, "%-6s: (%s)\n", "GREEN", knics[_GREEN_CARD_].macaddr); strcat(message, temp); } neednics++; } if (HAS_RED) { sprintf(temp, "%-6s: %s\n", "RED", knics[_RED_CARD_].description); strcat(message, temp); if (strlen(knics[_RED_CARD_].macaddr) ) { sprintf(temp, "%-6s: (%s)\n", "RED", knics[_RED_CARD_].macaddr); strcat(message, temp); } neednics++; } if (HAS_ORANGE) { sprintf(temp, "%-6s: %s\n", "ORANGE", knics[_ORANGE_CARD_].description); strcat(message, temp); if ( strlen(knics[_ORANGE_CARD_].macaddr) ) { sprintf(temp, "%-6s: (%s)\n", "ORANGE", knics[_ORANGE_CARD_].macaddr); strcat(message, temp); } neednics++; } if (HAS_BLUE) { sprintf(temp, "%-6s: %s\n", "BLUE", knics[_BLUE_CARD_].description); strcat(message, temp); if (strlen(knics[_BLUE_CARD_].macaddr)) { sprintf(temp, "%-6s: (%s)\n", "BLUE", knics[_BLUE_CARD_].macaddr); strcat(message, temp); } neednics++; } for ( i=0 ; i<4; i++) if (strcmp(knics[i].macaddr, "")) kcount++; if (neednics = kcount) { strcat(message, "\n"); strcat(message, _("Do you wish to change these settings?")); rc = newtWinChoice(_("Drivers and card assignments"), _("OK"), _("Cancel"), message); if (rc == 0 || rc == 1) { changedrivers(); } } else { changedrivers(); } freekeyvalues(kv); return 1; }
/* Driver menu. Choose drivers.. */ int drivermenu(void) { struct keyvalue *kv = initkeyvalues(); char message[1000]; char temp[STRING_SIZE], temp1[STRING_SIZE]; char driver[STRING_SIZE], dev[STRING_SIZE]; int configtype; int rc; if (!(readkeyvalues(kv, CONFIG_ROOT "ethernet/settings"))) { freekeyvalues(kv); errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]); return 0; } strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp); strcpy(message, ctr[TR_CONFIGURE_NETWORK_DRIVERS]); /* This horrible bit formats the heading :( */ strcpy(driver, ""); findkey(kv, "GREEN_DISPLAYDRIVER", driver); findnicdescription(driver, temp); strcpy(dev, ctr[TR_UNSET]); findkey(kv, "GREEN_DEV", dev); displaynicinfowithmac(temp1, sizeof(temp1), "GREEN", dev, temp); strcat(message, temp1); if (CONFIG_TYPE_ORANGE(configtype)) { strcpy(driver, ""); findkey(kv, "ORANGE_DISPLAYDRIVER", driver); findnicdescription(driver, temp); strcpy(dev, ctr[TR_UNSET]); findkey(kv, "ORANGE_DEV", dev); displaynicinfowithmac(temp1, sizeof(temp1), "ORANGE", dev, temp); strcat(message, temp1); } if (CONFIG_TYPE_PURPLE(configtype)) { strcpy(driver, ""); findkey(kv, "PURPLE_DISPLAYDRIVER", driver); findnicdescription(driver, temp); strcpy(dev, ctr[TR_UNSET]); findkey(kv, "PURPLE_DEV", dev); displaynicinfowithmac(temp1, sizeof(temp1), "PURPLE", dev, temp); strcat(message, temp1); } if (CONFIG_TYPE_RED(configtype)) { strcpy(driver, ""); findkey(kv, "RED_DISPLAYDRIVER", driver); findnicdescription(driver, temp); strcpy(dev, ctr[TR_UNSET]); findkey(kv, "RED_DEV", dev); displaynicinfowithmac(temp1, sizeof(temp1), "RED", dev, temp); strcat(message, temp1); } strcat(message, ctr[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS]); rc = newtWinChoice(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK], ctr[TR_CANCEL], message); if (rc == 0 || rc == 1) { /* Shit, got to do something.. */ changedrivers(); } freekeyvalues(kv); return 1; }