All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
json.h
Go to the documentation of this file.
1 /*
2  * This program is is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or (at
5  * your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 
17 /**
18  * $Id: f030a22e98c5b5257b481ce63a6694c49de33a21 $
19  * @file jpath.c
20  * @brief Implements the evaluation and parsing functions for the FreeRADIUS version of jpath.
21  *
22  * @author Arran Cudbard-Bell
23  *
24  * @copyright 2015 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
25  * @copyright 2015 Network RADIUS SARL <info@networkradius.com>
26  * @copyright 2015 The FreeRADIUS Server Project
27  */
28 #ifndef _FR_JSON_H
29 #define _FR_JSON_H
30 RCSIDH(json_h, "$Id: f030a22e98c5b5257b481ce63a6694c49de33a21 $")
31 
32 #include "config.h"
33 
34 #ifdef HAVE_JSON
35 # if defined(HAVE_JSONMC_JSON_H)
36 # include <json-c/json.h>
37 # elif defined(HAVE_JSON_JSON_H)
38 # include <json/json.h>
39 # else
40 # error "Need json-c headers"
41 # endif
42 # include "json_missing.h"
43 
44 # include <freeradius-devel/radiusd.h>
45 
46 /* jpath .c */
48 
49 size_t fr_jpath_escape_func(UNUSED REQUEST *request, char *out, size_t outlen,
50  char const *in, UNUSED void *arg);
51 
52 int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, value_data_t **out,
53  PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv,
54  json_object *root, fr_jpath_node_t const *jpath);
55 
56 char *fr_jpath_asprint(TALLOC_CTX *ctx, fr_jpath_node_t const *head);
57 
58 ssize_t fr_jpath_parse(TALLOC_CTX *ctx, fr_jpath_node_t **head, char const *in, size_t inlen);
59 
60 /* json.c */
61 int fr_json_object_to_value_data(TALLOC_CTX *ctx, value_data_t *out, json_object *object,
62  PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv);
63 
64 size_t fr_json_from_pair(char *out, size_t outlen, VALUE_PAIR const *vp);
65 
66 void fr_json_version_print(void);
67 #endif
68 #endif /* _FR_JSON_H */
#define RCSIDH(h, id)
Definition: build.h:136
Dictionary attribute.
Definition: dict.h:77
#define UNUSED
Definition: libradius.h:134
size_t fr_jpath_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
Escapes special chars.
Definition: jpath.c:110
void fr_json_version_print(void)
Print JSON-C version.
Definition: json.c:265
char * fr_jpath_asprint(TALLOC_CTX *ctx, fr_jpath_node_t const *head)
Print a node list to a string for debugging.
Definition: jpath.c:411
size_t fr_json_from_pair(char *out, size_t outlen, VALUE_PAIR const *vp)
Prints attribute as string, escaped suitably for use as JSON string.
Definition: json.c:150
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
int fr_jpath_evaluate_leaf(TALLOC_CTX *ctx, value_data_t **out, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv, json_object *root, fr_jpath_node_t const *jpath)
Evaluate a parsed jpath expression against a json-c tree.
Definition: jpath.c:379
Node in a jpath selector sequence.
Definition: jpath.c:91
int fr_json_object_to_value_data(TALLOC_CTX *ctx, value_data_t *out, json_object *object, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv)
Convert json object to value_data_t.
Definition: json.c:42
Function prototypes for missing functions in older json-c libraries.
ssize_t fr_jpath_parse(TALLOC_CTX *ctx, fr_jpath_node_t **head, char const *in, size_t inlen)
Parse a jpath string.
Definition: jpath.c:817
PW_TYPE
Internal data types used within libfreeradius.
Definition: radius.h:31