Coverage Report

Created: 2026-10-17 07:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libucl/include/ucl.h
Line
Count
Source
1
/* Copyright (c) 2013-2015, Vsevolod Stakhov
2
 * All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are met:
6
 *       * Redistributions of source code must retain the above copyright
7
 *         notice, this list of conditions and the following disclaimer.
8
 *       * Redistributions in binary form must reproduce the above copyright
9
 *         notice, this list of conditions and the following disclaimer in the
10
 *         documentation and/or other materials provided with the distribution.
11
 *
12
 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
13
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15
 * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
16
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
 */
23
24
#ifndef UCL_H_
25
#define UCL_H_
26
27
#include <string.h>
28
#include <stddef.h>
29
#include <stdlib.h>
30
#include <stdint.h>
31
#include <stdbool.h>
32
#include <stdarg.h>
33
#include <stdio.h>
34
35
#ifdef _WIN32
36
#define UCL_EXTERN __declspec(dllexport)
37
#else
38
#define UCL_EXTERN
39
#endif
40
41
/**
42
 * @mainpage
43
 * This is a reference manual for UCL API. You may find the description of UCL format by following this
44
 * [github repository](https://github.com/vstakhov/libucl).
45
 *
46
 * This manual has several main sections:
47
 *  - @ref structures
48
 *  - @ref utils
49
 *  - @ref parser
50
 *  - @ref emitter
51
 */
52
53
/**
54
 * @file ucl.h
55
 * @brief UCL parsing and emitting functions
56
 *
57
 * UCL is universal configuration language, which is a form of
58
 * JSON with less strict rules that make it more comfortable for
59
 * using as a configuration language
60
 */
61
#ifdef __cplusplus
62
extern "C" {
63
#endif
64
/*
65
 * Memory allocation utilities
66
 * UCL_ALLOC(size) - allocate memory for UCL
67
 * UCL_FREE(size, ptr) - free memory of specified size at ptr
68
 * Default: malloc and free
69
 */
70
#ifndef UCL_ALLOC
71
10.3M
#define UCL_ALLOC(size) malloc(size)
72
#endif
73
#ifndef UCL_FREE
74
10.3M
#define UCL_FREE(size, ptr) free(ptr)
75
#endif
76
#ifndef UCL_REALLOC
77
#define UCL_REALLOC(ptr, size) realloc(ptr, size)
78
#endif
79
#ifndef UCL_STRDUP
80
static inline char *ucl_strdup_impl(const char *s)
81
1.14M
{
82
1.14M
  size_t len = strlen(s) + 1;
83
1.14M
  char *p = (char *) UCL_ALLOC(len);
84
1.14M
  if (p) memcpy(p, s, len);
85
1.14M
  return p;
86
1.14M
}
Unexecuted instantiation: ucl_add_string_fuzzer.c:ucl_strdup_impl
ucl_parser.c:ucl_strdup_impl
Line
Count
Source
81
1.14M
{
82
1.14M
  size_t len = strlen(s) + 1;
83
1.14M
  char *p = (char *) UCL_ALLOC(len);
84
1.14M
  if (p) memcpy(p, s, len);
85
1.14M
  return p;
86
1.14M
}
ucl_util.c:ucl_strdup_impl
Line
Count
Source
81
6.71k
{
82
6.71k
  size_t len = strlen(s) + 1;
83
6.71k
  char *p = (char *) UCL_ALLOC(len);
84
6.71k
  if (p) memcpy(p, s, len);
85
6.71k
  return p;
86
6.71k
}
Unexecuted instantiation: ucl_msgpack.c:ucl_strdup_impl
Unexecuted instantiation: ucl_cbor.c:ucl_strdup_impl
Unexecuted instantiation: ucl_sexp.c:ucl_strdup_impl
Unexecuted instantiation: ucl_emitter_utils.c:ucl_strdup_impl
Unexecuted instantiation: ucl_hash.c:ucl_strdup_impl
Unexecuted instantiation: ucl_emitter.c:ucl_strdup_impl
87
1.14M
#define UCL_STRDUP(str) ucl_strdup_impl(str)
88
#endif
89
90
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
91
#define UCL_WARN_UNUSED_RESULT \
92
  __attribute__((warn_unused_result))
93
#else
94
#define UCL_WARN_UNUSED_RESULT
95
#endif
96
97
#ifdef __GNUC__
98
#define UCL_DEPRECATED(func) func __attribute__((deprecated))
99
#elif defined(_MSC_VER)
100
#define UCL_DEPRECATED(func) __declspec(deprecated) func
101
#else
102
#define UCL_DEPRECATED(func) func
103
#endif
104
105
/**
106
 * @defgroup structures Structures and types
107
 * UCL defines several enumeration types used for error reporting or specifying flags and attributes.
108
 *
109
 * @{
110
 */
111
112
/**
113
 * The common error codes returned by ucl parser
114
 */
115
typedef enum ucl_error {
116
  UCL_EOK = 0,   /**< No error */
117
  UCL_ESYNTAX,   /**< Syntax error occurred during parsing */
118
  UCL_EIO,       /**< IO error occurred during parsing */
119
  UCL_ESTATE,    /**< Invalid state machine state */
120
  UCL_ENESTED,   /**< Input has too many recursion levels */
121
  UCL_EUNPAIRED, /**< Input has too many recursion levels */
122
  UCL_EMACRO,    /**< Error processing a macro */
123
  UCL_EINTERNAL, /**< Internal unclassified error */
124
  UCL_ESSL,      /**< SSL error */
125
  UCL_EMERGE,    /**< A merge error occurred */
126
  UCL_ELIMIT     /**< Input exceeds one of the configured parser limits */
127
} ucl_error_t;
128
129
/**
130
 * #ucl_object_t may have one of specified types, some types are compatible with each other and some are not.
131
 * For example, you can always convert #UCL_TIME to #UCL_FLOAT. Also you can convert #UCL_FLOAT to #UCL_INTEGER
132
 * by loosing floating point. Every object may be converted to a string by #ucl_object_tostring_forced() function.
133
 *
134
 */
135
typedef enum ucl_type {
136
  UCL_OBJECT = 0, /**< UCL object - key/value pairs */
137
  UCL_ARRAY,      /**< UCL array */
138
  UCL_INT,        /**< Integer number */
139
  UCL_FLOAT,      /**< Floating point number */
140
  UCL_STRING,     /**< Null terminated string */
141
  UCL_BOOLEAN,    /**< Boolean value */
142
  UCL_TIME,       /**< Time value (floating point number of seconds) */
143
  UCL_USERDATA,   /**< Opaque userdata pointer (may be used in macros) */
144
  UCL_NULL        /**< Null value */
145
} ucl_type_t;
146
147
/**
148
 * You can use one of these types to serialise #ucl_object_t by using ucl_object_emit().
149
 */
150
typedef enum ucl_emitter {
151
  UCL_EMIT_JSON = 0,     /**< Emit fine formatted JSON */
152
  UCL_EMIT_JSON_COMPACT, /**< Emit compacted JSON */
153
  UCL_EMIT_CONFIG,       /**< Emit human readable config format */
154
  UCL_EMIT_YAML,         /**< Emit embedded YAML format */
155
  UCL_EMIT_MSGPACK,      /**< Emit msgpack output */
156
  UCL_EMIT_CBOR,         /**< Emit CBOR (RFC 8949) output */
157
  UCL_EMIT_MAX           /**< Unsupported emitter type */
158
} ucl_emitter_t;
159
160
/**
161
 * These flags defines parser behaviour. If you specify #UCL_PARSER_ZEROCOPY you must ensure
162
 * that the input memory is not freed if an object is in use. Moreover, if you want to use
163
 * zero-terminated keys and string values then you should not use zero-copy mode, as in this case
164
 * UCL still has to perform copying implicitly.
165
 */
166
typedef enum ucl_parser_flags {
167
  UCL_PARSER_DEFAULT = 0,                   /**< No special flags */
168
  UCL_PARSER_KEY_LOWERCASE = (1 << 0),      /**< Convert all keys to lower case */
169
  UCL_PARSER_ZEROCOPY = (1 << 1),           /**< Parse input in zero-copy mode if possible */
170
  UCL_PARSER_NO_TIME = (1 << 2),            /**< Do not parse time and treat time values as strings */
171
  UCL_PARSER_NO_IMPLICIT_ARRAYS = (1 << 3), /** Create explicit arrays instead of implicit ones */
172
  UCL_PARSER_SAVE_COMMENTS = (1 << 4),      /** Save comments in the parser context */
173
  UCL_PARSER_DISABLE_MACRO = (1 << 5),      /** Treat macros as comments */
174
  UCL_PARSER_NO_FILEVARS = (1 << 6)         /** Do not set file vars */
175
} ucl_parser_flags_t;
176
177
/**
178
 * Flags suitable for input that did not come from a trusted local file:
179
 * no macros, no file variables, no time suffixes and no implicit arrays.
180
 * Combine with ucl_parser_set_limits() to bound the structural cost as well.
181
 */
182
#define UCL_PARSER_SAFE_FLAGS (UCL_PARSER_NO_TIME |            \
183
                 UCL_PARSER_NO_IMPLICIT_ARRAYS | \
184
                 UCL_PARSER_DISABLE_MACRO |      \
185
                 UCL_PARSER_NO_FILEVARS)
