oweals/libubox.git
8 years agouloop: move kqueue code into a separate file
Felix Fietkau [Tue, 17 May 2016 10:24:04 +0000 (12:24 +0200)]
uloop: move kqueue code into a separate file

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agoblobmsg_json: simplify add_separator and fix thread-safety
Matthias Schiffer [Wed, 6 Apr 2016 15:40:22 +0000 (17:40 +0200)]
blobmsg_json: simplify add_separator and fix thread-safety

The hard-coded length limits are replaced with strlen to make the code more
robust.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
8 years agojshn: use an avl tree for env variables to speed up processing of bigger json files
Felix Fietkau [Sat, 5 Mar 2016 17:51:31 +0000 (18:51 +0100)]
jshn: use an avl tree for env variables to speed up processing of bigger json files

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agoexamples: add shunit2 tests for json_script
Yousong Zhou [Wed, 17 Feb 2016 07:45:06 +0000 (15:45 +0800)]
examples: add shunit2 tests for json_script

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
8 years agojson_script: add "isdir" support
Yousong Zhou [Wed, 17 Feb 2016 07:45:05 +0000 (15:45 +0800)]
json_script: add "isdir" support

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
8 years agoblobmsg_json: support json_type_null in blobmsg_add_json_element()
Jo-Philipp Wich [Tue, 9 Feb 2016 21:51:41 +0000 (22:51 +0100)]
blobmsg_json: support json_type_null in blobmsg_add_json_element()

We already serialize BLOBMSG_TYPE_UNSPEC as "null" so represent JSON null
values as blob attribute type unspec with payload size zero.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
8 years agousock: implement usock_inet_timeout() with RFC6555 support
Felix Fietkau [Thu, 28 Jan 2016 10:56:46 +0000 (11:56 +0100)]
usock: implement usock_inet_timeout() with RFC6555 support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agoustream-fd: handle ENOTCONN for read/write on not-yet-connected sockets
Felix Fietkau [Fri, 15 Jan 2016 20:35:48 +0000 (21:35 +0100)]
ustream-fd: handle ENOTCONN for read/write on not-yet-connected sockets

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agolua: add gc/delete support for processes
Felix Fietkau [Fri, 15 Jan 2016 20:25:48 +0000 (21:25 +0100)]
lua: add gc/delete support for processes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agolua: create a common function for userdata with gc
Felix Fietkau [Fri, 15 Jan 2016 20:19:47 +0000 (21:19 +0100)]
lua: create a common function for userdata with gc

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agousock: add usock_inet, which returns the remote address
Felix Fietkau [Fri, 15 Jan 2016 20:04:16 +0000 (21:04 +0100)]
usock: add usock_inet, which returns the remote address

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agolibubox: lua: use pkg-config built in module to search for alternatives
Karl Palsson [Thu, 24 Sep 2015 15:14:04 +0000 (15:14 +0000)]
libubox: lua: use pkg-config built in module to search for alternatives

Different distributions have different names for the lua 5.1 package.
Use cmake's built in pkg-config support to search for the first one,
rather than running it explicitly and searching for a single version.

Signed-off-by: Karl Palsson <karlp@remake.is>
9 years agojson_script: allow non-string types in command arguments
Felix Fietkau [Sun, 8 Nov 2015 19:19:08 +0000 (20:19 +0100)]
json_script: allow non-string types in command arguments

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojson_script: add support for aborting script processing
Felix Fietkau [Fri, 6 Nov 2015 21:58:15 +0000 (22:58 +0100)]
json_script: add support for aborting script processing

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoulog: avoid accidental /dev/kmsg creation
Sergiy Kibrik [Tue, 18 Aug 2015 06:28:39 +0000 (09:28 +0300)]
ulog: avoid accidental /dev/kmsg creation

Race is possible in ulog_kmsg(): if no /dev/kmsg exists
(e.g. while /dev gets re-mounted) regular file created instead.
>From this point system goes without kernel logger:
special character file can't be created anymore, all clients keep
overwriting single message in regular file.

To avoid this we open file in "r+" mode which doesn't create
file if it's not found.

