== AsteriskSource/ConSole == * argument c * option_console * ast_register_verbose(console_verboser); * ast_cli_register(&quit); * consolethread = pthread_self(); * rl_callback_handler_install(tmp, consolehandler); * rl_completion_entry_function = (void *)(Function *)cli_generator; * for(;;) * FD_ZERO(&rfds); * FD_SET(STDIN_FILENO, &rfds); * res = select(STDIN_FILENO + 1, &rfds, NULL, NULL, NULL); * if (res > 0) * rl_callback_read_char(); -> consolehandler * else * rl_forced_update_display(); * static void consolehandler(char *s) * asterisk.c * add_history(s); * ast_cli_command(STDOUT_FILENO, s); * int ast_cli_command(int fd, char *s) * cli.c * dup = parse_args(s, &x, argv) * e = find_cli(argv, 0); * switch(e->handler(fd, x, argv)) * case RESULT_SHOWUSAGE: * ast_cli(fd, e->usage); * static struct ast_cli_entry *find_cli(char *cmds[], int exact) {{{ //! A command line entry */ struct ast_cli_entry { /*! Null terminated list of the words of the command */ char *cmda[AST_MAX_CMD_LEN]; /*! Handler for the command (fd for output, # of arguments, argument list). Returns RESULT_SHOWUSAGE for improper arguments */ int (*handler)(int fd, int argc, char *argv[]); /*! Summary of the command (< 60 characters) */ char *summary; /*! Detailed usage information */ char *usage; /*! Generate a list of possible completions for a given word */ char *(*generator)(char *line, char *word, int pos, int state); /*! For linking */ struct ast_cli_entry *next; /*! For keeping track of usage */ int inuse; }; }}} * aborthalt * quit * astshutdownnow * astshutdowngracefully * astrestartnow * astrestartconvenient * builtins * help handle_help * _command complete handle_commandcomplete * load handle_load * reload handle_reload * set verbose handle_set_verbose * show channel handle_showchan * show channels handle_chanlist * show modules handle_modlist * show version handle_version * soft hangup handle_softhangup * unload handle_unload * helpers == GNU Readline library == * void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler) * Set up the terminal for readline I/O and display the initial expanded value of prompt. Save the value of lhandler to use as a function to call when a complete line of input has been entered. The function takes the text of the line as an argument. * void rl_callback_read_char (void) * Whenever an application determines that keyboard input is available, it should call rl_callback_read_char(), which will read the next character from the current input source. If that character completes the line, rl_callback_read_char will invoke the lhandler function saved by rl_callback_handler_install to process the line. Before calling the lhandler function, the terminal settings are reset to the values they had before calling rl_callback_handler_install. If the lhandler function returns, the terminal settings are modified for Readline's use again. EOF is indicated by calling lhandler with a NULL line. * int rl_complete (int ignore, int invoking_key) * Complete the word at or before point. You have supplied the function that does the initial simple matching selection algorithm (see rl_completion_matches()). The default is to do filename completion. * rl_compentry_func_t * rl_completion_entry_function * This is a pointer to the generator function for rl_completion_matches(). If the value of rl_completion_entry_function is NULL then the default filename generator function, rl_filename_completion_function(), is used. * rl_forced_update_display() * this redraws the readline prompt, nothing else works with the above commands