• Home
  • Raw
  • Download

Lines Matching refs:jbl

64 void jbl_set_user_data(JBL jbl, void *user_data, void (*user_data_free_fn)(void*)) {  in jbl_set_user_data()  argument
65 binn_set_user_data(&jbl->bn, user_data, user_data_free_fn); in jbl_set_user_data()
68 void* jbl_get_user_data(JBL jbl) { in jbl_get_user_data() argument
69 return jbl->bn.user_data; in jbl_get_user_data()
72 iwrc jbl_set_int64(JBL jbl, const char *key, int64_t v) { in jbl_set_int64() argument
73 jbl_type_t t = jbl_type(jbl); in jbl_set_int64()
74 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_int64()
77 binn *bv = &jbl->bn; in jbl_set_int64()
96 iwrc jbl_set_f64(JBL jbl, const char *key, double v) { in jbl_set_f64() argument
97 jbl_type_t t = jbl_type(jbl); in jbl_set_f64()
98 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_f64()
101 binn *bv = &jbl->bn; in jbl_set_f64()
120 iwrc jbl_set_string(JBL jbl, const char *key, const char *v) { in jbl_set_string() argument
121 jbl_type_t t = jbl_type(jbl); in jbl_set_string()
122 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_string()
125 binn *bv = &jbl->bn; in jbl_set_string()
144 iwrc jbl_set_string_printf(JBL jbl, const char *key, const char *format, ...) { in jbl_set_string_printf() argument
162 rc = jbl_set_string(jbl, key, buf); in jbl_set_string_printf()
230 iwrc jbl_set_bool(JBL jbl, const char *key, bool v) { in jbl_set_bool() argument
231 jbl_type_t t = jbl_type(jbl); in jbl_set_bool()
232 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_bool()
235 binn *bv = &jbl->bn; in jbl_set_bool()
254 iwrc jbl_set_null(JBL jbl, const char *key) { in jbl_set_null() argument
255 jbl_type_t t = jbl_type(jbl); in jbl_set_null()
256 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_null()
259 binn *bv = &jbl->bn; in jbl_set_null()
278 iwrc jbl_set_empty_array(JBL jbl, const char *key) { in jbl_set_empty_array() argument
282 rc = jbl_set_nested(jbl, key, v); in jbl_set_empty_array()
288 iwrc jbl_set_empty_object(JBL jbl, const char *key) { in jbl_set_empty_object() argument
292 rc = jbl_set_nested(jbl, key, v); in jbl_set_empty_object()
298 iwrc jbl_set_nested(JBL jbl, const char *key, JBL v) { in jbl_set_nested() argument
299 jbl_type_t t = jbl_type(jbl); in jbl_set_nested()
300 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_nested()
303 binn *bv = &jbl->bn; in jbl_set_nested()
334 JBL jbl = *jblp; in jbl_from_buf_keep() local
335 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep()
336 jbl->bn.type = type; in jbl_from_buf_keep()
337 jbl->bn.ptr = buf; in jbl_from_buf_keep()
338 jbl->bn.size = size; in jbl_from_buf_keep()
339 jbl->bn.count = count; in jbl_from_buf_keep()
340 jbl->bn.freefn = keep_on_destroy ? 0 : free; in jbl_from_buf_keep()
393 JBL jbl = iwpool_alloc(sizeof(*jbl) + src->bn.size, pool); in jbl_clone_into_pool() local
394 if (!jbl) { in jbl_clone_into_pool()
397 jbl->node = 0; in jbl_clone_into_pool()
398 memcpy(&jbl->bn, &src->bn, sizeof(jbl->bn)); in jbl_clone_into_pool()
399 jbl->bn.ptr = (char*) jbl + sizeof(*jbl); in jbl_clone_into_pool()
400 memcpy(jbl->bn.ptr, src->bn.ptr, src->bn.size); in jbl_clone_into_pool()
401 jbl->bn.freefn = 0; in jbl_clone_into_pool()
402 *targetp = jbl; in jbl_clone_into_pool()
406 iwrc jbl_from_buf_keep_onstack(JBL jbl, void *buf, size_t bufsz) { in jbl_from_buf_keep_onstack() argument
414 memset(jbl, 0, sizeof(*jbl)); in jbl_from_buf_keep_onstack()
415 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep_onstack()
416 jbl->bn.type = type; in jbl_from_buf_keep_onstack()
417 jbl->bn.ptr = buf; in jbl_from_buf_keep_onstack()
418 jbl->bn.size = size; in jbl_from_buf_keep_onstack()
419 jbl->bn.count = count; in jbl_from_buf_keep_onstack()
423 iwrc jbl_from_buf_keep_onstack2(JBL jbl, void *buf) { in jbl_from_buf_keep_onstack2() argument
428 memset(jbl, 0, sizeof(*jbl)); in jbl_from_buf_keep_onstack2()
429 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep_onstack2()
430 jbl->bn.type = type; in jbl_from_buf_keep_onstack2()
431 jbl->bn.ptr = buf; in jbl_from_buf_keep_onstack2()
432 jbl->bn.size = size; in jbl_from_buf_keep_onstack2()
433 jbl->bn.count = count; in jbl_from_buf_keep_onstack2()
439 JBL jbl = *jblp; in jbl_destroy() local
440 binn_free(&jbl->bn); in jbl_destroy()
441 free(jbl); in jbl_destroy()
454 iwrc jbl_iterator_init(JBL jbl, JBL_iterator *iter) { in jbl_iterator_init() argument
455 int btype = jbl->bn.type; in jbl_iterator_init()
461 if (!binn_iter_init(biter, &jbl->bn, btype)) { in jbl_iterator_init()
521 jbl_type_t jbl_type(JBL jbl) { in jbl_type() argument
522 if (jbl) { in jbl_type()
523 return _jbl_binn_type(jbl->bn.type); in jbl_type()
528 size_t jbl_count(JBL jbl) { in jbl_count() argument
529 return (size_t) jbl->bn.count; in jbl_count()
532 size_t jbl_size(JBL jbl) { in jbl_size() argument
533 return (size_t) jbl->bn.size; in jbl_size()
547 JBL jbl; in jbl_from_json() local
552 rc = jbl_create_empty_object(&jbl); in jbl_from_json()
555 rc = jbl_create_empty_array(&jbl); in jbl_from_json()
562 rc = jbl_fill_from_node(jbl, node); in jbl_from_json()
564 *jblp = jbl; in jbl_from_json()
806 iwrc jbl_as_json(JBL jbl, jbl_json_printer pt, void *op, jbl_print_flags_t pf) { in jbl_as_json() argument
807 if (!jbl || !pt) { in jbl_as_json()
810 return _jbl_as_json(&jbl->bn, pt, op, 0, pf); in jbl_as_json()
886 int64_t jbl_get_i64(JBL jbl) { in jbl_get_i64() argument
887 assert(jbl); in jbl_get_i64()
888 switch (jbl->bn.type) { in jbl_get_i64()
890 return jbl->bn.vuint8; in jbl_get_i64()
892 return jbl->bn.vuint16; in jbl_get_i64()
894 return jbl->bn.vuint32; in jbl_get_i64()
896 return jbl->bn.vuint64; in jbl_get_i64()
898 return jbl->bn.vint8; in jbl_get_i64()
900 return jbl->bn.vint16; in jbl_get_i64()
902 return jbl->bn.vint32; in jbl_get_i64()
904 return jbl->bn.vint64; in jbl_get_i64()
906 return jbl->bn.vbool; in jbl_get_i64()
908 return (int64_t) jbl->bn.vfloat; in jbl_get_i64()
910 return (int64_t) jbl->bn.vdouble; in jbl_get_i64()
916 int32_t jbl_get_i32(JBL jbl) { in jbl_get_i32() argument
917 return (int32_t) jbl_get_i64(jbl); in jbl_get_i32()
920 double jbl_get_f64(JBL jbl) { in jbl_get_f64() argument
921 assert(jbl); in jbl_get_f64()
922 switch (jbl->bn.type) { in jbl_get_f64()
924 return jbl->bn.vdouble; in jbl_get_f64()
926 return jbl->bn.vfloat; in jbl_get_f64()
928 return jbl->bn.vuint8; in jbl_get_f64()
930 return jbl->bn.vuint16; in jbl_get_f64()
932 return jbl->bn.vuint32; in jbl_get_f64()
934 return jbl->bn.vuint64; in jbl_get_f64()
936 return jbl->bn.vint8; in jbl_get_f64()
938 return jbl->bn.vint16; in jbl_get_f64()
940 return jbl->bn.vint32; in jbl_get_f64()
942 return jbl->bn.vint64; in jbl_get_f64()
944 return jbl->bn.vbool; in jbl_get_f64()
950 const char* jbl_get_str(JBL jbl) { in jbl_get_str() argument
951 assert(jbl && jbl->bn.type == BINN_STRING); in jbl_get_str()
952 if (jbl->bn.type != BINN_STRING) { in jbl_get_str()
955 return jbl->bn.ptr; in jbl_get_str()
959 size_t jbl_copy_strn(JBL jbl, char *buf, size_t bufsz) { in jbl_copy_strn() argument
960 assert(jbl && buf && jbl->bn.type == BINN_STRING); in jbl_copy_strn()
961 if (jbl->bn.type != BINN_STRING) { in jbl_copy_strn()
964 size_t slen = strlen(jbl->bn.ptr); in jbl_copy_strn()
966 memcpy(buf, jbl->bn.ptr, ret); in jbl_copy_strn()
970 jbl_type_t jbl_object_get_type(JBL jbl, const char *key) { in jbl_object_get_type() argument
971 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_type()
975 if (!binn_object_get_value(&jbl->bn, key, &bv)) { in jbl_object_get_type()
981 iwrc jbl_object_get_i64(JBL jbl, const char *key, int64_t *out) { in jbl_object_get_i64() argument
983 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_i64()
987 if (!binn_object_get_int64(&jbl->bn, key, &v)) { in jbl_object_get_i64()
994 iwrc jbl_object_get_f64(JBL jbl, const char *key, double *out) { in jbl_object_get_f64() argument
996 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_f64()
999 if (!binn_object_get_double(&jbl->bn, key, out)) { in jbl_object_get_f64()
1005 iwrc jbl_object_get_bool(JBL jbl, const char *key, bool *out) { in jbl_object_get_bool() argument
1007 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_bool()
1011 if (!binn_object_get_bool(&jbl->bn, key, &v)) { in jbl_object_get_bool()
1018 iwrc jbl_object_get_str(JBL jbl, const char *key, const char **out) { in jbl_object_get_str() argument
1020 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_str()
1023 if (!binn_object_get_str(&jbl->bn, key, (char**) out)) { in jbl_object_get_str()
1029 iwrc jbl_object_get_fill_jbl(JBL jbl, const char *key, JBL out) { in jbl_object_get_fill_jbl() argument
1030 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_fill_jbl()
1034 if (!binn_object_get_value(&jbl->bn, key, &out->bn)) { in jbl_object_get_fill_jbl()
1040 iwrc jbl_as_buf(JBL jbl, void **buf, size_t *size) { in jbl_as_buf() argument
1041 assert(jbl && buf && size); in jbl_as_buf()
1042 if (jbl->bn.writable && jbl->bn.dirty) { in jbl_as_buf()
1043 if (!binn_save_header(&jbl->bn)) { in jbl_as_buf()
1047 *buf = jbl->bn.ptr; in jbl_as_buf()
1048 *size = (size_t) jbl->bn.size; in jbl_as_buf()
1334 JBL jbl = vctx->result; in _jbl_get_visitor2() local
1335 memcpy(&jbl->bn, bv, sizeof(*bv)); in _jbl_get_visitor2()
1348 JBL jbl = malloc(sizeof(struct _JBL)); in _jbl_get_visitor() local
1349 if (!jbl) { in _jbl_get_visitor()
1353 memcpy(&jbl->bn, bv, sizeof(*bv)); in _jbl_get_visitor()
1354 vctx->result = jbl; in _jbl_get_visitor()
1362 bool _jbl_at(JBL jbl, JBL_PTR jp, JBL res) { in _jbl_at() argument
1364 .bn = &jbl->bn, in _jbl_at()
1373 iwrc jbl_at2(JBL jbl, JBL_PTR jp, JBL *res) { in jbl_at2() argument
1375 .bn = &jbl->bn, in jbl_at2()
1393 iwrc jbl_at(JBL jbl, const char *path, JBL *res) { in jbl_at() argument
1400 rc = jbl_at2(jbl, jp, res); in jbl_at()
2518 iwrc _jbl_from_node(JBL jbl, JBL_NODE node) { in _jbl_from_node() argument
2519 jbl->node = node; in _jbl_from_node()
2520 return _jbl_binn_from_node(&jbl->bn, node); in _jbl_from_node()
2551 static iwrc _jbl_patch(JBL jbl, const JBL_PATCH *p, size_t cnt, IWPOOL *pool) { in _jbl_patch() argument
2555 if (!jbl || !p) { in _jbl_patch()
2561 iwrc rc = _jbl_node_from_binn(&jbl->bn, &root, false, pool); in _jbl_patch()
2572 binn_free(&jbl->bn); in _jbl_patch()
2577 memcpy(&jbl->bn, bn, sizeof(jbl->bn)); in _jbl_patch()
2578 jbl->bn.allocated = 0; in _jbl_patch()
2580 memset(&jbl->bn, 0, sizeof(jbl->bn)); in _jbl_patch()
2642 iwrc jbl_to_node(JBL jbl, JBL_NODE *node, bool clone_strings, IWPOOL *pool) { in jbl_to_node() argument
2643 if (jbl->node) { in jbl_to_node()
2644 *node = jbl->node; in jbl_to_node()
2647 return _jbl_node_from_binn(&jbl->bn, node, clone_strings, pool); in jbl_to_node()
2654 iwrc jbl_patch(JBL jbl, const JBL_PATCH *p, size_t cnt) { in jbl_patch() argument
2658 if (!jbl || !p) { in jbl_patch()
2661 IWPOOL *pool = iwpool_create(jbl->bn.size); in jbl_patch()
2665 iwrc rc = _jbl_patch(jbl, p, cnt, pool); in jbl_patch()
2734 iwrc jbl_patch_from_json(JBL jbl, const char *patchjson) { in jbl_patch_from_json() argument
2735 if (!jbl || !patchjson) { in jbl_patch_from_json()
2750 rc = _jbl_patch(jbl, p, cnt, pool); in jbl_patch_from_json()
2764 iwrc jbl_fill_from_node(JBL jbl, JBL_NODE node) { in jbl_fill_from_node() argument
2765 if (!jbl || !node) { in jbl_fill_from_node()
2769 memset(jbl, 0, sizeof(*jbl)); in jbl_fill_from_node()
2775 binn_free(&jbl->bn); in jbl_fill_from_node()
2776 memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); in jbl_fill_from_node()
2777 jbl->bn.allocated = 0; in jbl_fill_from_node()
2867 iwrc jbl_merge_patch(JBL jbl, const char *patchjson) { in jbl_merge_patch() argument
2868 if (!jbl || !patchjson) { in jbl_merge_patch()
2873 IWPOOL *pool = iwpool_create(jbl->bn.size * 2); in jbl_merge_patch()
2877 iwrc rc = _jbl_node_from_binn(&jbl->bn, &target, false, pool); in jbl_merge_patch()
2885 binn_free(&jbl->bn); in jbl_merge_patch()
2886 memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); in jbl_merge_patch()
2887 jbl->bn.allocated = 0; in jbl_merge_patch()
2894 iwrc jbl_merge_patch_jbl(JBL jbl, JBL patch) { in jbl_merge_patch_jbl() argument
2901 rc = jbl_merge_patch(jbl, iwxstr_ptr(xstr)); in jbl_merge_patch_jbl()