From 11f37e28898b12bf53d8df6272fa28c48d79a96b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 2 Sep 2013 17:29:06 +0200 Subject: [PATCH] Fold plugin specific headers files into the plugins .c file --- file.c | 49 +++++++++++++++++++++++++++++++++++++++- file.h | 69 -------------------------------------------------------- iwinfo.c | 8 ++++++- iwinfo.h | 28 ----------------------- luci2.c | 12 +++++++++- luci2.h | 33 --------------------------- 6 files changed, 66 insertions(+), 133 deletions(-) delete mode 100644 file.h delete mode 100644 iwinfo.h delete mode 100644 luci2.h diff --git a/file.c b/file.c index 0e8df4f..b1cfe99 100644 --- a/file.c +++ b/file.c @@ -16,9 +16,56 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "file.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "plugin.h" +/* limit of sys & proc files */ +#define RPC_FILE_MIN_SIZE (128) + +/* limit of regular files and command output data */ +#define RPC_FILE_MAX_SIZE (4096 * 64) +#define RPC_FILE_MAX_RUNTIME (3 * 1000) + +#define ustream_for_each_read_buffer(stream, ptr, len) \ + for (ptr = ustream_get_read_buf(stream, &len); \ + ptr != NULL && len > 0; \ + ustream_consume(stream, len), ptr = ustream_get_read_buf(stream, &len)) + +#define ustream_declare(us, fd, name) \ + us.stream.string_data = true; \ + us.stream.r.buffer_len = 4096; \ + us.stream.r.max_buffers = RPC_FILE_MAX_SIZE / 4096; \ + us.stream.notify_read = rpc_file_##name##_read_cb; \ + us.stream.notify_state = rpc_file_##name##_state_cb; \ + ustream_fd_init(&us, fd); + +struct rpc_file_exec_context { + struct ubus_context *context; + struct ubus_request_data request; + struct uloop_timeout timeout; + struct uloop_process process; + struct ustream_fd opipe; + struct ustream_fd epipe; + int outlen; + char *out; + int errlen; + char *err; + int stat; +}; + + static struct blob_buf buf; enum { diff --git a/file.h b/file.h deleted file mode 100644 index 0cd2592..0000000 --- a/file.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * rpcd - UBUS RPC server - * - * Copyright (C) 2013 Jo-Philipp Wich - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __RPC_FILE_H -#define __RPC_FILE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* limit of sys & proc files */ -#define RPC_FILE_MIN_SIZE (128) - -/* limit of regular files and command output data */ -#define RPC_FILE_MAX_SIZE (4096 * 64) -#define RPC_FILE_MAX_RUNTIME (3 * 1000) - -#define ustream_for_each_read_buffer(stream, ptr, len) \ - for (ptr = ustream_get_read_buf(stream, &len); \ - ptr != NULL && len > 0; \ - ustream_consume(stream, len), ptr = ustream_get_read_buf(stream, &len)) - -#define ustream_declare(us, fd, name) \ - us.stream.string_data = true; \ - us.stream.r.buffer_len = 4096; \ - us.stream.r.max_buffers = RPC_FILE_MAX_SIZE / 4096; \ - us.stream.notify_read = rpc_file_##name##_read_cb; \ - us.stream.notify_state = rpc_file_##name##_state_cb; \ - ustream_fd_init(&us, fd); - -struct rpc_file_exec_context { - struct ubus_context *context; - struct ubus_request_data request; - struct uloop_timeout timeout; - struct uloop_process process; - struct ustream_fd opipe; - struct ustream_fd epipe; - int outlen; - char *out; - int errlen; - char *err; - int stat; -}; - -#endif diff --git a/iwinfo.c b/iwinfo.c index b78a335..78f4485 100644 --- a/iwinfo.c +++ b/iwinfo.c @@ -16,9 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "iwinfo.h" +#include +#include +#include +#include +#include + #include "plugin.h" + static struct blob_buf buf; static const struct iwinfo_ops *iw; static const char *ifname; diff --git a/iwinfo.h b/iwinfo.h deleted file mode 100644 index 29ecf9f..0000000 --- a/iwinfo.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * rpcd - UBUS RPC server - * - * Copyright (C) 2013 Jo-Philipp Wich - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __RPC_IWINFO_H -#define __RPC_IWINFO_H - -#include -#include -#include -#include -#include - -#endif diff --git a/luci2.c b/luci2.c index 27eead5..276c60d 100644 --- a/luci2.c +++ b/luci2.c @@ -30,10 +30,20 @@ #include #include #include +#include +#include +#include -#include "luci2.h" #include "plugin.h" +/* limit of log size buffer */ +#define RPC_LUCI2_MAX_LOGSIZE (128 * 1024) +#define RPC_LUCI2_DEF_LOGSIZE (16 * 1024) + +/* location of menu definitions */ +#define RPC_LUCI2_MENU_FILES "/usr/share/luci2/menu.d/*.json" /* */ + + static const struct rpc_daemon_ops *ops; static struct blob_buf buf; diff --git a/luci2.h b/luci2.h deleted file mode 100644 index 41c8321..0000000 --- a/luci2.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * rpcd - UBUS RPC server - * - * Copyright (C) 2013 Jo-Philipp Wich - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __RPC_LUCI2_H -#define __RPC_LUCI2_H - -#include -#include -#include - -/* limit of log size buffer */ -#define RPC_LUCI2_MAX_LOGSIZE (128 * 1024) -#define RPC_LUCI2_DEF_LOGSIZE (16 * 1024) - -/* location of menu definitions */ -#define RPC_LUCI2_MENU_FILES "/usr/share/luci2/menu.d/*.json" - -#endif