| 1 | /* |
| 2 | Authors: |
| 3 | Pavel Březina <[email protected]> |
| 4 | |
| 5 | Copyright (C) 2015 Red Hat |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _CLI_TOOL_H_ |
| 22 | #define _CLI_TOOL_H_cxx . . $ `src/cli/cli_tool.h:22:9`! |
| 23 | |
| 24 | #include <stdbool.h> |
| 25 | #include <popt.h> |
| 26 | |
| 27 | struct cli_cmdlinecxx . . $ cli_cmdline#; |
| 28 | |
| 29 | typedef errno_tcxx . . $ errno_t# |
| 30 | (*cli_route_fncxx . . $ cli_route_fn#)(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline); |
| 31 | |
| 32 | #define CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`! 0x0000 |
| 33 | #define CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`! 0x0001 |
| 34 | #define CLI_CMD_HIDDENcxx . . $ `src/cli/cli_tool.h:34:9`! 0x0002 |
| 35 | |
| 36 | #define CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!(cmd, msg, flags, fn) {cmd, _cxx . . $ `src/common/common.h:33:9`!(msg), (flags), fn} |
| 37 | #define CLI_TOOL_COMMAND_NOMSGcxx . . $ `src/cli/cli_tool.h:37:9`!(cmd, flags, fn) {cmd, NULL, (flags), fn} |
| 38 | #define CLI_TOOL_DELIMITERcxx . . $ `src/cli/cli_tool.h:38:9`!(message) {"", _cxx . . $ `src/common/common.h:33:9`!(message), CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!} |
| 39 | #define CLI_TOOL_LASTcxx . . $ `src/cli/cli_tool.h:39:9`! {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!} |
| 40 | |
| 41 | struct cli_cmdlinecxx . . $ cli_cmdline# { |
| 42 | const char *execcxx . . $ cli_cmdline#exec.; /* argv[0] */ |
| 43 | const char *commandcxx . . $ cli_cmdline#command.; /* command name */ |
| 44 | int argccxx . . $ cli_cmdline#argc.; /* rest of arguments */ |
| 45 | const char **argvcxx . . $ cli_cmdline#argv.; |
| 46 | }; |
| 47 | |
| 48 | struct cli_route_cmdcxx . . $ cli_route_cmd# { |
| 49 | const char *commandcxx . . $ cli_route_cmd#command.; |
| 50 | const char *descriptioncxx . . $ cli_route_cmd#description.; |
| 51 | uint32_tcxx . . $ uint32_t# flagscxx . . $ cli_route_cmd#flags.; |
| 52 | cli_route_fncxx . . $ cli_route_fn# fncxx . . $ cli_route_cmd#fn.; |
| 53 | }; |
| 54 | |
| 55 | void cli_tool_usagecxx . . $ cli_tool_usage(9ffe2780c1253a7a).(const char *tool_name, struct cli_route_cmdcxx . . $ cli_route_cmd# *commands); |
| 56 | |
| 57 | typedef errno_tcxx . . $ errno_t# (*cli_popt_fncxx . . $ cli_popt_fn#)(poptContextcxx . . $ poptContext# pc, char option, void *pvt); |
| 58 | |
| 59 | enum cli_tool_optcxx . . $ cli_tool_opt# { |
| 60 | CLI_TOOL_OPT_REQUIREDcxx . . $ CLI_TOOL_OPT_REQUIRED., |
| 61 | CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL. |
| 62 | }; |
| 63 | |
| 64 | errno_tcxx . . $ errno_t# cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline, |
| 65 | struct poptOptioncxx . . $ poptOption# *options, |
| 66 | enum cli_tool_optcxx . . $ cli_tool_opt# require_option, |
| 67 | cli_popt_fncxx . . $ cli_popt_fn# popt_fn, |
| 68 | void *popt_fn_pvt, |
| 69 | const char *fopt_name, |
| 70 | const char *fopt_help, |
| 71 | char **_fopt, |
| 72 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! allow_more_free_opts, |
| 73 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! *_opt_set); |
| 74 | |
| 75 | errno_tcxx . . $ errno_t# cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline, |
| 76 | struct poptOptioncxx . . $ poptOption# *options, |
| 77 | enum cli_tool_optcxx . . $ cli_tool_opt# require_option, |
| 78 | cli_popt_fncxx . . $ cli_popt_fn# popt_fn, |
| 79 | void *popt_fn_pvt); |
| 80 | |
| 81 | int cli_tool_maincxx . . $ cli_tool_main(d9b5b3c5de31f8fa).(int argc, const char **argv, |
| 82 | struct cli_route_cmdcxx . . $ cli_route_cmd# *commands, |
| 83 | void *pvt); |
| 84 | |
| 85 | #endif /* _CLI_TOOL_H_ */ |