return 0;
}
+#define DEFINE_PARSER(type, vartype, conv_func) \
+ int config_parse_##type( \
+ const char *filename, \
+ unsigned line, \
+ const char *section, \
+ const char *lvalue, \
+ int ltype, \
+ const char *rvalue, \
+ void *data) { \
+ \
+ vartype *i = data; \
+ \
+ assert(filename); \
+ assert(lvalue); \
+ assert(rvalue); \
+ assert(data); \
+ \
+ *i = conv_func(rvalue); \
+ return 0; \
+ }
-int config_parse_int(const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data)
-{
- int *i = data;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- *i = atoi(rvalue);
-
- return 0;
-}
+DEFINE_PARSER(int, int, atoi)
+DEFINE_PARSER(float, float, atof)
+DEFINE_PARSER(long, long, atol)
int config_parse_string(const char *filename,
unsigned line,
int config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
int config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
int config_parse_bytes(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
+int config_parse_float(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
+int config_parse_long(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data);
#endif