File: json_api.h

package info (click to toggle)
clamav 0.98.7+dfsg-0+deb6u2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 60,204 kB
  • ctags: 49,129
  • sloc: cpp: 267,090; ansic: 152,211; sh: 35,196; python: 2,630; makefile: 2,220; perl: 1,690; pascal: 1,218; lisp: 184; csh: 117; xml: 38; asm: 32; exp: 4
file content (92 lines) | stat: -rw-r--r-- 3,340 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * JSON Object API
 * 
 * Copyright (C) 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
 * 
 * Authors: Kevin Lin
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 2 as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __JSON_C_H__
#define __JSON_C_H__

#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif

#if HAVE_JSON
#include "json.h"
#endif

#include "cltypes.h"
#include "others.h"

#if HAVE_JSON
#define JSON_TIMEOUT_SKIP_CYCLES 3

int cli_json_timeout_cycle_check(cli_ctx *ctx, int *toval);
int cli_json_parse_error(json_object *root, const char *errstr);

int cli_jsonnull(json_object *obj, const char* key);
int cli_jsonstr(json_object *obj, const char* key, const char* s);
int cli_jsonstrlen(json_object *obj, const char* key, const char* s, int len);
int cli_jsonint(json_object *obj, const char* key, int32_t i);
int cli_jsonint64(json_object *obj, const char* key, int64_t i);
int cli_jsonbool(json_object *obj, const char* key, int i);
int cli_jsondouble(json_object *obj, const char* key, double d);
json_object *cli_jsonarray(json_object *obj, const char *key);
int cli_jsonint_array(json_object *obj, int32_t val);
json_object *cli_jsonobj(json_object *obj, const char *key);

#if HAVE_DEPRECATED_JSON
int json_object_object_get_ex(struct json_object *obj, const char *key, struct json_object **value);
#endif

#define JSON_KEY_FILETYPE   "FileType"
#define JSON_KEY_FILESIZE   "FileSize"

#define JSON_VALUE_FILETYPE_PDF     "CL_TYPE_PDF"
#define JSON_VALUE_FILETYPE_PPT     "CL_TYPE_MSPPT"
#define JSON_VALUE_FILETYPE_WORD    "CL_TYPE_WORD"
#define JSON_VALUE_FILETYPE_EXCEL   "CL_TYPE_MSXLS"

#else
#define nojson_func cli_dbgmsg

/* internal functions */
int cli_json_nojson(void);

int cli_jsonnull_nojson(const char* key);
int cli_jsonstr_nojson(const char* key, const char* s);
int cli_jsonstrlen_nojson(const char* key, const char* s, int len);
int cli_jsonint_nojson(const char* key, int32_t i);
int cli_jsonint64_nojson(const char* key, int64_t i);
int cli_jsonbool_nojson(const char* key, int i);
int cli_jsondouble_nojson(const char* key, double d);
void *cli_jsonarray_nojson(const char *key);
int cli_jsonint_array_nojson(int32_t val);

#define cli_jsonnull(o,n)          cli_jsonnull_nojson(n)
#define cli_jsonstr(o,n,s)         cli_jsonstr_nojson(n,s)
#define cli_jsonstrlen(o,n,s,len)  cli_jsonstrlen_nojson(n,s,len)
#define cli_jsonint(o,n,i)         cli_jsonint_nojson(n,i)
#define cli_jsonint64(o,n,i)       cli_jsonint64_nojson(n,i)
#define cli_jsonbool(o,n,b)        cli_jsonbool_nojson(n,b)
#define cli_jsondouble(o,n,d)      cli_jsondouble_nojson(n,d)
#define cli_jsonarray(o,k)         cli_jsonarray_nojson(k)
#define cli_jsonint_array(o,v)     cli_jsonint_array_nojson(v)
#endif

#endif /*__JSON_C_H__*/