X Tutup
Skip to content

Commit c07b23c

Browse files
conf-parser: add config_parse_permille()
1 parent 958acea commit c07b23c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/shared/conf-parser.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,3 +1203,34 @@ int config_parse_rlimit(
12031203

12041204
return 0;
12051205
}
1206+
1207+
int config_parse_permille(const char* unit,
1208+
const char *filename,
1209+
unsigned line,
1210+
const char *section,
1211+
unsigned section_line,
1212+
const char *lvalue,
1213+
int ltype,
1214+
const char *rvalue,
1215+
void *data,
1216+
void *userdata) {
1217+
1218+
unsigned *permille = data;
1219+
int r;
1220+
1221+
assert(filename);
1222+
assert(lvalue);
1223+
assert(rvalue);
1224+
assert(permille);
1225+
1226+
r = parse_permille(rvalue);
1227+
if (r < 0) {
1228+
log_syntax(unit, LOG_ERR, filename, line, r,
1229+
"Failed to parse permille value, ignoring: %s", rvalue);
1230+
return 0;
1231+
}
1232+
1233+
*permille = (unsigned) r;
1234+
1235+
return 0;
1236+
}

src/shared/conf-parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_log_facility);
140140
CONFIG_PARSER_PROTOTYPE(config_parse_log_level);
141141
CONFIG_PARSER_PROTOTYPE(config_parse_signal);
142142
CONFIG_PARSER_PROTOTYPE(config_parse_personality);
143+
CONFIG_PARSER_PROTOTYPE(config_parse_permille);
143144
CONFIG_PARSER_PROTOTYPE(config_parse_ifname);
144145
CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
145146
CONFIG_PARSER_PROTOTYPE(config_parse_join_controllers);

0 commit comments

Comments
 (0)
X Tutup