Commit graph

287 commits

Author SHA1 Message Date
Xiongfei Guo
79b56268b4 Added fd_add method for uloop lua binding.
Use uloop.fd_add like this:

    local socket = require "socket"

    udp = socket.udp()

    uloop.fd_add(
        udp, -- socket
        function( -- callback function
            ufd,    -- socket object when register the fd
            events  -- uloop events. eg. uloop.ULOOP_READ .
        )
            local words, msg_or_ip, port_or_nil = ufd:receivefrom()
            print('Recv UDP packet from '..msg_or_ip..':'..port_or_nil..' : '..words)
        end,
        uloop.ULOOP_READ -- event you want to listen
    )

The `examples/uloop-example.lua` show an example of this work.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
Xiongfei Guo
9565bf86ae Fix stack overflow bug of uloop lua binding.
The static variable `state` in `lua/uloop.c` should be clean after every callback.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24 14:30:30 +01:00
John Crispin
e130b08d98 build a static version of libubox
Signed-off-by: John Crispin <blogic@openwrt.org>
2014-06-11 01:39:12 +01:00
Felix Fietkau
949f0d00bf vlist: add static initializer macros
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-05 15:28:45 +02:00
Felix Fietkau
411d10c845 blobmsg_json: use cross-platform macro for fprintf on 64-bit values
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-31 14:48:03 +02:00
Felix Fietkau
1344d20ec0 json_script: fix a segfault in the file free handler
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-26 15:53:29 +02:00
Jacob Siverskog
4436338588 blob/blobmsg: Perform explicit casts from void* to avoid compilation errors when using libubox from C++.
Signed-off by: Jacob Siverskog <jacob@teenageengineering.com>
2014-05-09 14:33:39 +02:00
Luka Perkov
f32a53f92b uloop: fix multiple calls to uloop_run()
Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-05-05 11:24:07 +02:00
Felix Fietkau
9203927e58 utils: add a bitfield size macro
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-30 13:27:03 +02:00
Felix Fietkau
31b3893a72 kvlist: constify arguments
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-28 17:56:08 +02:00
Felix Fietkau
d416bf6655 json_script: add json_script_run_file()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-28 17:54:25 +02:00
Felix Fietkau
178fe974af json_script: implement json_script_eval_string
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-28 16:57:28 +02:00
Felix Fietkau
d07b174de8 blobmsg: make length variables unsigned
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-27 16:32:09 +02:00
Felix Fietkau
aa01be8ed0 blob: make length variables unsigned
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-27 16:29:31 +02:00
Bastian Bittorf
51766c25e9 sh/jshn.sh - json_cleanup() dont pollute env with local vars
this script is mostly sourced, so we should try to keep the pollution
of the users environment as low as possible. make the var 'tmp' local

Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
2014-04-26 21:30:33 +02:00
Felix Fietkau
73a88451dd uloop: clear uloop_fd::error on add
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-26 16:55:17 +02:00
Felix Fietkau
131b3352d9 blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-26 10:59:00 +02:00
Felix Fietkau
ef918710c0 blob: fix handling of custom validator callback
https://dev.openwrt.org/ticket/15638

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-21 12:02:32 +02:00
Felix Fietkau
c4b9eb1442 kvlist: avoid unused-but-set warnings in code not using the name in kvlist_for_each()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-15 16:58:55 +02:00
Felix Fietkau
b3a6939f38 md5: remove unnecessary variable change
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 20:25:32 +02:00
Felix Fietkau
31b2d244fd blobmsg_json: fix a memleak on error
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 20:23:23 +02:00
Felix Fietkau
c725f9f7a5 ustream: remove unnecessary initialization
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 20:21:13 +02:00
Felix Fietkau
93a4cb92c1 blobmsg: remove unnecessary initialization
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 20:20:36 +02:00
Felix Fietkau
d4b56b0940 kvlist: add a simply key/value store implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-12 01:42:44 +02:00
Felix Fietkau
f59f33f2c7 avl: add AVL_TREE macro to define an initialized struct avl_tree
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-27 17:39:53 +01:00
Felix Fietkau
93b415c08d list_compat.h: remove
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 23:06:42 +01:00
Felix Fietkau
97ec6311f2 list_compat.h: remove list_remove()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 23:00:53 +01:00
Felix Fietkau
f5e105b603 list_compat.h: remove list_add_before()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 23:00:24 +01:00
Felix Fietkau
7673f2ab47 list_compat.h: remove list_add_after()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 22:59:26 +01:00
Felix Fietkau
fdcf117ff3 list_compat.h: remove list_add_head()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 22:58:21 +01:00
Felix Fietkau
d1e59653fa list_compat.h: remove list_init_head()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 22:56:45 +01:00
Felix Fietkau
bbdfee8182 list_compat.h: remove list_entity compat define
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 22:55:45 +01:00
Felix Fietkau
3edc29942c avl.c: remove compat macros and switch to the argument order from list.h
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-20 22:54:59 +01:00
Felix Fietkau
4f44401ae8 utils: add __constructor and __hidden defines
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-18 14:04:06 +01:00
Felix Fietkau
c78b684104 blobmsg_json: unconditionally use blobmsg data/len accessor functions
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-12 20:18:12 +01:00
Felix Fietkau
58aec3c59a blobmsg: allow data/length iterator/accessor functions to work on non-blobmsg elements
This primarily helps with simplifying the ubus APIs.
blobmsg header presence is indicated by the BLOB_ATTR_EXTENDED bit in
the id_len field.

This changes the format ABI, but not the API.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-12 20:18:12 +01:00
Karl Vogel
926121113b uloop: Add flag to allow callback to be called on error conditions.
In some conditions, an application is interested in errors happening
on a file descriptor and might be able to resolve the issue in the
callback function.

This patch adds a flag to notify the uloop framework that errors
should be passed to the callback function, instead of silently
removing the fd from the polling set.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
2014-02-23 18:18:32 +01:00
Felix Fietkau
43d2d349cb jshn: drop json_select warnings when called from json_get_values()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-02 15:22:23 +01:00
Helmut Schaa
bbd846ec2d libubox: runqueue: Cancel task timeout when completeing task
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2014-01-29 03:32:30 +00:00
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