Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
48 void md_json_destroy(md_json_t *json);
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 */
70 md_json_t *md_json_create_s(apr_pool_t *pool, const char *s);
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 */
76 apr_time_t md_json_get_time(const md_json_t *json, ...);
78 
79 /* json manipulation */
80 md_json_t *md_json_getj(md_json_t *json, ...);
81 md_json_t *md_json_dupj(apr_pool_t *p, const md_json_t *json, ...);
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 /* Manipulating Object String values */
117 apr_status_t md_json_gets_dict(apr_table_t *dict, const md_json_t *json, ...);
119 
120 /* Manipulating String Arrays */
124 
125 /* serialization & parsing */
127 const char *md_json_writep(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt);
129  md_json_fmt_t fmt, struct apr_file_t *f);
131  const char *fpath, apr_fileperms_t perms);
133  const char *fpath, apr_fileperms_t perms);
134 
136 apr_status_t md_json_readd(md_json_t **pjson, apr_pool_t *pool, const char *data, size_t data_len);
137 apr_status_t md_json_readf(md_json_t **pjson, apr_pool_t *pool, const char *fpath);
138 
139 
140 /* http retrieval */
142  struct md_http_t *http, const char *url);
144  const struct md_http_response_t *res);
145 
147 
148 const char *md_json_dump_state(const md_json_t *json, apr_pool_t *p);
149 
150 apr_status_t md_json_set_timeperiod(const struct md_timeperiod_t *tp, md_json_t *json, ...);
152 
153 #endif /* md_json_h */
apr_status_t md_json_set_timeperiod(const struct md_timeperiod_t *tp, md_json_t *json,...)
size_t apr_size_t
Definition: apr.h:393
apr_status_t md_json_sets_dict(apr_table_t *dict, md_json_t *json,...)
const md_json_t * md_json_getcj(const md_json_t *json,...)
Definition: md_json.h:43
struct md_json_t md_json_t
Definition: md_json.h:29
int md_json_itera(md_json_itera_cb *cb, void *baton, md_json_t *json,...)
md_json_t * md_json_copy(apr_pool_t *pool, const 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_read_http(md_json_t **pjson, apr_pool_t *pool, const struct md_http_response_t *res)
Definition: apr_arch_file_io.h:107
Definition: apr_tables.h:62
md_json_t * md_json_getj(md_json_t *json,...)
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:555
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_size_t md_json_limita(size_t max_elements, 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,...)
md_json_t * md_json_create(apr_pool_t *pool)
apr_status_t md_json_getsa(apr_array_header_t *a, const md_json_t *json,...)
md_json_t * md_json_clone(apr_pool_t *pool, const md_json_t *json)
Definition: apr_buckets.h:258
APR File I/O Handling.
apr_status_t md_json_del(md_json_t *json,...)
apr_status_t md_json_setsa(apr_array_header_t *a, md_json_t *json,...)
md_json_t * md_json_create_s(apr_pool_t *pool, const char *s)
apr_status_t md_json_http_get(md_json_t **pjson, apr_pool_t *pool, struct md_http_t *http, const char *url)
int md_json_itera_cb(void *baton, size_t index, md_json_t *json)
Definition: md_json.h:113
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_addj(const md_json_t *value, md_json_t *json,...)
apr_int64_t apr_time_t
Definition: apr_time.h:45
apr_status_t md_json_clr(md_json_t *json,...)
apr_status_t md_json_geta(apr_array_header_t *a, md_json_from_cb *cb, void *baton, const md_json_t *json,...)
apr_bucket_brigade * bb
Definition: mod_dav.h:555
apr_status_t md_json_readd(md_json_t **pjson, apr_pool_t *pool, const char *data, size_t data_len)
void md_json_destroy(md_json_t *json)
Definition: md_json.h:34
Definition: md_json.h:33
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)
apr_status_t md_json_get_timeperiod(struct md_timeperiod_t *tp, md_json_t *json,...)
apr_int32_t apr_fileperms_t
Definition: apr_file_info.h:125
apr_status_t md_json_setl(long value, md_json_t *json,...)
dav_error * src
Definition: mod_dav.h:186
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_copy_to(md_json_t *dest, const md_json_t *src,...)
struct md_http_t md_http_t
Definition: md_http.h:25
apr_status_t md_json_pass_to(void *value, md_json_t *json, apr_pool_t *p, void *baton)
apr_status_t md_json_clone_to(void *value, md_json_t *json, apr_pool_t *p, void *baton)
proxy_worker proxy_server_conf char * url
Definition: mod_proxy.h:636
apr_status_t md_json_pass_from(void **pvalue, md_json_t *json, apr_pool_t *p, void *baton)
const char * md_json_writep(const md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt)
int md_json_has_key(const md_json_t *json,...)
double md_json_getn(const md_json_t *json,...)
apr_status_t md_json_set_time(apr_time_t value, md_json_t *json,...)
md_json_fmt_t
Definition: md_json.h:42
apr_status_t md_json_to_cb(void *value, md_json_t *json, apr_pool_t *p, void *baton)
Definition: md_json.h:95
apr_status_t md_json_readb(md_json_t **pjson, apr_pool_t *pool, struct apr_bucket_brigade *bb)
apr_pool_t * p
const char * md_json_dups(apr_pool_t *p, const md_json_t *json,...)
apr_status_t md_json_dupsa(apr_array_header_t *a, apr_pool_t *p, md_json_t *json,...)
Definition: md_json.h:36
Definition: md_json.h:44
Definition: md_json.h:35
apr_status_t md_json_setb(int value, md_json_t *json,...)
md_json_t * md_json_dupj(apr_pool_t *p, const md_json_t *json,...)
const char * md_json_dump_state(const md_json_t *json, apr_pool_t *p)
long md_json_getl(const md_json_t *json,...)
apr_status_t md_json_sets(const char *s, 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)
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
Definition: md_json.h:38
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
Definition: md_time.h:27
int apr_status_t
Definition: apr_errno.h:44
apr_status_t md_json_setn(double value, md_json_t *json,...)
int md_json_getb(const md_json_t *json,...)
apr_time_t md_json_get_time(const md_json_t *json,...)
Definition: md_json.h:37
const char * md_json_gets(const md_json_t *json,...)
int md_json_is(const md_json_type_t type, md_json_t *json,...)
apr_status_t md_json_readf(md_json_t **pjson, apr_pool_t *pool, const char *fpath)
md_json_type_t
Definition: md_json.h:31
apr_status_t md_json_writeb(const md_json_t *json, md_json_fmt_t fmt, struct apr_bucket_brigade *bb)
Definition: md_http.h:76
apr_status_t md_json_insertj(md_json_t *value, size_t index, md_json_t *json,...)
Definition: md_json.h:32