186
187
/**
188
 * String conversion flags, that are used in #ucl_object_fromstring_common function.
189
 */
190
typedef enum ucl_string_flags {
191
  UCL_STRING_RAW = 0x0,                                                                             /**< Treat string as is */
192
  UCL_STRING_ESCAPE = (1 << 0),                                                                     /**< Perform JSON escape */
193
  UCL_STRING_TRIM = (1 << 1),                                                                       /**< Trim leading and trailing whitespaces */
194
  UCL_STRING_PARSE_BOOLEAN = (1 << 2),                                                              /**< Parse passed string and detect boolean */
195
  UCL_STRING_PARSE_INT = (1 << 3),                                                                  /**< Parse passed string and detect integer number */
196
  UCL_STRING_PARSE_DOUBLE = (1 << 4),                                                               /**< Parse passed string and detect integer or float number */
197
  UCL_STRING_PARSE_TIME = (1 << 5),                                                                 /**< Parse time strings */
198
  UCL_STRING_PARSE_NUMBER = UCL_STRING_PARSE_INT | UCL_STRING_PARSE_DOUBLE | UCL_STRING_PARSE_TIME, /**<
199
                  Parse passed string and detect number */
200
  UCL_STRING_PARSE = UCL_STRING_PARSE_BOOLEAN | UCL_STRING_PARSE_NUMBER,                            /**<
201
                  Parse passed string (and detect booleans and numbers) */
202
  UCL_STRING_PARSE_BYTES = (1 << 6)                                                                 /**< Treat numbers as bytes */
203
} ucl_string_flags_t;
204
205
/**
206
 * Basic flags for an object (can use up to 12 bits as higher 4 bits are used
207
 * for priorities)
208
 */
209
typedef enum ucl_object_flags {
210
  UCL_OBJECT_ALLOCATED_KEY = (1 << 0),   /**< An object has key allocated internally */
211
  UCL_OBJECT_ALLOCATED_VALUE = (1 << 1), /**< An object has a string value allocated internally */
212
  UCL_OBJECT_NEED_KEY_ESCAPE = (1 << 2), /**< The key of an object need to be escaped on output */
213
  UCL_OBJECT_EPHEMERAL = (1 << 3),       /**< Temporary object that does not need to be freed really */
214
  UCL_OBJECT_MULTILINE = (1 << 4),       /**< String should be displayed as multiline string */
215
  UCL_OBJECT_MULTIVALUE = (1 << 5),      /**< Object is a key with multiple values */
216
  UCL_OBJECT_INHERITED = (1 << 6),       /**< Object has been inherited from another */
217
  UCL_OBJECT_BINARY = (1 << 7),          /**< Object contains raw binary data */
218
  UCL_OBJECT_SQUOTED = (1 << 8)          /**< Object has been enclosed in single quotes */
219
} ucl_object_flags_t;
220
221
/**
222
 * Duplicate policy types
223
 */
224
enum ucl_duplicate_strategy {
225
  UCL_DUPLICATE_APPEND = 0, /**< Default policy to merge based on priorities */
226
  UCL_DUPLICATE_MERGE,      /**< Merge new object with old one */
227
  UCL_DUPLICATE_REWRITE,    /**< Rewrite old keys */
228
  UCL_DUPLICATE_ERROR       /**< Stop parsing on duplicate found */
229
};
230
231
/**
232
 * Input format type
233
 */
234
enum ucl_parse_type {
235
  UCL_PARSE_UCL = 0, /**< Default ucl format */
236
  UCL_PARSE_MSGPACK, /**< Message pack input format */
237
  UCL_PARSE_CSEXP,   /**< Canonical S-expressions */
238
  UCL_PARSE_AUTO,    /**< Try to detect parse type */
239
  /*
240
   * Appended after UCL_PARSE_AUTO on purpose, so that the values of the
241
   * types that came before it stay what they have always been
242
   */
243
  UCL_PARSE_CBOR /**< CBOR (RFC 8949) input format */
244
};
245
246
/**
247
 * UCL object structure. Please mention that the most of fields should not be touched by
248
 * UCL users. In future, this structure may be converted to private one.
249
 */
250
typedef struct ucl_object_s {
251
  /**
252
   * Variant value type
253
   */
254
  union {
255
    int64_t iv;     /**< Int value of an object */
256
    const char *sv; /**< String value of an object */
257
    double dv;      /**< Double value of an object */
258
    void *av;       /**< Array          */
259
    void *ov;       /**< Object         */
260
    void *ud;       /**< Opaque user data   */
261
  } value;
262
  const char *key;               /**< Key of an object    */
263
  struct ucl_object_s *next;     /**< Array handle      */
264
  struct ucl_object_s *prev;     /**< Array handle      */
265
  uint32_t keylen;               /**< Length of a key   */
266
  uint32_t len;                  /**< Size of an object   */
267
  uint32_t ref;                  /**< Reference count   */
268
  uint16_t flags;                /**< Object flags      */
269
  uint16_t type;                 /**< Real type       */
270
  unsigned char *trash_stack[2]; /**< Pointer to allocated chunks */
271
} ucl_object_t;
272
273
/**
274
 * Destructor type for userdata objects
275
 * @param ud user specified data pointer
276
 */
277
typedef void (*ucl_userdata_dtor)(void *ud);
278
typedef const char *(*ucl_userdata_emitter)(void *ud);
279
280
/** @} */
281
282
/**
283
 * @defgroup utils Utility functions
284
 * A number of utility functions simplify handling of UCL objects
285
 *
286
 * @{
287
 */
288
/**
289
 * Copy and return a key of an object, returned key is zero-terminated
290
 * @param obj CL object
291
 * @return zero terminated key
292
 */
293
UCL_EXTERN char *ucl_copy_key_trash(const ucl_object_t *obj);
294
295
/**
296
 * Copy and return a string value of an object, returned key is zero-terminated
297
 * @param obj CL object
298
 * @return zero terminated string representation of object value
299
 */
300
UCL_EXTERN char *ucl_copy_value_trash(const ucl_object_t *obj);
301
302
/**
303
 * Creates a new object
304
 * @return new object
305
 */
306
UCL_EXTERN ucl_object_t *ucl_object_new(void) UCL_WARN_UNUSED_RESULT;
307
308
/**
309
 * Create new object with type specified
310
 * @param type type of a new object
311
 * @return new object
312
 */
313
UCL_EXTERN ucl_object_t *ucl_object_typed_new(ucl_type_t type) UCL_WARN_UNUSED_RESULT;
314
315
/**
316
 * Create new object with type and priority specified
317
 * @param type type of a new object
318
 * @param priority priority of an object
319
 * @return new object
320
 */
321
UCL_EXTERN ucl_object_t *ucl_object_new_full(ucl_type_t type, unsigned priority)
322
  UCL_WARN_UNUSED_RESULT;
323
324
/**
325
 * Create new object with userdata dtor
326
 * @param dtor destructor function
327
 * @param emitter emitter for userdata
328
 * @param ptr opaque pointer
329
 * @return new object
330
 */
331
UCL_EXTERN ucl_object_t *ucl_object_new_userdata(ucl_userdata_dtor dtor,
332
                         ucl_userdata_emitter emitter, void *ptr) UCL_WARN_UNUSED_RESULT;
333
334
/**
335
 * Perform deep copy of an object copying everything
336
 * @param other object to copy
337
 * @return new object with refcount equal to 1
338
 */
339
UCL_EXTERN ucl_object_t *ucl_object_copy(const ucl_object_t *other)
340
  UCL_WARN_UNUSED_RESULT;
341
342
/**
343
 * Return the type of an object
344
 * @return the object type
345
 */
346
UCL_EXTERN ucl_type_t ucl_object_type(const ucl_object_t *obj);
347
348
/**
349
 * Converts ucl object type to its string representation
350
 * @param type type of object
351
 * @return constant string describing type
352
 */
353
UCL_EXTERN const char *ucl_object_type_to_string(ucl_type_t type);
354
355
/**
356
 * Converts string that represents ucl type to real ucl type enum
357
 * @param input C string with name of type
358
 * @param res resulting target
359
 * @return true if `input` is a name of type stored in `res`
360
 */
361
UCL_EXTERN bool ucl_object_string_to_type(const char *input, ucl_type_t *res);
362
363
/**
364
 * Convert any string to an ucl object making the specified transformations
365
 * @param str fixed size or NULL terminated string
366
 * @param len length (if len is zero, than str is treated as NULL terminated)
367
 * @param flags conversion flags
368
 * @return new object
369
 */
370
UCL_EXTERN ucl_object_t *ucl_object_fromstring_common(const char *str, size_t len,
371
                            enum ucl_string_flags flags) UCL_WARN_UNUSED_RESULT;
372
373
/**
374
 * Create a UCL object from the specified string
375
 * @param str NULL terminated string, will be json escaped
376
 * @return new object
377
 */
378
UCL_EXTERN ucl_object_t *ucl_object_fromstring(const char *str) UCL_WARN_UNUSED_RESULT;
379
380
/**
381
 * Create a UCL object from the specified string
382
 * @param str fixed size string, will be json escaped
383
 * @param len length of a string
384
 * @return new object
385
 */
386
UCL_EXTERN ucl_object_t *ucl_object_fromlstring(const char *str,
387
                        size_t len) UCL_WARN_UNUSED_RESULT;
