cfgfile: add section number of entries by index
[dpdk.git] / lib / librte_cfgfile / rte_cfgfile.h
index b40e6a1..35dc419 100644 (file)
@@ -66,18 +66,60 @@ struct rte_cfgfile_entry {
        char value[CFG_VALUE_LEN]; /**< Value */
 };
 
+/** Configuration file operation optional arguments */
+struct rte_cfgfile_parameters {
+       /** Config file comment character; one of '!', '#', '%', ';', '@' */
+       char comment_character;
+};
+
+/**@{ cfgfile load operation flags */
+enum {
+       /**
+        * Indicates that the file supports key value entries before the first
+        * defined section.  These entries can be accessed in the "GLOBAL"
+        * section.
+        */
+       CFG_FLAG_GLOBAL_SECTION = 1,
+
+       /**
+        * Indicates that file supports key value entries where the value can
+        * be zero length (e.g., "key=").
+        */
+       CFG_FLAG_EMPTY_VALUES = 2,
+};
+/**@} */
+
+/** Defines the default comment character used for parsing config files. */
+#define CFG_DEFAULT_COMMENT_CHARACTER ';'
+
 /**
 * Open config file
 *
 * @param filename
 *   Config file name
 * @param flags
-*   Config file flags, Reserved for future use. Must be set to 0.
+*   Config file flags
 * @return
 *   Handle to configuration file on success, NULL otherwise
 */
 struct rte_cfgfile *rte_cfgfile_load(const char *filename, int flags);
 
+/**
+ * Open config file with specified optional parameters.
+ *
+ * @param filename
+ *   Config file name
+ * @param flags
+ *   Config file flags
+ * @param params
+ *   Additional configuration attributes.  Must be configured with desired
+ *   values prior to invoking this API.
+ * @return
+ *   Handle to configuration file on success, NULL otherwise
+ */
+struct rte_cfgfile *rte_cfgfile_load_with_params(const char *filename,
+       int flags, const struct rte_cfgfile_parameters *params);
+
 /**
 * Get number of sections in config file
 *
@@ -141,6 +183,26 @@ int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname);
 int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
        const char *sectionname);
 
+/**
+* Get number of entries in given config file section
+*
+* The index of a section is the same as the index of its name in the
+* result of rte_cfgfile_sections. This API can be used when there are
+* multiple sections with the same name.
+*
+* @param cfg
+*   Config file
+* @param sectionname
+*   Section name
+* @param index
+*   Section index
+* @return
+*   Number of entries in section on success, -1 otherwise
+*/
+int rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg,
+       char *sectionname,
+       int index);
+
 /**
 * Get section entries as key-value pairs
 *