Signed-off-by: Sergiy Kibrik <sakib@meta.ua>
Cc: John Crispin <blogic@openwrt.org>
9 years agob64_encode(): fixed input[] not initialized warn under gcc 4.4.5
Bachtin, Dmitri [Wed, 9 Sep 2015 07:23:58 +0000 (09:23 +0200)]
b64_encode(): fixed input[] not initialized warn under gcc 4.4.5

Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
9 years agoBuild static version of libblobmsg_json
Bachtin, Dmitri [Wed, 9 Sep 2015 07:23:57 +0000 (09:23 +0200)]
Build static version of libblobmsg_json

Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
9 years agoustream-fd: handle uloop errors
Philip Craig [Mon, 13 Jul 2015 02:12:28 +0000 (12:12 +1000)]
ustream-fd: handle uloop errors

The default uloop error handling is to delete the fd. Continue to do
that, but also set the write_error flag and notify the user.

Signed-off-by: Philip Craig <philipjcraig@gmail.com>
9 years agomd5: include utils.h instead of endian.h to fix portability issues
Felix Fietkau [Mon, 29 Jun 2015 14:13:08 +0000 (16:13 +0200)]
md5: include utils.h instead of endian.h to fix portability issues

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agomd5: include endian.h for musl, otherwise hashes are invalid for BE
Steven Barth [Mon, 29 Jun 2015 14:01:04 +0000 (16:01 +0200)]
md5: include endian.h for musl, otherwise hashes are invalid for BE

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoulog: always use stderr for ulog_stdio().
Yousong Zhou [Thu, 4 Jun 2015 13:41:38 +0000 (21:41 +0800)]
ulog: always use stderr for ulog_stdio().

stdout is for normal program output.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agolibubox: cmake: Add BUILD_EXAMPLES option
Nikolay Dimitrov [Sat, 6 Jun 2015 15:04:19 +0000 (18:04 +0300)]
libubox: cmake: Add BUILD_EXAMPLES option

Add ability to skip building the examples. The default value is ON to follow
the original cmake behavior.

Signed-off-by: Nikolay Dimitrov <picmaster@mail.bg>
9 years agoustream-fd: stop trying to read when s->read_blocked is set.
Yousong Zhou [Thu, 4 Jun 2015 13:41:42 +0000 (21:41 +0800)]
ustream-fd: stop trying to read when s->read_blocked is set.

User's s->notify_read is called in ustream_fill_read().  If
s->read_blocked is set there, then stop reading more.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoustream-fd: readability change.
Yousong Zhou [Thu, 4 Jun 2015 13:41:41 +0000 (21:41 +0800)]
ustream-fd: readability change.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoustream: tweak ustream_prepare_buf() a bit.
Yousong Zhou [Thu, 4 Jun 2015 13:41:40 +0000 (21:41 +0800)]
ustream: tweak ustream_prepare_buf() a bit.

No functional change.

 - Reuse existing NULL check on buf.
 - Add some comments for ease of reading the code.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoubox: CMake: fix json-c detection
Yegor Yefremov [Mon, 27 Apr 2015 20:13:42 +0000 (22:13 +0200)]
ubox: CMake: fix json-c detection

Use PKG_SEARCH_MODULE() to detect json-c library,
otherwise the search fails, if both json-c and json
are not present in pkg-config database.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
9 years agoadd a base64 implementation (based on FreeBSD code)
Felix Fietkau [Fri, 8 May 2015 12:28:51 +0000 (14:28 +0200)]
add a base64 implementation (based on FreeBSD code)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoallow process callback to call uloop_end()
John Crispin [Sat, 21 Mar 2015 04:49:38 +0000 (05:49 +0100)]
allow process callback to call uloop_end()

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoulog: implement ulog_close()
Jo-Philipp Wich [Thu, 26 Feb 2015 12:35:50 +0000 (13:35 +0100)]
ulog: implement ulog_close()

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoulog: introduce new simple logging api
Jo-Philipp Wich [Wed, 25 Feb 2015 19:42:03 +0000 (20:42 +0100)]
ulog: introduce new simple logging api

The ulog api is intended to be used by procd, fstools, ubox etc. to provide
a generic logging api for early boot messages and automatic switching between
syslog / kmsg / stdout depending on the way the process is executed.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agouloop: ignore SIGPIPE by default
Rafał Miłecki [Tue, 27 Jan 2015 07:19:31 +0000 (08:19 +0100)]
uloop: ignore SIGPIPE by default

