Apache2
md_json.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef mod_md_md_json_h
18 #define mod_md_md_json_h
19 
20 #include <apr_file_io.h>
21 
22 struct apr_bucket_brigade;
23 struct apr_file_t;
24 
25 struct md_http_t;
26 struct md_http_response_t;
27 struct md_timeperiod_t;
28 
29 typedef struct md_json_t md_json_t;
30 
31 typedef enum {
40 
41 
42 typedef enum {
46 
49 
52 
53 
54 int md_json_has_key(const md_json_t *json, ...);
55 int md_json_is(const md_json_type_t type, md_json_t *json, ...);
56 
57 /* boolean manipulation */
58 int md_json_getb(const md_json_t *json, ...);
59 apr_status_t md_json_setb(int value, md_json_t *json, ...);
60 
61 /* number manipulation */
62 double md_json_getn(const md_json_t *json, ...);
63 apr_status_t md_json_setn(double value, md_json_t *json, ...);
64 
65 /* long manipulation */
66 long md_json_getl(const md_json_t *json, ...);
67 apr_status_t md_json_setl(long value, md_json_t *json, ...);
68 
69 /* string manipulation */
71 const char *md_json_gets(const md_json_t *json, ...);
72 const char *md_json_dups(apr_pool_t *p, const md_json_t *json, ...);
73 apr_status_t md_json_sets(const char *s, md_json_t *json, ...);
74 
75 /* timestamp manipulation */
78 
79 /* json manipulation */
82 const md_json_t *md_json_getcj(const md_json_t *json, ...);
83 apr_status_t md_json_setj(const md_json_t *value, md_json_t *json, ...);
84 apr_status_t md_json_addj(const md_json_t *value, md_json_t *json, ...);
85 apr_status_t md_json_insertj(md_json_t *value, size_t index, md_json_t *json, ...);
86 
87 /* Array/Object manipulation */
90 
91 /* Remove all array elements beyond max_elements */
92 apr_size_t md_json_limita(size_t max_elements, md_json_t *json, ...);
93 
94 /* conversion function from and to json */
95 typedef apr_status_t md_json_to_cb(void *value, md_json_t *json, apr_pool_t *p, void *baton);
96 typedef apr_status_t md_json_from_cb(void **pvalue, md_json_t *json, apr_pool_t *p, void *baton);
97 
98 /* identity pass through from json to json */
99 apr_status_t md_json_pass_to(void *value, md_json_t *json, apr_pool_t *p, void *baton);
100 apr_status_t md_json_pass_from(void **pvalue, md_json_t *json, apr_pool_t *p, void *baton);
101 
102 /* conversions from json to json in specified pool */
103 apr_status_t md_json_clone_to(void *value, md_json_t *json, apr_pool_t *p, void *baton);
104 apr_status_t md_json_clone_from(void **pvalue, const md_json_t *json, apr_pool_t *p, void *baton);
105 
106 /* Manipulating/Iteration on generic Arrays */
108  void *baton, const md_json_t *json, ...);
110  void *baton, md_json_t *json, ...);
111 
112 /* Called on each array element, aborts iteration when returning 0 */
113 typedef int md_json_itera_cb(void *baton, size_t index, md_json_t *json);
114 int md_json_itera(md_json_itera_cb *cb, void *baton, md_json_t *json, ...);
115 
116 /* Called on each object key, aborts iteration when returning 0 */
117 typedef int md_json_iterkey_cb(void *baton, const char* key, md_json_t *json);
118 int md_json_iterkey(md_json_iterkey_cb *cb, void *baton, md_json_t *json, ...);
119 
120 /* Manipulating Object String values */
123 
124 /* Manipulating String Arrays */
128 
129 /* serialization & parsing */
131 const char *md_json_writep(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt);
133  md_json_fmt_t fmt, struct apr_file_t *f);
135  const char *fpath, apr_fileperms_t perms);
137  const char *fpath, apr_fileperms_t perms);
138 
140 apr_status_t md_json_readd(md_json_t **pjson, apr_pool_t *pool, const char *data, size_t data_len);
141 apr_status_t md_json_readf(md_json_t **pjson, apr_pool_t *pool, const char *fpath);
142 
143 
144 /* http retrieval */
146  struct md_http_t *http, const char *url);
148  const struct md_http_response_t *res);
149 
151 
152 const char *md_json_dump_state(const md_json_t *json, apr_pool_t *p);
153 
156 
157 #endif /* md_json_h */
APR File I/O Handling.
apr_bucket_brigade * bb
Definition: mod_dav.h:555
const char * s
Definition: mod_dav.h:1327
dav_error * src
Definition: mod_dav.h:186
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:557
proxy_worker proxy_server_conf char * url
Definition: mod_proxy.h:657
int apr_status_t
Definition: apr_errno.h:44
apr_int32_t apr_fileperms_t
Definition: apr_file_info.h:125
size_t apr_size_t
Definition: apr.h:394
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
apr_int64_t apr_time_t
Definition: apr_time.h:45
struct md_http_t md_http_t
Definition: md_http.h:25
apr_status_t md_json_to_cb(void *value, md_json_t *json, apr_pool_t *p, void *baton)
Definition: md_json.h:95
md_json_t * md_json_getj(md_json_t *json,...)
apr_status_t md_json_get_timeperiod(struct md_timeperiod_t *tp, md_json_t *json,...)
apr_status_t md_json_getsa(apr_array_header_t *a, const md_json_t *json,...)
int md_json_getb(const md_json_t *json,...)
apr_status_t md_json_clr(md_json_t *json,...)
double md_json_getn(const md_json_t *json,...)
md_json_t * md_json_dupj(apr_pool_t *p, const md_json_t *json,...)
md_json_t * md_json_create(apr_pool_t *pool)
long md_json_getl(const md_json_t *json,...)
apr_status_t md_json_setn(double value, md_json_t *json,...)
md_json_fmt_t
Definition: md_json.h:42
@ MD_JSON_FMT_COMPACT
Definition: md_json.h:43
@ MD_JSON_FMT_INDENT
Definition: md_json.h:44
apr_status_t md_json_pass_from(void **pvalue, md_json_t *json, apr_pool_t *p, void *baton)
apr_status_t md_json_geta(apr_array_header_t *a, md_json_from_cb *cb, void *baton, const md_json_t *json,...)
md_json_t * md_json_clone(apr_pool_t *pool, const md_json_t *json)
const char * md_json_gets(const md_json_t *json,...)
apr_status_t md_json_set_timeperiod(const struct md_timeperiod_t *tp, md_json_t *json,...)
md_json_t * md_json_create_s(apr_pool_t *pool, const char *s)
apr_status_t md_json_freplace(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt, const char *fpath, apr_fileperms_t perms)
md_json_type_t
Definition: md_json.h:31
@ MD_JSON_TYPE_INT
Definition: md_json.h:36
@ MD_JSON_TYPE_ARRAY
Definition: md_json.h:33
@ MD_JSON_TYPE_BOOL
Definition: md_json.h:37
@ MD_JSON_TYPE_STRING
Definition: md_json.h:34
@ MD_JSON_TYPE_OBJECT
Definition: md_json.h:32
@ MD_JSON_TYPE_NULL
Definition: md_json.h:38
@ MD_JSON_TYPE_REAL
Definition: md_json.h:35
struct md_json_t md_json_t
Definition: md_json.h:29
int md_json_iterkey(md_json_iterkey_cb *cb, void *baton, md_json_t *json,...)
const md_json_t * md_json_getcj(const md_json_t *json,...)
const char * md_json_dups(apr_pool_t *p, const md_json_t *json,...)
apr_status_t md_json_seta(apr_array_header_t *a, md_json_to_cb *cb, void *baton, md_json_t *json,...)
apr_status_t md_json_gets_dict(apr_table_t *dict, const md_json_t *json,...)
apr_status_t md_json_dupsa(apr_array_header_t *a, apr_pool_t *p, md_json_t *json,...)
apr_status_t md_json_addj(const md_json_t *value, md_json_t *json,...)
const char * md_json_dump_state(const md_json_t *json, apr_pool_t *p)
apr_status_t md_json_readb(md_json_t **pjson, apr_pool_t *pool, struct apr_bucket_brigade *bb)
apr_size_t md_json_limita(size_t max_elements, md_json_t *json,...)
apr_status_t md_json_set_time(apr_time_t value, md_json_t *json,...)
int md_json_iterkey_cb(void *baton, const char *key, md_json_t *json)
Definition: md_json.h:117
apr_status_t md_json_insertj(md_json_t *value, size_t index, md_json_t *json,...)
apr_status_t md_json_fcreatex(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt, const char *fpath, apr_fileperms_t perms)
apr_status_t md_json_pass_to(void *value, md_json_t *json, apr_pool_t *p, void *baton)
apr_status_t md_json_readf(md_json_t **pjson, apr_pool_t *pool, const char *fpath)
apr_status_t md_json_copy_to(md_json_t *dest, const md_json_t *src,...)
apr_status_t md_json_read_http(md_json_t **pjson, apr_pool_t *pool, const struct md_http_response_t *res)
const char * md_json_writep(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt)
apr_status_t md_json_del(md_json_t *json,...)
apr_status_t md_json_http_get(md_json_t **pjson, apr_pool_t *pool, struct md_http_t *http, const char *url)
apr_status_t md_json_from_cb(void **pvalue, md_json_t *json, apr_pool_t *p, void *baton)
Definition: md_json.h:96
apr_status_t md_json_setj(const md_json_t *value, md_json_t *json,...)
apr_status_t md_json_clone_from(void **pvalue, const md_json_t *json, apr_pool_t *p, void *baton)
apr_status_t md_json_sets_dict(apr_table_t *dict, md_json_t *json,...)
int md_json_has_key(const md_json_t *json,...)
int md_json_itera(md_json_itera_cb *cb, void *baton, md_json_t *json,...)
apr_status_t md_json_sets(const char *s, md_json_t *json,...)
apr_time_t md_json_get_time(const md_json_t *json,...)
int md_json_itera_cb(void *baton, size_t index, md_json_t *json)
Definition: md_json.h:113
int md_json_is(const md_json_type_t type, md_json_t *json,...)
void md_json_destroy(md_json_t *json)
apr_status_t md_json_setb(int value, md_json_t *json,...)
apr_status_t md_json_readd(md_json_t **pjson, apr_pool_t *pool, const char *data, size_t data_len)
apr_status_t md_json_clone_to(void *value, md_json_t *json, apr_pool_t *p, void *baton)
apr_status_t md_json_writef(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt, struct apr_file_t *f)
apr_status_t md_json_setl(long value, md_json_t *json,...)
md_json_t * md_json_copy(apr_pool_t *pool, const md_json_t *json)
apr_status_t md_json_setsa(apr_array_header_t *a, md_json_t *json,...)
apr_status_t md_json_writeb(const md_json_t *json, md_json_fmt_t fmt, struct apr_bucket_brigade *bb)
Definition: apr_tables.h:62
Definition: apr_buckets.h:263
Definition: apr_arch_file_io.h:107
Definition: md_http.h:78
Definition: md_time.h:27
apr_pool_t * p