388
389
/**
390
 * Create an object from an integer number
391
 * @param iv number
392
 * @return new object
393
 */
394
UCL_EXTERN ucl_object_t *ucl_object_fromint(int64_t iv) UCL_WARN_UNUSED_RESULT;
395
396
/**
397
 * Create an object from a float number
398
 * @param dv number
399
 * @return new object
400
 */
401
UCL_EXTERN ucl_object_t *ucl_object_fromdouble(double dv) UCL_WARN_UNUSED_RESULT;
402
403
/**
404
 * Create an object from a boolean
405
 * @param bv bool value
406
 * @return new object
407
 */
408
UCL_EXTERN ucl_object_t *ucl_object_frombool(bool bv) UCL_WARN_UNUSED_RESULT;
409
410
/**
411
 * Insert a object 'elt' to the hash 'top' and associate it with key 'key'
412
 * @param top destination object (must be of type UCL_OBJECT)
413
 * @param elt element to insert (must NOT be NULL)
414
 * @param key key to associate with this object (either const or preallocated)
415
 * @param keylen length of the key (or 0 for NULL terminated keys)
416
 * @param copy_key make an internal copy of key
417
 * @return true if key has been inserted
418
 */
419
UCL_EXTERN bool ucl_object_insert_key(ucl_object_t *top, ucl_object_t *elt,
420
                    const char *key, size_t keylen, bool copy_key);
421
422
/**
423
 * Replace a object 'elt' to the hash 'top' and associate it with key 'key', old object will be unrefed,
424
 * if no object has been found this function works like ucl_object_insert_key()
425
 * @param top destination object (must be of type UCL_OBJECT)
426
 * @param elt element to insert (must NOT be NULL)
427
 * @param key key to associate with this object (either const or preallocated)
428
 * @param keylen length of the key (or 0 for NULL terminated keys)
429
 * @param copy_key make an internal copy of key
430
 * @return true if key has been inserted
431
 */
432
UCL_EXTERN bool ucl_object_replace_key(ucl_object_t *top, ucl_object_t *elt,
433
                     const char *key, size_t keylen, bool copy_key);
434
435
/**
436
 * Merge the keys from one object to another object. Overwrite on conflict
437
 * @param top destination object (must be of type UCL_OBJECT)
438
 * @param elt element to insert (must be of type UCL_OBJECT)
439
 * @param copy copy rather than reference the elements
440
 * @return true if all keys have been merged
441
 */
442
UCL_EXTERN bool ucl_object_merge(ucl_object_t *top, ucl_object_t *elt, bool copy);
443
444
/**
445
 * Delete a object associated with key 'key', old object will be unrefered,
446
 * @param top object
447
 * @param key key associated to the object to remove
448
 * @param keylen length of the key (or 0 for NULL terminated keys)
449
 */
450
UCL_EXTERN bool ucl_object_delete_keyl(ucl_object_t *top,
451
                     const char *key, size_t keylen);
452
453
/**
454
 * Delete a object associated with key 'key', old object will be unrefered,
455
 * @param top object
456
 * @param key key associated to the object to remove
457
 */
458
UCL_EXTERN bool ucl_object_delete_key(ucl_object_t *top,
459
                    const char *key);
460
461
462
/**
463
 * Removes `key` from `top` object, returning the object that was removed. This
464
 * object is not released, caller must unref the returned object when it is no
465
 * longer needed.
466
 * @param top object
467
 * @param key key to remove
468
 * @param keylen length of the key (or 0 for NULL terminated keys)
469
 * @return removed object or NULL if object has not been found
470
 */
471
UCL_EXTERN ucl_object_t *ucl_object_pop_keyl(ucl_object_t *top, const char *key,
472
                       size_t keylen) UCL_WARN_UNUSED_RESULT;
473
474
/**
475
 * Removes `key` from `top` object returning the object that was removed. This
476
 * object is not released, caller must unref the returned object when it is no
477
 * longer needed.
478
 * @param top object
479
 * @param key key to remove
480
 * @return removed object or NULL if object has not been found
481
 */
482
UCL_EXTERN ucl_object_t *ucl_object_pop_key(ucl_object_t *top, const char *key)
483
  UCL_WARN_UNUSED_RESULT;
484
485
/**
486
 * Insert a object 'elt' to the hash 'top' and associate it with key 'key', if
487
 * the specified key exist, try to merge its content
488
 * @param top destination object (must be of type UCL_OBJECT)
489
 * @param elt element to insert (must NOT be NULL)
490
 * @param key key to associate with this object (either const or preallocated)
491
 * @param keylen length of the key (or 0 for NULL terminated keys)
492
 * @param copy_key make an internal copy of key
493
 * @return true if key has been inserted
494
 */
495
UCL_EXTERN bool ucl_object_insert_key_merged(ucl_object_t *top, ucl_object_t *elt,
496
                       const char *key, size_t keylen, bool copy_key);
497
498
/**
499
 * Reserve space in ucl array or object for `elt` elements
500
 * @param obj object to reserve
501
 * @param reserved size to reserve in an object
502
 * @return 0 on success, -1 on failure (i.e. ENOMEM)
503
 */
504
UCL_EXTERN bool ucl_object_reserve(ucl_object_t *obj, size_t reserved);
505
506
/**
507
 * Append an element to the end of array object
508
 * @param top destination object (must NOT be NULL)
509
 * @param elt element to append (must NOT be NULL)
510
 * @return true if value has been inserted
511
 */
512
UCL_EXTERN bool ucl_array_append(ucl_object_t *top,
513
                 ucl_object_t *elt);
514
515
/**
516
 * Append an element to the start of array object
517
 * @param top destination object (must NOT be NULL)
518
 * @param elt element to append (must NOT be NULL)
519
 * @return true if value has been inserted
520
 */
521
UCL_EXTERN bool ucl_array_prepend(ucl_object_t *top,
522
                  ucl_object_t *elt);
523
524
/**
525
 * Merge all elements of second array into the first array
526
 * @param top destination array (must be of type UCL_ARRAY)
527
 * @param elt array to copy elements from (must be of type UCL_ARRAY)
528
 * @param copy copy elements instead of referencing them
529
 * @return true if arrays were merged
530
 */
531
UCL_EXTERN bool ucl_array_merge(ucl_object_t *top, ucl_object_t *elt,
532
                bool copy);
533
534
/**
535
 * Removes an element `elt` from the array `top`, returning the object that was
536
 * removed. This object is not released, caller must unref the returned object
537
 * when it is no longer needed.
538
 * @param top array ucl object
539
 * @param elt element to remove
540
 * @return removed element or NULL if `top` is NULL or not an array
541
 */
542
UCL_EXTERN ucl_object_t *ucl_array_delete(ucl_object_t *top,
543
                      ucl_object_t *elt);
544
545
/**
546
 * Returns the first element of the array `top`
547
 * @param top array ucl object
548
 * @return element or NULL if `top` is NULL or not an array
549
 */
550
UCL_EXTERN const ucl_object_t *ucl_array_head(const ucl_object_t *top);
551
552
/**
553
 * Returns the last element of the array `top`
554
 * @param top array ucl object
555
 * @return element or NULL if `top` is NULL or not an array
556
 */
557
UCL_EXTERN const ucl_object_t *ucl_array_tail(const ucl_object_t *top);
558
559
/**
560
 * Removes the last element from the array `top`, returning the object that was
561
 * removed. This object is not released, caller must unref the returned object
562
 * when it is no longer needed.
563
 * @param top array ucl object
564
 * @return removed element or NULL if `top` is NULL or not an array
565
 */
566
UCL_EXTERN ucl_object_t *ucl_array_pop_last(ucl_object_t *top);
567
568
/**
569
 * Removes the first element from the array `top`, returning the object that was
570
 * removed. This object is not released, caller must unref the returned object
571
 * when it is no longer needed.
572
 * @param top array ucl object
573
 * @return removed element or NULL if `top` is NULL or not an array
574
 */
575
UCL_EXTERN ucl_object_t *ucl_array_pop_first(ucl_object_t *top);
576
577
/**
578
 * Return size of the array `top`
579
 * @param top object to get size from (must be of type UCL_ARRAY)
580
 * @return size of the array
581
 */
582
UCL_EXTERN unsigned int ucl_array_size(const ucl_object_t *top);
583
584
/**
585
 * Return object identified by index of the array `top`
586
 * @param top object to get a key from (must be of type UCL_ARRAY)
587
 * @param index array index to return
588
 * @return object at the specified index or NULL if index is not found
589
 */
590
UCL_EXTERN const ucl_object_t *ucl_array_find_index(const ucl_object_t *top,
591
                          unsigned int index);
592
593
/**
594
 * Return the index of `elt` in the array `top`
595
 * @param top object to get a key from (must be of type UCL_ARRAY)
596
 * @param elt element to find index of (must NOT be NULL)
597
 * @return index of `elt` in the array `top or (unsigned int)-1 if `elt` is not found
598
 */
599
UCL_EXTERN unsigned int ucl_array_index_of(ucl_object_t *top,
600
                       ucl_object_t *elt);
601
602
/**
603
 * Replace an element in an array with a different element, returning the object
604
 * that was replaced. This object is not released, caller must unref the
605
 * returned object when it is no longer needed.
606
 * @param top destination object (must be of type UCL_ARRAY)
607
 * @param elt element to append (must NOT be NULL)
608
 * @param index array index in destination to overwrite with elt
609
 * @return object that was replaced or NULL if index is not found
610
 */
