Commit graph

248 commits

Author SHA1 Message Date
Jo-Philipp Wich
e58fa88e1f jshn: add ability to pass default values to json_get_var and json_get_vars 2013-12-10 17:30:15 +00:00
Felix Fietkau
318d682d29 jshn: in json_get_values(), handle json_select errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-12-02 10:56:54 +01:00
Felix Fietkau
9636c0e79c jshn: optimize the shell code some more
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-12-01 22:06:16 +01:00
Jo-Philipp Wich
f6827c7c93 blobmsg_json: do not emit any whitespace when formatting without indentation 2013-11-27 18:56:04 +00:00
John Crispin
f100acef37 fix memset call in md5.c
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-11-19 22:53:18 +01:00
John Crispin
e8b26ce48d add md5.c to libubox
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-11-19 20:31:45 +01:00
John Crispin
bc8167eb99 runqueue: add a function that allows adding jobs to the front of the runqueue
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-11-18 12:25:21 +01:00
Felix Fietkau
a34c8f6918 jshn: refactor _jshn_append to require fewer evals
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30 11:50:39 +01:00
Felix Fietkau
dcbc14a701 jshn: improve performance by getting rid of unnecessary variables in parser related code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30 11:36:46 +01:00
Felix Fietkau
2d4ce122c4 jshn: do not export SEQ_*
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30 10:58:34 +01:00
Felix Fietkau
1a32939cb5 jshn: get rid of the table stack, use the UP_* variable instead to speed up processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30 10:58:34 +01:00
Felix Fietkau
554ed49c15 jshn: reduce the number of appends to the cleanup list to speed up processing of large json files
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-30 10:57:51 +01:00
Felix Fietkau
b7e61837e7 jshn: allow json_get_keys/values to refer to the currently selected array/table if no argument is given
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-29 15:11:42 +01:00
Felix Fietkau
b5aa522f5d jshn: add json_get_values (useful for arrays)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-29 14:59:47 +01:00
Felix Fietkau
a2453456f2 utils.h: fix name collisions in __u_bswap16 with using "val" both inside the macro and as argument
Reported-by: Markus Stenberg <markus.stenberg@iki.fi>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-24 11:33:23 +02:00
Kristian Evensen
13a9b7c709 Restore signal handler after uloop_run()
uloop_run calls uloop_setup_signals() to set up signal handling before the while
loop, but does not remove the signal handling after the loop has ended. This can
cause problems for for example applications using the ubus file descriptor in
their own event loops, and perhaps with their own signal handling.

This patch stores the signal handle that was in place when the initial
uloop_run() call was made, and restores the handle when this call returns.
For recursive calls, the signal handler is not updated.

One use-case I experienced was an application that subscribed to several ubus
objects and used the ubus file descriptor in its own event loop. Even though
ubus_register_subscriber() (which calls uloop_run()) had returned, the signal
handler was not removed. This caused SIGINT not to be caught by the application.

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22 17:26:05 +02:00
Felix Fietkau
914ef8f6b0 blobmsg: add blobmsg_len() for consistency (similar to blob_len)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-20 13:19:51 +02:00
Felix Fietkau
4bc1a3a46b jshn: add json_get_keys()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-20 00:00:42 +02:00
Felix Fietkau
734d28eb1a ustream: properly clear fields to fix ustream reuse
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-19 18:20:03 +02:00
Felix Fietkau
458c3937bc blob: add a magic offset to nesting cookies to ensure that NULL is never returned as a normal value
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-16 01:22:02 +02:00
Felix Fietkau
e9fb256ca5 vlist: constify key argument to vlist_add
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-05 21:40:04 +02:00
Felix Fietkau
76906bec1c blobmsg_json: allow signed output of integers
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-04 16:55:45 +02:00
Felix Fietkau
be458596bd blob: add blob_put_raw() for copying one or more blob attributes into the buffer directly
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-04 16:55:45 +02:00
Felix Fietkau
460d94d6e8 blobmsg-example: fix length handling in dump_table() calls 2013-09-11 17:59:33 +02:00
Felix Fietkau
04f194aa8a uloop: fix deleting pending fd events on uloop_fd_del
When a fd gets deleted internally due to errors, fd->registered gets set
to false before events are moved to the staging array.
This leads to pending events not getting cleared properly when the fd
user finally calls uloop_fd_del.
Fix this by moving the check down and always checking for pending
events.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-08-01 00:01:40 +02:00
Felix Fietkau
ef9b6b92df blob/blobmsg: add null pointer checks to the *_for_each_attr functions, fix formatting
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-07-29 14:44:11 +02:00
Helmut Schaa
510e4956e5 uloop: Fix incorrect timeout
uloop timeouts are calculated based on a time value that was fetched
before any callbacks were executed. Hence, the next timeout is off by
the time the callback execution took which can lead to strange side
effects.

