Browse Source

faux.ini: faux_ini_is_empty()

Serj Kalichev 3 years ago
parent
commit
e123327837
2 changed files with 18 additions and 0 deletions
  1. 1 0
      faux/ini.h
  2. 17 0
      faux/ini/ini.c

+ 1 - 0
faux/ini.h

@@ -24,6 +24,7 @@ void faux_ini_free(faux_ini_t *ini);
 
 const faux_pair_t *faux_ini_set(faux_ini_t *ini, const char *name, const char *value);
 void faux_ini_unset(faux_ini_t *ini, const char *name);
+bool_t faux_ini_is_empty(const faux_ini_t *ini);
 
 const faux_pair_t *faux_ini_find_pair(const faux_ini_t *ini, const char *name);
 const char *faux_ini_find(const faux_ini_t *ini, const char *name);

+ 17 - 0
faux/ini/ini.c

@@ -41,6 +41,8 @@ faux_ini_t *faux_ini_new(void)
  *
  * After using the INI object must be freed. Function frees INI object itself
  * and all pairs 'name/value' stored within INI object.
+ *
+ * @param [in] ini Allocated and initialized INI object.
  */
 void faux_ini_free(faux_ini_t *ini)
 {
@@ -52,6 +54,21 @@ void faux_ini_free(faux_ini_t *ini)
 }
 
 
+/** Checks if INI object is empty.
+ *
+ * @param [in] ini Allocated and initialized INI object.
+ * @return BOOL_TRUE - empty, BOOL_FALSE - not empty.
+ */
+bool_t faux_ini_is_empty(const faux_ini_t *ini)
+{
+	assert(ini);
+	if (!ini)
+		return BOOL_TRUE;
+
+	return faux_list_is_empty(ini->list);
+}
+
+
 /** @brief Adds pair 'name/value' to INI object.
  *
  * The 'name' field is a key. The key must be unique. Each key has its