611
ucl_object_t *
612
ucl_array_replace_index(ucl_object_t *top, ucl_object_t *elt,
613
            unsigned int index);
614
615
/**
616
 * Append a element to another element forming an implicit array
617
 * @param head head to append (may be NULL)
618
 * @param elt new element
619
 * @return the new implicit array
620
 */
621
UCL_EXTERN ucl_object_t *ucl_elt_append(ucl_object_t *head,
622
                    ucl_object_t *elt);
623
624
/**
625
 * Converts an object to double value
626
 * @param obj CL object
627
 * @param target target double variable
628
 * @return true if conversion was successful
629
 */
630
UCL_EXTERN bool ucl_object_todouble_safe(const ucl_object_t *obj, double *target);
631
632
/**
633
 * Unsafe version of \ref ucl_obj_todouble_safe
634
 * @param obj CL object
635
 * @return double value
636
 */
637
UCL_EXTERN double ucl_object_todouble(const ucl_object_t *obj);
638
639
/**
640
 * Converts an object to integer value
641
 * @param obj CL object
642
 * @param target target integer variable
643
 * @return true if conversion was successful
644
 */
645
UCL_EXTERN bool ucl_object_toint_safe(const ucl_object_t *obj, int64_t *target);
646
647
/**
648
 * Unsafe version of \ref ucl_obj_toint_safe
649
 * @param obj CL object
650
 * @return int value
651
 */
652
UCL_EXTERN int64_t ucl_object_toint(const ucl_object_t *obj);
653
654
/**
655
 * Converts an object to boolean value
656
 * @param obj CL object
657
 * @param target target boolean variable
658
 * @return true if conversion was successful
659
 */
660
UCL_EXTERN bool ucl_object_toboolean_safe(const ucl_object_t *obj, bool *target);
661
662
/**
663
 * Unsafe version of \ref ucl_obj_toboolean_safe
664
 * @param obj CL object
665
 * @return boolean value
666
 */
667
UCL_EXTERN bool ucl_object_toboolean(const ucl_object_t *obj);
668
669
/**
670
 * Converts an object to string value
671
 * @param obj CL object
672
 * @param target target string variable, no need to free value
673
 * @return true if conversion was successful
674
 */
675
UCL_EXTERN bool ucl_object_tostring_safe(const ucl_object_t *obj, const char **target);
676
677
/**
678
 * Unsafe version of \ref ucl_obj_tostring_safe
679
 * @param obj CL object
680
 * @return string value
681
 */
682
UCL_EXTERN const char *ucl_object_tostring(const ucl_object_t *obj);
683
684
/**
685
 * Convert any object to a string in JSON notation if needed
686
 * @param obj CL object
687
 * @return string value
688
 */
689
UCL_EXTERN const char *ucl_object_tostring_forced(const ucl_object_t *obj);
690
691
/**
692
 * Return string as char * and len, string may be not zero terminated, more efficient that \ref ucl_obj_tostring as it
693
 * allows zero-copy (if #UCL_PARSER_ZEROCOPY has been used during parsing)
694
 * @param obj CL object
695
 * @param target target string variable, no need to free value
696
 * @param tlen target length
697
 * @return true if conversion was successful
698
 */
699
UCL_EXTERN bool ucl_object_tolstring_safe(const ucl_object_t *obj,
700
                      const char **target, size_t *tlen);
701
702
/**
703
 * Unsafe version of \ref ucl_obj_tolstring_safe
704
 * @param obj CL object
705
 * @return string value
706
 */
707
UCL_EXTERN const char *ucl_object_tolstring(const ucl_object_t *obj, size_t *tlen);
708
709
/**
710
 * Return object identified by a key in the specified object
711
 * @param obj object to get a key from (must be of type UCL_OBJECT)
712
 * @param key key to search
713
 * @return object matching the specified key or NULL if key was not found
714
 */
715
UCL_EXTERN const ucl_object_t *ucl_object_lookup(const ucl_object_t *obj,
716
                         const char *key);
717
#define ucl_object_find_key ucl_object_lookup
718
719
/**
720
 * Return object identified by a key in the specified object, if the first key is
721
 * not found then look for the next one. This process is repeated unless
722
 * the next argument in the list is not NULL. So, `ucl_object_find_any_key(obj, key, NULL)`
723
 * is equal to `ucl_object_find_key(obj, key)`
724
 * @param obj object to get a key from (must be of type UCL_OBJECT)
725
 * @param key key to search
726
 * @param ... list of alternative keys to search (NULL terminated)
727
 * @return object matching the specified key or NULL if key was not found
728
 */
729
UCL_EXTERN const ucl_object_t *ucl_object_lookup_any(const ucl_object_t *obj,
730
                           const char *key, ...);
731
#define ucl_object_find_any_key ucl_object_lookup_any
732
733
/**
734
 * Return object identified by a fixed size key in the specified object
735
 * @param obj object to get a key from (must be of type UCL_OBJECT)
736
 * @param key key to search
737
 * @param klen length of a key
738
 * @return object matching the specified key or NULL if key was not found
739
 */
740
UCL_EXTERN const ucl_object_t *ucl_object_lookup_len(const ucl_object_t *obj,
741
                           const char *key, size_t klen);
742
#define ucl_object_find_keyl ucl_object_lookup_len
743
744
/**
745
 * Return object identified by dot notation string
746
 * @param obj object to search in
747
 * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays
748
 * @return object matched the specified path or NULL if path is not found
749
 */
750
UCL_EXTERN const ucl_object_t *ucl_object_lookup_path(const ucl_object_t *obj,
751
                            const char *path);
752
#define ucl_lookup_path ucl_object_lookup_path
753
754
/**
755
 * Return object identified by object notation string using arbitrary delimiter
756
 * @param obj object to search in
757
 * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays
758
 * @param sep the sepatorator to use in place of . (incase keys have . in them)
759
 * @return object matched the specified path or NULL if path is not found
760
 */
761
UCL_EXTERN const ucl_object_t *ucl_object_lookup_path_char(const ucl_object_t *obj,
762
                               const char *path, char sep);
763
#define ucl_lookup_path_char ucl_object_lookup_path_char
764
765
/**
766
 * Returns a key of an object as a NULL terminated string
767
 * @param obj CL object
768
 * @return key or NULL if there is no key
769
 */
770
UCL_EXTERN const char *ucl_object_key(const ucl_object_t *obj);
771
772
/**
773
 * Returns a key of an object as a fixed size string (may be more efficient)
774
 * @param obj CL object
775
 * @param len target key length
776
 * @return key pointer
777
 */
778
UCL_EXTERN const char *ucl_object_keyl(const ucl_object_t *obj, size_t *len);
779
780
/**
781
 * Increase reference count for an object
782
 * @param obj object to ref
783
 * @return the referenced object
784
 */
785
UCL_EXTERN ucl_object_t *ucl_object_ref(const ucl_object_t *obj);
786
787
/**
788
 * Free ucl object
789
 * @param obj ucl object to free
790
 */
791
UCL_DEPRECATED(UCL_EXTERN void ucl_object_free(ucl_object_t *obj));
792
793
/**
794
 * Decrease reference count for an object
795
 * @param obj object to unref
796
 */
797
UCL_EXTERN void ucl_object_unref(ucl_object_t *obj);
798
799
/**
800
 * Compare objects `o1` and `o2`
801
 * @param o1 the first object
802
 * @param o2 the second object
803
 * @return values >0, 0 and <0 if `o1` is more than, equal and less than `o2`.
804
 * The order of comparison:
805
 * 1) Type of objects
806
 * 2) Size of objects
807
 * 3) Content of objects
808
 */
809
UCL_EXTERN int ucl_object_compare(const ucl_object_t *o1,
810
                  const ucl_object_t *o2);
811
812
/**
813
 * Compare objects `o1` and `o2` useful for sorting
814
 * @param o1 the first object
815
 * @param o2 the second object
816
 * @return values >0, 0 and <0 if `o1` is more than, equal and less than `o2`.
817
 * The order of comparison:
818
 * 1) Type of objects
819
 * 2) Size of objects
820
 * 3) Content of objects
821
 */
822
UCL_EXTERN int ucl_object_compare_qsort(const ucl_object_t **o1,
823
                    const ucl_object_t **o2);
824
825
/**
826
 * Sort UCL array using `cmp` compare function
827
 * @param ar
828
 * @param cmp
829
 */
830
UCL_EXTERN void ucl_object_array_sort(ucl_object_t *ar,
831
                    int (*cmp)(const ucl_object_t **o1, const ucl_object_t **o2));
832
833
enum ucl_object_keys_sort_flags {
834
  UCL_SORT_KEYS_DEFAULT = 0,
835
  UCL_SORT_KEYS_ICASE = (1u << 0u),
836
  UCL_SORT_KEYS_RECURSIVE = (1u << 1u),
837
};
838
/***
839
 * Sorts keys in object in place
840
 * @param obj
841
 * @param how
842
 */
843
UCL_EXTERN void ucl_object_sort_keys(ucl_object_t *obj,
844
                   enum ucl_object_keys_sort_flags how);
845
846
/**
847
 * Get the priority for specific UCL object
848
 * @param obj any ucl object
849
 * @return priority of an object
850
 */
