Commit graph

39 commits

Author SHA1 Message Date
Petr Štetiar
d2e026a33d iron out all extra compiler warnings
clang-9 on x86/64 has reported following warnings/errors:

 libubus-acl.c:123:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 libubus-io.c:108:18: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 libubus-io.c:395:56: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 libubus-req.c:441:4: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:119:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_acl.c:152:5: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:348:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:352:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:357:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:362:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:367:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:447:16: error: comparison of integers of different signs: 'int' and '__size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 ubusd_acl.c:502:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:123:13: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:170:15: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:262:43: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:287:30: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_event.c:170:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_obj.c:71:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-16 23:39:16 +01:00
Hans Dedecker
34c6e818e4 cli: fix listen_timeout compile issue
Variable listen_timeout is redefined as a function resulting into
a compile issue. Define the function as ubus_cli_listen_timeout
to fix the compile issue.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2017-02-20 11:32:19 +01:00
Felix Fietkau
6eb3c9647e cli: do not use default timeout for listen
Default to listening for events forever unless -t is explicitly
specified on the command line

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-02-15 11:35:38 +01:00
Felix Fietkau
453b87f631 cli: add support for subscribing to objects
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-02-14 15:58:49 +01:00
Alexandru Ardelean
312448a5b1 cli: register event handler first, then do lookup
We seem to be getting timeout for ubus wait_for calls
every now and then.

And it's not reliably reproducible.
Looking at the code the only thing that would look like
a potetntial reason, is that between the ubus_lookup() and
ubus_register_event_handler() calls, there's a very narrow
window where the event would get sent out and we would not
get it, thus having to timeout.

It doesn't look like registering the event handler first
is a big problem for the whole wait_check_object() logic.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-10-12 20:00:35 +02:00
Zhao, Gang
b958a9aa60 cli: add timeout support for listen command
Currently 'ubus listen' command does not respect the timeout parameter,
i.e., whether timeout parameter is provided, 'ubus listen' will always
run infinitely. This patch let 'ubus listen' command support the timeout
parameter. For example, 'ubus listen -t 60' will cause the command to
exit after 60 seconds.

Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
2016-02-29 21:06:42 +01:00
Zhao, Gang
6cd8912f10 cli: static keyword tweak
Function ubus_cli_listen() is called only once, and function uloop_run()
and uloop_done() which need struct ubus_event_handler listener are
called within this function, so it's not needed to mark struct
ubus_event_handler listener as static. The same as pointer struct
ubus_context *ctx in main function.

Global struct commands is only used in this file, so it should be marked
static.

Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
2016-02-29 21:06:28 +01:00
Felix Fietkau
259450f414 cli: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:29 +01:00
Felix Fietkau
2c30506a4f cli: flush stdout after printing an event
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-12 16:56:09 +02:00
Felix Fietkau
9fda19140e cli: implement wait_for
Allows waiting for one or more objects to appear
Returns instantly if objects are already present

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-06 16:58:11 +02:00
Felix Fietkau
1e3220d9df cli: add array and table types to method signature dump 2012-09-28 23:10:23 +02:00
Felix Fietkau
f60010a424 cli: prevent indenting if simple output is requested 2012-05-06 10:22:29 +02:00
Felix Fietkau
d9211374c5 add -v 2011-09-05 04:00:20 +02:00
Felix Fietkau
460672c6da cli: indent call result data 2011-07-18 13:08:53 +02:00
Felix Fietkau
42bc27ae38 add copyright/license information 2011-06-17 16:35:11 +02:00
Felix Fietkau
7cd569acc8 suppress stderr output with -S 2011-03-27 18:28:47 +02:00
Felix Fietkau
6facb81409 improve output for scripts 2011-03-27 17:41:33 +02:00
Felix Fietkau
155f8059cc use int8 as boolean 2011-03-27 01:05:30 +01:00
Felix Fietkau
f2ee96c51d add support for timeouts on synchronous requests 2011-02-11 02:40:39 +01:00
Felix Fietkau
fb45e383c2 remove separate catch all list, always require a pattern argument for registering events, even if it is just * 2011-02-11 01:21:07 +01:00
Felix Fietkau
e76b1a29ca cli: clean up code 2011-02-07 02:30:18 +01:00
Felix Fietkau
87bb1cb171 cli: use stdout for output 2011-02-07 02:07:39 +01:00
Felix Fietkau
f9f602533a add code for sending events and fix the code for receiving events 2011-02-07 01:25:28 +01:00
Felix Fietkau
5e78a80128 more const for the signature type table 2011-02-07 00:10:57 +01:00
Felix Fietkau
7a56ab0411 add options to override the ubus socket name for the cli and the example program 2011-02-06 18:50:07 +01:00
Felix Fietkau
45c873325e cli: display proper types for the method signatures 2011-02-06 16:48:58 +01:00
Felix Fietkau
8c81142828 use the json to blobmsg library 2011-02-06 16:15:14 +01:00
Felix Fietkau
4ae1159f62 add support for parsing method calls with json arguments 2011-02-06 01:22:54 +01:00
Felix Fietkau
ed4b742f3f implement code for receiving events 2011-02-05 23:23:44 +01:00
Felix Fietkau
f87a9dc69e cli: wait for incoming events on listen 2011-02-05 23:01:48 +01:00
Felix Fietkau
f6a6b0d492 add functionality for registering anonymous objects as event listeners 2011-02-05 19:53:14 +01:00
Felix Fietkau
fa989780bd add some stub functionality for the ubus event switch 2011-02-05 01:29:52 +01:00
Felix Fietkau
f0d75430d2 cli: return the ubus ret code 2011-02-05 00:02:22 +01:00
Felix Fietkau
83a6386ede libubus: add generic lookup code 2011-01-31 18:26:24 +01:00
Felix Fietkau
23c9984a6c cli: use ubus_invoke() instead of low level handling 2011-01-31 17:27:11 +01:00
Felix Fietkau
1555e4610f add support for data replies 2011-01-31 17:18:10 +01:00
Felix Fietkau
527d252333 remove path based invoke functions, add stub implementation for invoking method calls 2011-01-31 02:41:32 +01:00
Felix Fietkau
8321f8c523 add stubs for invoke 2011-01-30 23:57:14 +01:00
Felix Fietkau
dbd4c2f121 Initial import 2011-01-30 14:16:09 +01:00