/usr/include/searpc-utils.h is in libsearpc-dev 3.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #include <glib.h>
#include <glib-object.h>
#include <jansson.h>
#define SEARPC_JSON_DOMAIN g_quark_from_string("SEARPC_JSON")
typedef enum {
SEARPC_JSON_ERROR_LOAD,
SEARPC_JSON_ERROR_PACK,
SEARPC_JSON_ERROR_UPACK
} SEARPCJSONERROR;
json_t *json_gobject_serialize (GObject *);
GObject *json_gobject_deserialize (GType , json_t *);
inline static void setjetoge(const json_error_t *jerror, GError **error)
{
/* Load is the only function I use which reports errors */
g_set_error(error, SEARPC_JSON_DOMAIN, SEARPC_JSON_ERROR_LOAD, "%s", jerror->text);
}
inline static const char *json_object_get_string_or_null_member (json_t *object,const char *member_name)
{
json_t *ret = json_object_get (object, member_name);
if (ret)
return json_string_value(ret);
else
return NULL;
}
inline static void json_object_set_string_or_null_member (json_t *object,const char *member_name,const char *value)
{
if (value)
json_object_set_new(object,member_name, json_string(value));
else
json_object_set_new(object,member_name, json_null());
}
inline static const char *json_array_get_string_or_null_element (json_t *array, size_t index)
{
json_t *ret=json_array_get (array,index);
if (ret)
return json_string_value (ret);
else
return NULL;
}
inline static void json_array_add_string_or_null_element (json_t *array, const char *value)
{
if (value)
json_array_append_new (array, json_string (value));
else
json_array_append_new (array, json_null ());
}
inline static json_int_t json_array_get_int_element (json_t *array, size_t index)
{
return json_integer_value (json_array_get (array, index));
}
inline static const json_t *json_array_get_json_or_null_element (json_t *array, size_t index)
{
return json_array_get (array, index);
}
inline static void json_array_add_json_or_null_element (json_t *array, const json_t *value)
{
if (value) {
json_t *obj = json_deep_copy((json_t*)value);
json_array_append_new (array, obj);
} else {
json_array_append_new (array, json_null ());
}
}
|