851
UCL_EXTERN unsigned int ucl_object_get_priority(const ucl_object_t *obj);
852
853
/**
854
 * Set explicit priority of an object.
855
 * @param obj any ucl object
856
 * @param priority new priroity value (only 4 least significant bits are considred)
857
 */
858
UCL_EXTERN void ucl_object_set_priority(ucl_object_t *obj,
859
                    unsigned int priority);
860
861
/**
862
 * Opaque iterator object
863
 */
864
typedef void *ucl_object_iter_t;
865
866
/**
867
 * Get next key from an object
868
 * @param obj object to iterate
869
 * @param iter opaque iterator, must be set to NULL on the first call:
870
 * ucl_object_iter_t it = NULL;
871
 * while ((cur = ucl_iterate_object (obj, &it)) != NULL) ...
872
 * @param ep pointer record exception (such as ENOMEM), could be NULL
873
 * @return the next object or NULL
874
 */
875
UCL_EXTERN const ucl_object_t *ucl_object_iterate_with_error(const ucl_object_t *obj,
876
                               ucl_object_iter_t *iter, bool expand_values, int *ep);
877
878
#define ucl_iterate_object ucl_object_iterate
879
2.73M
#define ucl_object_iterate(ob, it, ev) ucl_object_iterate_with_error((ob), (it), (ev), NULL)
880
881
/**
882
 * Free resources associated with an inline iterator when iteration is
883
 * abandoned before completion. Only needed for UCL_OBJECT iteration where
884
 * internal heap state is allocated. Safe to call with a NULL iterator or
885
 * on non-object types.
886
 *
887
 * Example usage:
888
 * ucl_object_iter_t it = NULL;
889
 * while ((cur = ucl_iterate_object(obj, &it, true))) {
890
 *     if (error) {
891
 *         ucl_object_iterate_end(obj, &it);
892
 *         return;
893
 *     }
894
 * }
895
 *
896
 * @param obj the object being iterated
897
 * @param iter pointer to the iterator to free
898
 */
899
UCL_EXTERN void ucl_object_iterate_end(const ucl_object_t *obj,
900
                    ucl_object_iter_t *iter);
901
902
#define ucl_iterate_object_end ucl_object_iterate_end
903
904
/**
905
 * Create new safe iterator for the specified object
906
 * @param obj object to iterate
907
 * @return new iterator object that should be used with safe iterators API only
908
 */
909
UCL_EXTERN ucl_object_iter_t ucl_object_iterate_new(const ucl_object_t *obj)
910
  UCL_WARN_UNUSED_RESULT;
911
/**
912
 * Check safe iterator object after performing some operations on it
913
 * (such as ucl_object_iterate_safe()) to see if operation has encountered
914
 * fatal exception while performing that operation (e.g. ENOMEM).
915
 * @param iter opaque iterator
916
 * @return true if exception has occured, false otherwise
917
 */
918
UCL_EXTERN bool ucl_object_iter_chk_excpn(ucl_object_iter_t it);
919
920
/**
921
 * Reset initialized iterator to a new object
922
 * @param obj new object to iterate
923
 * @return modified iterator object
924
 */
925
UCL_EXTERN ucl_object_iter_t ucl_object_iterate_reset(ucl_object_iter_t it,
926
                            const ucl_object_t *obj);
927
928
/**
929
 * Get the next object from the `obj`. This function iterates over arrays, objects
930
 * and implicit arrays
931
 * @param iter safe iterator
932
 * @param expand_values expand explicit arrays and objects
933
 * @return the next object in sequence
934
 */
935
UCL_EXTERN const ucl_object_t *ucl_object_iterate_safe(ucl_object_iter_t iter,
936
                             bool expand_values);
937
/**
938
 * Iteration type enumerator
939
 */
940
enum ucl_iterate_type {
941
  UCL_ITERATE_EXPLICIT = 1 << 0,          /**< Iterate just explicit arrays and objects */
942
  UCL_ITERATE_IMPLICIT = 1 << 1,          /**< Iterate just implicit arrays */
943
  UCL_ITERATE_BOTH = (1 << 0) | (1 << 1), /**< Iterate both explicit and implicit arrays*/
944
};
945
946
/**
947
 * Get the next object from the `obj`. This function iterates over arrays, objects
948
 * and implicit arrays if needed
949
 * @param iter safe iterator
950
 * @param
951
 * @return the next object in sequence
952
 */
953
UCL_EXTERN const ucl_object_t *ucl_object_iterate_full(ucl_object_iter_t iter,
954
                             enum ucl_iterate_type type);
955
956
/**
957
 * Free memory associated with the safe iterator
958
 * @param it safe iterator object
959
 */
960
UCL_EXTERN void ucl_object_iterate_free(ucl_object_iter_t it);
961
962
/** @} */
963
964
965
/**
966
 * @defgroup parser Parsing functions
967
 * These functions are used to parse UCL objects
968
 *
969
 * @{
970
 */
971
972
/**
973
 * Macro handler for a parser
974
 * @param data the content of macro
975
 * @param len the length of content
976
 * @param arguments arguments object
977
 * @param ud opaque user data
978
 * @param err error pointer
979
 * @return true if macro has been parsed
980
 */
981
typedef bool (*ucl_macro_handler)(const unsigned char *data, size_t len,
982
                  const ucl_object_t *arguments,
983
                  void *ud);
984
985
/**
986
 * Context dependent macro handler for a parser
987
 * @param data the content of macro
988
 * @param len the length of content
989
 * @param arguments arguments object
990
 * @param context previously parsed context
991
 * @param ud opaque user data
992
 * @param err error pointer
993
 * @return true if macro has been parsed
994
 */
995
typedef bool (*ucl_context_macro_handler)(const unsigned char *data, size_t len,
996
                      const ucl_object_t *arguments,
997
                      const ucl_object_t *context,
998
                      void *ud);
999
1000
/* Opaque parser */
1001
struct ucl_parser;
1002
1003
/**
1004
 * Creates new parser object
1005
 * @param pool pool to allocate memory from
1006
 * @return new parser object
1007
 */
1008
UCL_EXTERN struct ucl_parser *ucl_parser_new(int flags);
1009
1010
/**
1011
 * Sets the default priority for the parser applied to chunks that do not
1012
 * specify priority explicitly
1013
 * @param parser parser object
1014
 * @param prio default priority (0 .. 16)
1015
 * @return true if parser's default priority was set
1016
 */
1017
UCL_EXTERN bool ucl_parser_set_default_priority(struct ucl_parser *parser,
1018
                        unsigned prio);
1019
/**
1020
 * Gets the default priority for the parser applied to chunks that do not
1021
 * specify priority explicitly
1022
 * @param parser parser object
1023
 * @return true default priority (0 .. 16), -1 for failure
1024
 */
1025
UCL_EXTERN int ucl_parser_get_default_priority(struct ucl_parser *parser);
1026
1027
/**
1028
 * Structural and allocation budgets applied while parsing.
1029
 *
1030
 * The input size alone is a poor proxy for the cost of parsing it: a small
1031
 * document can describe a very deep or very fragmented tree, and every
1032
 * element of that tree costs an object, a copied key/value and hash
1033
 * bookkeeping. These limits bound that amplification and should be set
1034
 * whenever the input is untrusted.
1035
 *
1036
 * A zero value means "no limit" for that particular field. Exceeding a limit
1037
 * aborts the parse with #UCL_ELIMIT (or #UCL_ENESTED for the depth limit).
1038
 */
1039
struct ucl_parser_limits {
1040
  uint64_t max_depth;         /**< Maximum nesting depth of objects and arrays */
1041
  uint64_t max_nodes;         /**< Maximum number of elements in the parsed tree */
1042
  uint64_t max_alloc;         /**< Maximum aggregate bytes attributed to the parsed tree */
1043
  uint64_t max_key_length;    /**< Maximum length of a single key */
1044
  uint64_t max_string_length; /**< Maximum length of a single string value */
1045
};
1046
1047
/**
1048
 * Sets the parser limits, replacing all of them at once
1049
 * @param parser parser object
1050
 * @param limits limits to apply, NULL restores the defaults
1051
 */
1052
UCL_EXTERN void ucl_parser_set_limits(struct ucl_parser *parser,
1053
                    const struct ucl_parser_limits *limits);
1054
1055
/**
1056
 * Gets the limits currently in effect for a parser
1057
 * @param parser parser object
1058
 * @param limits output, filled with the current limits
1059
 */
1060
UCL_EXTERN void ucl_parser_get_limits(struct ucl_parser *parser,
1061
                    struct ucl_parser_limits *limits);
1062
1063
/**
1064
 * Register new handler for a macro
1065
 * @param parser parser object
1066
 * @param macro macro name (without leading dot)
1067
 * @param handler handler (it is called immediately after macro is parsed)
1068
 * @param ud opaque user data for a handler
1069
 * @return true on success, false on failure (i.e. ENOMEM)
1070
 */
1071
UCL_EXTERN bool ucl_parser_register_macro(struct ucl_parser *parser,
1072
                      const char *macro,
1073
                      ucl_macro_handler handler, void *ud);
1074
1075
/**
1076
 * Register new context dependent handler for a macro
1077
 * @param parser parser object
1078
 * @param macro macro name (without leading dot)
1079
 * @param handler handler (it is called immediately after macro is parsed)
1080
 * @param ud opaque user data for a handler
1081
 * @return true on success, false on failure (i.e. ENOMEM)
1082
 */