Most app don't want to crash because of unhandled SIGPIPE. It could
happen is such trivial situations like writing to socket.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agoutils: use clock_get_time() for clock_gettime() on Apple.
Yousong Zhou [Wed, 21 Jan 2015 13:21:28 +0000 (21:21 +0800)]
utils: use clock_get_time() for clock_gettime() on Apple.

It turns out that mach_absolute_time() is not monotonic at all.  While
at it, convert the CLOCK_REALTIME implementation to using
clock_get_time() as well.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agouloop: optimize uloop_timeout_set() implementaiton a bit.
Yousong Zhou [Wed, 21 Jan 2015 13:21:27 +0000 (21:21 +0800)]
uloop: optimize uloop_timeout_set() implementaiton a bit.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoustream-fd: fix logic invert of write polling.
Yousong Zhou [Wed, 21 Jan 2015 13:21:26 +0000 (21:21 +0800)]
ustream-fd: fix logic invert of write polling.

ustream_write_pending() returns true if write buffer was flushed there.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoustream: add function ustream_read().
Yousong Zhou [Wed, 21 Jan 2015 13:21:25 +0000 (21:21 +0800)]
ustream: add function ustream_read().

It can be used to fill caller-specified buffer with data already in
ustream read buffer.  Useful in the following use pattern.

int available = ustream_pending_data(s, false);
if (available >= sizeof(struct msghdr)) {
struct msghdr h;
ustream_read(s, &h, sizeof(h));
}

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agousock: set socket flags right after creating it
Rafał Miłecki [Thu, 15 Jan 2015 11:42:52 +0000 (12:42 +0100)]
usock: set socket flags right after creating it

Otherwise some flags like USOCK_NONBLOCK wouldn't work as expected
(O_NONBLOCK affects connect behavior).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agousock: add helper waiting for socket to be ready
Rafał Miłecki [Thu, 15 Jan 2015 11:59:18 +0000 (12:59 +0100)]
usock: add helper waiting for socket to be ready

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agoexamples: add example code for json_script.
Yousong Zhou [Tue, 16 Dec 2014 21:15:37 +0000 (05:15 +0800)]
examples: add example code for json_script.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agojson_script: fix logic invert of handle_expr_not().
Yousong Zhou [Tue, 16 Dec 2014 21:15:36 +0000 (05:15 +0800)]
json_script: fix logic invert of handle_expr_not().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agojson_script: remove unneed argument check before calling __json_script_file_free().
Yousong Zhou [Wed, 12 Nov 2014 13:59:23 +0000 (21:59 +0800)]
json_script: remove unneed argument check before calling __json_script_file_free().

NULL check is present at the begining of function body.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agojson_script: fix eval_string().
Yousong Zhou [Wed, 12 Nov 2014 13:59:22 +0000 (21:59 +0800)]
json_script: fix eval_string().

- Fix handling of "%%".
 - Fix length requirement when calling blobmsg_realloc_string_buffer().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agojshn: add error handling and fix memory leak in jshn_format().
Yousong Zhou [Wed, 12 Nov 2014 13:59:20 +0000 (21:59 +0800)]
jshn: add error handling and fix memory leak in jshn_format().

Though currently jshn is more a one-shot data transformation tool and
won't leak much memory in its lifetime, people may use it as example
code, so do it right.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoblobmsg: remove unneeded assignment in blobmsg_alloc_string_buffer().
Yousong Zhou [Wed, 12 Nov 2014 13:59:19 +0000 (21:59 +0800)]
blobmsg: remove unneeded assignment in blobmsg_alloc_string_buffer().

data_dest should already be assigned by blobmsg_new() if the return
value is not NULL.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoexamples: fix build.
Yousong Zhou [Wed, 12 Nov 2014 13:59:16 +0000 (21:59 +0800)]
examples: fix build.

- runqueue-example.c: fix include path for in-tree build.
 - blobmsg-example.c: add inttypes.h for using PRIu64.
 - add examples/ subdirectory to main CMakeLists.txt

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agolua: do not hardcode /opt/local/include for Apple.
Yousong Zhou [Wed, 12 Nov 2014 13:59:15 +0000 (21:59 +0800)]
lua: do not hardcode /opt/local/include for Apple.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agolibubox: drop legacy json-c support
Yousong Zhou [Wed, 12 Nov 2014 13:59:14 +0000 (21:59 +0800)]
libubox: drop legacy json-c support

