Просмотр исходного кода

ncd: Consolidate some code that appears in modules.

Ambroz Bizjak 11 лет назад
Родитель
Сommit
73a264c3d5
78 измененных файлов с 177 добавлено и 330 удалено
  1. 40 0
      ncd/module_common.h
  2. 2 4
      ncd/modules/alias.c
  3. 2 5
      ncd/modules/arithmetic.c
  4. 1 4
      ncd/modules/assert.c
  5. 1 5
      ncd/modules/backtrack.c
  6. 1 5
      ncd/modules/basic_functions.c
  7. 2 3
      ncd/modules/blocker.c
  8. 2 6
      ncd/modules/buffer.c
  9. 2 5
      ncd/modules/call2.c
  10. 1 5
      ncd/modules/choose.c
  11. 2 5
      ncd/modules/concat.c
  12. 2 4
      ncd/modules/daemon.c
  13. 2 4
      ncd/modules/depend.c
  14. 2 3
      ncd/modules/depend_scope.c
  15. 2 4
      ncd/modules/dynamic_depend.c
  16. 1 4
      ncd/modules/exit.c
  17. 2 5
      ncd/modules/explode.c
  18. 2 5
      ncd/modules/file.c
  19. 2 6
      ncd/modules/file_open.c
  20. 2 6
      ncd/modules/foreach.c
  21. 2 4
      ncd/modules/from_string.c
  22. 1 4
      ncd/modules/getargs.c
  23. 2 6
      ncd/modules/getenv.c
  24. 1 4
      ncd/modules/if.c
  25. 2 5
      ncd/modules/imperative.c
  26. 2 4
      ncd/modules/implode.c
  27. 1 5
      ncd/modules/index.c
  28. 2 4
      ncd/modules/list.c
  29. 2 5
      ncd/modules/load_module.c
  30. 2 5
      ncd/modules/log.c
  31. 1 5
      ncd/modules/logical.c
  32. 2 4
      ncd/modules/multidepend.c
  33. 2 3
      ncd/modules/net_backend_badvpn.c
  34. 2 3
      ncd/modules/net_backend_rfkill.c
  35. 2 3
      ncd/modules/net_backend_waitdevice.c
  36. 2 3
      ncd/modules/net_backend_waitlink.c
  37. 2 3
      ncd/modules/net_backend_wpa_supplicant.c
  38. 2 5
      ncd/modules/net_dns.c
  39. 2 5
      ncd/modules/net_iptables.c
  40. 2 3
      ncd/modules/net_ipv4_addr.c
  41. 2 4
      ncd/modules/net_ipv4_addr_in_network.c
  42. 2 4
      ncd/modules/net_ipv4_arp_probe.c
  43. 2 3
      ncd/modules/net_ipv4_dhcp.c
  44. 2 4
      ncd/modules/net_ipv4_route.c
  45. 2 3
      ncd/modules/net_ipv6_addr.c
  46. 2 4
      ncd/modules/net_ipv6_addr_in_network.c
  47. 2 4
      ncd/modules/net_ipv6_route.c
  48. 2 3
      ncd/modules/net_ipv6_wait_dynamic_addr.c
  49. 2 3
      ncd/modules/net_up.c
  50. 2 3
      ncd/modules/net_watch_interfaces.c
  51. 2 4
      ncd/modules/netmask.c
  52. 2 3
      ncd/modules/ondemand.c
  53. 2 6
      ncd/modules/parse.c
  54. 1 3
      ncd/modules/print.c
  55. 2 5
      ncd/modules/process_manager.c
  56. 1 3
      ncd/modules/reboot.c
  57. 2 4
      ncd/modules/ref.c
  58. 2 4
      ncd/modules/regex_match.c
  59. 2 2
      ncd/modules/run.c
  60. 2 4
      ncd/modules/runonce.c
  61. 1 5
      ncd/modules/sleep.c
  62. 2 6
      ncd/modules/socket.c
  63. 2 4
      ncd/modules/spawn.c
  64. 1 5
      ncd/modules/strcmp.c
  65. 1 5
      ncd/modules/substr.c
  66. 2 6
      ncd/modules/sys_evdev.c
  67. 2 6
      ncd/modules/sys_request_client.c
  68. 2 6
      ncd/modules/sys_request_server.c
  69. 2 5
      ncd/modules/sys_start_process.c
  70. 1 3
      ncd/modules/sys_watch_directory.c
  71. 2 3
      ncd/modules/sys_watch_input.c
  72. 2 3
      ncd/modules/sys_watch_usb.c
  73. 2 4
      ncd/modules/timer.c
  74. 2 4
      ncd/modules/to_string.c
  75. 2 6
      ncd/modules/try.c
  76. 2 6
      ncd/modules/value.c
  77. 1 5
      ncd/modules/valuemetic.c
  78. 1 4
      ncd/modules/var.c