1083
UCL_EXTERN bool ucl_parser_register_context_macro(struct ucl_parser *parser,
1084
                          const char *macro,
1085
                          ucl_context_macro_handler handler,
1086
                          void *ud);
1087
1088
/**
1089
 * Handler to detect unregistered variables
1090
 * @param data variable data
1091
 * @param len length of variable
1092
 * @param replace (out) replace value for variable
1093
 * @param replace_len (out) replace length for variable
1094
 * @param need_free (out) UCL will free `dest` after usage
1095
 * @param ud opaque userdata
1096
 * @return true if variable
1097
 */
1098
typedef bool (*ucl_variable_handler)(const unsigned char *data, size_t len,
1099
                   unsigned char **replace, size_t *replace_len, bool *need_free, void *ud);
1100
1101
/**
1102
 * Register new parser variable
1103
 * @param parser parser object
1104
 * @param var variable name
1105
 * @param value variable value
1106
 */
1107
UCL_EXTERN void ucl_parser_register_variable(struct ucl_parser *parser, const char *var,
1108
                       const char *value);
1109
1110
/**
1111
 * Set handler for unknown variables
1112
 * @param parser parser structure
1113
 * @param handler desired handler
1114
 * @param ud opaque data for the handler
1115
 */
1116
UCL_EXTERN void ucl_parser_set_variables_handler(struct ucl_parser *parser,
1117
                         ucl_variable_handler handler, void *ud);
1118
1119
/**
1120
 * Load new chunk to a parser
1121
 * @param parser parser structure
1122
 * @param data the pointer to the beginning of a chunk
1123
 * @param len the length of a chunk
1124
 * @return true if chunk has been added and false in case of error
1125
 */
1126
UCL_EXTERN bool ucl_parser_add_chunk(struct ucl_parser *parser,
1127
                   const unsigned char *data, size_t len);
1128
1129
/**
1130
 * Load new chunk to a parser with the specified priority
1131
 * @param parser parser structure
1132
 * @param data the pointer to the beginning of a chunk
1133
 * @param len the length of a chunk
1134
 * @param priority the desired priority of a chunk (only 4 least significant bits
1135
 * are considered for this parameter)
1136
 * @return true if chunk has been added and false in case of error
1137
 */
1138
UCL_EXTERN bool ucl_parser_add_chunk_priority(struct ucl_parser *parser,
1139
                        const unsigned char *data, size_t len, unsigned priority);
1140
1141
/**
1142
 * Insert new chunk to a parser (must have previously processed data with an existing top object)
1143
 * @param parser parser structure
1144
 * @param data the pointer to the beginning of a chunk
1145
 * @param len the length of a chunk
1146
 * @return true if chunk has been added and false in case of error
1147
 */
1148
UCL_EXTERN bool ucl_parser_insert_chunk(struct ucl_parser *parser,
1149
                    const unsigned char *data, size_t len);
1150
1151
/**
1152
 * Full version of ucl_add_chunk with priority and duplicate strategy
1153
 * @param parser parser structure
1154
 * @param data the pointer to the beginning of a chunk
1155
 * @param len the length of a chunk
1156
 * @param priority the desired priority of a chunk (only 4 least significant bits
1157
 * are considered for this parameter)
1158
 * @param strat duplicates merging strategy
1159
 * @param parse_type input format
1160
 * @return true if chunk has been added and false in case of error
1161
 */
1162
UCL_EXTERN bool ucl_parser_add_chunk_full(struct ucl_parser *parser,
1163
                      const unsigned char *data, size_t len, unsigned priority,
1164
                      enum ucl_duplicate_strategy strat, enum ucl_parse_type parse_type);
1165
1166
/**
1167
 * Load ucl object from a string
1168
 * @param parser parser structure
1169
 * @param data the pointer to the string
1170
 * @param len the length of the string, if `len` is 0 then `data` must be zero-terminated string
1171
 * @return true if string has been added and false in case of error
1172
 */
1173
UCL_EXTERN bool ucl_parser_add_string(struct ucl_parser *parser,
1174
                    const char *data, size_t len);
1175
1176
/**
1177
 * Load ucl object from a string
1178
 * @param parser parser structure
1179
 * @param data the pointer to the string
1180
 * @param len the length of the string, if `len` is 0 then `data` must be zero-terminated string
1181
 * @param priority the desired priority of a chunk (only 4 least significant bits
1182
 * are considered for this parameter)
1183
 * @return true if string has been added and false in case of error
1184
 */
1185
UCL_EXTERN bool ucl_parser_add_string_priority(struct ucl_parser *parser,
1186
                         const char *data, size_t len, unsigned priority);
1187
1188
/**
1189
 * Load and add data from a file
1190
 * @param parser parser structure
1191
 * @param filename the name of file
1192
 * @param err if *err is NULL it is set to parser error
1193
 * @return true if chunk has been added and false in case of error
1194
 */
1195
UCL_EXTERN bool ucl_parser_add_file(struct ucl_parser *parser,
1196
                  const char *filename);
1197
1198
/**
1199
 * Load and add data from a file
1200
 * @param parser parser structure
1201
 * @param filename the name of file
1202
 * @param err if *err is NULL it is set to parser error
1203
 * @param priority the desired priority of a chunk (only 4 least significant bits
1204
 * are considered for this parameter)
1205
 * @return true if chunk has been added and false in case of error
1206
 */
1207
UCL_EXTERN bool ucl_parser_add_file_priority(struct ucl_parser *parser,
1208
                       const char *filename, unsigned priority);
1209
1210
/**
1211
 * Load and add data from a file
1212
 * @param parser parser structure
1213
 * @param filename the name of file
1214
 * @param priority the desired priority of a chunk (only 4 least significant bits
1215
 * are considered for this parameter)
1216
 * @param strat Merge strategy to use while parsing this file
1217
 * @param parse_type Parser type to use while parsing this file
1218
 * @return true if chunk has been added and false in case of error
1219
 */
1220
UCL_EXTERN bool ucl_parser_add_file_full(struct ucl_parser *parser, const char *filename,
1221
                     unsigned priority, enum ucl_duplicate_strategy strat,
1222
                     enum ucl_parse_type parse_type);
1223
1224
/**
1225
 * Load and add data from a file descriptor
1226
 * @param parser parser structure
1227
 * @param filename the name of file
1228
 * @param err if *err is NULL it is set to parser error
1229
 * @return true if chunk has been added and false in case of error
1230
 */
1231
UCL_EXTERN bool ucl_parser_add_fd(struct ucl_parser *parser,
1232
                  int fd);
1233
1234
/**
1235
 * Load and add data from a file descriptor
1236
 * @param parser parser structure
1237
 * @param filename the name of file
1238
 * @param err if *err is NULL it is set to parser error
1239
 * @param priority the desired priority of a chunk (only 4 least significant bits
1240
 * are considered for this parameter)
1241
 * @return true if chunk has been added and false in case of error
1242
 */
1243
UCL_EXTERN bool ucl_parser_add_fd_priority(struct ucl_parser *parser,
1244
                       int fd, unsigned priority);
1245
1246
/**
1247
 * Load and add data from a file descriptor
1248
 * @param parser parser structure
1249
 * @param filename the name of file
1250
 * @param err if *err is NULL it is set to parser error
1251
 * @param priority the desired priority of a chunk (only 4 least significant bits
1252
 * are considered for this parameter)
1253
 * @param strat Merge strategy to use while parsing this file
1254
 * @param parse_type Parser type to use while parsing this file
1255
 * @return true if chunk has been added and false in case of error
1256
 */
1257
UCL_EXTERN bool ucl_parser_add_fd_full(struct ucl_parser *parser, int fd,
1258
                     unsigned priority, enum ucl_duplicate_strategy strat,
1259
                     enum ucl_parse_type parse_type);
1260
1261
/**
1262
 * Provide a UCL_ARRAY of paths to search for include files. The object is
1263
 * copied so caller must unref the object.
1264
 * @param parser parser structure
1265
 * @param paths UCL_ARRAY of paths to search
1266
 * @return true if the path search array was replaced in the parser
1267
 */
1268
UCL_EXTERN bool ucl_set_include_path(struct ucl_parser *parser,
1269
                   ucl_object_t *paths);
1270
1271
/**
1272
 * Get a top object for a parser (refcount is increased)
1273
 * @param parser parser structure
1274
 * @param err if *err is NULL it is set to parser error
1275
 * @return top parser object or NULL
1276
 */
1277
UCL_EXTERN ucl_object_t *ucl_parser_get_object(struct ucl_parser *parser);
1278
1279
/**
1280
 * Get the current stack object as stack accessor function for use in macro
1281
 * functions (refcount is increased)
1282
 * @param parser parser object
1283
 * @param depth depth of stack to retrieve (top is 0)
1284
 * @return current stack object or NULL
1285
 */
1286
UCL_EXTERN ucl_object_t *ucl_parser_get_current_stack_object(struct ucl_parser *parser, unsigned int depth);
1287
1288
/**
1289
 * Peek at the character at the current chunk position
1290
 * @param parser parser structure
1291
 * @return current chunk position character
1292
 */
