summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxjson/json.c
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-05 09:40:48 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-03-05 09:40:48 +0000
commit3afdae1c3fc06fe0d465f9c8416dec27ab5c957f (patch)
tree76ebd3d5a3c92a9cfc90aba16abe65742c29df79 /src/libs/zbxjson/json.c
parentf22d3a3a6028166edc8c87825375a1dd26426f84 (diff)
downloadzabbix-3afdae1c3fc06fe0d465f9c8416dec27ab5c957f.tar.gz
zabbix-3afdae1c3fc06fe0d465f9c8416dec27ab5c957f.tar.xz
zabbix-3afdae1c3fc06fe0d465f9c8416dec27ab5c957f.zip
- [DEV-100] JSON library
git-svn-id: svn://svn.zabbix.com/trunk@5438 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxjson/json.c')
-rw-r--r--src/libs/zbxjson/json.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/libs/zbxjson/json.c b/src/libs/zbxjson/json.c
index 809cc396..131e1e08 100644
--- a/src/libs/zbxjson/json.c
+++ b/src/libs/zbxjson/json.c
@@ -554,7 +554,7 @@ static const char *zbx_json_decodeint(const char *p, char *string, size_t len)
char *o = string;
while (*p != '\0') { /* this should never happen */
- if (*p < '0' || *p > '9') {
+ if ((*p < '0' || *p > '9') && *p != '-') {
*o = '\0';
return p;
} else if (o - string < len - 1/*'\0'*/)
@@ -684,7 +684,7 @@ int zbx_json_brackets_open(const char *p, struct zbx_json_parse *jp)
{
if (NULL == (jp->end = __zbx_json_rbracket(p))) {
zbx_set_json_strerror("Can't open JSON object or array \"%.64s\"",
- p);
+ p);
return FAIL;
}
@@ -695,6 +695,35 @@ int zbx_json_brackets_open(const char *p, struct zbx_json_parse *jp)
/******************************************************************************
* *
+ * Function: zbx_json_brackets_by_name *
+ * *
+ * Purpose: *
+ * *
+ * Parameters: *
+ * *
+ * Return value: SUCCESS - processed succesfully *
+ * FAIL - an error occured *
+ * *
+ * Author: Aleksander Vladishev *
+ * *
+ * Comments: *
+ * *
+ ******************************************************************************/
+int zbx_json_brackets_by_name(struct zbx_json_parse *jp, const char *name, struct zbx_json_parse *out)
+{
+ const char *p = NULL;
+
+ if (NULL == (p = zbx_json_pair_by_name(jp, name)))
+ return FAIL;
+
+ if (FAIL == zbx_json_brackets_open(p, out))
+ return FAIL;
+
+ return SUCCEED;
+}
+
+/******************************************************************************
+ * *
* Function: zbx_json_type *
* *
* Purpose: return type of pointed value *
@@ -712,7 +741,7 @@ zbx_json_type_t zbx_json_type(const char *p)
{
if (*p == '"')
return ZBX_JSON_TYPE_STRING;
- if (*p >= '0' && *p <= '9')
+ if ((*p >= '0' && *p <= '9') || *p == '-')
return ZBX_JSON_TYPE_INT;
if (*p == '[')
return ZBX_JSON_TYPE_ARRAY;