X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=plugin.c;h=70d2c563ba3f12329b138481be12f825efd2f2ea;hb=f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5;hp=2d5b6c1cb2d0fccd2b4483df3beebb2c5450e4cf;hpb=e0afdb10ae879d26d7f81d1dba8d47978a9a2aa9;p=project%2Frpcd.git diff --git a/plugin.c b/plugin.c index 2d5b6c1..70d2c56 100644 --- a/plugin.c +++ b/plugin.c @@ -1,7 +1,7 @@ /* * rpcd - UBUS RPC server * - * Copyright (C) 2013 Jo-Philipp Wich + * Copyright (C) 2013-2014 Jo-Philipp Wich * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -108,12 +108,9 @@ rpc_plugin_call_finish_cb(struct blob_buf *blob, int stat, void *priv) { if (c->obj) { - if (json_object_get_type(c->obj) == json_type_object || - json_object_get_type(c->obj) == json_type_array) - { - blobmsg_add_json_element(blob, NULL, c->obj); + if (json_object_get_type(c->obj) == json_type_object && + blobmsg_add_object(blob, c->obj)) rv = UBUS_STATUS_OK; - } json_object_put(c->obj); } @@ -194,7 +191,7 @@ rpc_plugin_parse_signature(struct blob_attr *sig, struct ubus_method *method) struct blob_attr *attr; struct blobmsg_policy *policy = NULL; - if (!sig || blob_id(sig) != BLOBMSG_TYPE_TABLE) + if (!sig || blobmsg_type(sig) != BLOBMSG_TYPE_TABLE) return false; n_attr = 0; @@ -213,7 +210,7 @@ rpc_plugin_parse_signature(struct blob_attr *sig, struct ubus_method *method) blobmsg_for_each_attr(attr, sig, rem) { - type = blob_id(attr); + type = blobmsg_type(attr); if (type == BLOBMSG_TYPE_INT32) { @@ -327,7 +324,9 @@ rpc_plugin_parse_exec(const char *name, int fd) if (!obj_type) return NULL; - asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name); + if (asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name) < 0) + return NULL; + obj_type->methods = methods; obj_type->n_methods = n_method;