X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fconf-parser.h;h=019b7afd13bbdce46fac90c935ab5d0815949285;hp=b3b2915d412abf0e69978aefcfc2149abcbf171d;hb=f1a1cd6497a970a8744b6d71cf5355fa9f75669c;hpb=10e87ee7f66b59a504c0ed2025463ba5faa69923 diff --git a/src/conf-parser.h b/src/conf-parser.h index b3b2915d4..019b7afd1 100644 --- a/src/conf-parser.h +++ b/src/conf-parser.h @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ #ifndef fooconfparserhfoo #define fooconfparserhfoo @@ -46,6 +46,7 @@ int config_parse(const char *filename, FILE *f, const char* const *sections, con /* Generic parsers */ int config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); int config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); +int config_parse_uint64(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); int config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); int config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); int config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); @@ -53,4 +54,31 @@ int config_parse_path(const char *filename, unsigned line, const char *section, int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); int config_parse_path_strv(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata); +#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \ + int function( \ + const char *filename, \ + unsigned line, \ + const char *section, \ + const char *lvalue, \ + const char *rvalue, \ + void *data, \ + void *userdata) { \ + \ + type *i = data, x; \ + \ + assert(filename); \ + assert(lvalue); \ + assert(rvalue); \ + assert(data); \ + \ + if ((x = name##_from_string(rvalue)) < 0) { \ + log_error("[%s:%u] " msg ", ignoring: %s", filename, line, rvalue); \ + return 0; \ + } \ + \ + *i = x; \ + \ + return 0; \ + } + #endif