Commit graph

358 commits

Author SHA1 Message Date
Felix Fietkau
bc7e277276 ustream-fd: handle ENOTCONN for read/write on not-yet-connected sockets
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-15 21:35:48 +01:00
Felix Fietkau
663d7d4b88 lua: add gc/delete support for processes
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-15 21:26:43 +01:00
Felix Fietkau
a8d12b22e0 lua: create a common function for userdata with gc
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-15 21:19:47 +01:00
Felix Fietkau
f8b32f7620 usock: add usock_inet, which returns the remote address
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-15 21:04:16 +01:00
Karl Palsson
682e071ef7 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>
2015-11-22 13:17:07 +01:00
Felix Fietkau
10429bccd0 json_script: allow non-string types in command arguments
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-08 20:19:08 +01:00
Felix Fietkau
3d45c47752 json_script: add support for aborting script processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-06 22:58:15 +01:00
Sergiy Kibrik
136a519626 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>
2015-09-15 07:29:59 +02:00
Bachtin, Dmitri
d66a89f010 b64_encode(): fixed input[] not initialized warn under gcc 4.4.5
Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
2015-09-09 11:03:07 +02:00
Bachtin, Dmitri
2b89f2169b Build static version of libblobmsg_json
Signed-off-by: Dmitri Bachtin <dbachtin@init-ka.de>
2015-09-09 11:02:49 +02:00
Philip Craig
e88d816d6e 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>
2015-07-14 16:57:05 +02:00
Felix Fietkau
e7e554c194 md5: include utils.h instead of endian.h to fix portability issues
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-06-29 16:13:08 +02:00
Steven Barth
32e49d687b md5: include endian.h for musl, otherwise hashes are invalid for BE
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-29 16:09:32 +02:00
Yousong Zhou
d1c66ef113 ulog: always use stderr for ulog_stdio().
stdout is for normal program output.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-06-14 15:45:57 +02:00
Nikolay Dimitrov
4c94515cc8 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>
2015-06-14 15:25:38 +02:00
Yousong Zhou
8964d77f80 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>
2015-06-14 15:16:25 +02:00
Yousong Zhou
cead67c804 ustream-fd: readability change.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-06-14 15:16:10 +02:00
Yousong Zhou
9386d0717a 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>
2015-06-14 15:15:43 +02:00
Yegor Yefremov
791a361ad1 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>
2015-05-10 14:14:45 +02:00
Felix Fietkau
a8e70c6d36 add a base64 implementation (based on FreeBSD code)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-08 14:34:29 +02:00
John Crispin
b8d9b382e3 allow process callback to call uloop_end()
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-03-21 05:50:23 +01:00
Jo-Philipp Wich
2a9edb4642 ulog: implement ulog_close()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-02-26 13:35:50 +01:00
Jo-Philipp Wich
ca6d547205 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>
2015-02-26 10:43:56 +01:00
Rafał Miłecki
827ad8337e 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>
2015-01-28 10:51:15 +01:00
Yousong Zhou
ad9aa180d3 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>
2015-01-21 20:11:30 +01:00
Yousong Zhou
08c27ceb01 uloop: optimize uloop_timeout_set() implementaiton a bit.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-01-21 20:02:46 +01:00
Yousong Zhou
73c4b4fdfe 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>
2015-01-21 20:02:03 +01:00
Yousong Zhou
60236c4853 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>
2015-01-21 20:00:39 +01:00
Rafał Miłecki
f1c794b29e 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>
2015-01-15 13:10:58 +01:00
Rafał Miłecki
ad9b5a387d usock: add helper waiting for socket to be ready
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
2015-01-15 13:10:49 +01:00
Yousong Zhou
fecaf2f5f6 examples: add example code for json_script.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-22 15:46:35 +01:00
Yousong Zhou
13b5c1d4ca json_script: fix logic invert of handle_expr_not().
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-22 15:46:21 +01:00
Yousong Zhou
0d22684faa 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>
2014-12-11 17:59:22 +01:00
Yousong Zhou
30e6cca939 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>
2014-12-11 17:59:02 +01:00
Yousong Zhou
8c6dadbe03 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>
2014-12-11 17:58:42 +01:00
Yousong Zhou
7f1ce63a84 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>
2014-12-11 17:58:29 +01:00
Yousong Zhou
8cc3903383 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>
2014-12-11 17:57:19 +01:00
Yousong Zhou
c5d80836cd lua: do not hardcode /opt/local/include for Apple.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:57:07 +01:00
Yousong Zhou
cbf80de7f4 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>
2014-12-11 17:56:54 +01:00
Felix Fietkau
f09ae76445 Revert "jshn: only keep UP_* variables around while they are needed"
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 23:53:44 +01:00
Felix Fietkau
0bfb44f590 jshn: shorten JSON_VAR to J_V
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 20:59:49 +01:00
Felix Fietkau
d59fa8d588 jshn: shorten variable names to speed up processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 20:02:51 +01:00
Felix Fietkau
f386a0d7d8 jshn: remove TYPE_JSON_VAR
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 19:45:07 +01:00
Felix Fietkau
4a09bb0284 jshn: do not export JSON_SEQ
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 19:44:10 +01:00
Felix Fietkau
37b5203e18 jshn: only keep UP_* variables around while they are needed
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 19:43:56 +01:00
Felix Fietkau
d5d384b0ba jshn: improve performance by using let instead of $(( ))
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23 19:25:39 +01:00
Felix Fietkau
d133da5562 blobmsg_json: avoid redefinition of json_object
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-10-24 13:40:14 +02:00
Michel Stam
464e05e33b uloop: Do not override signal handlers not installed by us
Signed-off-by: Michel Stam <m.stam@fugro.nl>
2014-10-12 13:21:20 +02:00
Michel Stam
213122a083 uloop: Remove uloop_cancelled variable, it is not used anywhere
Signed-off-by: Michel Stam <m.stam@fugro.nl>
2014-10-12 13:21:17 +02:00
Felix Fietkau
bae6bd19f3 md5: add a new implementation under permissive license
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-10-01 16:39:15 +02:00