The cmake logic is wrong (E.G. PKG_CHECK_FOR_MODULES fails unless all
modules are found), and the legacy libjson.so name is also used by the other
libjson (http://sourceforge.net/projects/libjson/) which provides an
incompatible API, so just drop it.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoRevert "jshn: only keep UP_* variables around while they are needed"
Felix Fietkau [Sun, 23 Nov 2014 22:53:37 +0000 (23:53 +0100)]
Revert "jshn: only keep UP_* variables around while they are needed"

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: shorten JSON_VAR to J_V
Felix Fietkau [Sun, 23 Nov 2014 19:21:14 +0000 (20:21 +0100)]
jshn: shorten JSON_VAR to J_V

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: shorten variable names to speed up processing
Felix Fietkau [Sun, 23 Nov 2014 19:02:33 +0000 (20:02 +0100)]
jshn: shorten variable names to speed up processing

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: remove TYPE_JSON_VAR
Felix Fietkau [Sun, 23 Nov 2014 18:45:07 +0000 (19:45 +0100)]
jshn: remove TYPE_JSON_VAR

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: do not export JSON_SEQ
Felix Fietkau [Sun, 23 Nov 2014 18:44:10 +0000 (19:44 +0100)]
jshn: do not export JSON_SEQ

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: only keep UP_* variables around while they are needed
Felix Fietkau [Sun, 23 Nov 2014 18:43:56 +0000 (19:43 +0100)]
jshn: only keep UP_* variables around while they are needed

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojshn: improve performance by using let instead of $(( ))
Felix Fietkau [Sun, 23 Nov 2014 18:25:39 +0000 (19:25 +0100)]
jshn: improve performance by using let instead of $(( ))

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg_json: avoid redefinition of json_object
Felix Fietkau [Fri, 24 Oct 2014 11:40:10 +0000 (13:40 +0200)]
blobmsg_json: avoid redefinition of json_object

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agouloop: Do not override signal handlers not installed by us
Michel Stam [Mon, 13 Oct 2014 14:14:28 +0000 (16:14 +0200)]
uloop: Do not override signal handlers not installed by us

Signed-off-by: Michel Stam <m.stam@fugro.nl>
10 years agouloop: Remove uloop_cancelled variable, it is not used anywhere
Michel Stam [Mon, 13 Oct 2014 14:14:27 +0000 (16:14 +0200)]
uloop: Remove uloop_cancelled variable, it is not used anywhere

Signed-off-by: Michel Stam <m.stam@fugro.nl>
10 years agomd5: add a new implementation under permissive license
Felix Fietkau [Wed, 1 Oct 2014 14:38:17 +0000 (16:38 +0200)]
md5: add a new implementation under permissive license

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg_json: include json.h inside blobmsg_json.c instead of the public header file
Felix Fietkau [Tue, 23 Sep 2014 10:03:32 +0000 (12:03 +0200)]
blobmsg_json: include json.h inside blobmsg_json.c instead of the public header file

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoavoid using the deprecated is_error() function from json-c
Felix Fietkau [Tue, 23 Sep 2014 10:02:31 +0000 (12:02 +0200)]
avoid using the deprecated is_error() function from json-c

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agousock: add usock_port() for convenient use of numeric ports
Jo-Philipp Wich [Mon, 22 Sep 2014 16:15:58 +0000 (18:15 +0200)]
usock: add usock_port() for convenient use of numeric ports

Add a new helper function usock_port() which converts the given numeric port number
into a string using a private static buffer. This way a calling application can
conveniently use numeric port arguments without having to convert them before:

  int fd = usock(USOCK_UDP, "example.org", usock_port(80));

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agojshn: pretty print indented output with jshn -i -w
John Crispin [Mon, 4 Aug 2014 17:26:18 +0000 (19:26 +0200)]
jshn: pretty print indented output with jshn -i -w

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoblobmsg: accept NULL attr in blobmsg_get_string()
Felix Fietkau [Sun, 3 Aug 2014 13:00:54 +0000 (15:00 +0200)]
blobmsg: accept NULL attr in blobmsg_get_string()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolua/uloop: 'end' is the keyword of Lua, use 'cancel' replace it.
xfguo@credosemi.com [Sun, 27 Jul 2014 09:21:35 +0000 (17:21 +0800)]
lua/uloop: 'end' is the keyword of Lua, use 'cancel' replace it.

Signed-off-by: Xiongfei Guo <xfguo@credosemi.com>
10 years agoblob: improve out-of-memory handling
ewolfok [Tue, 8 Jul 2014 13:43:58 +0000 (21:43 +0800)]
blob: improve out-of-memory handling

Signed-off-by: Chen Bin <ewolfok@126.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg: add a helper function to reset the name of a blobmsg attribute
Felix Fietkau [Sun, 20 Jul 2014 23:24:01 +0000 (01:24 +0200)]
blobmsg: add a helper function to reset the name of a blobmsg attribute

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agojshn: do not collapse whitespace in json_load()
Jo-Philipp Wich [Tue, 15 Jul 2014 13:57:47 +0000 (15:57 +0200)]
jshn: do not collapse whitespace in json_load()

When running the test case below the $key variable holds "foo bar" instead
of the expected "foo  bar".

-- 8< --
. /usr/share/libubox/jshn.sh
json_init
json_load '{ "key": "foo  bar" }'
json_get_var key key
-- >8 --

Quote the output of the "jshn -r" backtick expression to prevent the shell
from erroneously collapsing whitespace.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agoblobmsg: add blobmsg_check_array, which returns the size of the array
Felix Fietkau [Tue, 15 Jul 2014 08:51:09 +0000 (10:51 +0200)]
blobmsg: add blobmsg_check_array, which returns the size of the array

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg-example: use blobmsg_get_string()
Felix Fietkau [Thu, 3 Jul 2014 11:50:49 +0000 (13:50 +0200)]
blobmsg-example: use blobmsg_get_string()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoexamples: fix build error
Luka Perkov [Thu, 3 Jul 2014 11:46:24 +0000 (13:46 +0200)]
examples: fix build error

Patch fixes the following error:

error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘void *’ [-Werror=format=]
   indent_printf(indent, "%s\n", blobmsg_data(data));

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoblobmsg_example: fix output
Felix Fietkau [Thu, 3 Jul 2014 10:56:40 +0000 (12:56 +0200)]
blobmsg_example: fix output

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoexamples: use PRIu64 instead %lld when printing uint64_t values
Luka Perkov [Thu, 3 Jul 2014 10:28:24 +0000 (12:28 +0200)]
examples: use PRIu64 instead %lld when printing uint64_t values

Patch fixes build failure:

error: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘uint64_t’ [-Werror=format=]
   indent_printf(indent, "%lld\n", *(uint64_t *)data);

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoexamples: add missing include
Luka Perkov [Thu, 3 Jul 2014 10:28:23 +0000 (12:28 +0200)]
examples: add missing include

Patch fixes following build error:

error: implicit declaration of function ‘close’ [-Werror=implicit-function-declaration]
  close(cl->s.fd.fd);

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoexamples: fix linking with json-c
Luka Perkov [Thu, 3 Jul 2014 10:28:22 +0000 (12:28 +0200)]
examples: fix linking with json-c

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoexamples: remove set but unused variable
Luka Perkov [Thu, 3 Jul 2014 10:28:21 +0000 (12:28 +0200)]
examples: remove set but unused variable

Fixes build failure.

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agousock: fix indentation
Luka Perkov [Thu, 3 Jul 2014 10:28:20 +0000 (12:28 +0200)]
usock: fix indentation

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoFix bug of GC in fd and timeout objects for lua binding.
Xiongfei Guo [Fri, 20 Jun 2014 10:31:21 +0000 (10:31 +0000)]
Fix bug of GC in fd and timeout objects for lua binding.

fd and timeout lua object has a __gc method in its metatable. After the object
is freed and the another new object use the same reference in __uloop_cb and
__uloop_fds, the new object will be freed by the old __gc of the old object
when garbag collecting.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
10 years agoFix bug of unref resources in Lua binding; fd method delete -> cancel.
Xiongfei Guo [Fri, 20 Jun 2014 10:31:20 +0000 (10:31 +0000)]
Fix bug of unref resources in Lua binding; fd method delete -> cancel.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
10 years agoSupport delete a fd event.
Xiongfei Guo [Fri, 20 Jun 2014 10:31:19 +0000 (10:31 +0000)]
Support delete a fd event.

When you call the fd_add, it will return an object with `delete` method.
So you can delete that event if you want.

Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
10 years agoAdded fd_add method for uloop lua binding.
Xiongfei Guo [Fri, 20 Jun 2014 10:31:18 +0000 (10:31 +0000)]
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>
10 years agoFix stack overflow bug of uloop lua binding.
Xiongfei Guo [Fri, 20 Jun 2014 10:31:17 +0000 (10:31 +0000)]
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>
10 years agobuild a static version of libubox
John Crispin [Wed, 11 Jun 2014 00:39:12 +0000 (01:39 +0100)]
build a static version of libubox

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agovlist: add static initializer macros
Felix Fietkau [Thu, 5 Jun 2014 13:28:45 +0000 (15:28 +0200)]
vlist: add static initializer macros

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg_json: use cross-platform macro for fprintf on 64-bit values
Felix Fietkau [Sat, 31 May 2014 12:48:03 +0000 (14:48 +0200)]
blobmsg_json: use cross-platform macro for fprintf on 64-bit values

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agojson_script: fix a segfault in the file free handler
Felix Fietkau [Mon, 26 May 2014 13:53:29 +0000 (15:53 +0200)]
json_script: fix a segfault in the file free handler

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblob/blobmsg: Perform explicit casts from void* to avoid compilation errors when...
Jacob Siverskog [Fri, 9 May 2014 12:31:37 +0000 (14:31 +0200)]
blob/blobmsg: Perform explicit casts from void* to avoid compilation errors when using libubox from C++.

Signed-off by: Jacob Siverskog <jacob@teenageengineering.com>

10 years agouloop: fix multiple calls to uloop_run()
Luka Perkov [Mon, 5 May 2014 00:41:34 +0000 (02:41 +0200)]
uloop: fix multiple calls to uloop_run()

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoutils: add a bitfield size macro
Felix Fietkau [Wed, 30 Apr 2014 11:27:03 +0000 (13:27 +0200)]
utils: add a bitfield size macro

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agokvlist: constify arguments
Felix Fietkau [Mon, 28 Apr 2014 15:56:08 +0000 (17:56 +0200)]
kvlist: constify arguments

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agojson_script: add json_script_run_file()
Felix Fietkau [Mon, 28 Apr 2014 15:54:25 +0000 (17:54 +0200)]
json_script: add json_script_run_file()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agojson_script: implement json_script_eval_string
Felix Fietkau [Mon, 28 Apr 2014 14:57:28 +0000 (16:57 +0200)]
json_script: implement json_script_eval_string

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg: make length variables unsigned
Felix Fietkau [Sun, 27 Apr 2014 14:32:09 +0000 (16:32 +0200)]
blobmsg: make length variables unsigned

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblob: make length variables unsigned
Felix Fietkau [Sun, 27 Apr 2014 14:29:31 +0000 (16:29 +0200)]
blob: make length variables unsigned

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agosh/jshn.sh - json_cleanup() dont pollute env with local vars
Bastian Bittorf [Sun, 20 Apr 2014 20:55:48 +0000 (22:55 +0200)]
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>
10 years agouloop: clear uloop_fd::error on add
Felix Fietkau [Sat, 26 Apr 2014 14:55:17 +0000 (16:55 +0200)]
uloop: clear uloop_fd::error on add

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays
Felix Fietkau [Sat, 26 Apr 2014 08:58:54 +0000 (10:58 +0200)]
blobmsg_json: let blobmsg_format_json_with_cb with list == true also format arrays

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblob: fix handling of custom validator callback
Felix Fietkau [Mon, 21 Apr 2014 10:02:30 +0000 (12:02 +0200)]
blob: fix handling of custom validator callback

https://dev.openwrt.org/ticket/15638

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agokvlist: avoid unused-but-set warnings in code not using the name in kvlist_for_each()
Felix Fietkau [Tue, 15 Apr 2014 14:58:55 +0000 (16:58 +0200)]
kvlist: avoid unused-but-set warnings in code not using the name in kvlist_for_each()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agomd5: remove unnecessary variable change
Felix Fietkau [Sat, 12 Apr 2014 18:25:32 +0000 (20:25 +0200)]
md5: remove unnecessary variable change

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoblobmsg_json: fix a memleak on error
Felix Fietkau [Sat, 12 Apr 2014 18:23:23 +0000 (20:23 +0200)]
blobmsg_json: fix a memleak on error

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoustream: remove unnecessary initialization
Felix Fietkau [Sat, 12 Apr 2014 18:21:13 +0000 (20:21 +0200)]
ustream: remove unnecessary initialization

Signed-off-by: Felix Fietkau <nbd@openwrt.org>