Change-Id: Ib3133cbcd458fbd1ca1ee5aac64700c9ebc83b60
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
| helpers for argument scanning
+--------------------------------------------------------- */
| helpers for argument scanning
+--------------------------------------------------------- */
-static const char *optname(int optc)
+static const char *name_of_option(int optc)
{
AFB_options *o = cliOptions;
while (o->name && o->val != optc)
{
AFB_options *o = cliOptions;
while (o->name && o->val != optc)
{
if (optarg == 0) {
ERROR("option [--%s] needs a value i.e. --%s=xxx",
{
if (optarg == 0) {
ERROR("option [--%s] needs a value i.e. --%s=xxx",
- optname(optc), optname(optc));
+ name_of_option(optc), name_of_option(optc));
exit(1);
}
return optarg;
exit(1);
}
return optarg;
list = malloc(len + i + i);
if (!i || !list)
ERROR("option [--%s] bad value (found %s)",
list = malloc(len + i + i);
if (!i || !list)
ERROR("option [--%s] bad value (found %s)",
+ name_of_option(optc), name);
else {
i = 0;
strcpy(list, desc[i].name ? : "");
while(desc[++i].name)
strcat(strcat(list, ", "), desc[i].name);
ERROR("option [--%s] bad value, only accepts values %s (found %s)",
else {
i = 0;
strcpy(list, desc[i].name ? : "");
while(desc[++i].name)
strcat(strcat(list, ", "), desc[i].name);
ERROR("option [--%s] bad value, only accepts values %s (found %s)",
- optname(optc), list, name);
+ name_of_option(optc), list, name);
val = strtol(beg, &end, base);
if (*end || end == beg) {
ERROR("option [--%s] requires a valid integer (found %s)",
val = strtol(beg, &end, base);
if (*end || end == beg) {
ERROR("option [--%s] requires a valid integer (found %s)",
+ name_of_option(optc), beg);
exit(1);
}
if (val < (long int)mini || val > (long int)maxi) {
ERROR("option [--%s] value out of bounds (not %d<=%ld<=%d)",
exit(1);
}
if (val < (long int)mini || val > (long int)maxi) {
ERROR("option [--%s] value out of bounds (not %d<=%ld<=%d)",
- optname(optc), mini, val, maxi);
+ name_of_option(optc), mini, val, maxi);
exit(1);
}
return (int)val;
exit(1);
}
return (int)val;
static void noarg(int optc)
{
if (optarg != 0) {
static void noarg(int optc)
{
if (optarg != 0) {
- ERROR("option [--%s] need no value (found %s)", optname(optc), optarg);
+ ERROR("option [--%s] need no value (found %s)", name_of_option(optc), optarg);
case SET_SESSION_DIR:
/* config->sessiondir = argvalstr(optc); */
case SET_SESSION_DIR:
/* config->sessiondir = argvalstr(optc); */
- WARNING("Obsolete otpion %s ignored", optname(optc));
+ WARNING("Obsolete otpion %s ignored", name_of_option(optc));
break;
case SET_UPLOAD_DIR:
break;
case SET_UPLOAD_DIR: