Read a configuration file: Difference between revisions

Content added Content deleted
Line 671: Line 671:
}
}


if (!confs->fullname && ini_string_match_si("FULLNAME", this->data, this->format)) {
if (ini_string_match_si("FULLNAME", this->data, this->format)) {


if (confs->fullname) { return 0; }
this->v_len = ini_string_parse(this->value, this->format); /* Remove all quotes, if any */
this->v_len = ini_string_parse(this->value, this->format); /* Remove all quotes, if any */
confs->fullname = strndup(this->value, this->v_len);
confs->fullname = strndup(this->value, this->v_len);
confs->_configs_left_--;
confs->_configs_left_--;


} else if (!confs->favouritefruit && ini_string_match_si("FAVOURITEFRUIT", this->data, this->format)) {
} else if (ini_string_match_si("FAVOURITEFRUIT", this->data, this->format)) {


if (confs->favouritefruit) { return 0; }
this->v_len = ini_string_parse(this->value, this->format); /* Remove all quotes, if any */
this->v_len = ini_string_parse(this->value, this->format); /* Remove all quotes, if any */
confs->favouritefruit = strndup(this->value, this->v_len);
confs->favouritefruit = strndup(this->value, this->v_len);
confs->_configs_left_--;
confs->_configs_left_--;


} else if ((confs->needspeeling & 0x80) && ini_string_match_si("NEEDSPEELING", this->data, this->format)) {
} else if (ini_string_match_si("NEEDSPEELING", this->data, this->format)) {


if (~confs->needspeeling & 0x80) { return 0; }
confs->needspeeling = ini_get_bool(this->value, TRUE);
confs->needspeeling = ini_get_bool(this->value, TRUE);
confs->_configs_left_--;
confs->_configs_left_--;


} else if ((confs->seedsremoved & 0x80) && ini_string_match_si("SEEDSREMOVED", this->data, this->format)) {
} else if (ini_string_match_si("SEEDSREMOVED", this->data, this->format)) {


if (~confs->seedsremoved & 0x80) { return 0; }
confs->seedsremoved = ini_get_bool(this->value, TRUE);
confs->seedsremoved = ini_get_bool(this->value, TRUE);
confs->_configs_left_--;
confs->_configs_left_--;
Line 695: Line 699:
} else if (!confs->otherfamily && ini_string_match_si("OTHERFAMILY", this->data, this->format)) {
} else if (!confs->otherfamily && ini_string_match_si("OTHERFAMILY", this->data, this->format)) {


if (confs->otherfamily) { return 0; }
this->v_len = ini_array_collapse(this->value, INI_ARRAY_DELIMITER, this->format); /* Save memory (not strictly needed) */
this->v_len = ini_array_collapse(this->value, INI_ARRAY_DELIMITER, this->format); /* Save memory (not strictly needed) */
confs->otherfamily = make_array(&confs->otherfamily_len, this->value, this->v_len + 1, this->format);
confs->otherfamily = make_array(&confs->otherfamily_len, this->value, this->v_len + 1, this->format);