1293
UCL_EXTERN unsigned char ucl_parser_chunk_peek(struct ucl_parser *parser);
1294
1295
/**
1296
 * Skip the character at the current chunk position
1297
 * @param parser parser structure
1298
 * @return success boolean
1299
 */
1300
UCL_EXTERN bool ucl_parser_chunk_skip(struct ucl_parser *parser);
1301
1302
/**
1303
 * Get the error string if parsing has been failed
1304
 * @param parser parser object
1305
 * @return error description
1306
 */
1307
UCL_EXTERN const char *ucl_parser_get_error(struct ucl_parser *parser);
1308
1309
/**
1310
 * Get the code of the last error
1311
 * @param parser parser object
1312
 * @return error code
1313
 */
1314
UCL_EXTERN int ucl_parser_get_error_code(struct ucl_parser *parser);
1315
1316
/**
1317
 * Get the current column number within parser
1318
 * @param parser parser object
1319
 * @return current column number
1320
 */
1321
UCL_EXTERN unsigned ucl_parser_get_column(struct ucl_parser *parser);
1322
1323
/**
1324
 * Get the current line number within parser
1325
 * @param parser parser object
1326
 * @return current line number
1327
 */
1328
UCL_EXTERN unsigned ucl_parser_get_linenum(struct ucl_parser *parser);
1329
1330
/**
1331
 * Clear the error in the parser
1332
 * @param parser parser object
1333
 */
1334
UCL_EXTERN void ucl_parser_clear_error(struct ucl_parser *parser);
1335
1336
/**
1337
 * Free ucl parser object
1338
 * @param parser parser object
1339
 */
1340
UCL_EXTERN void ucl_parser_free(struct ucl_parser *parser);
1341
1342
/**
1343
 * Get constant opaque pointer to comments structure for this parser. Increase
1344
 * refcount to prevent this object to be destroyed on parser's destruction
1345
 * @param parser parser structure
1346
 * @return ucl comments pointer or NULL
1347
 */
1348
UCL_EXTERN const ucl_object_t *ucl_parser_get_comments(struct ucl_parser *parser);
1349
1350
/**
1351
 * Utility function to find a comment object for the specified object in the input
1352
 * @param comments comments object
1353
 * @param srch search object
1354
 * @return string comment enclosed in ucl_object_t
1355
 */
1356
UCL_EXTERN const ucl_object_t *ucl_comments_find(const ucl_object_t *comments,
1357
                         const ucl_object_t *srch);
1358
1359
/**
1360
 * Move comment from `from` object to `to` object
1361
 * @param comments comments object
1362
 * @param what source object
1363
 * @param with destination object
1364
 * @return `true` if `from` has comment and it has been moved to `to`
1365
 */
1366
UCL_EXTERN bool ucl_comments_move(ucl_object_t *comments,
1367
                  const ucl_object_t *from, const ucl_object_t *to);
1368
1369
/**
1370
 * Adds a new comment for an object
1371
 * @param comments comments object
1372
 * @param obj object to add comment to
1373
 * @param comment string representation of a comment
1374
 */
1375
UCL_EXTERN void ucl_comments_add(ucl_object_t *comments,
1376
                 const ucl_object_t *obj, const char *comment);
1377
1378
/**
1379
 * Add new public key to parser for signatures check
1380
 * @param parser parser object
1381
 * @param key PEM representation of a key
1382
 * @param len length of the key
1383
 * @param err if *err is NULL it is set to parser error
1384
 * @return true if a key has been successfully added
1385
 */
1386
UCL_EXTERN bool ucl_parser_pubkey_add(struct ucl_parser *parser,
1387
                    const unsigned char *key, size_t len);
1388
1389
/**
1390
 * Set FILENAME and CURDIR variables in parser
1391
 * @param parser parser object
1392
 * @param filename filename to set or NULL to set FILENAME to "undef" and CURDIR to getcwd()
1393
 * @param need_expand perform realpath() if this variable is true and filename is not NULL
1394
 * @return true if variables has been set
1395
 */
1396
UCL_EXTERN bool ucl_parser_set_filevars(struct ucl_parser *parser, const char *filename,
1397
                    bool need_expand);
1398
1399
/**
1400
 * Returns current file for the parser
1401
 * @param parser parser object
1402
 * @return current file or NULL if parsing memory
1403
 */
1404
UCL_EXTERN const char *ucl_parser_get_cur_file(struct ucl_parser *parser);
1405
1406
/**
1407
 * Defines special handler for certain types of data (identified by magic)
1408
 */
1409
typedef bool (*ucl_parser_special_handler_t)(struct ucl_parser *parser,
1410
                       const unsigned char *source, size_t source_len,
1411
                       unsigned char **destination, size_t *dest_len,
1412
                       void *user_data);
1413
1414
/**
1415
 * Special handler flags
1416
 */
1417
enum ucl_special_handler_flags {
1418
  UCL_SPECIAL_HANDLER_DEFAULT = 0,
1419
  UCL_SPECIAL_HANDLER_PREPROCESS_ALL = (1u << 0),
1420
};
1421
1422
/**
1423
 * Special handler structure
1424
 */
1425
struct ucl_parser_special_handler {
1426
  const unsigned char *magic;
1427
  size_t magic_len;
1428
  enum ucl_special_handler_flags flags;
1429
  ucl_parser_special_handler_t handler;
1430
  void (*free_function)(unsigned char *data, size_t len, void *user_data);
1431
  void *user_data;
1432
  struct ucl_parser_special_handler *next; /* Used internally */
1433
};
1434
1435
/**
1436
 * Add special handler for a parser, handles special sequences identified by magic
1437
 * @param parser parser structure
1438
 * @param handler handler structure
1439
 */
1440
UCL_EXTERN void ucl_parser_add_special_handler(struct ucl_parser *parser,
1441
                         struct ucl_parser_special_handler *handler);
1442
1443
/**
1444
 * Handler for include traces:
1445
 * @param parser parser object
1446
 * @param parent where include is done from
1447
 * @param args arguments to an include
1448
 * @param path path of the include
1449
 * @param pathlen length of the path
1450
 * @param user_data opaque userdata
1451
 */
1452
typedef void(ucl_include_trace_func_t)(struct ucl_parser *parser,
1453
                     const ucl_object_t *parent,
1454
                     const ucl_object_t *args,
1455
                     const char *path,
1456
                     size_t pathlen,
1457
                     void *user_data);
1458
1459
/**
1460
 * Register trace function for an include handler
1461
 * @param parser parser object
1462
 * @param func function to trace includes
1463
 * @param user_data opaque data
1464
 */
1465
UCL_EXTERN void ucl_parser_set_include_tracer(struct ucl_parser *parser,
1466
                        ucl_include_trace_func_t func,
1467
                        void *user_data);
1468
1469
/** @} */
1470
1471
/**
1472
 * @defgroup emitter Emitting functions
1473
 * These functions are used to serialise UCL objects to some string representation.
1474
 *
1475
 * @{
1476
 */
1477
1478
struct ucl_emitter_context;
1479
/**
1480
 * Structure using for emitter callbacks
1481
 */
1482
struct ucl_emitter_functions {
1483
  /** Append a single character */
1484
  int (*ucl_emitter_append_character)(unsigned char c, size_t nchars, void *ud);
1485
  /** Append a string of a specified length */
1486
  int (*ucl_emitter_append_len)(unsigned const char *str, size_t len, void *ud);
1487
  /** Append a 64 bit integer */
1488
  int (*ucl_emitter_append_int)(int64_t elt, void *ud);
1489
  /** Append floating point element */
1490
  int (*ucl_emitter_append_double)(double elt, void *ud);
1491
  /** Free userdata */
1492
  void (*ucl_emitter_free_func)(void *ud);
1493
  /** Opaque userdata pointer */
1494
  void *ud;
1495
};
1496
1497
struct ucl_emitter_operations {
1498
  /** Write a primitive element */
1499
  void (*ucl_emitter_write_elt)(struct ucl_emitter_context *ctx,
1500
                  const ucl_object_t *obj, bool first, bool print_key);
1501
  /** Start ucl object */
1502
  void (*ucl_emitter_start_object)(struct ucl_emitter_context *ctx,
1503
                   const ucl_object_t *obj, bool first, bool print_key);
1504
  /** End ucl object */
1505
  void (*ucl_emitter_end_object)(struct ucl_emitter_context *ctx,
1506
                   const ucl_object_t *obj);
1507
  /** Start ucl array */
1508
  void (*ucl_emitter_start_array)(struct ucl_emitter_context *ctx,
1509
                  const ucl_object_t *obj, bool first, bool print_key);
1510
  void (*ucl_emitter_end_array)(struct ucl_emitter_context *ctx,
1511
                  const ucl_object_t *obj);
1512
};
1513
1514
/**
1515
 * Structure that defines emitter functions
1516
 */
1517
struct ucl_emitter_context {
1518
  /** Name of emitter (e.g. json, compact_json) */
1519
  const char *name;
1520
  /** Unique id (e.g. UCL_EMIT_JSON for standard emitters */
1521
  int id;
1522
  /** A set of output functions */
1523
  const struct ucl_emitter_functions *func;
1524
  /** A set of output operations */
1525
  const struct ucl_emitter_operations *ops;
1526
  /** Current amount of indent tabs */
1527
  unsigned int indent;
1528
  /** Top level object */
1529
  const ucl_object_t *top;
1530
  /** Optional comments */
1531
  const ucl_object_t *comments;
1532
};
1533
1534
/**
1535
 * Emit object to a string
1536
 * @param obj object
1537
 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
1538
 * #UCL_EMIT_CONFIG then emit config like object
1539
 * @return dump of an object (must be freed after using) or NULL in case of error
1540
 */
