void LoadConf() { int retval; #ifdef VERBOSE_FUNCTION_CONF PrintLog("CDVD config: LoadConf()\n"); #endif /* VERBOSE_FUNCTION_CONF */ retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname); if(retval < 0) { sprintf(conf.isoname, "[Put an Image Name here]"); } // ENDIF- Couldn't find keyword? Fill in a default retval = INILoadString(conffilename, "Settings", "Device", conf.devicename); if(retval < 0) { sprintf(conf.devicename, "/dev/dvd"); } // ENDIF- Couldn't find keyword? Fill in a default retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure); if(retval < 0) { conf.startconfigure = 0; // False } // ENDIF- Couldn't find keyword? Fill in a default retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure); if(retval < 0) { conf.restartconfigure = 1; // True } // ENDIF- Couldn't find keyword? Fill in a default } // END LoadConf()
int INILoadUInt(char *file, char *section, char *keyword, unsigned int *buffer) { char numvalue[INIMAXLEN + 1]; int retval; unsigned int value; // unsigned int sign; // Not needed in unsigned numbers int pos; if (buffer == NULL) return (-1); *(buffer) = 0; retval = INILoadString(file, section, keyword, numvalue); if (retval < 0) return (retval); value = 0; // sign = 1; // Start positive pos = 0; // Note: skip leading spaces? (Shouldn't have to, I hope) // if(numvalue[pos] == '-') { // pos++; // sign = -1; // } // ENDIF- Negative sign check while ((pos < INIMAXLEN) && (numvalue[pos] != 0)) { if (value > (0xFFFFFFFF / 10)) return (-1); // Overflow? if ((numvalue[pos] >= '0') && (numvalue[pos] <= '9')) { value *= 10; value += numvalue[pos] - '0'; pos++; } else numvalue[pos] = 0; // ENDIF- Add a digit in? Or stop searching for digits? } // ENDWHILE- Adding digits of info to our ever-increasing value // value *= sign *(buffer) = value; return (0); } // END INILoadUInt()
void LoadConf() { int retval; #ifdef VERBOSE_FUNCTION_CONF PrintLog("CDVD config: LoadConf()"); #endif /* VERBOSE_FUNCTION_CONF */ retval = INILoadString(conffilename, "Settings", "Device", conf.devicename); if (retval < 0) sprintf(conf.devicename, "D:"); // ENDIF- Couldn't find keyword? Fill in a default } // END LoadConf()