summaryrefslogtreecommitdiff
path: root/cli.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-02-11 01:21:07 +0100
committerFelix Fietkau <nbd@openwrt.org>2011-02-11 01:21:07 +0100
commitfb45e383c2985c43a9aaf42050fef039473745ce (patch)
treeb3154b4b3d4dfb8cd8518f89fd404e249c8cbf82 /cli.c
parent756d284a0add0796a92d874be58c61b4b66852c7 (diff)
downloadubus-fb45e383c2985c43a9aaf42050fef039473745ce.tar.gz
remove separate catch all list, always require a pattern argument for registering events, even if it is just *
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/cli.c b/cli.c
index 61f1bb2..d020b8e 100644
--- a/cli.c
+++ b/cli.c
@@ -108,17 +108,25 @@ static int ubus_cli_listen(struct ubus_context *ctx, int argc, char **argv)
memset(&listener, 0, sizeof(listener));
listener.cb = receive_event;
- if (!argc) {
+ if (argc > 0) {
+ event = argv[0];
+ } else {
event = "*";
- ret = ubus_register_event_handler(ctx, &listener, NULL);
+ argc = 1;
}
- for (;argc;argv++, argc--) {
- event = argv[0];
- ret = ubus_register_event_handler(ctx, &listener, argv[0]);
+ do {
+ ret = ubus_register_event_handler(ctx, &listener, event);
if (ret)
break;
- }
+
+ argv++;
+ argc--;
+ if (argc <= 0)
+ break;
+
+ event = argv[0];
+ } while (1);
if (ret) {
fprintf(stderr, "Error while registering for event '%s': %s\n",