aboutsummaryrefslogtreecommitdiff
path: root/include/ucl.h
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2014-03-10 10:23:43 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2014-03-10 10:23:43 +0000
commit2ae6de7c252d1781a158740c2481220dfdd6cc77 (patch)
tree44e99c17cbb39524d859345699343791cbc999d7 /include/ucl.h
parent337c43ffbe4b39c23f85d4ad6413da1070457d63 (diff)
downloadsrc-2ae6de7c252d1781a158740c2481220dfdd6cc77.tar.gz
src-2ae6de7c252d1781a158740c2481220dfdd6cc77.zip
Update libucl to 2014-03-02 version which fixes an important bug when parsing empty arraysvendor/libucl/20140302
Notes
Notes: svn path=/vendor/libucl/dist/; revision=262973 svn path=/vendor/libucl/20140302/; revision=262974; tag=vendor/libucl/20140302
Diffstat (limited to 'include/ucl.h')
-rw-r--r--include/ucl.h65
1 files changed, 43 insertions, 22 deletions
diff --git a/include/ucl.h b/include/ucl.h
index 8376b8adc462..a464a006ef78 100644
--- a/include/ucl.h
+++ b/include/ucl.h
@@ -32,6 +32,12 @@
#include <stdarg.h>
#include <stdio.h>
+#ifdef _WIN32
+# define UCL_EXTERN __declspec(dllexport)
+#else
+# define UCL_EXTERN
+#endif
+
/**
* @mainpage
* This is a reference manual for UCL API. You may find the description of UCL format by following this
@@ -200,14 +206,14 @@ typedef struct ucl_object_s {
* @param obj CL object
* @return zero terminated key
*/
-char* ucl_copy_key_trash (ucl_object_t *obj);
+UCL_EXTERN char* ucl_copy_key_trash (ucl_object_t *obj);
/**
* Copy and return a string value of an object, returned key is zero-terminated
* @param obj CL object
* @return zero terminated string representation of object value
*/
-char* ucl_copy_value_trash (ucl_object_t *obj);
+UCL_EXTERN char* ucl_copy_value_trash (ucl_object_t *obj);
/**
* Creates a new object
@@ -253,7 +259,7 @@ ucl_object_typed_new (unsigned int type)
* @param flags conversion flags
* @return new object
*/
-ucl_object_t * ucl_object_fromstring_common (const char *str, size_t len,
+UCL_EXTERN ucl_object_t * ucl_object_fromstring_common (const char *str, size_t len,
enum ucl_string_flags flags) UCL_WARN_UNUSED_RESULT;
/**
@@ -345,7 +351,7 @@ ucl_object_frombool (bool bv)
* @param copy_key make an internal copy of key
* @return new value of top object
*/
-ucl_object_t* ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt,
+UCL_EXTERN ucl_object_t* ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt,
const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
/**
@@ -358,10 +364,25 @@ ucl_object_t* ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt,
* @param copy_key make an internal copy of key
* @return new value of top object
*/
-ucl_object_t* ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt,
+UCL_EXTERN ucl_object_t* ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt,
const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
/**
+ * Delete a object associated with key 'key', old object will be unrefered,
+ * @param top object
+ * @param key key associated to the object to remove
+ * @param keylen length of the key (or 0 for NULL terminated keys)
+ */
+UCL_EXTERN bool ucl_object_delete_keyl (ucl_object_t *top, const char *key, size_t keylen);
+
+/**
+ * Delete a object associated with key 'key', old object will be unrefered,
+ * @param top object
+ * @param key key associated to the object to remove
+ */
+UCL_EXTERN bool ucl_object_delete_key (ucl_object_t *top, const char *key);
+
+/**
* Insert a object 'elt' to the hash 'top' and associate it with key 'key', if the specified key exist,
* try to merge its content
* @param top destination object (will be created automatically if top is NULL)
@@ -371,7 +392,7 @@ ucl_object_t* ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt,
* @param copy_key make an internal copy of key
* @return new value of top object
*/
-ucl_object_t* ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *elt,
+UCL_EXTERN ucl_object_t* ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *elt,
const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
/**
@@ -791,7 +812,7 @@ ucl_object_tolstring (ucl_object_t *obj, size_t *tlen)
* @param key key to search
* @return object matched the specified key or NULL if key is not found
*/
-ucl_object_t * ucl_object_find_key (ucl_object_t *obj, const char *key);
+UCL_EXTERN ucl_object_t * ucl_object_find_key (ucl_object_t *obj, const char *key);
/**
* Return object identified by a fixed size key in the specified object
@@ -800,7 +821,7 @@ ucl_object_t * ucl_object_find_key (ucl_object_t *obj, const char *key);
* @param klen length of a key
* @return object matched the specified key or NULL if key is not found
*/
-ucl_object_t *ucl_object_find_keyl (ucl_object_t *obj, const char *key, size_t klen);
+UCL_EXTERN ucl_object_t *ucl_object_find_keyl (ucl_object_t *obj, const char *key, size_t klen);
/**
* Returns a key of an object as a NULL terminated string
@@ -830,7 +851,7 @@ ucl_object_keyl (ucl_object_t *obj, size_t *len)
* Free ucl object
* @param obj ucl object to free
*/
-void ucl_object_free (ucl_object_t *obj);
+UCL_EXTERN void ucl_object_free (ucl_object_t *obj);
/**
* Increase reference count for an object
@@ -865,7 +886,7 @@ typedef void* ucl_object_iter_t;
* while ((cur = ucl_iterate_object (obj, &it)) != NULL) ...
* @return the next object or NULL
*/
-ucl_object_t* ucl_iterate_object (ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values);
+UCL_EXTERN ucl_object_t* ucl_iterate_object (ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values);
/** @} */
@@ -894,7 +915,7 @@ struct ucl_parser;
* @param pool pool to allocate memory from
* @return new parser object
*/
-struct ucl_parser* ucl_parser_new (int flags);
+UCL_EXTERN struct ucl_parser* ucl_parser_new (int flags);
/**
* Register new handler for a macro
@@ -903,7 +924,7 @@ struct ucl_parser* ucl_parser_new (int flags);
* @param handler handler (it is called immediately after macro is parsed)
* @param ud opaque user data for a handler
*/
-void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro,
+UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro,
ucl_macro_handler handler, void* ud);
/**
@@ -912,7 +933,7 @@ void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro,
* @param var variable name
* @param value variable value
*/
-void ucl_parser_register_variable (struct ucl_parser *parser, const char *var,
+UCL_EXTERN void ucl_parser_register_variable (struct ucl_parser *parser, const char *var,
const char *value);
/**
@@ -923,7 +944,7 @@ void ucl_parser_register_variable (struct ucl_parser *parser, const char *var,
* @param err if *err is NULL it is set to parser error
* @return true if chunk has been added and false in case of error
*/
-bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len);
+UCL_EXTERN bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len);
/**
* Load and add data from a file
@@ -932,7 +953,7 @@ bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data,
* @param err if *err is NULL it is set to parser error
* @return true if chunk has been added and false in case of error
*/
-bool ucl_parser_add_file (struct ucl_parser *parser, const char *filename);
+UCL_EXTERN bool ucl_parser_add_file (struct ucl_parser *parser, const char *filename);
/**
* Get a top object for a parser
@@ -940,18 +961,18 @@ bool ucl_parser_add_file (struct ucl_parser *parser, const char *filename);
* @param err if *err is NULL it is set to parser error
* @return top parser object or NULL
*/
-ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser);
+UCL_EXTERN ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser);
/**
* Get the error string if failing
* @param parser parser object
*/
-const char *ucl_parser_get_error(struct ucl_parser *parser);
+UCL_EXTERN const char *ucl_parser_get_error(struct ucl_parser *parser);
/**
* Free ucl parser object
* @param parser parser object
*/
-void ucl_parser_free (struct ucl_parser *parser);
+UCL_EXTERN void ucl_parser_free (struct ucl_parser *parser);
/**
* Add new public key to parser for signatures check
@@ -961,7 +982,7 @@ void ucl_parser_free (struct ucl_parser *parser);
* @param err if *err is NULL it is set to parser error
* @return true if a key has been successfully added
*/
-bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len);
+UCL_EXTERN bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len);
/**
* Set FILENAME and CURDIR variables in parser
@@ -970,7 +991,7 @@ bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t
* @param need_expand perform realpath() if this variable is true and filename is not NULL
* @return true if variables has been set
*/
-bool ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename,
+UCL_EXTERN bool ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename,
bool need_expand);
/** @} */
@@ -1005,7 +1026,7 @@ struct ucl_emitter_functions {
* #UCL_EMIT_CONFIG then emit config like object
* @return dump of an object (must be freed after using) or NULL in case of error
*/
-unsigned char *ucl_object_emit (ucl_object_t *obj, enum ucl_emitter emit_type);
+UCL_EXTERN unsigned char *ucl_object_emit (ucl_object_t *obj, enum ucl_emitter emit_type);
/**
* Emit object to a string
@@ -1014,7 +1035,7 @@ unsigned char *ucl_object_emit (ucl_object_t *obj, enum ucl_emitter emit_type);
* #UCL_EMIT_CONFIG then emit config like object
* @return dump of an object (must be freed after using) or NULL in case of error
*/
-bool ucl_object_emit_full (ucl_object_t *obj, enum ucl_emitter emit_type,
+UCL_EXTERN bool ucl_object_emit_full (ucl_object_t *obj, enum ucl_emitter emit_type,
struct ucl_emitter_functions *emitter);
/** @} */