2014-04-22 14:22:39 -04:00
|
|
|
/*
|
|
|
|
* JSON Object API
|
|
|
|
*
|
2014-04-30 15:42:11 -04:00
|
|
|
* Copyright (C) 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
2014-04-22 14:22:39 -04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2014-04-23 17:37:23 -04:00
|
|
|
#if HAVE_JSON
|
2014-05-23 09:46:06 -04:00
|
|
|
#include "json.h"
|
2014-04-23 17:37:23 -04:00
|
|
|
#endif
|
|
|
|
|
2014-04-22 14:22:39 -04:00
|
|
|
#include "cltypes.h"
|
|
|
|
#include "others.h"
|
|
|
|
|
2014-04-23 17:37:23 -04:00
|
|
|
#if HAVE_JSON
|
2014-04-22 14:22:39 -04:00
|
|
|
int cli_jsonnull(json_object *obj, const char* key);
|
|
|
|
int cli_jsonstr(json_object *obj, const char* key, const char* s);
|
2014-04-30 15:16:11 -04:00
|
|
|
int cli_jsonstrlen(json_object *obj, const char* key, const char* s, int len);
|
2014-04-24 14:22:00 -04:00
|
|
|
int cli_jsonint(json_object *obj, const char* key, int32_t i);
|
2014-04-22 14:22:39 -04:00
|
|
|
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);
|
2014-06-13 20:39:52 -04:00
|
|
|
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);
|
2014-04-29 15:39:06 -04:00
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2014-04-22 14:22:39 -04:00
|
|
|
#else
|
2014-04-24 14:22:00 -04:00
|
|
|
#define nojson_func cli_dbgmsg
|
|
|
|
|
|
|
|
/* internal functions */
|
|
|
|
int cli_json_nojson();
|
|
|
|
|
|
|
|
int cli_jsonnull_nojson(const char* key);
|
2014-04-30 15:16:11 -04:00
|
|
|
int cli_jsonstr_nojson(const char* key, const char* s);
|
|
|
|
int cli_jsonstrlen_nojson(const char* key, const char* s, int len);
|
2014-04-24 14:22:00 -04:00
|
|
|
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);
|
2014-06-13 20:39:52 -04:00
|
|
|
void *cli_jsonarray_nojson(const char *key);
|
|
|
|
int cli_jsonint_array_nojson(int32_t val);
|
2014-04-24 14:22:00 -04:00
|
|
|
|
2014-04-30 15:16:11 -04:00
|
|
|
#define cli_jsonnull(o,n) cli_jsonnull_nojson(n)
|
|
|
|
#define cli_jsonstr(o,n,s) cli_jsonstr_nojson(n,s)
|
2014-06-13 20:39:52 -04:00
|
|
|
#define cli_jsonstrlen(o,n,s,len) cli_jsonstrlen_nojson(n,s,len)
|
2014-04-30 15:16:11 -04:00
|
|
|
#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)
|
2014-06-13 20:39:52 -04:00
|
|
|
#define cli_jsonarray(o,k) cli_jsonarray_nojson(k)
|
|
|
|
#define cli_jsonint_array(o,v) cli_jsonint_array_nojson(v)
|
2014-04-22 14:22:39 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*__JSON_C_H__*/
|