2 * Asterisk -- A telephony toolkit for Linux.
4 * Standard Command Line Interface
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #ifndef _ASTERISK_CLI_H
15 #define _ASTERISK_CLI_H
17 #if defined(__cplusplus) || defined(c_plusplus)
23 extern void ast_cli(int fd, char *fmt, ...);
25 #define RESULT_SUCCESS 0
26 #define RESULT_SHOWUSAGE 1
27 #define RESULT_FAILURE 2
29 #define AST_MAX_CMD_LEN 16
31 /* A command line entry */
32 #define AST_MAX_ARGS 64
34 struct ast_cli_entry {
35 /* Null terminated list of the words of the command */
36 char *cmda[AST_MAX_CMD_LEN];
37 /* Handler for the command (fd for output, # of arguments, argument list).
38 Returns RESULT_SHOWUSAGE for improper arguments */
39 int (*handler)(int fd, int argc, char *argv[]);
40 /* Summary of the command (< 60 characters) */
42 /* Detailed usage information */
44 /* Generate a list of possible completions for a given word */
45 char *(*generator)(char *line, char *word, int pos, int state);
47 struct ast_cli_entry *next;
50 /* Interpret a command s, sending output to fd */
51 extern int ast_cli_command(int fd, char *s);
53 /* Register your own command */
54 extern int ast_cli_register(struct ast_cli_entry *e);
56 /* Unregister your own command */
57 extern int ast_cli_unregister(struct ast_cli_entry *e);
59 /* Useful for readline, that's about it */
60 extern char *ast_cli_generator(char *, char *, int);
62 #if defined(__cplusplus) || defined(c_plusplus)