* not NULL. Returns PE_NONE (0) if OK or an error code among :
* - PE_ENUM_OOR if <type> does not exist
* - PE_EXIST if <type> is already registered
+ * - PE_ARG_NOT_USE if <sa> was provided but not expected
+ * - PE_ARG_MISSING if <sa> was expected but not provided
*/
static inline int stktable_alloc_data_type(struct stktable *t, int type, const char *sa)
{
/* already allocated */
return PE_EXIST;
+ switch (stktable_data_types[type].arg_type) {
+ case ARG_T_NONE:
+ if (sa)
+ return PE_ARG_NOT_USED;
+ break;
+ case ARG_T_INT:
+ if (!sa)
+ return PE_ARG_MISSING;
+ t->data_arg[type].i = atoi(sa);
+ break;
+ case ARG_T_DELAY:
+ if (!sa)
+ return PE_ARG_MISSING;
+ sa = parse_time_err(sa, &t->data_arg[type].u, TIME_UNIT_MS);
+ if (sa)
+ return PE_ARG_INVC; /* invalid char */
+ break;
+ }
+
t->data_size += stktable_data_types[type].data_length;
t->data_ofs[type] = -t->data_size;
- /* right now only int type is supported, but we may later support type-
- * specific arg type.
- */
- t->data_arg[type].i = sa ? atoi(sa) : 0;
return PE_NONE;
}
/* myidx already points to next arg */
}
else if (strcmp(args[myidx], "store") == 0) {
- int type;
+ int type, err;
char *cw, *nw, *sa;
myidx++;
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- if (stktable_alloc_data_type(&curproxy->table, type, sa)) {
+
+ err = stktable_alloc_data_type(&curproxy->table, type, sa);
+ switch (err) {
+ case PE_NONE: break;
+ case PE_EXIST:
Warning("parsing [%s:%d]: %s: store option '%s' already enabled, ignored.\n",
file, linenum, args[0], cw);
err_code |= ERR_WARN;
+ break;
+
+ case PE_ARG_MISSING:
+ Alert("parsing [%s:%d] : %s: missing argument to store option '%s'.\n",
+ file, linenum, args[0], cw);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+
+ case PE_ARG_NOT_USED:
+ Alert("parsing [%s:%d] : %s: unexpected argument to store option '%s'.\n",
+ file, linenum, args[0], cw);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+
+ default:
+ Alert("parsing [%s:%d] : %s: error when processing store option '%s'.\n",
+ file, linenum, args[0], cw);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
}
}
myidx++;