aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_internal.h
diff options
context:
space:
mode:
authorAnthony PERARD <anthony.perard@citrix.com>2012-10-08 11:45:31 +0100
committerAnthony PERARD <anthony.perard@citrix.com>2012-10-08 11:45:31 +0100
commit2b3072ed0cbeed8c0385f20e92ba0f1201db8a17 (patch)
tree2064aba86fb931200cab209da33c098eba3c0f55 /tools/libxl/libxl_internal.h
parent469848a080f1be2676cb003a68363edb7de0657e (diff)
downloadxen-2b3072ed0cbeed8c0385f20e92ba0f1201db8a17.tar.gz
xen-2b3072ed0cbeed8c0385f20e92ba0f1201db8a17.tar.bz2
xen-2b3072ed0cbeed8c0385f20e92ba0f1201db8a17.zip
libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.
Those two JSON_TRUE and JSON_FALSE were types of node. But it's better to have a unique JSON_BOOL type. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.h')
-rw-r--r--tools/libxl/libxl_internal.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 6977a6da17..6744fda9af 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1433,8 +1433,7 @@ _hidden yajl_gen_status libxl__yajl_gen_enum(yajl_gen hand, const char *str);
typedef enum {
JSON_NULL,
- JSON_TRUE,
- JSON_FALSE,
+ JSON_BOOL,
JSON_INTEGER,
JSON_DOUBLE,
/* number is store in string, it's too big to be a long long or a double */
@@ -1448,6 +1447,7 @@ typedef enum {
typedef struct libxl__json_object {
libxl__json_node_type type;
union {
+ bool b;
long long i;
double d;
char *string;
@@ -1466,6 +1466,10 @@ typedef struct {
typedef struct libxl__yajl_ctx libxl__yajl_ctx;
+static inline bool libxl__json_object_is_bool(const libxl__json_object *o)
+{
+ return o != NULL && o->type == JSON_BOOL;
+}
static inline bool libxl__json_object_is_string(const libxl__json_object *o)
{
return o != NULL && o->type == JSON_STRING;
@@ -1483,6 +1487,13 @@ static inline bool libxl__json_object_is_array(const libxl__json_object *o)
return o != NULL && o->type == JSON_ARRAY;
}
+static inline bool libxl__json_object_get_bool(const libxl__json_object *o)
+{
+ if (libxl__json_object_is_bool(o))
+ return o->u.b;
+ else
+ return false;
+}
static inline
const char *libxl__json_object_get_string(const libxl__json_object *o)
{