/* functions below are dedicated to the config parsers */
/*******************************************************/
-/* Parses <arg> as a decimal integer into <*val>. Returns 0 on success, or -1
- * if <arg> is empty, contains anything but an optional sign and digits, or
- * does not fit in an int.
- */
-static int h2_parse_int(const char *arg, int *val)
-{
- char *end;
- long v;
-
- errno = 0;
- v = strtol(arg, &end, 10);
- if (!*arg || *end || errno || v < INT_MIN || v > INT_MAX)
- return -1;
- *val = v;
- return 0;
-}
-
/* config parser for global "tune.h2.{fe,be}.glitches-threshold" */
static int h2_parse_glitches_threshold(char **args, int section_type, struct proxy *curpx,
const struct proxy *defpx, const char *file, int line,
/* backend/frontend */
vptr = (args[0][8] == 'b') ? &h2_be_glitches_threshold : &h2_fe_glitches_threshold;
- if (h2_parse_int(args[1], vptr) || *vptr < 0) {
+ if (str2irc(args[1], vptr) != 0 || *vptr < 0) {
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
return -1;
}
if (too_many_args(1, args, err, NULL))
return -1;
- if (h2_parse_int(args[1], &h2_settings_header_table_size) ||
+ if (str2irc(args[1], &h2_settings_header_table_size) != 0 ||
h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]);
return -1;
(args[0][8] == 'f') ? &h2_fe_settings_initial_window_size :
&h2_settings_initial_window_size;
- if (h2_parse_int(args[1], vptr) || *vptr < 0) {
+ if (str2irc(args[1], vptr) != 0 || *vptr < 0) {
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
return -1;
}
if (args[0][8] != 'f' && too_many_args(1, args, err, NULL))
return -1;
- if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+ if (str2uirc(args[1], vptr) != 0) {
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
return -1;
}
h2_fe_max_rq_load = ~0;
else if (strcmp(args[arg + 1], "auto") == 0)
h2_fe_max_rq_load = 0;
- else if (h2_parse_int(args[arg + 1], (int *)&h2_fe_max_rq_load) || (int)h2_fe_max_rq_load <= 0) {
+ else if (str2uirc(args[arg + 1], &h2_fe_max_rq_load) != 0 || h2_fe_max_rq_load == 0) {
memprintf(err, "'%s' expects a strictly positive run-queue length, or 'auto' or 'ignore'.", args[0]);
return -1;
}
}
else if (strcmp(args[arg], "min") == 0) {
- if (h2_parse_int(args[arg + 1], (int *)&h2_fe_min_concurrent_streams) || (int)h2_fe_min_concurrent_streams <= 0) {
+ if (str2uirc(args[arg + 1], &h2_fe_min_concurrent_streams) != 0|| h2_fe_min_concurrent_streams == 0) {
memprintf(err, "'%s' expects a strictly positive minimum number of streams'.", args[0]);
return -1;
}
/* frontend only for now */
vptr = &h2_fe_max_total_streams;
- if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+ if (str2uirc(args[1], vptr) != 0) {
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
return -1;
}
if (too_many_args(1, args, err, NULL))
return -1;
- if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+ if (str2uirc(args[1], vptr) != 0) {
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
return -1;
}
if (too_many_args(1, args, err, NULL))
return -1;
- if (h2_parse_int(args[1], &h2_settings_max_frame_size) ||
+ if (str2irc(args[1], &h2_settings_max_frame_size) != 0 ||
h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
memprintf(err, "'%s' expects a numeric value between 16384 and 16777215.", args[0]);
return -1;