# description (or NULL)
# array of struct def_values if TYPE == T_TUPLE
#
+# NOTE: for tuples that can be used in a boolean context the first
+# value corresponds to boolean FALSE and the second to TRUE.
+#
syslog
T_LOGFAC|T_BOOL
}
break;
case T_TUPLE:
- if (!val) {
- /* Check for bogus boolean usage or lack of a value. */
- if (!ISSET(cur->type, T_BOOL) || op != FALSE) {
- warningx("no value specified for `%s'", var);
- return(FALSE);
- }
+ if (!val && !ISSET(cur->type, T_BOOL)) {
+ warningx("no value specified for `%s'", var);
+ return(FALSE);
}
if (!store_tuple(val, cur, op)) {
warningx("value `%s' is invalid for option `%s'", val, var);
* This does assume that the first entry in the tuple enum will
* be the equivalent to a boolean "false".
*/
- if (op == FALSE) {
- def->sd_un.ival = 0;
+ if (!val) {
+ def->sd_un.ival = (op == FALSE) ? 0 : 1;
} else {
- for (v = def->values; v != NULL; v++) {
+ for (v = def->values; v->sval != NULL; v++) {
if (strcmp(v->sval, val) == 0) {
def->sd_un.ival = v->ival;
break;
}
}
- if (v == NULL)
+ if (v->sval == NULL)
return(FALSE);
}
if (def->callback)