aboutsummaryrefslogtreecommitdiff
path: root/include/parcini.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/parcini.h')
-rw-r--r--include/parcini.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/parcini.h b/include/parcini.h
index 3bcaf59..d485ffd 100644
--- a/include/parcini.h
+++ b/include/parcini.h
@@ -94,6 +94,21 @@ struct parcini_line {
};
/*
+ * Helper function to handle a value that was parsed by parcini. Pass a pointer
+ * of a parcini_value, and the expected type. If the parcini_value typematches
+ * the expected type, then *dst is set to the provided value casting it to the
+ * correct type.
+ *
+ * IMPORTANT: in the case of "string" values, you need to pass a pointer to a
+ * char pointer (i.e. char **), and the memory in the string value is copied
+ * over to the char *. That means, that if some memory was already allocated in
+ * the passed pointer, there could be a memory leak if you don't free that
+ * memory before, unless you have another pointer to that same memory elsewhere.
+ */
+bool parcini_value_handle(const struct parcini_value *,
+ const enum parcini_value_type expected, void *dst);
+
+/*
* Parse the next line in the stream returning the kind of result/error of
* parsing and filling the parcini_line structure with the information that was
* extracted from the line, as well as the current section (including after
@@ -115,7 +130,7 @@ parcini_t *parcini_init(FILE *stream);
/*
* Helper function to open a file and then initialize a parcini_t object with
- * said as the source stream.
+ * said as the source stream. Returns NULL if the file couldn't be opened.
*/
parcini_t *parcini_from_file(const char *fpath);