int oktoleave(void) { struct keyvalue *kv = initkeyvalues(); char temp[STRING_SIZE]; int configtype; int rc; if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings"))) { freekeyvalues(kv); errorbox(_("Unable to open settings file")); return 0; } strcpy(temp, "1"); findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp); if (configtype < 1 || configtype > 4) configtype = 1; if (HAS_GREEN) { strcpy(temp, ""); findkey(kv, "GREEN_DEV", temp); if (!(strlen(temp))) { errorbox(_("No GREEN interface assigned.")); freekeyvalues(kv); return 0; } if (!(interfacecheck(kv, "GREEN"))) { errorbox(_("Missing an IP address on GREEN.")); freekeyvalues(kv); return 0; } } if (HAS_RED) { strcpy(temp, ""); findkey(kv, "RED_DEV", temp); if (!(strlen(temp))) { rc = newtWinChoice(_("Error"), _("OK"), _("Ignore"), _("No RED interface assigned.")); if (rc == 0 || rc == 1) { freekeyvalues(kv); return 0; } } if (!(interfacecheck(kv, "RED"))) { errorbox(_("Missing an IP address on RED.")); freekeyvalues(kv); return 0; } } if (HAS_ORANGE) { strcpy(temp, ""); findkey(kv, "ORANGE_DEV", temp); if (!(strlen(temp))) { errorbox(_("No ORANGE interface assigned.")); freekeyvalues(kv); return 0; } if (!(interfacecheck(kv, "ORANGE"))) { errorbox(_("Missing an IP address on ORANGE.")); freekeyvalues(kv); return 0; } } if (HAS_BLUE) { strcpy(temp, ""); findkey(kv, "BLUE_DEV", temp); if (!(strlen(temp))) { errorbox(_("No BLUE interface assigned.")); freekeyvalues(kv); return 0; } if (!(interfacecheck(kv, "BLUE"))) { errorbox(_("Missing an IP address on BLUE.")); freekeyvalues(kv); return 0; } } strcpy(temp, ""); findkey(kv, "RED_TYPE", temp); if ((configtype == 0) || (strcmp(temp, "STATIC") == 0)) { strcpy(temp, ""); findkey(kv, "DNS1", temp); if (!(strlen(temp))) { errorbox(_("Missing DNS.")); freekeyvalues(kv); return 0; } strcpy(temp, ""); findkey(kv, "DEFAULT_GATEWAY", temp); if (!(strlen(temp))) { errorbox(_("Missing Default Gateway.")); freekeyvalues(kv); return 0; } } return 1; }
int oktoleave(char *errormessage) { struct keyvalue *kv = initkeyvalues(); char temp[STRING_SIZE]; int configtype; 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); if (configtype < 0 || configtype > 7) configtype = 0; if (CONFIG_TYPE_GREEN(configtype)) { strcpy(temp, ""); findkey(kv, "GREEN_DEV", temp); if (!(strlen(temp))) { strcpy(errormessage, ctr[TR_NO_GREEN_INTERFACE]); goto EXIT; } if (!(interfacecheck(kv, "GREEN"))) { strcpy(errormessage, ctr[TR_MISSING_GREEN_IP]); goto EXIT; } } if (CONFIG_TYPE_ORANGE(configtype)) { strcpy(temp, ""); findkey(kv, "ORANGE_DEV", temp); if (!(strlen(temp))) { strcpy(errormessage, ctr[TR_NO_ORANGE_INTERFACE]); goto EXIT; } if (!(interfacecheck(kv, "ORANGE"))) { strcpy(errormessage, ctr[TR_MISSING_ORANGE_IP]); goto EXIT; } } if (CONFIG_TYPE_PURPLE(configtype)) { strcpy(temp, ""); findkey(kv, "PURPLE_DEV", temp); if (strlen(temp) == 0) { strcpy(errormessage, ctr[TR_NO_PURPLE_INTERFACE]); goto EXIT; } if (!interfacecheck(kv, "PURPLE")) { strcpy(errormessage, ctr[TR_MISSING_PURPLE_IP]); goto EXIT; } } if (CONFIG_TYPE_RED(configtype)) { strcpy(temp, ""); findkey(kv, "RED_DEV", temp); if (!(strlen(temp))) { strcpy(errormessage, ctr[TR_NO_RED_INTERFACE]); goto EXIT; } if (!(interfacecheck(kv, "RED"))) { strcpy(errormessage, ctr[TR_MISSING_RED_IP]); goto EXIT; } } strcpy(errormessage, ""); EXIT: freekeyvalues(kv); if (strlen(errormessage)) return 0; else return 1; }