conf-parser: add config_parse_permille()
This commit is contained in:
@@ -1203,3 +1203,34 @@ int config_parse_rlimit(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_permille(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) {
|
||||
|
||||
unsigned *permille = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(permille);
|
||||
|
||||
r = parse_permille(rvalue);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse permille value, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*permille = (unsigned) r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user