Mercurial > hg > th-libs
diff th_args.c @ 457:85fa3d333556
Actually, revert the boolean changes .. meh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Jan 2018 23:09:29 +0200 |
parents | 347bfd3e017e |
children | e4ce60239d16 |
line wrap: on
line diff
--- a/th_args.c Tue Jan 02 22:57:47 2018 +0200 +++ b/th_args.c Tue Jan 02 23:09:29 2018 +0200 @@ -23,15 +23,15 @@ * @param opts options list array * @param nopts number of elements in options list array * @param handle_option function pointer to callback that handles option arguments - * @param doProcess if true, actually handle the argument, aka call the handle_option() function. if false, only validity of options are checked. - * @param isLong true if the option is a --long-format one + * @param doProcess if TRUE, actually handle the argument, aka call the handle_option() function. if FALSE, only validity of options are checked. + * @param isLong TRUE if the option is a --long-format one */ -static bool th_args_process_opt( +static BOOL th_args_process_opt( char *currArg, int *argIndex, int argc, char *argv[], const th_optarg opts[], int nopts, - bool (*handle_option)(int id, char *, char *), - bool doProcess, bool isLong) + BOOL (*handle_option)(int id, char *, char *), + BOOL doProcess, BOOL isLong) { const th_optarg *opt = NULL; char *optArg = NULL; @@ -85,13 +85,13 @@ THERR("Option '%s%s' requires an argument.\n", isLong ? "--" : "-", currArg); - return false; + return FALSE; } } // Option was given succesfully, try to process it if (doProcess && !handle_option(opt->id, optArg, currArg)) - return false; + return FALSE; } else { @@ -100,10 +100,10 @@ isLong ? "--" : "-", currArg); - return false; + return FALSE; } - return true; + return TRUE; } @@ -118,15 +118,15 @@ * @param handle_option callback function * @param handle_other callback function * @param flags processing flags - * @return return true if all is well + * @return return TRUE if all is well */ -bool th_args_process(int argc, char *argv[], +BOOL th_args_process(int argc, char *argv[], const th_optarg *opts, const int nopts, - bool(*handle_option)(int id, char *, char *), - bool(*handle_other)(char *), const int flags) + BOOL(*handle_option)(int id, char *, char *), + BOOL(*handle_other)(char *), const int flags) { int argIndex, handleFlags = flags & OPTH_ONLY_MASK; - bool optionsOK = true, endOfOptions = false; + BOOL optionsOK = TRUE, endOfOptions = FALSE; for (argIndex = 1; argIndex < argc; argIndex++) { @@ -134,8 +134,8 @@ if (*str == '-' && !endOfOptions) { // Should we process options? - bool doProcess = (handleFlags & OPTH_ONLY_OPTS) || handleFlags == 0; - bool isLong; + BOOL doProcess = (handleFlags & OPTH_ONLY_OPTS) || handleFlags == 0; + BOOL isLong; str++; if (*str == '-') @@ -144,19 +144,19 @@ str++; if (*str == 0) { - endOfOptions = true; + endOfOptions = TRUE; continue; } // We have a long option - isLong = true; + isLong = TRUE; } else - isLong = false; + isLong = FALSE; if (!th_args_process_opt(str, &argIndex, argc, argv, opts, nopts, handle_option, doProcess, isLong)) - optionsOK = false; + optionsOK = FALSE; } else if (handleFlags == OPTH_ONLY_OTHER || handleFlags == 0) @@ -166,13 +166,13 @@ (handle_other != NULL && !handle_other(str))) { THERR("Invalid argument '%s'\n", str); - optionsOK = false; + optionsOK = FALSE; } } // Check if we bail out on invalid argument if (!optionsOK && (flags & OPTH_BAILOUT)) - return false; + return FALSE; } return optionsOK;