Fix this by calculating the next timeout based on a fresh time value.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-07-24 15:01:19 +02:00
John Crispin
11e8afea0f runqueue should cal the complete handler from more places
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-07-02 18:33:46 +02:00
Felix Fietkau
316e3fb6c2 safe_list: add missing null pointer check in safe_list_del()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-28 13:05:06 +02:00
Felix Fietkau
c434230a76 ustream: return NULL in ustream_get_read_buf if there's a buffer, but no data
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 19:53:09 +02:00
Felix Fietkau
6f192a6fb0 blobmsg_json: do not corrupt UTF-8 strings
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 17:19:37 +02:00
Felix Fietkau
7c5d2b3081 blobmsg_json: fix \u escaping for control characters
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 17:06:34 +02:00
Felix Fietkau
b9ebdbcc64 uloop: fix corner cases with recursive uloop_run calls
With multiple recursive calls to uloop_run, the callback for the same fd
can be run multiple times from different levels in the stack.
Prevent this by tracking the stack of uloop_fd callbacks and buffering new
incoming events for fds already on the stack.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
35cee2c206 uloop: fix event flags processing on mac os x
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
e386259632 libubox: make uloop_fd::flags generic
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
cd5238b500 uloop: fix edge trigger handling on mac os x
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 11:02:20 +02:00
Felix Fietkau
ae40b66130 uloop: rework event processing, fix use-after-free issues
Recursive calls to uloop_run() need to process already fetched events
first, before running kqueue/epoll to get more.

The state of cur_fd/cur_nfds and the event list needs to be maintained
properly to prevent accidental running of events pointing at deleted
uloop_fd structs.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-11 12:55:21 +02:00
Felix Fietkau
e5032709b2 utils: add bitfield inline ops
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-10 13:37:14 +02:00
Felix Fietkau
2851ce7edb ustream: only report stream eof once via state_change callback
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-31 11:18:26 +02:00
Felix Fietkau
70e7c09bcb ustream: only report a write error once via state_change callback
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-31 11:17:02 +02:00
Felix Fietkau
54a0b49326 blobmsg_json: add blobmsg_add_json_from_file
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-29 12:14:48 +02:00
Felix Fietkau
c4b79e4b54 runqueue: move completion handler from runqueue_process to runqueue_task to make it more generic
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:27:45 +02:00
Felix Fietkau
92fdad5448 runqueue: fix include path
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:15:05 +02:00
Felix Fietkau
cb6c1718e7 runqueue: add a simple task queueing/completion tracking implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:10:00 +02:00
Felix Fietkau
3ceb819690 ustream-example: fix container_of type errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:06:55 +02:00
Helmut Schaa
ecee1a3bea libubox: Allow to build against libjson-c > 0.9
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-05-07 15:53:36 +02:00
Felix Fietkau
dcf93f3322 safe_list: add safe_list_empty()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-04-15 15:53:57 +02:00
Felix Fietkau
ee3e7a6f9f safe_list: fix typo
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-04-15 15:39:09 +02:00
Felix Fietkau
009b4d574e list.h: implement type safety for container_of()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:55:00 +01:00
Felix Fietkau
cdb9f71971 avl: fix type handling in container_of uses
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:53:44 +01:00