return sections;
}
+int pakfire_config_has_section(struct pakfire_config* config, const char* section) {
+ struct pakfire_config_entry* entry;
+
+ STAILQ_FOREACH(entry, &config->entries, nodes) {
+ if (strcmp(entry->section, section) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
static ssize_t strip(char* s) {
if (!s)
return 0;
const char* section, const char* key, int _default);
char** pakfire_config_sections(struct pakfire_config* config);
+int pakfire_config_has_section(struct pakfire_config* config, const char* section);
int pakfire_config_read(struct pakfire_config* config, FILE* f);
// Return default instead of NULL
ASSERT_STRING_EQUALS(pakfire_config_get(config, "section1", "D", "XXX"), "XXX");
+ // Check if sections exist
+ ASSERT(pakfire_config_has_section(config, "section1"));
+ ASSERT(!pakfire_config_has_section(config, "section3"));
+
pakfire_config_free(config);
return EXIT_SUCCESS;