X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_cfgfile%2Frte_cfgfile.c;h=d72052a08e88147b7c3771ccfea7c394280c10a1;hb=425781ff5afe08b77c58ec5e4d5cf56b9ac19e02;hp=a677dadecf7741b4eeeeb9f7388b387f14854ed0;hpb=8646ea0116df6ef4cdd3c39f94ce53d17724d2cb;p=dpdk.git diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index a677dadecf..d72052a08e 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -232,6 +232,7 @@ rte_cfgfile_load(const char *filename, int flags) return cfg; error1: + cfg->num_sections = curr_section + 1; rte_cfgfile_close(cfg); error2: fclose(f); @@ -306,7 +307,7 @@ _get_section(struct rte_cfgfile *cfg, const char *sectionname) int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname) { - return (_get_section(cfg, sectionname) != NULL); + return _get_section(cfg, sectionname) != NULL; } int @@ -333,6 +334,24 @@ rte_cfgfile_section_entries(struct rte_cfgfile *cfg, const char *sectionname, return i; } +int +rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg, int index, + char *sectionname, + struct rte_cfgfile_entry *entries, int max_entries) +{ + int i; + const struct rte_cfgfile_section *sect; + + if (index < 0 || index >= cfg->num_sections) + return -1; + + sect = cfg->sections[index]; + snprintf(sectionname, CFG_NAME_LEN, "%s", sect->name); + for (i = 0; i < max_entries && i < sect->num_entries; i++) + entries[i] = *sect->entries[i]; + return i; +} + const char * rte_cfgfile_get_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname) @@ -352,5 +371,5 @@ int rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname) { - return (rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL); + return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL; }