1 /*
2  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
3  * Michael Clark <michael@metaparadigm.com>
4  *
5  * This library is free software; you can redistribute it and/or modify
6  * it under the terms of the MIT license. See COPYING for details.
7  *
8  */
9 
10 #ifndef _fj_json_util_h_
11 #define _fj_json_util_h_
12 
13 #include "json_object.h"
14 
15 #ifndef fjson_min
16 #define fjson_min(a,b) ((a) < (b) ? (a) : (b))
17 #endif
18 
19 #ifndef fjson_max
20 #define fjson_max(a,b) ((a) > (b) ? (a) : (b))
21 #endif
22 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define FJSON_FILE_BUF_SIZE 4096
29 
30 /* utility functions */
31 extern struct fjson_object* fjson_object_from_file(const char *filename);
32 extern struct fjson_object* fjson_object_from_fd(int fd);
33 extern int fjson_object_to_file(const char *filename, struct fjson_object *obj);
34 extern int fjson_object_to_file_ext(const char *filename, struct fjson_object *obj, int flags);
35 extern int fjson_parse_int64(const char *buf, int64_t *retval);
36 extern int fjson_parse_double(const char *buf, double *retval);
37 
38 /**
39  * Return a string describing the type of the object.
40  * e.g. "int", or "object", etc...
41  */
42 extern const char *fjson_type_to_name(enum fjson_type o_type);
43 
44 #ifndef FJSON_NATIVE_API_ONLY
45 #define json_type_to_name fjson_type_to_name
46 #endif
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif
53