From: Zbigniew Jędrzejewski-Szmek Date: Fri, 16 Feb 2018 08:29:57 +0000 (+0100) Subject: shared/conf-parser: define a macro for the repeating argument set X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c3d60196c5b20e6209fcc649a63c6d7c1692d798;p=elogind.git 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. --- 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; \