From 2d2869ce6060f974004ef98020b38b67366166d1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 30 Dec 2023 23:29:43 +0100 Subject: json: add the lib prefix to wrapper functions It makes it easier to audit for non-wrapped json-c usage. --- src/json.h | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'src/json.h') diff --git a/src/json.h b/src/json.h index 2d496c1..175a41c 100644 --- a/src/json.h +++ b/src/json.h @@ -8,45 +8,38 @@ #ifndef __JSON_H__ #define __JSON_H__ -#include "log.h" - #include #include -#define json_errno(fn) \ - do { \ - log_err("JSON: %s failed\n", fn); \ - } while (0) - -void json_free(struct json_object *); +void libjson_free(struct json_object *); -const char *json_to_string(struct json_object *); -const char *json_to_string_pretty(struct json_object *); -struct json_object *json_from_string(const char *); +const char *libjson_to_string(struct json_object *); +const char *libjson_to_string_pretty(struct json_object *); +struct json_object *libjson_from_string(const char *); -int json_clone(const struct json_object *, const char *key, struct json_object **value); +int libjson_clone(const struct json_object *, const char *key, struct json_object **value); -int json_send(struct json_object *, int fd); -struct json_object *json_recv(int fd); +int libjson_send(struct json_object *, int fd); +struct json_object *libjson_recv(int fd); -int json_new_object(struct json_object **); -int json_new_array(struct json_object **); +int libjson_new_object(struct json_object **); +int libjson_new_array(struct json_object **); -int json_has(const struct json_object *, const char *key); +int libjson_has(const struct json_object *, const char *key); -int json_get(const struct json_object *, const char *key, struct json_object **value); -int json_get_string(const struct json_object *, const char *key, const char **value); -int json_get_int(const struct json_object *, const char *key, int64_t *value); +int libjson_get(const struct json_object *, const char *key, struct json_object **value); +int libjson_get_string(const struct json_object *, const char *key, const char **value); +int libjson_get_int(const struct json_object *, const char *key, int64_t *value); -int json_set(struct json_object *, const char *key, struct json_object *value); -int json_set_string(struct json_object *, const char *key, const char *value); -int json_set_int(struct json_object *, const char *key, int64_t value); +int libjson_set(struct json_object *, const char *key, struct json_object *value); +int libjson_set_string(struct json_object *, const char *key, const char *value); +int libjson_set_int(struct json_object *, const char *key, int64_t value); -int json_set_const_key(struct json_object *, const char *, struct json_object *value); -int json_set_string_const_key(struct json_object *, const char *, const char *value); -int json_set_int_const_key(struct json_object *, const char *, int64_t value); +int libjson_set_const_key(struct json_object *, const char *, struct json_object *value); +int libjson_set_string_const_key(struct json_object *, const char *, const char *value); +int libjson_set_int_const_key(struct json_object *, const char *, int64_t value); -int json_append(struct json_object *arr, struct json_object *elem); +int libjson_append(struct json_object *arr, struct json_object *elem); #endif -- cgit v1.2.3