/* * Copyright (c) 2020, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/ #include"common/args_helper.h"
if (arg->val[0] != '\0' && endptr[0] == '\0') { if (rawval <= UINT_MAX) return (unsignedint)rawval;
SET_ERR_STRING("Option %s: Value %lu out of range for unsigned int\n",
arg->name, rawval); return 0;
}
SET_ERR_STRING("Option %s: Invalid character '%c'\n", arg->name, *endptr); return 0;
}
if (arg->val[0] != '\0' && endptr[0] == '\0') { if (rawval >= INT_MIN && rawval <= INT_MAX) return (int)rawval;
SET_ERR_STRING("Option %s: Value %ld out of range for signed int\n",
arg->name, rawval); return 0;
}
SET_ERR_STRING("Option %s: Invalid character '%c'\n", arg->name, *endptr); return 0;
}
if (arg->val[0] != '\0' && endptr[0] == '\0') { if (rawval >= INT_MIN && rawval <= INT_MAX) {
rat.den = (int)rawval;
} else {
SET_ERR_STRING("Option %s: Value %ld out of range for signed int\n",
arg->name, rawval); return rat;
}
} else {
SET_ERR_STRING("Option %s: Invalid character '%c'\n", arg->name, *endptr); return rat;
}
return rat;
}
int arg_parse_enum_helper(conststruct arg *arg, char *err_msg) { conststruct arg_enum_list *listptr; long rawval; // NOLINT char *endptr;
if (err_msg) err_msg[0] = '\0';
/* First see if the value can be parsed as a raw value */
rawval = strtol(arg->val, &endptr, 10); if (arg->val[0] != '\0' && endptr[0] == '\0') { /* Got a raw value, make sure it's valid */ for (listptr = arg->def->enums; listptr->name; listptr++) if (listptr->val == rawval) return (int)rawval;
}
/* Next see if it can be parsed as a string */ for (listptr = arg->def->enums; listptr->name; listptr++) if (!strcmp(arg->val, listptr->name)) return listptr->val;
SET_ERR_STRING("Option %s: Invalid value '%s'\n", arg->name, arg->val); return 0;
}
int arg_parse_enum_or_int_helper(conststruct arg *arg, char *err_msg) { if (arg->def->enums) return arg_parse_enum_helper(arg, err_msg); return arg_parse_int_helper(arg, err_msg);
}
// parse a comma separated list of at most n integers // return the number of elements in the list int arg_parse_list_helper(conststruct arg *arg, int *list, int n, char *err_msg) { constchar *ptr = arg->val; char *endptr; int i = 0;
if (err_msg) err_msg[0] = '\0';
while (ptr[0] != '\0') { long rawval = strtol(ptr, &endptr, 10); // NOLINT if (rawval < INT_MIN || rawval > INT_MAX) {
SET_ERR_STRING("Option %s: Value %ld out of range for signed int\n",
arg->name, rawval); return 0;
} elseif (i >= n) {
SET_ERR_STRING("Option %s: List has more than %d entries\n", arg->name,
n); return 0;
} elseif (*endptr == ',') {
endptr++;
} elseif (*endptr != '\0') {
SET_ERR_STRING("Option %s: Bad list separator '%c'\n", arg->name,
*endptr); return 0;
}
list[i++] = (int)rawval;
ptr = endptr;
} return i;
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.