db ini checks

Fixes #128

Also addresses telling the correct parameter that is missing from the ini
This commit is contained in:
Image 2020-06-06 07:58:17 -04:00
parent 65934e9969
commit 3ec034e172
2 changed files with 12 additions and 1 deletions

View file

@ -104,7 +104,7 @@ bool Database::Init(bool silentLoad) {
for (i = 0; i < 4; i++)
{
if ( !items[i] )
LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i]);
LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i+1]); // offset by 1 because the [Database] entry
}
LogWrite(DATABASE__ERROR, 0, "DB", "Example File:");
int length = sizeof exampleIni / sizeof exampleIni[0];

View file

@ -100,12 +100,23 @@ bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, int
key = strtok(line, "=");
if (key == NULL)
continue;
//don't do anything until we find the [Database] section
if (!on_database_section && strncasecmp(key, "[Database]", 10) == 0)
on_database_section = true;
else {
val = strtok(NULL, "=");
if (val == NULL)
{
if (strcasecmp(key, "password") == 0) {
strcpy(passwd, "");
items[2] = true;
}
continue;
}
if (strcasecmp(key, "host") == 0) {
strcpy(host, val);
items[0] = true;