1541
UCL_EXTERN unsigned char *ucl_object_emit(const ucl_object_t *obj,
1542
                      enum ucl_emitter emit_type);
1543
1544
/**
1545
 * Emit object to a string that can contain `\0` inside
1546
 * @param obj object
1547
 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
1548
 * #UCL_EMIT_CONFIG then emit config like object
1549
 * @param len the resulting length
1550
 * @return dump of an object (must be freed after using) or NULL in case of error
1551
 */
1552
UCL_EXTERN unsigned char *ucl_object_emit_len(const ucl_object_t *obj,
1553
                        enum ucl_emitter emit_type, size_t *len);
1554
1555
/**
1556
 * Emit object to a string
1557
 * @param obj object
1558
 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
1559
 * #UCL_EMIT_CONFIG then emit config like object
1560
 * @param emitter a set of emitter functions
1561
 * @param comments optional comments for the parser
1562
 * @return dump of an object (must be freed after using) or NULL in case of error
1563
 */
1564
UCL_EXTERN bool ucl_object_emit_full(const ucl_object_t *obj,
1565
                   enum ucl_emitter emit_type,
1566
                   struct ucl_emitter_functions *emitter,
1567
                   const ucl_object_t *comments);
1568
1569
/**
1570
 * Start streamlined UCL object emitter
1571
 * @param obj top UCL object
1572
 * @param emit_type emit type
1573
 * @param emitter a set of emitter functions
1574
 * @return new streamlined context that should be freed by
1575
 * `ucl_object_emit_streamline_finish`
1576
 */
1577
UCL_EXTERN struct ucl_emitter_context *ucl_object_emit_streamline_new(
1578
  const ucl_object_t *obj, enum ucl_emitter emit_type,
1579
  struct ucl_emitter_functions *emitter);
1580
1581
/**
1582
 * Start object or array container for the streamlined output
1583
 * @param ctx streamlined context
1584
 * @param obj container object
1585
 * @return true if the container was started, false if obj is not a container
1586
 */
1587
UCL_EXTERN bool ucl_object_emit_streamline_start_container(
1588
  struct ucl_emitter_context *ctx, const ucl_object_t *obj);
1589
/**
1590
 * Add a complete UCL object to streamlined output
1591
 * @param ctx streamlined context
1592
 * @param obj object to output
1593
 */
1594
UCL_EXTERN void ucl_object_emit_streamline_add_object(
1595
  struct ucl_emitter_context *ctx, const ucl_object_t *obj);
1596
/**
1597
 * End previously added container
1598
 * @param ctx streamlined context
1599
 */
1600
UCL_EXTERN void ucl_object_emit_streamline_end_container(
1601
  struct ucl_emitter_context *ctx);
1602
/**
1603
 * Terminate streamlined container finishing all containers in it
1604
 * @param ctx streamlined context
1605
 */
1606
UCL_EXTERN void ucl_object_emit_streamline_finish(
1607
  struct ucl_emitter_context *ctx);
1608
1609
/**
1610
 * Returns functions to emit object to memory
1611
 * @param pmem target pointer (should be freed by caller)
1612
 * @return emitter functions structure
1613
 */
1614
UCL_EXTERN struct ucl_emitter_functions *ucl_object_emit_memory_funcs(
1615
  void **pmem);
1616
1617
/**
1618
 * Returns functions to emit object to FILE *
1619
 * @param fp FILE * object
1620
 * @return emitter functions structure
1621
 */
1622
UCL_EXTERN struct ucl_emitter_functions *ucl_object_emit_file_funcs(
1623
  FILE *fp);
1624
/**
1625
 * Returns functions to emit object to a file descriptor
1626
 * @param fd file descriptor
1627
 * @return emitter functions structure
1628
 */
1629
UCL_EXTERN struct ucl_emitter_functions *ucl_object_emit_fd_funcs(
1630
  int fd);
1631
1632
/**
1633
 * Free emitter functions
1634
 * @param f pointer to functions
1635
 */
1636
UCL_EXTERN void ucl_object_emit_funcs_free(struct ucl_emitter_functions *f);
1637
1638
/** @} */
1639
1640
/**
1641
 * @defgroup schema Schema functions
1642
 * These functions are used to validate UCL objects using json schema format
1643
 *
1644
 * @{
1645
 */
1646
1647
/**
1648
 * Used to define UCL schema error
1649
 */
1650
enum ucl_schema_error_code {
1651
  UCL_SCHEMA_OK = 0,               /**< no error */
1652
  UCL_SCHEMA_TYPE_MISMATCH,        /**< type of object is incorrect */
1653
  UCL_SCHEMA_INVALID_SCHEMA,       /**< schema is invalid */
1654
  UCL_SCHEMA_MISSING_PROPERTY,     /**< one or more missing properties */
1655
  UCL_SCHEMA_CONSTRAINT,           /**< constraint found */
1656
  UCL_SCHEMA_MISSING_DEPENDENCY,   /**< missing dependency */
1657
  UCL_SCHEMA_EXTERNAL_REF_MISSING, /**< cannot fetch external ref */
1658
  UCL_SCHEMA_EXTERNAL_REF_INVALID, /**< invalid external ref */
1659
  UCL_SCHEMA_INTERNAL_ERROR,       /**< something bad happened */
1660
  UCL_SCHEMA_UNKNOWN               /**< generic error */
1661
};
1662
1663
/**
1664
 * Generic ucl schema error
1665
 */
1666
struct ucl_schema_error {
1667
  enum ucl_schema_error_code code; /**< error code */
1668
  char msg[128];                   /**< error message */
1669
  const ucl_object_t *obj;         /**< object where error occurred */
1670
};
1671
1672
/**
1673
 * Validate object `obj` using schema object `schema`.
1674
 * @param schema schema object
1675
 * @param obj object to validate
1676
 * @param err error pointer, if this parameter is not NULL and error has been
1677
 * occurred, then `err` is filled with the exact error definition.
1678
 * @return true if `obj` is valid using `schema`
1679
 */
1680
UCL_EXTERN bool ucl_object_validate(const ucl_object_t *schema,
1681
                  const ucl_object_t *obj, struct ucl_schema_error *err);
1682
1683
/**
1684
 * Validate object `obj` using schema object `schema` and root schema at `root`.
1685
 * @param schema schema object
1686
 * @param obj object to validate
1687
 * @param root root schema object
1688
 * @param err error pointer, if this parameter is not NULL and error has been
1689
 * occurred, then `err` is filled with the exact error definition.
1690
 * @return true if `obj` is valid using `schema`
1691
 */
1692
UCL_EXTERN bool ucl_object_validate_root(const ucl_object_t *schema,
1693
                     const ucl_object_t *obj,
1694
                     const ucl_object_t *root,
1695
                     struct ucl_schema_error *err);
1696
1697
/**
1698
 * Validate object `obj` using schema object `schema` and root schema at `root`
1699
 * using some external references provided.
1700
 * @param schema schema object
1701
 * @param obj object to validate
1702
 * @param root root schema object
1703
 * @param ext_refs external references (might be modified during validation)
1704
 * @param err error pointer, if this parameter is not NULL and error has been
1705
 * occurred, then `err` is filled with the exact error definition.
1706
 * @return true if `obj` is valid using `schema`
1707
 */
1708
UCL_EXTERN bool ucl_object_validate_root_ext(const ucl_object_t *schema,
1709
                       const ucl_object_t *obj,
1710
                       const ucl_object_t *root,
1711
                       ucl_object_t *ext_refs,
1712
                       struct ucl_schema_error *err);
1713
1714
/** @} */
1715
1716
#ifdef __cplusplus
1717
}
1718
#endif
1719
/*
1720
 * XXX: Poorly named API functions, need to replace them with the appropriate
1721
 * named function. All API functions *must* use naming ucl_object_*. Usage of
1722
 * ucl_obj* should be avoided.
1723
 */
1724
#define ucl_obj_todouble_safe ucl_object_todouble_safe
1725
#define ucl_obj_todouble ucl_object_todouble
1726
#define ucl_obj_tostring ucl_object_tostring
1727
#define ucl_obj_tostring_safe ucl_object_tostring_safe
1728
#define ucl_obj_tolstring ucl_object_tolstring
1729
#define ucl_obj_tolstring_safe ucl_object_tolstring_safe
1730
#define ucl_obj_toint ucl_object_toint
1731
#define ucl_obj_toint_safe ucl_object_toint_safe
1732
#define ucl_obj_toboolean ucl_object_toboolean
1733
#define ucl_obj_toboolean_safe ucl_object_toboolean_safe
1734
#define ucl_obj_get_key ucl_object_find_key
1735
#define ucl_obj_get_keyl ucl_object_find_keyl
1736
#define ucl_obj_unref ucl_object_unref
1737
#define ucl_obj_ref ucl_object_ref
1738
#define ucl_obj_free ucl_object_free
1739
1740
#define UCL_PRIORITY_MIN 0
1741
#define UCL_PRIORITY_MAX 15
1742
1743
#endif /* UCL_H_ */