static int config_parse_input_datefmt(void *dummy, const char *val) { if (config_parse_int(&conf.input_datefmt, val)) { if (conf.input_datefmt <= 0 || conf.input_datefmt > DATE_FORMATS) conf.input_datefmt = 1; return 1; } else { return 0; } }
int config_parse_ipv6_flowlabel(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) { IPv6FlowLabel *ipv6_flowlabel = data; Tunnel *t = userdata; int k = 0; int r; assert(filename); assert(lvalue); assert(rvalue); assert(ipv6_flowlabel); if (streq(rvalue, "inherit")) { *ipv6_flowlabel = IP6_FLOWINFO_FLOWLABEL; t->flags |= IP6_TNL_F_USE_ORIG_FLOWLABEL; } else { r = config_parse_int(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &k, userdata); if (r < 0) return r; if (k > 0xFFFFF) log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue); else { *ipv6_flowlabel = htobe32(k) & IP6_FLOWINFO_FLOWLABEL; t->flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL; } } return 0; }
static void test_config_parse_int_one(const char *rvalue, int expected) { int v = -1; assert_se(config_parse_int("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL) >= 0); assert_se(expected == v); }