23#ifndef _ASTERISK_CLI_H
24#define _ASTERISK_CLI_H
26#if defined(__cplusplus) || defined(c_plusplus)
33void 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"
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__ }
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)
int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *mod)
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),...
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
char * ast_cli_generator(const char *, const char *, int)
Readline madness Useful for readline, that's about it.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *mod)
int ast_cli_allow_at_shutdown(struct ast_cli_entry *e)
Allow a CLI command to be executed while Asterisk is shutting down.
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
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,...
ast_cli_command
calling arguments for new-style handlers.
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...
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,...
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static char prefix[MAX_PREFIX]
A set of macros to manage forward-linked lists.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
String manipulation functions.
descriptor for a cli entry.
struct ast_cli_entry::@212 list
int args
This gets set in ast_cli_register()
const char *const summary
struct ast_module * module
const char *const cmda[AST_MAX_CMD_LEN]
String vector definitions.