23 #ifndef _ASTERISK_CLI_H
24 #define _ASTERISK_CLI_H
26 #if defined(__cplusplus) || defined(c_plusplus)
33 void ast_cli(
int fd,
const char *fmt, ...)
34 __attribute__((format(printf, 2, 3)));
38 #define CLI_NO_PERMS -1
40 #define RESULT_SUCCESS 0
41 #define RESULT_SHOWUSAGE 1
42 #define RESULT_FAILURE 2
44 #define CLI_SUCCESS (char *)RESULT_SUCCESS
45 #define CLI_SHOWUSAGE (char *)RESULT_SHOWUSAGE
46 #define CLI_FAILURE (char *)RESULT_FAILURE
48 #define AST_MAX_CMD_LEN 16
50 #define AST_MAX_ARGS 64
52 #define AST_CLI_COMPLETE_EOF "_EOF_"
59 #define ESS(x) ((x) == 1 ? "" : "s")
71 #define AST_CLI_YESNO(x) AST_YESNO(x)
78 #define AST_CLI_ONOFF(x) (x) ? "On" : "Off"
161 const char *
const *argv;
172 const char *
const cmda[AST_MAX_CMD_LEN];
192 #if defined(__cplusplus) || defined(c_plusplus)
193 #define AST_CLI_DEFINE(fn, txt) { { "" }, txt, NULL, 0, NULL, NULL, 0, 0, NULL, fn }
197 #define AST_CLI_DEFINE(fn, txt , ... ) { .handler = fn, .summary = txt, ## __VA_ARGS__ }
216 char *
ast_cli_complete(
const char *word,
const char *
const choices[],
int pos);
232 #define ast_cli_command(fd,s) ast_cli_command_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, s)
248 #define ast_cli_command_multiple(fd,size,s) ast_cli_command_multiple_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, size, s)
256 #define ast_cli_register(e) __ast_cli_register(e, AST_MODULE_SELF)
265 #define ast_cli_register_multiple(e, len) \
266 __ast_cli_register_multiple(e, len, AST_MODULE_SELF)
386 #if defined(__cplusplus) || defined(c_plusplus)
char ** ast_cli_completion_matches(const char *, const char *)
Generates a NULL-terminated array of strings that 1) begin with the string in the second parameter...
String manipulation functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
struct ast_cli_entry::@210 list
int args
This gets set in ast_cli_register()
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
struct ast_vector_string * ast_cli_completion_vector(const char *text, const char *word)
Generates a vector of strings for CLI completion.
int ast_cli_command_full(int uid, int gid, int fd, const char *s)
Interprets a command Interpret a command s, sending output to fd if uid:gid has permissions to run th...
A set of macros to manage forward-linked lists.
ast_cli_command
calling arguments for new-style handlers.
int ast_cli_allow_at_shutdown(struct ast_cli_entry *e)
Allow a CLI command to be executed while Asterisk is shutting down.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
char * ast_cli_generator(const char *, const char *, int)
Readline madness Useful for readline, that's about it.
void ast_cli_print_timestr_fromseconds(int fd, int seconds, const char *prefix)
Print on cli a duration in seconds in format s year(s), s week(s), s day(s), s hour(s), s second(s)
int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const char *s)
Executes multiple CLI commands Interpret strings separated by NULL and execute each one...
const char *const summary
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
String vector definitions.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
const char *const cmda[AST_MAX_CMD_LEN]
struct ast_module * module