1 /*
2 * Copyright (C) 2020-2021 Bareos GmbH & Co. KG
3 * Copyright (C) 2010 SCALITY SA. All rights reserved.
4 * http://www.scality.com
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY SCALITY SA ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL SCALITY SA OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * The views and conclusions contained in the software and documentation
30 * are those of the authors and should not be interpreted as representing
31 * official policies, either expressed or implied, of SCALITY SA.
32 *
33 * https://github.com/scality/Droplet
34 */
35 #ifndef BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_JSON_ADAPTER_H_
36 #define BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_JSON_ADAPTER_H_
37
38 #ifdef SCAL_JSON_C
39
json_object_get_string_length(struct json_object * o)40 static inline long_t json_object_get_string_length(struct json_object* o)
41 {
42 long_t len;
43 json_object_get_string_len(o, &len);
44 return len;
45 }
46
47 # define json_type_int json_type_integer
48 # define json_object_new_int(i) json_object_new_integer(i)
49 # define json_object_get_int(o) json_ojbect_get_integer(o)
50
51 #else
52
json_object_get_string_length(struct json_object * o)53 static inline int json_object_get_string_length(struct json_object* o)
54 {
55 return json_object_get_string_len(o);
56 }
57
58
59 #endif
60
61 #endif // BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_JSON_ADAPTER_H_
62