summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'json.c')
-rw-r--r--json.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/json.c b/json.c
index ca192856..92b9dbf6 100644
--- a/json.c
+++ b/json.c
@@ -128,6 +128,12 @@ static char *json_target_address(const struct json_attr_t *cursor,
case t_uinteger:
targetaddr = (char *)&cursor->addr.uinteger[offset];
break;
+ case t_short:
+ targetaddr = (char *)&cursor->addr.shortint[offset];
+ break;
+ case t_ushort:
+ targetaddr = (char *)&cursor->addr.ushortint[offset];
+ break;
case t_time:
case t_real:
targetaddr = (char *)&cursor->addr.real[offset];
@@ -197,6 +203,13 @@ static int json_internal_read_object(const char *cp,
case t_uinteger:
memcpy(lptr, &cursor->dflt.uinteger, sizeof(unsigned int));
break;
+ case t_short:
+ memcpy(lptr, &cursor->dflt.shortint, sizeof(short));
+ break;
+ case t_ushort:
+ memcpy(lptr, &cursor->dflt.ushortint,
+ sizeof(unsigned short));
+ break;
case t_time:
case t_real:
memcpy(lptr, &cursor->dflt.real, sizeof(double));
@@ -478,6 +491,18 @@ static int json_internal_read_object(const char *cp,
memcpy(lptr, &tmp, sizeof(unsigned int));
}
break;
+ case t_short:
+ {
+ short tmp = atoi(valbuf);
+ memcpy(lptr, &tmp, sizeof(short));
+ }
+ break;
+ case t_ushort:
+ {
+ unsigned short tmp = (unsigned int)atoi(valbuf);
+ memcpy(lptr, &tmp, sizeof(unsigned short));
+ }
+ break;
case t_time:
{
double tmp = iso8601_to_unix(valbuf);
@@ -645,6 +670,24 @@ int json_read_array(const char *cp, const struct json_array_t *arr,
cp = ep;
break;
#endif /* JSON_MINIMAL */
+ case t_short:
+#ifndef JSON_MINIMAL
+ arr->arr.shorts.store[offset] = (short)strtol(cp, &ep, 0);
+ if (ep == cp)
+ return JSON_ERR_BADNUM;
+ else
+ cp = ep;
+ break;
+#endif /* JSON_MINIMAL */
+ case t_ushort:
+#ifndef JSON_MINIMAL
+ arr->arr.ushorts.store[offset] = (unsigned short)strtoul(cp, &ep, 0);
+ if (ep == cp)
+ return JSON_ERR_BADNUM;
+ else
+ cp = ep;
+ break;
+#endif /* JSON_MINIMAL */
case t_time:
#ifndef JSON_MINIMAL
if (*cp != '"')