diff --git a/includes/internal/cli/cli_handlers.h b/includes/internal/cli/cli_handlers.h index f72dcd9..1264d59 100644 --- a/includes/internal/cli/cli_handlers.h +++ b/includes/internal/cli/cli_handlers.h @@ -3,11 +3,12 @@ #include -int cli_handle_help(const char *arg, void *config); +int cli_handle_help(const char *arg, void *config_void); int cli_handle_version(const char *arg, void *config); -int cli_handle_p(const char *arg, void *config); -int cli_handle_q(const char *arg, void *config); -int cli_handle_r(const char *arg, void *config); -int cli_handle_s(const char *arg, void *config); +int digest_handle_help(const char *arg, void *config); +int digest_handle_p(const char *arg, void *config); +int digest_handle_q(const char *arg, void *config); +int digest_handle_r(const char *arg, void *config); +int digest_handle_s(const char *arg, void *config); #endif diff --git a/includes/internal/cmd/command.h b/includes/internal/cli/command.h similarity index 59% rename from includes/internal/cmd/command.h rename to includes/internal/cli/command.h index 68d9923..c622770 100644 --- a/includes/internal/cmd/command.h +++ b/includes/internal/cli/command.h @@ -12,15 +12,15 @@ enum command_category { }; struct command_descriptor { - const char *name; - enum command_category category; - const struct option_descriptor *opts; - size_t nb_opts; - const void *impl; + const char *name; + enum command_category category; + const struct option_descriptor *opts; + size_t nb_opts; + const void *impl; int (*run)(int argc, char **argv, const struct command_descriptor *self); }; const struct command_descriptor *find_command(const char *name); -void print_commands(FILE *out); +void print_commands(FILE *out); #endif diff --git a/includes/internal/cmd/digest_cmd.h b/includes/internal/cli/digest_cmd.h similarity index 81% rename from includes/internal/cmd/digest_cmd.h rename to includes/internal/cli/digest_cmd.h index d7d3582..362587f 100644 --- a/includes/internal/cmd/digest_cmd.h +++ b/includes/internal/cli/digest_cmd.h @@ -5,32 +5,14 @@ #include #include "internal/cli/cli_handlers.h" -#include "internal/cmd/command.h" +#include "internal/cli/command.h" #define DIGEST_OPTION_LIST \ - X( \ - 'h', \ - "help", \ - no_argument, \ - cli_handle_help, \ - OPT_ARG_NONE, \ - "Display this help and exit", \ - 0 \ - ) \ - X( \ - 'V', \ - "version", \ - no_argument, \ - cli_handle_version, \ - OPT_ARG_NONE, \ - "Display version information and exit", \ - 0 \ - ) \ X( \ 'p', \ "stdin", \ no_argument, \ - cli_handle_p, \ + digest_handle_p, \ OPT_ARG_NONE, \ "Echo stdin to stdout and append checksum to output", \ 0 \ @@ -39,7 +21,7 @@ 'q', \ "quiet", \ no_argument, \ - cli_handle_q, \ + digest_handle_q, \ OPT_ARG_NONE, \ "Quiet mode: only print the digest", \ 0 \ @@ -48,7 +30,7 @@ 'r', \ "reverse", \ no_argument, \ - cli_handle_r, \ + digest_handle_r, \ OPT_ARG_NONE, \ "Reverse the output format (digest then filename)", \ 0 \ @@ -57,11 +39,29 @@ 's', \ "string", \ required_argument, \ - cli_handle_s, \ + digest_handle_s, \ OPT_ARG_STRING, \ "Hash a string", \ CLI_OPT_F_REPEATABLE \ + ) \ + X( \ + 'h', \ + "help", \ + no_argument, \ + digest_handle_help, \ + OPT_ARG_NONE, \ + "Display this help and exit", \ + 0 \ ) +// X( \ +// 'V', \ +// "version", \ +// no_argument, \ +// digest_handle_version, \ +// OPT_ARG_NONE, \ +// "Display version information and exit", \ +// 0 \ +// ) #undef X #define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) + 1 diff --git a/includes/internal/cli/option.h b/includes/internal/cli/option.h index f6c1bc3..993e097 100644 --- a/includes/internal/cli/option.h +++ b/includes/internal/cli/option.h @@ -2,74 +2,31 @@ #define FT_SSL_OPT_H #include +#include -#define FT_SSL_OPTION_LIST \ - X( \ - 'h', \ - "help", \ - no_argument, \ - cli_handle_help, \ - OPT_ARG_NONE, \ - "Display this help and exit", \ - 0 \ - ) \ - X( \ - 'V', \ - "version", \ - no_argument, \ - cli_handle_version, \ - OPT_ARG_NONE, \ - "Display version information and exit", \ - 0 \ - ) \ - X( \ - 'p', \ - "stdin", \ - no_argument, \ - cli_handle_p, \ - OPT_ARG_NONE, \ - "Echo stdin to stdout and append checksum to output", \ - 0 \ - ) \ - X( \ - 'q', \ - "quiet", \ - no_argument, \ - cli_handle_q, \ - OPT_ARG_NONE, \ - "Quiet mode: only print the digest", \ - 0 \ - ) \ - X( \ - 'r', \ - "reverse", \ - no_argument, \ - cli_handle_r, \ - OPT_ARG_NONE, \ - "Reverse the output format (digest then filename)", \ - 0 \ - ) \ - X( \ - 's', \ - "string", \ - required_argument, \ - cli_handle_s, \ - OPT_ARG_STRING, \ - "Hash a string", \ - CLI_OPT_F_REPEATABLE \ - ) +#include "internal/cli/command.h" +#include "internal/cli/digest_cmd.h" -#undef X -#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) + 1 -enum { FT_SSL_OPT_LEN = (0 FT_SSL_OPTION_LIST ) }; -#undef X -#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) \ - + (1 * (has_arg == no_argument) \ - + (2 * (has_arg == required_argument) \ - + (3 * (has_arg == optional_argument)))) -enum { FT_SSL_OPTSTR_LEN = (2 FT_SSL_OPTION_LIST) }; -/* +2 for ':' to disable getopt error messages and \0 */ +/* Forward-declare all digest algo globals */ +#define DIGEST_ALGO(lower, ds, bs) extern const struct digest_algo g_##lower; +#include +#undef DIGEST_ALGO + +static const struct command_descriptor g_commands[] = { + /* Digest commands */ +#define DIGEST_ALGO(lower, ds, bs) \ + { #lower, CMD_DIGEST, g_digest_opts, DIGEST_OPT_LEN, &g_##lower, digest_run }, +#include +#undef DIGEST_ALGO + /* Cipher commands (not yet implemented) */ + { "base64", CMD_CIPHER, NULL, 0, NULL, NULL }, + { "des", CMD_CIPHER, NULL, 0, NULL, NULL }, + { "des-ecb", CMD_CIPHER, NULL, 0, NULL, NULL }, + { "des-cbc", CMD_CIPHER, NULL, 0, NULL, NULL }, + /* Sentinel */ + { NULL, 0, NULL, 0, NULL, NULL } +}; void print_usage(const char *prog); diff --git a/includes/internal/ssl/ssl.h b/includes/internal/ssl/ssl.h index a96b1d2..6b5ad3a 100644 --- a/includes/internal/ssl/ssl.h +++ b/includes/internal/ssl/ssl.h @@ -8,9 +8,9 @@ #define MAX_DIGEST_SIZE 64 #define READ_BUFSIZE 4096 -int run_string(const struct digest_config *config, const char *s); -int run_file(const struct digest_config *config, const char *path); -int run_stdin(const struct digest_config *config); +int digest_run_string(const struct digest_config *config, const char *s); +int digest_run_file(const struct digest_config *config, const char *path); +int digest_run_stdin(const struct digest_config *config); int digest_stream(const struct digest_config *config, int fd, const char *label, int show_algo, int echo); void print_digest(const struct digest_config *config, const uint8_t *digest, diff --git a/src/Makefile.am b/src/Makefile.am index 2343f9c..73bddf1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,20 +42,23 @@ FORCE: ft_ssl_SOURCES = \ main.c \ cmd/command_table.c \ + cmd/global_option.c \ cmd/digest_run.c \ - ssl/run_stdin.c \ - ssl/run_string.c \ - ssl/run_file.c \ - ssl/digest.c \ - ssl/output.c \ - cli/version.c \ - cli/handlers/option_map.c \ - cli/handlers/handle_help.c \ + ssl/digest/run_stdin.c \ + ssl/digest/run_string.c \ + ssl/digest/run_file.c \ + ssl/digest/digest.c \ + ssl/digest/output.c \ + cli/print_version.c \ + cli/print_help.c \ cli/handlers/handle_version.c \ - cli/handlers/handle_p.c \ - cli/handlers/handle_q.c \ - cli/handlers/handle_r.c \ - cli/handlers/handle_s.c + cli/handlers/handle_help.c \ + cli/handlers/digest/option_map.c \ + cli/handlers/digest/handle_help.c \ + cli/handlers/digest/handle_p.c \ + cli/handlers/digest/handle_q.c \ + cli/handlers/digest/handle_r.c \ + cli/handlers/digest/handle_s.c ft_ssl_CPPFLAGS = \ -I $(top_srcdir)/includes \ diff --git a/src/cli/handlers/digest/handle_help.c b/src/cli/handlers/digest/handle_help.c new file mode 100644 index 0000000..2aaccad --- /dev/null +++ b/src/cli/handlers/digest/handle_help.c @@ -0,0 +1,17 @@ +#include +#include + +#include "compiler.h" +#include "ft_ssl.h" +#include "internal/cli/digest_cmd.h" +#include "version_gen.h" + +int +digest_handle_help(__unused const char *arg, void *config_void) +{ + struct digest_config *config = (struct digest_config *)config_void; + + printf("Usage: %s %s [OPTIONS] [FILE...]\n\n", g_prog_name, config->cmd_name); + cli_print_options(g_digest_opts, DIGEST_OPT_LEN, cli_arg_type_to_str); + return CLI_EXIT_SUCCESS; +} diff --git a/src/cli/handlers/handle_p.c b/src/cli/handlers/digest/handle_p.c similarity index 79% rename from src/cli/handlers/handle_p.c rename to src/cli/handlers/digest/handle_p.c index a79c3a2..5c243d6 100644 --- a/src/cli/handlers/handle_p.c +++ b/src/cli/handlers/digest/handle_p.c @@ -4,7 +4,7 @@ #include "internal/cli/cli_handlers.h" int -cli_handle_p(__unused const char *arg, void *config_void) +digest_handle_p(__unused const char *arg, void *config_void) { struct digest_config *config = (struct digest_config *)config_void; diff --git a/src/cli/handlers/handle_q.c b/src/cli/handlers/digest/handle_q.c similarity index 79% rename from src/cli/handlers/handle_q.c rename to src/cli/handlers/digest/handle_q.c index a22af3e..414bac8 100644 --- a/src/cli/handlers/handle_q.c +++ b/src/cli/handlers/digest/handle_q.c @@ -4,7 +4,7 @@ #include "internal/cli/cli_handlers.h" int -cli_handle_q(__unused const char *arg, void *config_void) +digest_handle_q(__unused const char *arg, void *config_void) { struct digest_config *config = (struct digest_config *)config_void; diff --git a/src/cli/handlers/handle_r.c b/src/cli/handlers/digest/handle_r.c similarity index 79% rename from src/cli/handlers/handle_r.c rename to src/cli/handlers/digest/handle_r.c index a529712..7415e78 100644 --- a/src/cli/handlers/handle_r.c +++ b/src/cli/handlers/digest/handle_r.c @@ -4,7 +4,7 @@ #include "internal/cli/cli_handlers.h" int -cli_handle_r(__unused const char *arg, void *config_void) +digest_handle_r(__unused const char *arg, void *config_void) { struct digest_config *config = (struct digest_config *)config_void; diff --git a/src/cli/handlers/handle_s.c b/src/cli/handlers/digest/handle_s.c similarity index 83% rename from src/cli/handlers/handle_s.c rename to src/cli/handlers/digest/handle_s.c index bc2302e..850c7e8 100644 --- a/src/cli/handlers/handle_s.c +++ b/src/cli/handlers/digest/handle_s.c @@ -2,7 +2,7 @@ #include "internal/cli/cli_handlers.h" int -cli_handle_s(const char *arg, void *config_void) +digest_handle_s(const char *arg, void *config_void) { struct digest_config *config = (struct digest_config *)config_void; diff --git a/src/cli/handlers/option_map.c b/src/cli/handlers/digest/option_map.c similarity index 88% rename from src/cli/handlers/option_map.c rename to src/cli/handlers/digest/option_map.c index 3f42467..318ca07 100644 --- a/src/cli/handlers/option_map.c +++ b/src/cli/handlers/digest/option_map.c @@ -1,4 +1,4 @@ -#include "internal/cmd/digest_cmd.h" +#include "internal/cli/digest_cmd.h" #undef X #define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) \ diff --git a/src/cli/handlers/handle_help.c b/src/cli/handlers/handle_help.c index 972a2c8..0d63c45 100644 --- a/src/cli/handlers/handle_help.c +++ b/src/cli/handlers/handle_help.c @@ -1,17 +1,14 @@ -#include -#include +#include "internal/cli/option.h" +#include +#include + +#include "internal/cli/option.h" #include "compiler.h" -#include "ft_ssl.h" -#include "internal/cmd/digest_cmd.h" -#include "version_gen.h" int -cli_handle_help(__unused const char *arg, void *config_void) +handle_help(__unused const char *arg, __unused void *config_void) { - struct digest_config *config = (struct digest_config *)config_void; - - printf("Usage: %s %s [OPTIONS] [FILE...]\n\n", g_prog_name, config->cmd_name); - cli_print_options(g_digest_opts, DIGEST_OPT_LEN, cli_arg_type_to_str); + print_commands(stdout); return CLI_EXIT_SUCCESS; } diff --git a/src/cli/handlers/handle_version.c b/src/cli/handlers/handle_version.c index 9e64fe6..d817357 100644 --- a/src/cli/handlers/handle_version.c +++ b/src/cli/handlers/handle_version.c @@ -1,5 +1,3 @@ -#include - #include #include "compiler.h" diff --git a/src/cli/parse.c b/src/cli/parse_digest.c similarity index 98% rename from src/cli/parse.c rename to src/cli/parse_digest.c index 3cf9a0e..fcff647 100644 --- a/src/cli/parse.c +++ b/src/cli/parse_digest.c @@ -7,7 +7,6 @@ #include "ft_ssl.h" #include "internal/cli/cli_handlers.h" -#include "internal/cli/interactive.h" #include "internal/cli/option.h" /* Forward declarations */ diff --git a/src/cli/print_help.c b/src/cli/print_help.c new file mode 100644 index 0000000..48539d7 --- /dev/null +++ b/src/cli/print_help.c @@ -0,0 +1,21 @@ +#include + +#include + +#include "internal/cli/option.h" + +void +print_commands(FILE *out) +{ + const struct command_descriptor *cmd; + + fprintf(out, "\nStandard commands:\n"); + fprintf(out, "\nMessage Digest commands:\n"); + for (cmd = g_commands; NULL != cmd->name; cmd++) + if (CMD_DIGEST == cmd->category) + fprintf(out, " %s\n", cmd->name); + fprintf(out, "\nCipher commands:\n"); + for (cmd = g_commands; NULL != cmd->name; cmd++) + if (CMD_CIPHER == cmd->category) + fprintf(out, " %s\n", cmd->name); +} diff --git a/src/cli/version.c b/src/cli/print_version.c similarity index 100% rename from src/cli/version.c rename to src/cli/print_version.c diff --git a/src/cmd/command_table.c b/src/cmd/command_table.c index 85d6757..941d031 100644 --- a/src/cmd/command_table.c +++ b/src/cmd/command_table.c @@ -1,54 +1,16 @@ -#include #include -#include +#include "internal/cli/option.h" -#include "internal/cmd/command.h" -#include "internal/cmd/digest_cmd.h" - -/* Forward-declare all digest algo globals */ -#define DIGEST_ALGO(lower, ds, bs) extern const struct digest_algo g_##lower; -#include -#undef DIGEST_ALGO - -static const struct command_descriptor s_commands[] = { - /* Digest commands */ -#define DIGEST_ALGO(lower, ds, bs) \ - { #lower, CMD_DIGEST, g_digest_opts, DIGEST_OPT_LEN, &g_##lower, digest_run }, -#include -#undef DIGEST_ALGO - /* Cipher commands (not yet implemented) */ - { "base64", CMD_CIPHER, NULL, 0, NULL, NULL }, - { "des", CMD_CIPHER, NULL, 0, NULL, NULL }, - { "des-ecb", CMD_CIPHER, NULL, 0, NULL, NULL }, - { "des-cbc", CMD_CIPHER, NULL, 0, NULL, NULL }, - /* Sentinel */ - { NULL, 0, NULL, 0, NULL, NULL } -}; const struct command_descriptor * find_command(const char *name) { const struct command_descriptor *cmd; - for (cmd = s_commands; NULL != cmd->name; cmd++) + for (cmd = g_commands; NULL != cmd->name; cmd++) if (0 == strcmp(cmd->name, name)) return cmd; return NULL; } -void -print_commands(FILE *out) -{ - const struct command_descriptor *cmd; - - fprintf(out, "\nStandard commands:\n"); - fprintf(out, "\nMessage Digest commands:\n"); - for (cmd = s_commands; NULL != cmd->name; cmd++) - if (CMD_DIGEST == cmd->category) - fprintf(out, " %s\n", cmd->name); - fprintf(out, "\nCipher commands:\n"); - for (cmd = s_commands; NULL != cmd->name; cmd++) - if (CMD_CIPHER == cmd->category) - fprintf(out, " %s\n", cmd->name); -} diff --git a/src/cmd/digest_run.c b/src/cmd/digest_run.c index fb8b93c..6a625e0 100644 --- a/src/cmd/digest_run.c +++ b/src/cmd/digest_run.c @@ -7,8 +7,8 @@ #include "compiler.h" #include "ft_ssl.h" #include "ft_ssl_flags.h" -#include "internal/cmd/command.h" -#include "internal/cmd/digest_cmd.h" +#include "internal/cli/command.h" +#include "internal/cli/digest_cmd.h" #include "internal/ssl/ssl.h" #include "version_gen.h" @@ -45,11 +45,11 @@ digest_run(int argc, char **argv, const struct command_descriptor *self) ret_val = (int)CLI_SUCCESS; has_input = (0 < config.nb_strings || 0 < config.nb_files); if (HAS_FLAG(config.flags, FLAG_P) || !has_input) - update_ret(&ret_val, run_stdin(&config)); + update_ret(&ret_val, digest_run_stdin(&config)); for (i = 0; i < config.nb_strings; i++) - update_ret(&ret_val, run_string(&config, config.strings[i])); + update_ret(&ret_val, digest_run_string(&config, config.strings[i])); for (i = 0; i < config.nb_files; i++) - update_ret(&ret_val, run_file(&config, config.files[i])); + update_ret(&ret_val, digest_run_file(&config, config.files[i])); return ret_val; } diff --git a/src/cmd/global_option.c b/src/cmd/global_option.c new file mode 100644 index 0000000..dfc4efa --- /dev/null +++ b/src/cmd/global_option.c @@ -0,0 +1,22 @@ +#include "cli.h" +#include + +#define GLOBAL_OPTIONS_LIST \ + X('h', "help", no_argument, NULL, OPT_ARG_NONE, "Display this help and exit", 0) \ + X('v', "version", no_argument, NULL, OPT_ARG_NONE, "Display version informations and exit", 0) + +#define X(s, l, a, h, t, d, f) + 1 +enum { GLOBAL_NB_OPTS = 0 GLOBAL_OPTIONS_LIST }; +#undef X + +#define X(s, l, a, h, t, d, f) + (1 + (a != no_argument ? 1 : 0)) +enum { GLOBAL_OPTSTR_LEN = 1 GLOBAL_OPTIONS_LIST }; +#undef X + +/*static*/ const struct option_descriptor g_option_ft_ssl[] = { +#define X(s, l, a, h, t, d, f) { s, l, a, h, t, d, f }, + GLOBAL_OPTIONS_LIST +#undef X +}; + + diff --git a/src/main.c b/src/main.c index 5c54c94..d9c8830 100644 --- a/src/main.c +++ b/src/main.c @@ -4,11 +4,12 @@ #include -#include "internal/cmd/command.h" +#include "internal/cli/command.h" #include "version_gen.h" char *g_prog_name = NULL; + int main(int argc, char **argv) { @@ -17,6 +18,7 @@ main(int argc, char **argv) g_prog_name = argv[0]; cli_set_prog_name(g_prog_name); + /* if (argc < 2) { print_commands(stderr); @@ -40,6 +42,7 @@ main(int argc, char **argv) fprintf(stderr, "%s: %s: not yet implemented\n", argv[0], argv[1]); return 2; } + */ ret = cmd->run(argc - 1, argv + 1, cmd); return ((int)CLI_ERROR == ret) ? 2 : EXIT_SUCCESS; } diff --git a/src/ssl/digest.c b/src/ssl/digest/digest.c similarity index 100% rename from src/ssl/digest.c rename to src/ssl/digest/digest.c diff --git a/src/ssl/output.c b/src/ssl/digest/output.c similarity index 100% rename from src/ssl/output.c rename to src/ssl/digest/output.c diff --git a/src/ssl/run_file.c b/src/ssl/digest/run_file.c similarity index 85% rename from src/ssl/run_file.c rename to src/ssl/digest/run_file.c index a7c60a3..8a6a40d 100644 --- a/src/ssl/run_file.c +++ b/src/ssl/digest/run_file.c @@ -11,7 +11,7 @@ #include "version_gen.h" int -run_file(const struct digest_config *config, const char *path) +digest_run_file(const struct digest_config *config, const char *path) { int fd; int ret; diff --git a/src/ssl/run_stdin.c b/src/ssl/digest/run_stdin.c similarity index 96% rename from src/ssl/run_stdin.c rename to src/ssl/digest/run_stdin.c index 9cd774c..9ecdd94 100644 --- a/src/ssl/run_stdin.c +++ b/src/ssl/digest/run_stdin.c @@ -17,7 +17,7 @@ static ssize_t read_and_hash(const struct digest_config *config, union digest_ct /* ------------------- */ int -run_stdin(const struct digest_config *config) +digest_run_stdin(const struct digest_config *config) { if (HAS_FLAG(config->flags, FLAG_P) && !HAS_FLAG(config->flags, FLAG_Q)) return run_stdin_p(config); diff --git a/src/ssl/run_string.c b/src/ssl/digest/run_string.c similarity index 86% rename from src/ssl/run_string.c rename to src/ssl/digest/run_string.c index bc81892..353e9fc 100644 --- a/src/ssl/run_string.c +++ b/src/ssl/digest/run_string.c @@ -8,7 +8,7 @@ #include "internal/ssl/ssl.h" int -run_string(const struct digest_config *config, const char *s) +digest_run_string(const struct digest_config *config, const char *s) { union digest_ctx ctx; uint8_t digest[MAX_DIGEST_SIZE]; diff --git a/src/ssl_run.c b/src/ssl_run.c deleted file mode 100644 index 9ae5c3d..0000000 --- a/src/ssl_run.c +++ /dev/null @@ -1,56 +0,0 @@ -#include - -#include -#include - -#include "compiler.h" -#include "ft_ssl.h" -#include "ft_ssl_flags.h" -#include "internal/ssl/ssl.h" -#include "version_gen.h" - -/* Forward declarations */ -static int check_algo(const struct ssl_config *config); -static inline void update_ret(int *ret, int result); -/* ------------------- */ - -int -ssl_run(const struct ssl_config *config) -{ - int ret; - int has_input; - int i; - - if (CLI_SUCCESS != check_algo(config)) - return CLI_ERROR; - ret = CLI_SUCCESS; - has_input = (0 < config->nb_strings || 0 < config->nb_files); - if (HAS_FLAG(config->flags, FLAG_P) || !has_input) - update_ret(&ret, run_stdin(config)); - for (i = 0; i < config->nb_strings; i++) - update_ret(&ret, run_string(config, config->strings[i])); - for (i = 0; i < config->nb_files; i++) - update_ret(&ret, run_file(config, config->files[i])); - return ret; -} - -static int -check_algo(const struct ssl_config *config) -{ - if (NULL == config->algo->init - || NULL == config->algo->update - || NULL == config->algo->final) - { - fprintf(stderr, "%s: %s: not yet implemented\n", - g_prog_name, config->algo->name); - return CLI_ERROR; - } - return CLI_SUCCESS; -} - -static inline void -update_ret(int *ret, int result) -{ - if (CLI_ERROR == result) - *ret = CLI_ERROR; -}