Add validation features to json_unpack()
[jansson.git] / src / value.c
index 3895882..534624c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009-2011 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -7,8 +7,6 @@
 
 #define _GNU_SOURCE
 
-#include <config.h>
-
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
 #include "hashtable.h"
 #include "jansson_private.h"
 #include "utf.h"
-#include "util.h"
 
 
-static inline void json_init(json_t *json, json_type type)
+static JSON_INLINE void json_init(json_t *json, json_type type)
 {
     json->type = type;
     json->refcount = 1;
@@ -35,7 +32,7 @@ static inline void json_init(json_t *json, json_type type)
    an object_key_t instance. */
 #define string_to_key(string)  container_of(string, object_key_t, key)
 
-static size_t hash_key(const void *ptr)
+size_t jsonp_hash_key(const void *ptr)
 {
     const char *str = ((const object_key_t *)ptr)->key;
 
@@ -51,7 +48,7 @@ static size_t hash_key(const void *ptr)
     return hash;
 }
 
-static int key_equal(const void *ptr1, const void *ptr2)
+int jsonp_key_equal(const void *ptr1, const void *ptr2)
 {
     return strcmp(((const object_key_t *)ptr1)->key,
                   ((const object_key_t *)ptr2)->key) == 0;
@@ -69,7 +66,8 @@ json_t *json_object(void)
         return NULL;
     json_init(&object->json, JSON_OBJECT);
 
-    if(hashtable_init(&object->hashtable, hash_key, key_equal,
+    if(hashtable_init(&object->hashtable,
+                      jsonp_hash_key, jsonp_key_equal,
                       free, value_decref))
     {
         free(object);
@@ -837,30 +835,21 @@ double json_number_value(const json_t *json)
 
 json_t *json_true(void)
 {
-    static json_t the_true = {
-        .type = JSON_TRUE,
-        .refcount = (size_t)-1
-    };
+    static json_t the_true = {JSON_TRUE, (size_t)-1};
     return &the_true;
 }
 
 
 json_t *json_false(void)
 {
-    static json_t the_false = {
-        .type = JSON_FALSE,
-        .refcount = (size_t)-1
-    };
+    static json_t the_false = {JSON_FALSE, (size_t)-1};
     return &the_false;
 }
 
 
 json_t *json_null(void)
 {
-    static json_t the_null = {
-        .type = JSON_NULL,
-        .refcount = (size_t)-1
-    };
+    static json_t the_null = {JSON_NULL, (size_t)-1};
     return &the_null;
 }