summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-16 09:29:57 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:58:58 +0200
commitc3d60196c5b20e6209fcc649a63c6d7c1692d798 (patch)
treedcdbf0f35cd556bdbfd2e611d2579d2430460fd7 /src
parentd0b6cf4a8d61960fe97062bbc6b6f7874a2754e0 (diff)
shared/conf-parser: define a macro for the repeating argument set
The arguments have to be indentical everywhere, so let's use a macro to make things more readable. But only in the headers, in the .c files let's keep them verbose so that it's easy to see the argument list.
Diffstat (limited to 'src')
-rw-r--r--src/shared/conf-parser.h85
1 files changed, 38 insertions, 47 deletions
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index b974b7b91..aed80ee28 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -123,56 +123,57 @@ int config_parse_many(
#endif // 0
/* Generic parsers */
-int config_parse_int(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_unsigned(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_long(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_uint8(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_uint16(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_uint32(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
-int config_parse_uint64(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_double(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_iec_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_si_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_iec_uint64(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
-int config_parse_bool(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_tristate(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
-int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_path(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_strv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_sec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_nsec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
-int config_parse_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_log_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
-int config_parse_log_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_signal(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#if 0 /// UNNEEDED by elogind
-int config_parse_personality(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_ifname(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_ip_port(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#endif // 0
+#define GENERIC_PARSER_ARGS \
+ const char *unit, \
+ const char *filename, \
+ unsigned line, \
+ const char *section, \
+ unsigned section_line, \
+ const char *lvalue, \
+ int ltype, \
+ const char *rvalue, \
+ void *data, \
+ void *userdata
+int config_parse_int(GENERIC_PARSER_ARGS);
+int config_parse_unsigned(GENERIC_PARSER_ARGS);
+int config_parse_long(GENERIC_PARSER_ARGS);
+int config_parse_uint8(GENERIC_PARSER_ARGS);
+int config_parse_uint16(GENERIC_PARSER_ARGS);
+int config_parse_uint32(GENERIC_PARSER_ARGS);
+int config_parse_uint64(GENERIC_PARSER_ARGS);
+int config_parse_double(GENERIC_PARSER_ARGS);
+int config_parse_iec_size(GENERIC_PARSER_ARGS);
+int config_parse_si_size(GENERIC_PARSER_ARGS);
+int config_parse_iec_uint64(GENERIC_PARSER_ARGS);
+int config_parse_bool(GENERIC_PARSER_ARGS);
+int config_parse_tristate(GENERIC_PARSER_ARGS);
+int config_parse_string(GENERIC_PARSER_ARGS);
+int config_parse_path(GENERIC_PARSER_ARGS);
+int config_parse_strv(GENERIC_PARSER_ARGS);
+int config_parse_sec(GENERIC_PARSER_ARGS);
+int config_parse_nsec(GENERIC_PARSER_ARGS);
+int config_parse_mode(GENERIC_PARSER_ARGS);
+int config_parse_log_facility(GENERIC_PARSER_ARGS);
+int config_parse_log_level(GENERIC_PARSER_ARGS);
+int config_parse_signal(GENERIC_PARSER_ARGS);
+int config_parse_personality(GENERIC_PARSER_ARGS);
+int config_parse_ifname(GENERIC_PARSER_ARGS);
+int config_parse_ip_port(GENERIC_PARSER_ARGS);
#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \
- int function(const char *unit, \
- const char *filename, \
- unsigned line, \
- const char *section, \
- unsigned section_line, \
- const char *lvalue, \
- int ltype, \
- const char *rvalue, \
- void *data, \
- void *userdata) { \
- \
+ int function(GENERIC_PARSER_ARGS) { \
type *i = data, x; \
\
assert(filename); \
@@ -191,17 +192,7 @@ int config_parse_ip_port(const char *unit, const char *filename, unsigned line,
}
#define DEFINE_CONFIG_PARSE_ENUMV(function,name,type,invalid,msg) \
- int function(const char *unit, \
- const char *filename, \
- unsigned line, \
- const char *section, \
- unsigned section_line, \
- const char *lvalue, \
- int ltype, \
- const char *rvalue, \
- void *data, \
- void *userdata) { \
- \
+ int function(GENERIC_PARSER_ARGS) { \
type **enums = data, x, *ys; \
_cleanup_free_ type *xs = NULL; \
const char *word, *state; \