+ 40 - 0
ncd/module_common.h

@@ -0,0 +1,40 @@
+/**
+ * @file module_common.h
+ * @author Ambroz Bizjak <ambrop7@gmail.com>
+ * 
+ * @section LICENSE
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the
+ *    names of its contributors may be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+
+#include <base/BLog.h>
+#include <ncd/NCDModule.h>
+#include <ncd/static_strings.h>
+#include <ncd/extra/value_utils.h>
+
+#define ModuleGlobal(i) ((i)->m->group->group_state)
+#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#define FunctionLog(params, ...) BContextLog(NCDModuleFunction_LogContext(params), __VA_ARGS__)

+ 2 - 4
ncd/modules/alias.c

@@ -43,12 +43,10 @@
 
 #include <misc/debug.h>
 #include <misc/balloc.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_alias.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_alias.h>
 
 #define NUM_STATIC_NAMES 4
 

+ 2 - 5
ncd/modules/arithmetic.c

@@ -70,13 +70,10 @@
 #include <limits.h>
 
 #include <misc/parse_number.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_arithmetic.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_arithmetic.h>
 
 struct boolean_instance {
     NCDModuleInst *i;

+ 1 - 4
ncd/modules/assert.c

@@ -41,13 +41,10 @@
  *   or "false".
  */
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_assert.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 static void func_new_common (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_false)
 {
     // check arguments

+ 1 - 5
ncd/modules/backtrack.c

@@ -40,14 +40,10 @@
  *   priority.
  */
 
-#include <stddef.h>
-
-#include <ncd/NCDModule.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_backtrack.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments

+ 1 - 5
ncd/modules/basic_functions.c

@@ -27,14 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <stddef.h>
-
-#include <ncd/NCDModule.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_basic_functions.h>
 
-#define FunctionLog(params, ...) BContextLog(NCDModuleFunction_LogContext(params), __VA_ARGS__)
-
 static int error_eval (NCDEvaluatorArgs args, NCDValMem *mem, NCDValRef *out, struct NCDModuleFunction_eval_params const *params)
 {
     FunctionLog(params, BLOG_ERROR, "error: failing");

+ 2 - 3
ncd/modules/blocker.c

@@ -76,11 +76,10 @@
 #include <misc/debug.h>
 #include <structure/LinkedList1.h>
 #include <structure/LinkedList0.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_blocker.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_blocker.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 6
ncd/modules/buffer.c

@@ -63,7 +63,6 @@
  *   'amount' must not be larger than the current length of the buffer.
  */
 
-#include <stddef.h>
 #include <string.h>
 #include <limits.h>
 
@@ -72,13 +71,10 @@
 #include <misc/compare.h>
 #include <misc/offset.h>
 #include <structure/SAvl.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_buffer.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_buffer.h>
 
 struct chunk;
 

+ 2 - 5
ncd/modules/call2.c

@@ -93,13 +93,10 @@
 
 #include <misc/debug.h>
 #include <misc/offset.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_call2.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_call2.h>
 
 #define STATE_WORKING 1
 #define STATE_UP 2

+ 1 - 5
ncd/modules/choose.c

@@ -43,14 +43,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_choose.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     NCDValRef result;

+ 2 - 5
ncd/modules/concat.c

@@ -39,18 +39,15 @@
  *   themselves.
  */
 
-#include <stddef.h>
 #include <string.h>
 
 #include <misc/balloc.h>
 #include <misc/offset.h>
 #include <misc/BRefTarget.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_concat.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_concat.h>
 
 struct result {
     BRefTarget ref_target;

+ 2 - 4
ncd/modules/daemon.c

@@ -55,13 +55,11 @@
 #include <misc/cmdline.h>
 #include <misc/strdup.h>
 #include <system/BProcess.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/NCDBProcessOpts.h>
 
-#include <generated/blog_channel_ncd_daemon.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_daemon.h>
 
 #define RETRY_TIME 10000
 

+ 2 - 4
ncd/modules/depend.c

@@ -62,12 +62,10 @@
 #include <misc/balloc.h>
 #include <structure/LinkedList1.h>
 #include <structure/LinkedList3.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_depend.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_depend.h>
 
 struct provide {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/depend_scope.c

@@ -88,11 +88,10 @@
 #include <misc/balloc.h>
 #include <misc/BRefTarget.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_depend_scope.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_depend_scope.h>
 
 struct scope {
     BRefTarget ref_target;

+ 2 - 4
ncd/modules/dynamic_depend.c

@@ -44,12 +44,10 @@
 #include <misc/balloc.h>
 #include <structure/LinkedList0.h>
 #include <structure/BAVL.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_dynamic_depend.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_dynamic_depend.h>
 
 struct provide;
 

+ 1 - 4
ncd/modules/exit.c

@@ -39,13 +39,10 @@
 
 #include <limits.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_exit.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 static void func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments

+ 2 - 5
ncd/modules/explode.c

@@ -51,13 +51,10 @@
 #include <misc/string_begins_with.h>
 #include <misc/substring.h>
 #include <misc/balloc.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_explode.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_explode.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 5
ncd/modules/file.c

@@ -86,13 +86,10 @@
 #include <misc/read_file.h>
 #include <misc/write_file.h>
 #include <misc/parse_number.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_file.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_file.h>
 
 struct read_instance {
     NCDModuleInst *i;

+ 2 - 6
ncd/modules/file_open.c

@@ -98,7 +98,6 @@
  *   the close() statement goes up .
  */
 
-#include <stddef.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <limits.h>
@@ -106,14 +105,11 @@
 #include <misc/debug.h>
 #include <misc/balloc.h>
 #include <misc/parse_number.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/NCDBuf.h>
 
-#include <generated/blog_channel_ncd_file_open.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_file_open.h>
 
 #define READ_BUF_SIZE 8192
 

+ 2 - 6
ncd/modules/foreach.c

@@ -73,14 +73,10 @@
 #include <misc/debug.h>
 #include <misc/offset.h>
 #include <system/BReactor.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_foreach.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_foreach.h>
 
 #define ISTATE_WORKING 1
 #define ISTATE_UP 2

+ 2 - 4
ncd/modules/from_string.c

@@ -37,13 +37,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
 #include <ncd/NCDValParser.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_from_string.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_from_string.h>
 
 struct instance {
     NCDModuleInst *i;

+ 1 - 4
ncd/modules/getargs.c

@@ -37,13 +37,10 @@
 
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_getargs.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
 };

+ 2 - 6
ncd/modules/getenv.c

@@ -39,14 +39,10 @@
 #include <stdlib.h>
 
 #include <misc/strdup.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_getenv.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_getenv.h>
 
 struct instance {
     NCDModuleInst *i;

+ 1 - 4
ncd/modules/if.c

@@ -42,13 +42,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_if.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 static void new_templ (NCDModuleInst *i, const struct NCDModuleInst_new_params *params, int is_not)
 {
     // check arguments

+ 2 - 5
ncd/modules/imperative.c

@@ -54,13 +54,10 @@
 
 #include <misc/string_begins_with.h>
 #include <misc/offset.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_imperative.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_imperative.h>
 
 #define STATE_INIT_WORKING 1
 #define STATE_INIT_CLEANING 2

+ 2 - 4
ncd/modules/implode.c

@@ -40,12 +40,10 @@
 #include <string.h>
 
 #include <misc/expstring.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_implode.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_implode.h>
 
 struct instance {
     NCDModuleInst *i;

+ 1 - 5
ncd/modules/index.c

@@ -45,15 +45,11 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <stddef.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_index.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     size_t value;

+ 2 - 4
ncd/modules/list.c

@@ -95,12 +95,10 @@
 #include <misc/offset.h>
 #include <misc/parse_number.h>
 #include <structure/IndexedList.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_list.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_list.h>
 
 struct elem {
     IndexedListNode il_node;

+ 2 - 5
ncd/modules/load_module.c

@@ -32,7 +32,6 @@
  *   load_module(string name)
  */
 
-#include <stddef.h>
 #include <limits.h>
 #include <string.h>
 #include <errno.h>
@@ -45,12 +44,10 @@
 #include <misc/offset.h>
 #include <misc/debug.h>
 #include <structure/LinkedList0.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_load_module.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_load_module.h>
 
 struct global {
     LinkedList0 modules_list;

+ 2 - 5
ncd/modules/log.c

@@ -55,13 +55,10 @@
 #include <stdio.h>
 
 #include <misc/debug.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_log.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_log.h>
 
 struct rlog_instance {
     NCDModuleInst *i;

+ 1 - 5
ncd/modules/logical.c

@@ -46,14 +46,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_logical.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     int value;

+ 2 - 4
ncd/modules/multidepend.c

@@ -74,12 +74,10 @@
 #include <misc/debug.h>
 #include <misc/balloc.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_multidepend.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_multidepend.h>
 
 struct provide {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/net_backend_badvpn.c

@@ -37,15 +37,14 @@
 #include <string.h>
 
 #include <misc/cmdline.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 
+#include <ncd/module_common.h>
+
 #include <generated/blog_channel_ncd_net_backend_badvpn.h>
 
 #define RETRY_TIME 5000
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     NCDValNullTermString ifname_nts;

+ 2 - 3
ncd/modules/net_backend_rfkill.c

@@ -49,12 +49,11 @@
 #include <dirent.h>
 
 #include <misc/string_begins_with.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDRfkillMonitor.h>
 
-#include <generated/blog_channel_ncd_net_backend_rfkill.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_backend_rfkill.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/net_backend_waitdevice.c

@@ -40,12 +40,11 @@
 #include <regex.h>
 
 #include <misc/parse_number.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 
-#include <generated/blog_channel_ncd_net_backend_waitdevice.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_backend_waitdevice.h>
 
 #define DEVPATH_REGEX "/net/[^/]+$"
 

+ 2 - 3
ncd/modules/net_backend_waitlink.c

@@ -37,13 +37,12 @@
 #include <string.h>
 
 #include <misc/get_iface_info.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 #include <ncd/extra/NCDInterfaceMonitor.h>
 
-#include <generated/blog_channel_ncd_net_backend_waitlink.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_backend_waitlink.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/net_backend_wpa_supplicant.c

@@ -57,7 +57,8 @@
 #include <misc/find_program.h>
 #include <flow/LineBuffer.h>
 #include <system/BInputProcess.h>
-#include <ncd/NCDModule.h>
+
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_net_backend_wpa_supplicant.h>
 
@@ -65,8 +66,6 @@
 #define EVENT_STRING_CONNECTED "CTRL-EVENT-CONNECTED"
 #define EVENT_STRING_DISCONNECTED "CTRL-EVENT-DISCONNECTED"
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     const char *ifname;

+ 2 - 5
ncd/modules/net_dns.c

@@ -46,14 +46,11 @@
 #include <misc/expstring.h>
 #include <misc/ipaddr.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_dns.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_net_dns.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 5
ncd/modules/net_iptables.c

@@ -114,14 +114,11 @@
 #include <misc/debug.h>
 #include <misc/find_program.h>
 #include <misc/balloc.h>
-#include <ncd/extra/BEventLock.h>
-
 #include <ncd/modules/command_template.h>
 
-#include <generated/blog_channel_ncd_net_iptables.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleGlobal(i) ((i)->m->group->group_state)
+#include <generated/blog_channel_ncd_net_iptables.h>
 
 static void template_free_func (void *vo, int is_error);
 

+ 2 - 3
ncd/modules/net_ipv4_addr.c

@@ -43,12 +43,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 
-#include <generated/blog_channel_ncd_net_ipv4_addr.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv4_addr.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/net_ipv4_addr_in_network.c

@@ -48,12 +48,10 @@
 #include <string.h>
 
 #include <misc/ipaddr.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_ipv4_addr_in_network.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv4_addr_in_network.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/net_ipv4_arp_probe.c

@@ -48,12 +48,10 @@
 
 #include <misc/ipaddr.h>
 #include <arpprobe/BArpProbe.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_ipv4_arp_probe.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv4_arp_probe.h>
 
 #define STATE_UNKNOWN 1
 #define STATE_EXIST 2

+ 2 - 3
ncd/modules/net_ipv4_dhcp.c

@@ -60,11 +60,10 @@
 #include <misc/debug.h>
 #include <misc/ipaddr.h>
 #include <dhcpclient/BDHCPClient.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_net_ipv4_dhcp.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv4_dhcp.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/net_ipv4_route.c

@@ -47,13 +47,11 @@
 #include <limits.h>
 
 #include <misc/debug.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_ipv4_route.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv4_route.h>
 
 #define TYPE_NORMAL 1
 #define TYPE_IFONLY 2

+ 2 - 3
ncd/modules/net_ipv6_addr.c

@@ -43,12 +43,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 
-#include <generated/blog_channel_ncd_net_ipv6_addr.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv6_addr.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/net_ipv6_addr_in_network.c

@@ -48,12 +48,10 @@
 #include <string.h>
 
 #include <misc/ipaddr6.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_ipv6_addr_in_network.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv6_addr_in_network.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/net_ipv6_route.c

@@ -49,13 +49,11 @@
 #include <string.h>
 
 #include <misc/debug.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_net_ipv6_route.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv6_route.h>
 
 #define TYPE_NORMAL 1
 #define TYPE_IFONLY 2

+ 2 - 3
ncd/modules/net_ipv6_wait_dynamic_addr.c

@@ -49,12 +49,11 @@
 
 #include <misc/get_iface_info.h>
 #include <misc/ipaddr6.h>
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDInterfaceMonitor.h>
 
-#include <generated/blog_channel_ncd_net_ipv6_wait_dynamic_addr.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_ipv6_wait_dynamic_addr.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/net_up.c

@@ -37,12 +37,11 @@
 
 #include <stdlib.h>
 
-#include <ncd/NCDModule.h>
 #include <ncd/extra/NCDIfConfig.h>
 
-#include <generated/blog_channel_ncd_net_up.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_up.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/net_watch_interfaces.c

@@ -54,12 +54,11 @@
 #include <misc/bsize.h>
 #include <structure/LinkedList1.h>
 #include <udevmonitor/NCDUdevManager.h>
-#include <ncd/NCDModule.h>
 #include <ncd/modules/event_template.h>
 
-#include <generated/blog_channel_ncd_net_watch_interfaces.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_net_watch_interfaces.h>
 
 #define DEVPATH_REGEX "/net/[^/]+$"
 #define DEVPATH_USB_REGEX "/usb[^/]*(/[^/]+)+/([^/]+)/net/[^/]+$"

+ 2 - 4
ncd/modules/netmask.c

@@ -56,12 +56,10 @@
 
 #include <misc/ipaddr.h>
 #include <misc/parse_number.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_netmask.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_netmask.h>
 
 struct addr_instance {
     NCDModuleInst *i;

+ 2 - 3
ncd/modules/ondemand.c

@@ -58,11 +58,10 @@
 #include <misc/offset.h>
 #include <misc/debug.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
 
-#include <generated/blog_channel_ncd_ondemand.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_ondemand.h>
 
 struct ondemand {
     NCDModuleInst *i;

+ 2 - 6
ncd/modules/parse.c

@@ -57,14 +57,10 @@
 #include <misc/ipaddr.h>
 #include <misc/ipaddr6.h>
 #include <ncd/NCDValParser.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_parse.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_parse.h>
 
 struct instance {
     NCDModuleInst *i;

+ 1 - 3
ncd/modules/print.c

@@ -54,12 +54,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <ncd/NCDModule.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_print.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct rprint_instance {
     NCDModuleInst *i;
     NCDValRef args;

+ 2 - 5
ncd/modules/process_manager.c

@@ -76,13 +76,10 @@
 #include <misc/strdup.h>
 #include <misc/balloc.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_process_manager.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_process_manager.h>
 
 #define RETRY_TIME 10000
 

+ 1 - 3
ncd/modules/reboot.c

@@ -36,12 +36,10 @@
 #include <unistd.h>
 #include <sys/reboot.h>
 
-#include <ncd/NCDModule.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_reboot.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 static void func_new_hard_reboot (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
 {
     // check arguments

+ 2 - 4
ncd/modules/ref.c

@@ -48,12 +48,10 @@
 
 #include <misc/offset.h>
 #include <structure/LinkedList0.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_ref.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_ref.h>
 
 struct refhere_instance {
     NCDModuleInst *i;

+ 2 - 4
ncd/modules/regex_match.c

@@ -74,12 +74,10 @@
 #include <misc/expstring.h>
 #include <misc/debug.h>
 #include <misc/balloc.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_regex_match.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_regex_match.h>
 
 #define MAX_MATCHES 64
 

+ 2 - 2
ncd/modules/run.c

@@ -47,9 +47,9 @@
 #include <ncd/extra/value_utils.h>
 #include <ncd/modules/command_template.h>
 
-#include <generated/blog_channel_ncd_run.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_run.h>
 
 static void template_free_func (void *vo, int is_error);
 

+ 2 - 4
ncd/modules/runonce.c

@@ -57,13 +57,11 @@
 #include <misc/cmdline.h>
 #include <misc/strdup.h>
 #include <system/BProcess.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/NCDBProcessOpts.h>
 
-#include <generated/blog_channel_ncd_runonce.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_runonce.h>
 
 #define STATE_RUNNING 1
 #define STATE_RUNNING_DIE 2

+ 1 - 5
ncd/modules/sleep.c

@@ -46,14 +46,10 @@
 #include <inttypes.h>
 #include <limits.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_sleep.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     btime_t ms_stop;

+ 2 - 6
ncd/modules/socket.c

@@ -142,16 +142,12 @@
 #include <structure/LinkedList0.h>
 #include <system/BConnection.h>
 #include <system/BConnectionGeneric.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/address_utils.h>
 #include <ncd/extra/NCDBuf.h>
 
-#include <generated/blog_channel_ncd_socket.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_socket.h>
 
 #define CONNECTION_TYPE_CONNECT 1
 #define CONNECTION_TYPE_LISTEN 2

+ 2 - 4
ncd/modules/spawn.c

@@ -57,12 +57,10 @@
 #include <misc/offset.h>
 #include <misc/debug.h>
 #include <structure/LinkedList0.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_spawn.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_spawn.h>
 
 #define STATE_WORKING 1
 #define STATE_UP 2

+ 1 - 5
ncd/modules/strcmp.c

@@ -38,14 +38,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_strcmp.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     int result;

+ 1 - 5
ncd/modules/substr.c

@@ -42,14 +42,10 @@
 #include <string.h>
 #include <limits.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_substr.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct substr_instance {
     NCDModuleInst *i;
     const char *data;

+ 2 - 6
ncd/modules/sys_evdev.c

@@ -58,17 +58,13 @@
 
 #include <misc/nonblocking.h>
 #include <misc/debug.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_sys_evdev.h>
 
 #include "linux_input_names.h"
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
-
 struct instance {
     NCDModuleInst *i;
     int evdev_fd;

+ 2 - 6
ncd/modules/sys_request_client.c

@@ -87,16 +87,12 @@
 #include <misc/offset.h>
 #include <structure/LinkedList0.h>
 #include <structure/LinkedList1.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 #include <ncd/extra/NCDRequestClient.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/address_utils.h>
 
-#include <generated/blog_channel_ncd_sys_request_client.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_sys_request_client.h>
 
 #define CSTATE_CONNECTING 1
 #define CSTATE_CONNECTED 2

+ 2 - 6
ncd/modules/sys_request_server.c

@@ -86,15 +86,11 @@
 #include <flow/PacketPassFifoQueue.h>
 #include <ncd/NCDValParser.h>
 #include <ncd/NCDValGenerator.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/address_utils.h>
 
-#include <generated/blog_channel_ncd_sys_request_server.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_sys_request_server.h>
 
 #define SEND_PAYLOAD_MTU 32768
 #define RECV_PAYLOAD_MTU 32768

+ 2 - 5
ncd/modules/sys_start_process.c

@@ -142,16 +142,13 @@
 #include <structure/LinkedList0.h>
 #include <system/BProcess.h>
 #include <system/BConnection.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
 #include <ncd/extra/NCDBuf.h>
-#include <ncd/extra/value_utils.h>
 #include <ncd/extra/build_cmdline.h>
 #include <ncd/extra/NCDBProcessOpts.h>
 
-#include <generated/blog_channel_ncd_sys_start_process.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_sys_start_process.h>
 
 #define READ_BUF_SIZE 8192
 

+ 1 - 3
ncd/modules/sys_watch_directory.c

@@ -54,12 +54,10 @@
 #include <misc/nonblocking.h>
 #include <misc/concat_strings.h>
 
-#include <ncd/NCDModule.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_sys_watch_directory.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 #define MAX_INOTIFY_EVENTS 128
 
 struct instance {

+ 2 - 3
ncd/modules/sys_watch_input.c

@@ -54,12 +54,11 @@
 #include <misc/offset.h>
 #include <structure/LinkedList1.h>
 #include <udevmonitor/NCDUdevManager.h>
-#include <ncd/NCDModule.h>
 #include <ncd/modules/event_template.h>
 
-#include <generated/blog_channel_ncd_sys_watch_input.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_sys_watch_input.h>
 
 struct device {
     char *devname;

+ 2 - 3
ncd/modules/sys_watch_usb.c

@@ -55,12 +55,11 @@
 #include <misc/parse_number.h>
 #include <structure/LinkedList1.h>
 #include <udevmonitor/NCDUdevManager.h>
-#include <ncd/NCDModule.h>
 #include <ncd/modules/event_template.h>
 
-#include <generated/blog_channel_ncd_sys_watch_usb.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_sys_watch_usb.h>
 
 struct device {
     char *devname;

+ 2 - 4
ncd/modules/timer.c

@@ -40,12 +40,10 @@
 #include <stddef.h>
 
 #include <misc/debug.h>
-#include <ncd/NCDModule.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_timer.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_timer.h>
 
 #define STATE_DOWN 1
 #define STATE_UP 2

+ 2 - 4
ncd/modules/to_string.c

@@ -37,13 +37,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
 #include <ncd/NCDValGenerator.h>
-#include <ncd/static_strings.h>
 
-#include <generated/blog_channel_ncd_to_string.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
+#include <generated/blog_channel_ncd_to_string.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 6
ncd/modules/try.c

@@ -60,14 +60,10 @@
 #include <string.h>
 
 #include <misc/offset.h>
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_try.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_try.h>
 
 struct instance {
     NCDModuleInst *i;

+ 2 - 6
ncd/modules/value.c

@@ -162,15 +162,11 @@
 #include <structure/LinkedList0.h>
 #include <structure/IndexedList.h>
 #include <structure/SAvl.h>
-#include <ncd/NCDModule.h>
 #include <ncd/NCDStringIndex.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
 
-#include <generated/blog_channel_ncd_value.h>
+#include <ncd/module_common.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-#define ModuleString(i, id) ((i)->m->group->strings[(id)])
+#include <generated/blog_channel_ncd_value.h>
 
 #define STOREDSTRING_TYPE (NCDVAL_STRING | (0 << 3))
 #define IDSTRING_TYPE (NCDVAL_STRING | (1 << 3))

+ 1 - 5
ncd/modules/valuemetic.c

@@ -57,14 +57,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
-#include <ncd/extra/value_utils.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_valuemetic.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     int result;

+ 1 - 4
ncd/modules/var.c

@@ -40,13 +40,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ncd/NCDModule.h>
-#include <ncd/static_strings.h>
+#include <ncd/module_common.h>
 
 #include <generated/blog_channel_ncd_var.h>
 
-#define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
-
 struct instance {
     NCDModuleInst *i;
     NCDValMem mem;