16 #define MACRO_LIMIT 1024
17 #define MACRO_LABELS 20
18 #define RZ_CMD_MAXLEN 4096
67 #define RZ_CMD_ARG_FLAG_LAST (1 << 0)
72 #define RZ_CMD_ARG_FLAG_ARRAY (1 << 1)
76 #define RZ_CMD_ARG_FLAG_OPTION (1 << 2)
573 #define rz_cmd_desc_children_foreach(root, it_cd) rz_pvector_foreach (&root->children, it_cd)
600 #define rz_cmd_parsed_args_foreach_arg(args, i, arg) for ((i) = 1; (i) < (args->argc) && ((arg) = (args)->argv[i]); (i)++)
RZ_API void rz_cmd_macro_item_free(RzCmdMacroItem *item)
RZ_API RzCmdParsedArgs * rz_cmd_parsed_args_newargs(int n_args, char **args)
RZ_API void rz_cmd_desc_details_free(RzCmdDescDetail *details)
Free an array of RzCmdDescDetail sections.
RZ_API bool rz_cmd_get_help_json(RzCmd *cmd, const RzCmdDesc *cd, PJ *j)
Generates a JSON output of the given help message description.
RZ_API void rz_cmd_state_output_free(RZ_NONNULL RzCmdStateOutput *state)
Free the RzCmdStateOutput structure and its inner fields appropriately.
RZ_API RzCmdDesc * rz_cmd_get_desc(RzCmd *cmd, const char *cmd_identifier)
Retrieve the command descriptor for the command named cmd_identifier.
RZ_API char * rz_cmd_parsed_args_argstr(RzCmdParsedArgs *a)
RZ_API void rz_cmd_batch_end(RzCmd *cmd)
Mark the end of the batched changes to RzCmd.
RZ_API int rz_cmd_macro_call_multiple(RzCmdMacro *mac, const char *name)
RZ_API char * rz_cmd_parsed_args_execstr(RzCmdParsedArgs *a)
RZ_API bool rz_cmd_desc_set_default_mode(RzCmdDesc *cd, RzOutputMode mode)
Set the default mode of the command descriptor, if the type allows it.
RZ_API bool rz_cmd_state_output_init(RZ_NONNULL RzCmdStateOutput *state, RzOutputMode mode)
Initialize a RzCmdStateOutput structure and its inner fields based on the provided mode.
RZ_API RzCmdDesc * rz_cmd_desc_fake_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help)
RZ_API RzCmdDesc * rz_cmd_desc_argv_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdArgvCb cb, const RzCmdDescHelp *help)
RZ_API const char * rz_cmd_parsed_args_cmd(RzCmdParsedArgs *a)
RZ_API void rz_cmd_foreach_cmdname(RzCmd *cmd, RzCmdDesc *begin, RzCmdForeachNameCb cb, void *user)
Execute a callback function on each possible command the user can execute.
RZ_API void rz_cmd_alias_free(RzCmd *cmd)
RZ_API RzCmdDesc * rz_cmd_desc_oldinput_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdCb cb, const RzCmdDescHelp *help)
RZ_API void rz_cmd_state_output_set_columnsf(RzCmdStateOutput *state, const char *fmt,...)
Specify the columns of the command output.
RZ_API bool rz_cmd_alias_del(RzCmd *cmd, const char *k)
RZ_API bool rz_cmd_parsed_args_setcmd(RzCmdParsedArgs *a, const char *cmd)
RZ_API int rz_cmd_add(RzCmd *c, const char *cmd, RzCmdCb cb)
RZ_API char * rz_cmd_unescape_arg(const char *arg, RzCmdEscape esc)
RZ_API int rz_cmd_macro_add(RzCmdMacro *mac, const char *oname)
RZ_API void rz_cmd_macro_init(RzCmdMacro *mac)
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
RZ_API int rz_cmd_call(RzCmd *cmd, const char *input)
RZ_API bool rz_cmd_desc_has_handler(const RzCmdDesc *cd)
RZ_API void rz_cmd_state_output_fini(RZ_NONNULL RzCmdStateOutput *state)
Clear the inner fields of RzCmdStateOutput structure, but do not free it.
RZ_API bool rz_cmd_get_help_strbuf(RzCmd *cmd, const RzCmdDesc *cd, bool use_color, RzStrBuf *sb)
Generates a text output of the given help message description (summary format)
RZ_API RzCmdParsedArgs * rz_cmd_parsed_args_newcmd(const char *cmd)
RZ_API bool rz_cmd_parsed_args_setargs(RzCmdParsedArgs *a, int n_args, char **args)
RZ_API int rz_cmd_alias_set(RzCmd *cmd, const char *k, const char *v, int remote)
RZ_API char * rz_cmd_alias_get(RzCmd *cmd, const char *k, int remote)
RZ_API void rz_cmd_macro_fini(RzCmdMacro *mac)
RZ_API bool rz_cmd_desc_remove(RzCmd *cmd, RzCmdDesc *cd)
RZ_API RzCmdDesc * rz_cmd_get_root(RzCmd *cmd)
Get the root command descriptor.
RZ_API int rz_cmd_macro_call(RzCmdMacro *mac, const char *name)
RZ_API RzCmd * rz_cmd_free(RzCmd *cmd)
RZ_API RzCmdDesc * rz_cmd_desc_inner_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help)
RZ_API void rz_cmd_batch_start(RzCmd *cmd)
Mark the start of the batched changes to RzCmd.
RZ_API RzCmdStatus rz_cmd_call_parsed_args(RzCmd *cmd, RzCmdParsedArgs *args)
RZ_API RzCmdDesc * rz_cmd_desc_group_modes_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvModesCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help)
Create a new command descriptor for a name that is used both as a group but that has a sub-command wi...
RZ_API int rz_cmd_set_data(RzCmd *cmd, void *data)
RZ_API char * rz_cmd_get_help(RzCmd *cmd, RzCmdParsedArgs *args, bool use_color)
RZ_API RzCmdDesc * rz_cmd_desc_argv_modes_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvModesCb cb, const RzCmdDescHelp *help)
Create a new command descriptor for a command that supports multiple output modes (e....
RZ_API void rz_cmd_macro_meta(RzCmdMacro *mac)
RZ_API RzCmd * rz_cmd_new(bool has_cons)
RZ_API int rz_cmd_macro_break(RzCmdMacro *mac, const char *value)
RZ_API int rz_cmd_macro_rm(RzCmdMacro *mac, const char *_name)
RZ_API RzCmdDesc * rz_cmd_desc_group_state_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvStateCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help)
Create a new command descriptor for a name that is used both as a group but that has a sub-command wi...
RZ_API const RzCmdDescArg * rz_cmd_desc_get_arg(RzCmd *cmd, const RzCmdDesc *cd, size_t i)
Get a reference to the i-th argument of a command descriptor.
RZ_API RzCmdMacroItem * rz_cmd_macro_item_new(void)
RZ_API RzCmdDesc * rz_cmd_desc_parent(RzCmdDesc *cd)
RZ_API RzCmdDesc * rz_cmd_get_desc_best(RzCmd *cmd, const char *cmd_identifier)
Retrieve the command descriptor that best matches the name cmd_identifier.
RZ_API void rz_cmd_parsed_args_free(RzCmdParsedArgs *a)
RZ_API RzCmdDesc * rz_cmd_desc_get_exec(RzCmdDesc *cd)
RZ_API void rz_cmd_state_output_print(RZ_NONNULL RzCmdStateOutput *state)
Print the output accumulated in state to RzCons, if necessary.
RZ_API char * rz_cmd_escape_arg(const char *arg, RzCmdEscape esc)
RZ_API bool rz_cmd_parsed_args_addarg(RzCmdParsedArgs *a, const char *arg)
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
RZ_API RzCmdDesc * rz_cmd_desc_argv_state_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvStateCb cb, const RzCmdDescHelp *help)
Create a new command descriptor for a command that supports multiple output modes (e....
RZ_API RzCmdParsedArgs * rz_cmd_parsed_args_new(const char *cmd, int n_args, char **args)
RZ_API void rz_cmd_macro_list(RzCmdMacro *mac)
RZ_API char ** rz_cmd_alias_keys(RzCmd *cmd, int *sz)
RZ_API RzCmdDesc * rz_cmd_desc_group_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdArgvCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help)
Create a new command descriptor for a name that is used both as a group but that has a sub-command wi...
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
static static fork const void static count static fd const char const char static newpath char char argv
int(* RzCoreCmd)(void *core, const char *cmd)
bool(* RzCmdForeachNameCb)(RzCmd *cmd, const RzCmdDesc *desc, void *user)
enum rz_cmd_arg_type_t RzCmdArgType
RzCmdStatus(* RzCmdArgvModesCb)(RzCore *core, int argc, const char **argv, RzOutputMode mode)
@ RZ_CMD_ESCAPE_MULTI_ARG
The string should be escaped so that it appears as one or multiple arguments.
@ RZ_CMD_ESCAPE_SINGLE_QUOTED_ARG
The string should be escaped so that it can be wrapped in '....'.
@ RZ_CMD_ESCAPE_PF_ARG
The string should be escaped so that it appears as one or multiple pf arguments.
@ RZ_CMD_ESCAPE_ONE_ARG
The string should be escaped so that it appears as one single argument.
@ RZ_CMD_ESCAPE_DOUBLE_QUOTED_ARG
The string should be escaped so that it can be wrapped in "....".
struct rz_cmd_descriptor_t RzCmdDescriptor
struct rz_cmd_desc_detail_t RzCmdDescDetail
struct rz_cmd_item_t RzCmdItem
int(* RzCmdCb)(void *user, const char *input)
enum rz_cmd_desc_type_t RzCmdDescType
RZ_OWN RzCmdDescDetail *(* RzCmdDescDetailCb)(RzCore *core, int argc, const char **argv)
struct rz_cmd_desc_help_t RzCmdDescHelp
@ RZ_CMD_DESC_TYPE_ARGV_STATE
@ RZ_CMD_DESC_TYPE_ARGV_MODES
@ RZ_CMD_DESC_TYPE_OLDINPUT
struct rz_cmd_macro_t RzCmdMacro
int(* RzCmdNullCb)(void *user)
enum rz_cmd_status_t RzCmdStatus
enum rz_cmd_escape_t RzCmdEscape
struct rz_cmd_parsed_args_t RzCmdParsedArgs
struct rz_cmd_desc_arg_t RzCmdDescArg
@ RZ_CMD_ARG_TYPE_FCN
Argument can be the name of an existing function.
@ RZ_CMD_ARG_TYPE_CLASS_TYPE
Argument is a C++/etc class name.
@ RZ_CMD_ARG_TYPE_MACRO
Argument is the name of a pre-defined macro.
@ RZ_CMD_ARG_TYPE_CMD
Argument is an rizin command.
@ RZ_CMD_ARG_TYPE_STRING
Argument that can be an arbitrary string.
@ RZ_CMD_ARG_TYPE_EVAL_KEY
Argument is the name of a evaluable variable (e.g. et command)
@ RZ_CMD_ARG_TYPE_EVAL_FULL
Argument is the name+(optional)value of a evaluable variable (e.g. e command)
@ RZ_CMD_ARG_TYPE_FCN_VAR
Argument is the name of a function variable/argument.
@ RZ_CMD_ARG_TYPE_STRUCT_TYPE
Argument is a C struct type name.
@ RZ_CMD_ARG_TYPE_ENUM_TYPE
Argument is a C enum type name.
@ RZ_CMD_ARG_TYPE_OPTION
Argument is an option, prefixed with -. It is present or not. No argument.
@ RZ_CMD_ARG_TYPE_CHOICES
Argument can be one of the provided choices.
@ RZ_CMD_ARG_TYPE_NUM
Argument is a number.
@ RZ_CMD_ARG_TYPE_RZNUM
Argument that can be interpreted by RzNum (numbers, flags, operations, etc.)
@ RZ_CMD_ARG_TYPE_REG_TYPE
Argument is a register type/arena like "gpr".
@ RZ_CMD_ARG_TYPE_ANY_TYPE
Argument is the any of the C or C++ type name.
@ RZ_CMD_ARG_TYPE_FLAG
Argument is a rizin flag.
@ RZ_CMD_ARG_TYPE_UNION_TYPE
Argument is a C union type name.
@ RZ_CMD_ARG_TYPE_ALIAS_TYPE
Argument is a C typedef (alias) name.
@ RZ_CMD_ARG_TYPE_REG_FILTER
Argument is a register name, size, type or "all".
@ RZ_CMD_ARG_TYPE_FILE
Argument is a filename.
@ RZ_CMD_ARG_TYPE_GLOBAL_VAR
Argument is a user defined global variable.
@ RZ_CMD_ARG_TYPE_ENV
Argument can be the name of an existing rizin variable.
@ RZ_CMD_ARG_TYPE_FAKE
This is not considered a real argument, just used to show something in the help. Name of arg is shown...
struct rz_cmd_desc_t RzCmdDesc
struct rz_cmd_desc_detail_entry_t RzCmdDescDetailEntry
A detailed entry that can be used to show additional info about a command entry.
struct rz_cmd_macro_item_t RzCmdMacroItem
RzCmdStatus(* RzCmdArgvCb)(RzCore *core, int argc, const char **argv)
RZ_OWN char **(* RzCmdArgChoiceCb)(RzCore *core)
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_WRONG_ARGS
command handler could not handle the arguments passed to it
@ RZ_CMD_STATUS_NONEXISTINGCMD
command does not exist
@ RZ_CMD_STATUS_INVALID
command could not be executed (e.g. shell level error, bad expression, etc.)
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
@ RZ_CMD_STATUS_EXIT
command handler asks to exit the prompt loop
struct rz_cmd_alias_t RzCmdAlias
RzCmdStatus(* RzCmdArgvStateCb)(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
struct rz_cmd_state_output_t RzCmdStateOutput
Represent the output state of a command handler.
struct rz_cmd_macro_label_t RzCmdMacroLabel
int(* PrintfCallback)(const char *str,...) RZ_PRINTF_CHECK(1
RzOutputMode
Enum to describe the way data are printed.
RzCmdArgChoiceCb choices_cb
const char * default_value
A detailed entry that can be used to show additional info about a command entry.
const RzCmdDescDetailEntry * entries
RzCmdDescDetailCb details_cb
const RzCmdDescDetail * details
const RzCmdDescArg * args
struct rz_cmd_desc_t * exec_cd
struct rz_cmd_desc_t * parent
int modes
A combination of RzOutputMode values.
const RzCmdDescHelp * help
RzOutputMode default_mode
Make one of the modes the default one, used even when the special suffix is not specified.
struct rz_cmd_desc_t::@262::@267 argv_state_data
union rz_cmd_desc_t::@262 d
struct rz_cmd_desc_t::@262::@264 argv_data
struct rz_cmd_desc_t::@262::@265 group_data
struct rz_cmd_desc_t::@262::@263 oldinput_data
struct rz_cmd_desc_t::@262::@266 argv_modes_data
const char ** help_detail2
struct rz_cmd_descriptor_t * sub[127]
const char ** help_detail
RzCmdMacroLabel labels[MACRO_LABELS]
char * extra
Extra data that is neither a command name nor an argument (e.g. command modifiers/specifiers,...
Represent the output state of a command handler.
union rz_cmd_state_output_t::@259 d
RzCmdDesc * root_cmd_desc
RzCmdItem * cmds[UT8_MAX]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)