cli: use ubus_invoke() instead of low level handling
authorFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 16:27:08 +0000 (17:27 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 16:27:11 +0000 (17:27 +0100)
cli.c

diff --git a/cli.c b/cli.c
index a1c90fee8cc42f13436fa7aed466cde2091a4c54..45addc69cf79a3051ea2114ee697a3e51e49db53 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -96,6 +96,7 @@ int main(int argc, char **argv)
 
                ubus_start_request(ctx, &req, b.head, UBUS_MSG_LOOKUP, 0);
                req.raw_data_cb = receive_lookup;
+               ret = ubus_complete_request(ctx, &req);
        } else if (!strcmp(cmd, "call")) {
                if (argc < 4 || argc > 5)
                        return usage(argv[0]);
@@ -105,16 +106,11 @@ int main(int argc, char **argv)
                        return 1;
                }
 
-               blob_buf_init(&b, 0);
-               blob_put_int32(&b, UBUS_ATTR_OBJID, objid);
-               blob_put_string(&b, UBUS_ATTR_METHOD, argv[3]);
-               ubus_start_request(ctx, &req, b.head, UBUS_MSG_INVOKE, objid);
-               req.data_cb = receive_data;
+               ret = ubus_invoke(ctx, objid, argv[3], NULL, receive_data, NULL);
        } else {
                return usage(argv[0]);
        }
 
-       ret = ubus_complete_request(ctx, &req);
        if (ret)
                fprintf(stderr, "Failed: %s\n", ubus_strerror(ret));