diff --git a/qse/include/qse/cmn/opt.h b/qse/include/qse/cmn/opt.h index 98013236..e49976ac 100644 --- a/qse/include/qse/cmn/opt.h +++ b/qse/include/qse/cmn/opt.h @@ -66,8 +66,13 @@ struct qse_opt_t /* --------------------------------------------------------------------- */ -#define QSE_CLI_OPTNAME (1 << 0) -#define QSE_CLI_OPTVAL (1 << 1) +enum qse_cli_optflag_t +{ + QSE_CLI_REQUIRE_OPTNAME = (1 << 0), /* if set, the option itself is require */ + QSE_CLI_REQUIRE_OPTVAL = (1 << 1), /* if set, the option's value is mandatory */ + QSE_CLI_DISCRETIONARY_OPTVAL = (1 << 2) /* if set, the option's value is optional. */ +}; +typedef enum qse_cli_optflag_t qse_cli_optflag_t; enum qse_cli_error_code_t { @@ -86,7 +91,7 @@ struct qse_cli_opt_t { /* input */ const qse_char_t* name; - int requires; + int optflags; /* 0 or bitwise-ORed of qse_cli_optflags_t enumerartors */ /* output - you don't have to initialize this field */ qse_char_t* value; diff --git a/qse/include/qse/si/log.h b/qse/include/qse/si/log.h index c776b20c..3126ec5d 100644 --- a/qse/include/qse/si/log.h +++ b/qse/include/qse/si/log.h @@ -57,7 +57,7 @@ /* options */ #define QSE_LOG_KEEP_FILE_OPEN (1 << 13) -#define QSE_LOG_MASKED_PRIORITY (1 << 14) +#define QSE_LOG_MASKED_PRIORITY (1 << 14) #define QSE_LOG_INCLUDE_PID (1 << 15) #define QSE_LOG_HOST_IN_REMOTE_SYSLOG (1 << 16) diff --git a/qse/lib/cmn/opt-cli.c b/qse/lib/cmn/opt-cli.c index 18d42c15..1c110649 100644 --- a/qse/lib/cmn/opt-cli.c +++ b/qse/lib/cmn/opt-cli.c @@ -124,7 +124,7 @@ int qse_parsecli (qse_cli_t* cli, qse_mmgr_t* mmgr, int argc, qse_char_t* const } else { - if (value && !(opt->requires & QSE_CLI_OPTVAL)) + if (value && !(opt->optflags & (QSE_CLI_REQUIRE_OPTVAL | QSE_CLI_DISCRETIONARY_OPTVAL))) { if (cli->data.errcb(cli, QSE_CLI_ERROR_REDUNDANT_OPTVAL, name.ptr, value) <= -1) { @@ -132,7 +132,7 @@ int qse_parsecli (qse_cli_t* cli, qse_mmgr_t* mmgr, int argc, qse_char_t* const return -1; } } - else if (!value && (opt->requires & QSE_CLI_OPTVAL)) + else if (!value && (opt->optflags & QSE_CLI_REQUIRE_OPTVAL)) { if (cli->data.errcb(cli, QSE_CLI_ERROR_MISSING_OPTVAL, name.ptr, value) <= -1) { @@ -175,7 +175,7 @@ int qse_parsecli (qse_cli_t* cli, qse_mmgr_t* mmgr, int argc, qse_char_t* const for (opt = cli->data.opts; opt->name != QSE_NULL; opt++) { - if ((opt->requires & QSE_CLI_OPTNAME) && opt->value == QSE_NULL) + if ((opt->optflags & QSE_CLI_REQUIRE_OPTNAME) && opt->value == QSE_NULL) { if (cli->data.errcb(cli, QSE_CLI_ERROR_MISSING_OPTNAME, opt->name, QSE_NULL) <= -1) { diff --git a/qse/lib/si/App.cpp b/qse/lib/si/App.cpp index 112e69d9..2217008b 100644 --- a/qse/lib/si/App.cpp +++ b/qse/lib/si/App.cpp @@ -136,12 +136,12 @@ int App::daemonize (bool chdir_to_root, int fork_count, bool root_only) QSE_CPP_ { int keep[] = { 0, 1, 2}; - if (qse_close_open_fds_using_proc (keep, QSE_COUNTOF(keep)) <= -1) + if (qse_close_open_fds_using_proc(keep, QSE_COUNTOF(keep)) <= -1) { for (int i = qse_get_highest_fd(); i >= 3; i--) QSE_CLOSE (i); } - int fd = QSE_OPEN ("/dev/null", O_RDWR, 0); + int fd = QSE_OPEN("/dev/null", O_RDWR, 0); if (fd >= 0) { if (fd != 0) QSE_DUP2 (fd, 0);