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  */
17 #ifndef mod_md_md_json_h
18 #define mod_md_md_json_h
20 #include <apr_file_io.h>
22 struct apr_bucket_brigade;
23 struct apr_file_t;
25 struct md_http_t;
26 struct md_http_response_t;
27 struct md_timeperiod_t;
29 typedef struct md_json_t md_json_t;
31 typedef enum {
42 typedef enum {
48 void md_json_destroy(md_json_t *json);
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, ...);
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, ...);
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, ...);
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, ...);
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, ...);
75 /* timestamp manipulation */
76 apr_time_t md_json_get_time(const md_json_t *json, ...);
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, ...);
87 /* Array/Object manipulation */
91 /* Remove all array elements beyond max_elements */
92 apr_size_t md_json_limita(size_t max_elements, md_json_t *json, ...);
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);
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);
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);
106 /* Manipulating/Iteration on generic Arrays */
108  void *baton, const md_json_t *json, ...);
110  void *baton, md_json_t *json, ...);
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, ...);
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, ...);
120 /* Manipulating Object String values */
121 apr_status_t md_json_gets_dict(apr_table_t *dict, const md_json_t *json, ...);
124 /* Manipulating String Arrays */
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);
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);
144 /* http retrieval */
146  struct md_http_t *http, const char *url);
148  const struct md_http_response_t *res);
152 const char *md_json_dump_state(const md_json_t *json, apr_pool_t *p);
154 apr_status_t md_json_set_timeperiod(const struct md_timeperiod_t *tp, md_json_t *json, ...);
157 #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
int md_json_iterkey_cb(void *baton, const char *key, md_json_t *json)
Definition: md_json.h:117
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:637
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,...)
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
int md_json_iterkey(md_json_iterkey_cb *cb, void *baton, md_json_t *json,...)
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)
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:77
apr_status_t md_json_insertj(md_json_t *value, size_t index, md_json_t *json,...)
Definition: md_json.h:32