Standard Command Line Interface. More...
#include <stdarg.h>
#include "asterisk/linkedlists.h"
Go to the source code of this file.
Data Structures | |
struct | ast_cli_entry |
A command line entry. More... | |
Defines | |
#define | AST_CLI_COMPLETE_EOF "_EOF_" |
#define | AST_MAX_ARGS 64 |
#define | AST_MAX_CMD_LEN 16 |
#define | RESULT_FAILURE 2 |
#define | RESULT_SHOWUSAGE 1 |
#define | RESULT_SUCCESS 0 |
Functions | |
void | ast_cli (int fd, char *fmt,...) |
int | ast_cli_command (int fd, const char *s) |
Interprets a command Interpret a command s, sending output to fd Returns 0 on succes, -1 on failure. | |
int | ast_cli_command_multiple (int fd, size_t size, const char *s) |
Executes multiple CLI commands Interpret strings separated by '' and execute each one, sending output to fd. | |
char * | ast_cli_complete (const char *word, char *const choices[], int pos) |
Helper function to generate cli entries from a NULL-terminated array. Returns the n-th matching entry from the array, or NULL if not found. Can be used to implement generate() for static entries as below (in this example we complete the word in position 2):. | |
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, and 2) are valid in a command after the string in the first parameter. | |
char * | ast_cli_generator (const char *, const char *, int) |
Readline madness Useful for readline, that's about it Returns 0 on success, -1 on failure. | |
int | ast_cli_generatornummatches (const char *, const char *) |
Return the number of unique matches for the generator. | |
int | ast_cli_register (struct ast_cli_entry *e) |
Registers a command or an array of commands. | |
void | ast_cli_register_multiple (struct ast_cli_entry *e, int len) |
Register multiple commands. | |
int | ast_cli_unregister (struct ast_cli_entry *e) |
Unregisters a command or an array of commands. | |
void | ast_cli_unregister_multiple (struct ast_cli_entry *e, int len) |
Unregister multiple commands. | |
char * | ast_complete_channels (const char *line, const char *word, int pos, int state, int rpos) |
Command completion for the list of active channels. |
Standard Command Line Interface.
Definition in file cli.h.
#define AST_CLI_COMPLETE_EOF "_EOF_" |
Definition at line 45 of file cli.h.
Referenced by ast_el_strtoarr(), cli_complete(), and handle_commandmatchesarray().
#define AST_MAX_ARGS 64 |
Definition at line 43 of file cli.h.
Referenced by __ast_cli_generator(), and ast_cli_command().
#define AST_MAX_CMD_LEN 16 |
Definition at line 41 of file cli.h.
Referenced by find_best().
#define RESULT_FAILURE 2 |
Definition at line 39 of file cli.h.
Referenced by agi_handle_command(), aji_test(), cli_audio_convert(), cli_audio_convert_deprecated(), cli_queue_member_count(), cli_realtime_load(), cli_realtime_update(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_hangup(), console_hangup_deprecated(), console_sendtext(), console_sendtext_deprecated(), console_transfer(), console_transfer_deprecated(), dahdi_destroy_channel_bynum(), dahdi_restart_cmd(), dahdi_show_channel(), dahdi_show_channels(), dahdi_show_status(), handle_answer(), handle_commandmatchesarray(), handle_context_add_extension(), handle_context_add_extension_deprecated(), handle_context_add_ignorepat(), handle_context_add_ignorepat_deprecated(), handle_context_add_include(), handle_context_add_include_deprecated(), handle_context_dont_include_deprecated(), handle_context_remove_extension(), handle_context_remove_extension_deprecated(), handle_context_remove_ignorepat(), handle_context_remove_ignorepat_deprecated(), handle_context_remove_include(), handle_controlstreamfile(), handle_getoption(), handle_load(), handle_load_deprecated(), handle_logger_reload(), handle_logger_rotate(), handle_mfcr2_set_debug(), handle_mfcr2_show_variants(), handle_queue_add_member(), handle_queue_remove_member(), handle_recordfile(), handle_recvchar(), handle_save_dialplan(), handle_sayalpha(), handle_saydate(), handle_saydatetime(), handle_saydigits(), handle_saynumber(), handle_sayphonetic(), handle_saytime(), handle_sendimage(), handle_sendtext(), handle_show_application(), handle_show_application_deprecated(), handle_show_dialplan(), handle_show_function(), handle_show_function_deprecated(), handle_streamfile(), handle_unload(), handle_unload_deprecated(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_waitfordigit(), logger_reload(), misdn_send_display(), qmc_handler(), realtime_pgsql_status(), rpt_do_dump(), rpt_do_fun(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_reload(), rpt_do_restart(), rpt_do_stats(), set_member_paused(), show_channeltype(), show_channeltype_deprecated(), and sip_notify().
#define RESULT_SHOWUSAGE 1 |
Definition at line 38 of file cli.h.
Referenced by __iax2_show_peers(), __queues_show(), __say_init(), __sip_show_channels(), _sip_show_peer(), _sip_show_peers(), agent_logoff_cmd(), agents_show(), agents_show_online(), agi_do_debug(), agi_handle_command(), agi_no_debug(), agi_no_debug_deprecated(), aji_test(), ast_cli_command(), cli_audio_convert(), cli_audio_convert_deprecated(), cli_queue_member_count(), console_active(), console_active_deprecated(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_hangup(), console_hangup_deprecated(), console_mute(), console_mute_deprecated(), console_sendtext(), console_sendtext_deprecated(), console_transfer(), console_transfer_deprecated(), console_unmute(), console_unmute_deprecated(), dahdi_destroy_channel(), dahdi_restart_cmd(), dahdi_show_channel(), dahdi_show_channels(), database_del(), database_deltree(), database_get(), database_put(), database_show(), database_showkey(), dundi_do_debug(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_do_store_history(), dundi_flush(), dundi_no_debug(), dundi_no_store_history(), dundi_show_entityid(), dundi_show_mappings(), dundi_show_peer(), dundi_show_peers(), dundi_show_precache(), dundi_show_requests(), dundi_show_trans(), features_show(), group_show_channels(), gtalk_show_channels(), h323_do_debug(), h323_do_trace(), h323_ep_hangup(), h323_gk_cycle(), h323_no_debug(), h323_no_trace(), h323_tokens_show(), h323_version_show(), handle_abort_halt(), handle_add_indication(), handle_agidumphtml(), handle_autohangup(), handle_chanlist(), handle_chanlist_deprecated(), handle_channelstatus(), handle_cli_refresh(), handle_cli_reload(), handle_cli_status(), handle_cli_submit(), handle_commandcomplete(), handle_commandmatchesarray(), handle_commandnummatches(), handle_context_add_extension(), handle_context_add_extension_deprecated(), handle_context_add_ignorepat(), handle_context_add_ignorepat_deprecated(), handle_context_add_include(), handle_context_add_include_deprecated(), handle_context_dont_include_deprecated(), handle_context_remove_extension(), handle_context_remove_extension_deprecated(), handle_context_remove_ignorepat(), handle_context_remove_ignorepat_deprecated(), handle_context_remove_include(), handle_controlstreamfile(), handle_core_set_debug_channel(), handle_dbdel(), handle_dbdeltree(), handle_dbget(), handle_dbput(), handle_debugchan_deprecated(), handle_debuglevel_deprecated(), handle_exec(), handle_getdata(), handle_getoption(), handle_getvariable(), handle_getvariablefull(), handle_hangup(), handle_help(), handle_load(), handle_load_deprecated(), handle_logger_mute(), handle_mfcr2_call_files(), handle_mfcr2_set_debug(), handle_mfcr2_show_channels(), handle_modlist(), handle_nodebug(), handle_nodebugchan_deprecated(), handle_orig(), handle_pri_debug(), handle_pri_no_debug(), handle_pri_really_debug(), handle_pri_set_debug_file(), handle_pri_show_span(), handle_pri_show_spans(), handle_queue_add_member(), handle_queue_remove_member(), handle_recordfile(), handle_recvchar(), handle_recvtext(), handle_reload(), handle_reload_deprecated(), handle_reload_extensions(), handle_remove_indication(), handle_restart_gracefully(), handle_restart_now(), handle_restart_when_convenient(), handle_save_dialplan(), handle_sayalpha(), handle_saydate(), handle_saydatetime(), handle_saydigits(), handle_saynumber(), handle_sayphonetic(), handle_saytime(), handle_sendimage(), handle_sendtext(), handle_set_debug(), handle_set_debug_deprecated(), handle_set_global(), handle_set_global_deprecated(), handle_set_verbose_deprecated(), handle_setcontext(), handle_setextension(), handle_setmusic(), handle_setpriority(), handle_show_application(), handle_show_application_deprecated(), handle_show_dialplan(), handle_show_function(), handle_show_function_deprecated(), handle_show_functions(), handle_show_functions_deprecated(), handle_show_http(), handle_show_version_files(), handle_show_version_files_deprecated(), handle_showagi(), handle_showchan(), handle_showchan_deprecated(), handle_showmanager(), handle_showmanagers(), handle_showmancmd(), handle_showuptime(), handle_showuptime_deprecated(), handle_shutdown_gracefully(), handle_shutdown_now(), handle_shutdown_when_convenient(), handle_softhangup(), handle_streamfile(), handle_tddmode(), handle_unload(), handle_unload_deprecated(), handle_verbose(), handle_version(), handle_version_deprecated(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_waitfordigit(), iax2_do_debug(), iax2_do_jb_debug(), iax2_do_trunk_debug(), iax2_no_debug(), iax2_no_jb_debug(), iax2_no_trunk_debug(), iax2_prov_cmd(), iax2_prune_realtime(), iax2_show_callnumber_usage(), iax2_show_channels(), iax2_show_firmware(), iax2_show_netstats(), iax2_show_peer(), iax2_show_registry(), iax2_show_stats(), iax2_show_threads(), iax2_show_users(), iax2_test_losspct(), iax_show_provisioning(), locals_show(), meetme_cmd(), mgcp_audit_endpoint(), mgcp_do_debug(), mgcp_no_debug(), mgcp_show_endpoints(), misdn_port_block(), misdn_port_down(), misdn_port_unblock(), misdn_port_up(), misdn_restart_pid(), misdn_restart_port(), misdn_send_cd(), misdn_send_digit(), misdn_send_display(), misdn_send_restart(), misdn_set_crypt_debug(), misdn_set_debug(), misdn_set_tics(), misdn_show_cl(), misdn_show_config(), misdn_show_port(), misdn_toggle_echocancel(), mixmonitor_cli(), orig_app(), orig_exten(), osp_show(), rpt_do_debug(), rpt_do_dump(), rpt_do_fun(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_reload(), rpt_do_restart(), rpt_do_stats(), rtcp_do_debug(), rtcp_do_debug_deprecated(), rtcp_do_debug_ip(), rtcp_do_debug_ip_deprecated(), rtcp_do_stats(), rtcp_do_stats_deprecated(), rtcp_no_debug(), rtcp_no_debug_deprecated(), rtcp_no_stats(), rtcp_no_stats_deprecated(), rtp_do_debug(), rtp_do_debug_ip(), rtp_no_debug(), show_channeltype(), show_channeltype_deprecated(), show_codec_n(), show_codec_n_deprecated(), show_codecs(), show_codecs_deprecated(), show_file_formats(), show_file_formats_deprecated(), show_image_formats(), show_image_formats_deprecated(), show_translation(), show_translation_deprecated(), sip_do_debug(), sip_do_debug_deprecated(), sip_do_debug_ip(), sip_do_debug_peer(), sip_do_history(), sip_no_debug(), sip_no_debug_deprecated(), sip_no_history(), sip_notify(), sip_prune_realtime(), sip_show_channel(), sip_show_history(), sip_show_inuse(), sip_show_objects(), sip_show_registry(), sip_show_settings(), sip_show_user(), sip_show_users(), skinny_do_debug(), skinny_no_debug(), skinny_reset_device(), skinny_show_devices(), skinny_show_lines(), stun_do_debug(), stun_no_debug(), udptl_do_debug(), udptl_do_debug_ip(), and udptl_nodebug().
#define RESULT_SUCCESS 0 |
Definition at line 37 of file cli.h.
Referenced by __console_mute_unmute(), __iax2_show_peers(), __queues_show(), __say_init(), __sip_show_channels(), _sip_show_peer(), _sip_show_peers(), agent_logoff_cmd(), agents_show(), agents_show_online(), agi_do_debug(), agi_no_debug(), agi_no_debug_deprecated(), aji_do_debug(), aji_do_reload(), aji_no_debug(), aji_show_clients(), cli_audio_convert(), cli_audio_convert_deprecated(), cli_queue_member_count(), cli_realtime_load(), cli_realtime_update(), console_active(), console_active_deprecated(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_hangup(), console_hangup_deprecated(), console_sendtext(), console_sendtext_deprecated(), console_transfer(), console_transfer_deprecated(), dahdi_destroy_channel_bynum(), dahdi_restart_cmd(), dahdi_show_channel(), dahdi_show_channels(), dahdi_show_status(), database_del(), database_deltree(), database_get(), database_put(), database_show(), database_showkey(), do_boost(), dundi_do_debug(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_do_store_history(), dundi_flush(), dundi_no_debug(), dundi_no_store_history(), dundi_show_entityid(), dundi_show_mappings(), dundi_show_peer(), dundi_show_peers(), dundi_show_precache(), dundi_show_requests(), dundi_show_trans(), features_show(), group_show_channels(), gtalk_do_reload(), gtalk_show_channels(), h323_do_debug(), h323_do_trace(), h323_ep_hangup(), h323_gk_cycle(), h323_no_debug(), h323_no_trace(), h323_tokens_show(), h323_version_show(), handle_abort_halt(), handle_agidumphtml(), handle_answer(), handle_autohangup(), handle_bang(), handle_chanlist(), handle_chanlist_deprecated(), handle_channelstatus(), handle_cli_wait_fullybooted(), handle_commandcomplete(), handle_commandmatchesarray(), handle_commandnummatches(), handle_context_add_extension(), handle_context_add_extension_deprecated(), handle_context_add_ignorepat(), handle_context_add_ignorepat_deprecated(), handle_context_add_include(), handle_context_add_include_deprecated(), handle_context_dont_include_deprecated(), handle_context_remove_extension(), handle_context_remove_extension_deprecated(), handle_context_remove_ignorepat(), handle_context_remove_ignorepat_deprecated(), handle_context_remove_include(), handle_controlstreamfile(), handle_core_set_debug_channel(), handle_dbdel(), handle_dbdeltree(), handle_dbget(), handle_dbput(), handle_debugchan_deprecated(), handle_debuglevel_deprecated(), handle_getdata(), handle_getoption(), handle_getvariable(), handle_getvariablefull(), handle_hangup(), handle_help(), handle_load(), handle_load_deprecated(), handle_logger_mute(), handle_logger_rotate(), handle_logger_show_channels(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_mfcr2_show_variants(), handle_mfcr2_version(), handle_modlist(), handle_nodebug(), handle_nodebugchan_deprecated(), handle_noop(), handle_parkedcalls(), handle_pri_debug(), handle_pri_no_debug(), handle_pri_really_debug(), handle_pri_set_debug_file(), handle_pri_show_debug(), handle_pri_show_span(), handle_pri_show_spans(), handle_pri_version(), handle_queue_add_member(), handle_queue_remove_member(), handle_recordfile(), handle_recvchar(), handle_recvtext(), handle_reload(), handle_reload_deprecated(), handle_reload_extensions(), handle_restart_gracefully(), handle_restart_now(), handle_restart_when_convenient(), handle_save_dialplan(), handle_sayalpha(), handle_saydate(), handle_saydatetime(), handle_saydigits(), handle_saynumber(), handle_sayphonetic(), handle_saytime(), handle_sendimage(), handle_sendtext(), handle_set_debug(), handle_set_debug_deprecated(), handle_set_global(), handle_set_global_deprecated(), handle_set_verbose_deprecated(), handle_setcallerid(), handle_setcontext(), handle_setextension(), handle_setmusic(), handle_setpriority(), handle_setvariable(), handle_show_application(), handle_show_application_deprecated(), handle_show_applications(), handle_show_applications_deprecated(), handle_show_dialplan(), handle_show_function(), handle_show_function_deprecated(), handle_show_functions(), handle_show_functions_deprecated(), handle_show_globals(), handle_show_hints(), handle_show_http(), handle_show_settings(), handle_show_switches(), handle_show_threads(), handle_show_version_files(), handle_show_version_files_deprecated(), handle_showagi(), handle_showchan(), handle_showchan_deprecated(), handle_showfeatures(), handle_showmanager(), handle_showmanagers(), handle_showmancmd(), handle_showmancmds(), handle_showmanconn(), handle_showmaneventq(), handle_showuptime(), handle_showuptime_deprecated(), handle_shutdown_gracefully(), handle_shutdown_now(), handle_shutdown_when_convenient(), handle_softhangup(), handle_streamfile(), handle_tddmode(), handle_unload(), handle_unload_deprecated(), handle_verbose(), handle_version(), handle_version_deprecated(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_waitfordigit(), help1(), iax2_do_debug(), iax2_do_jb_debug(), iax2_do_trunk_debug(), iax2_no_debug(), iax2_no_jb_debug(), iax2_no_trunk_debug(), iax2_prov_cmd(), iax2_prune_realtime(), iax2_show_cache(), iax2_show_callnumber_usage(), iax2_show_channels(), iax2_show_firmware(), iax2_show_netstats(), iax2_show_peer(), iax2_show_registry(), iax2_show_stats(), iax2_show_threads(), iax2_show_users(), iax2_test_losspct(), iax_show_provisioning(), init_keys(), locals_show(), logger_reload(), manager_iax2_show_netstats(), manager_parking_status(), manager_queue_member_count(), manager_queues_show(), manager_queues_status(), meetme_cmd(), mgcp_audit_endpoint(), mgcp_do_debug(), mgcp_no_debug(), mgcp_show_endpoints(), misdn_send_display(), mixmonitor_cli(), orig_app(), orig_exten(), osp_show(), qmc_handler(), realtime_pgsql_status(), rpt_do_debug(), rpt_do_dump(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_stats(), rtcp_do_debug(), rtcp_do_debug_deprecated(), rtcp_do_debug_ip(), rtcp_do_debug_ip_deprecated(), rtcp_do_stats(), rtcp_do_stats_deprecated(), rtcp_no_debug(), rtcp_no_debug_deprecated(), rtcp_no_stats(), rtcp_no_stats_deprecated(), rtp_do_debug(), rtp_do_debug_ip(), rtp_no_debug(), set_member_paused(), show_channeltype(), show_channeltype_deprecated(), show_channeltypes(), show_codec_n(), show_codec_n_deprecated(), show_codecs(), show_codecs_deprecated(), show_file_formats(), show_file_formats_deprecated(), show_image_formats(), show_image_formats_deprecated(), show_keys(), show_license(), show_translation(), show_translation_deprecated(), show_warranty(), sip_do_debug(), sip_do_debug_deprecated(), sip_do_debug_ip(), sip_do_debug_peer(), sip_do_history(), sip_no_debug(), sip_no_debug_deprecated(), sip_no_history(), sip_notify(), sip_prune_realtime(), sip_show_channel(), sip_show_domains(), sip_show_history(), sip_show_inuse(), sip_show_objects(), sip_show_registry(), sip_show_settings(), sip_show_user(), sip_show_users(), skinny_do_debug(), skinny_no_debug(), skinny_reset_device(), skinny_show_devices(), skinny_show_lines(), sla_show_stations(), sla_show_trunks(), stun_do_debug(), stun_no_debug(), transcoder_show(), udptl_do_debug(), udptl_do_debug_ip(), and udptl_nodebug().
void ast_cli | ( | int | fd, | |
char * | fmt, | |||
... | ||||
) |
Definition at line 59 of file cli.c.
References ast_carefulwrite(), AST_CLI_INITLEN, ast_dynamic_str_thread_get(), ast_dynamic_str_thread_set_va, AST_DYNSTR_BUILD_FAILED, and ast_dynamic_str::str.
Referenced by __iax2_show_peers(), __queues_show(), __say_init(), __sip_show_channels(), _sip_show_peer(), _sip_show_peers(), agent_logoff_cmd(), agents_show(), agents_show_online(), agi_do_debug(), agi_no_debug(), agi_no_debug_deprecated(), aji_do_debug(), aji_do_reload(), aji_no_debug(), aji_show_clients(), aji_test(), ast_cli_command(), ast_cli_netstats(), ast_console_toggle_mute(), ast_httpd_helper_thread(), cli_audio_convert(), cli_audio_convert_deprecated(), cli_files_show(), cli_queue_member_count(), cli_realtime_load(), cli_realtime_update(), config_command(), console_active(), console_active_deprecated(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_hangup(), console_hangup_deprecated(), console_sendtext(), console_sendtext_deprecated(), console_transfer(), console_transfer_deprecated(), dahdi_show_channel(), dahdi_show_channels(), dahdi_show_status(), database_del(), database_deltree(), database_get(), database_put(), database_show(), database_showkey(), do_boost(), dundi_do_debug(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_do_store_history(), dundi_flush(), dundi_no_debug(), dundi_no_store_history(), dundi_show_entityid(), dundi_show_mappings(), dundi_show_peer(), dundi_show_peers(), dundi_show_precache(), dundi_show_requests(), dundi_show_trans(), features_show(), group_show_channels(), gtalk_show_channels(), h323_do_debug(), h323_do_trace(), h323_no_debug(), h323_no_trace(), handle_agidumphtml(), handle_chanlist(), handle_chanlist_deprecated(), handle_cli_refresh(), handle_cli_status(), handle_cli_submit(), handle_cli_wait_fullybooted(), handle_commandcomplete(), handle_commandmatchesarray(), handle_commandnummatches(), handle_context_add_extension(), handle_context_add_extension_deprecated(), handle_context_add_ignorepat(), handle_context_add_ignorepat_deprecated(), handle_context_add_include(), handle_context_add_include_deprecated(), handle_context_dont_include_deprecated(), handle_context_remove_extension(), handle_context_remove_extension_deprecated(), handle_context_remove_ignorepat(), handle_context_remove_ignorepat_deprecated(), handle_context_remove_include(), handle_core_set_debug_channel(), handle_dahdi_show_cadences(), handle_debugchan_deprecated(), handle_debuglevel_deprecated(), handle_help(), handle_load(), handle_load_deprecated(), handle_logger_reload(), handle_logger_rotate(), handle_logger_show_channels(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_mfcr2_show_variants(), handle_mfcr2_version(), handle_modlist(), handle_nodebug(), handle_nodebugchan_deprecated(), handle_parkedcalls(), handle_pri_debug(), handle_pri_no_debug(), handle_pri_really_debug(), handle_pri_set_debug_file(), handle_pri_show_debug(), handle_pri_show_span(), handle_pri_show_spans(), handle_pri_version(), handle_queue_add_member(), handle_queue_remove_member(), handle_reload(), handle_reload_deprecated(), handle_reload_extensions(), handle_restart_when_convenient(), handle_save_dialplan(), handle_set_debug(), handle_set_debug_deprecated(), handle_set_global(), handle_set_global_deprecated(), handle_set_verbose_deprecated(), handle_show_application(), handle_show_application_deprecated(), handle_show_applications(), handle_show_applications_deprecated(), handle_show_dialplan(), handle_show_function(), handle_show_function_deprecated(), handle_show_functions(), handle_show_functions_deprecated(), handle_show_globals(), handle_show_hints(), handle_show_http(), handle_show_indications(), handle_show_profile(), handle_show_profile_deprecated(), handle_show_settings(), handle_show_switches(), handle_show_threads(), handle_show_version_files(), handle_show_version_files_deprecated(), handle_showagi(), handle_showchan(), handle_showchan_deprecated(), handle_showfeatures(), handle_showmanager(), handle_showmanagers(), handle_showmancmd(), handle_showmancmds(), handle_showmanconn(), handle_showmaneventq(), handle_shutdown_when_convenient(), handle_softhangup(), handle_unload(), handle_unload_deprecated(), handle_verbose(), handle_version(), handle_version_deprecated(), handle_voicemail_show_users(), handle_voicemail_show_zones(), help1(), help_workhorse(), iax2_do_debug(), iax2_do_jb_debug(), iax2_do_trunk_debug(), iax2_no_debug(), iax2_no_jb_debug(), iax2_no_trunk_debug(), iax2_prov_cmd(), iax2_prune_realtime(), iax2_show_cache(), iax2_show_callnumber_usage(), iax2_show_channels(), iax2_show_firmware(), iax2_show_netstats(), iax2_show_peer(), iax2_show_registry(), iax2_show_stats(), iax2_show_threads(), iax2_show_users(), iax_show_provisioning(), locals_show(), meetme_cmd(), mgcp_audit_endpoint(), mgcp_do_debug(), mgcp_no_debug(), mgcp_show_endpoints(), misdn_reload(), misdn_send_cd(), misdn_send_digit(), misdn_send_display(), misdn_set_debug(), misdn_show_cls(), misdn_show_config(), misdn_show_port(), misdn_show_ports_stats(), misdn_show_stacks(), misdn_toggle_echocancel(), mixmonitor_cli(), modlist_modentry(), moh_classes_show(), odbc_show_command(), orig_app(), orig_exten(), osp_show(), print_bc_info(), print_codec_to_cli(), print_group(), print_uptimestr(), realtime_pgsql_status(), rpt_do_debug(), rpt_do_dump(), rpt_do_fun(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_stats(), rtcp_do_debug(), rtcp_do_debug_deprecated(), rtcp_do_debug_ip(), rtcp_do_debug_ip_deprecated(), rtcp_do_stats(), rtcp_do_stats_deprecated(), rtcp_no_debug(), rtcp_no_debug_deprecated(), rtcp_no_stats(), rtcp_no_stats_deprecated(), rtp_do_debug(), rtp_do_debug_ip(), rtp_no_debug(), show_channeltype(), show_channeltype_deprecated(), show_channeltypes(), show_codec_n(), show_codec_n_deprecated(), show_codecs(), show_codecs_deprecated(), show_config_description(), show_dialplan_helper(), show_file_formats(), show_file_formats_deprecated(), show_image_formats(), show_image_formats_deprecated(), show_keys(), show_license(), show_translation(), show_translation_deprecated(), show_warranty(), sip_do_debug(), sip_do_debug_deprecated(), sip_do_debug_ip(), sip_do_debug_peer(), sip_do_history(), sip_no_debug(), sip_no_debug_deprecated(), sip_no_history(), sip_notify(), sip_prune_realtime(), sip_show_channel(), sip_show_domains(), sip_show_history(), sip_show_inuse(), sip_show_objects(), sip_show_registry(), sip_show_settings(), sip_show_user(), sip_show_users(), skinny_do_debug(), skinny_no_debug(), skinny_show_devices(), skinny_show_lines(), sla_show_stations(), sla_show_trunks(), stun_do_debug(), stun_no_debug(), transcoder_show(), udptl_do_debug(), udptl_do_debug_ip(), and udptl_nodebug().
00060 { 00061 int res; 00062 struct ast_dynamic_str *buf; 00063 va_list ap; 00064 00065 if (!(buf = ast_dynamic_str_thread_get(&ast_cli_buf, AST_CLI_INITLEN))) 00066 return; 00067 00068 va_start(ap, fmt); 00069 res = ast_dynamic_str_thread_set_va(&buf, 0, &ast_cli_buf, fmt, ap); 00070 va_end(ap); 00071 00072 if (res != AST_DYNSTR_BUILD_FAILED) 00073 ast_carefulwrite(fd, buf->str, strlen(buf->str), 100); 00074 }
int ast_cli_command | ( | int | fd, | |
const char * | s | |||
) |
Interprets a command Interpret a command s, sending output to fd Returns 0 on succes, -1 on failure.
Definition at line 2000 of file cli.c.
References ast_cli_entry::_deprecated_by, ast_cli_entry::_full_cmd, ast_atomic_fetchadd_int(), ast_cli(), AST_LIST_LOCK, AST_LIST_UNLOCK, AST_MAX_ARGS, ast_cli_entry::deprecated, find_best(), find_cli(), free, ast_cli_entry::handler, ast_cli_entry::inuse, parse_args(), RESULT_SHOWUSAGE, and ast_cli_entry::usage.
Referenced by action_command(), ast_cli_command_multiple(), cli_activate(), consolehandler(), exit_completely(), and rpt_exec().
02001 { 02002 char *argv[AST_MAX_ARGS]; 02003 struct ast_cli_entry *e; 02004 int x; 02005 char *dup; 02006 int tws; 02007 02008 if (!(dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) 02009 return -1; 02010 02011 /* We need at least one entry, or ignore */ 02012 if (x > 0) { 02013 AST_LIST_LOCK(&helpers); 02014 e = find_cli(argv, 0); 02015 if (e) 02016 e->inuse++; 02017 AST_LIST_UNLOCK(&helpers); 02018 if (e) { 02019 switch(e->handler(fd, x, argv)) { 02020 case RESULT_SHOWUSAGE: 02021 if (e->usage) 02022 ast_cli(fd, "%s", e->usage); 02023 else 02024 ast_cli(fd, "Invalid usage, but no usage information available.\n"); 02025 AST_LIST_LOCK(&helpers); 02026 if (e->deprecated) 02027 ast_cli(fd, "The '%s' command is deprecated and will be removed in a future release. Please use '%s' instead.\n", e->_full_cmd, e->_deprecated_by); 02028 AST_LIST_UNLOCK(&helpers); 02029 break; 02030 default: 02031 AST_LIST_LOCK(&helpers); 02032 if (e->deprecated == 1) { 02033 ast_cli(fd, "The '%s' command is deprecated and will be removed in a future release. Please use '%s' instead.\n", e->_full_cmd, e->_deprecated_by); 02034 e->deprecated = 2; 02035 } 02036 AST_LIST_UNLOCK(&helpers); 02037 break; 02038 } 02039 } else 02040 ast_cli(fd, "No such command '%s' (type 'help %s' for other possible commands)\n", s, find_best(argv)); 02041 if (e) 02042 ast_atomic_fetchadd_int(&e->inuse, -1); 02043 } 02044 free(dup); 02045 02046 return 0; 02047 }
int ast_cli_command_multiple | ( | int | fd, | |
size_t | size, | |||
const char * | s | |||
) |
Executes multiple CLI commands Interpret strings separated by '' and execute each one, sending output to fd.
size | is the total size of the string |
number | of commands executed |
Definition at line 2049 of file cli.c.
References ast_cli_command().
Referenced by netconsole().
02050 { 02051 char cmd[512]; 02052 int x, y = 0, count = 0; 02053 02054 for (x = 0; x < size; x++) { 02055 cmd[y] = s[x]; 02056 y++; 02057 if (s[x] == '\0') { 02058 ast_cli_command(fd, cmd); 02059 y = 0; 02060 count++; 02061 } 02062 } 02063 return count; 02064 }
char* ast_cli_complete | ( | const char * | word, | |
char *const | choices[], | |||
int | pos | |||
) |
Helper function to generate cli entries from a NULL-terminated array. Returns the n-th matching entry from the array, or NULL if not found. Can be used to implement generate() for static entries as below (in this example we complete the word in position 2):.
char *my_generate(const char *line, const char *word, int pos, int n) { static char *choices = { "one", "two", "three", NULL }; if (pos == 2) return ast_cli_complete(word, choices, n); else return NULL; }
Definition at line 1173 of file cli.c.
References ast_strdup, ast_strlen_zero(), and len().
Referenced by autoanswer_complete(), autoanswer_complete_deprecated(), complete_meetmecmd(), complete_orig(), complete_show_applications(), complete_show_applications_deprecated(), complete_show_channels(), and complete_show_channels_deprecated().
01174 { 01175 int i, which = 0, len; 01176 len = ast_strlen_zero(word) ? 0 : strlen(word); 01177 01178 for (i = 0; choices[i]; i++) { 01179 if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) 01180 return ast_strdup(choices[i]); 01181 } 01182 return NULL; 01183 }
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, and 2) are valid in a command after the string in the first parameter.
The first entry (offset 0) of the result is the longest common substring in the results, useful to extend the string that has been completed. Subsequent entries are all possible values, followe by a NULL. All strings and the array itself are malloc'ed and must be freed by the caller.
Definition at line 1904 of file cli.c.
References ast_cli_generator(), ast_copy_string(), ast_malloc, and ast_realloc.
Referenced by cli_complete(), and handle_commandmatchesarray().
01905 { 01906 char **match_list = NULL, *retstr, *prevstr; 01907 size_t match_list_len, max_equal, which, i; 01908 int matches = 0; 01909 01910 /* leave entry 0 free for the longest common substring */ 01911 match_list_len = 1; 01912 while ((retstr = ast_cli_generator(text, word, matches)) != NULL) { 01913 if (matches + 1 >= match_list_len) { 01914 match_list_len <<= 1; 01915 if (!(match_list = ast_realloc(match_list, match_list_len * sizeof(*match_list)))) 01916 return NULL; 01917 } 01918 match_list[++matches] = retstr; 01919 } 01920 01921 if (!match_list) 01922 return match_list; /* NULL */ 01923 01924 /* Find the longest substring that is common to all results 01925 * (it is a candidate for completion), and store a copy in entry 0. 01926 */ 01927 prevstr = match_list[1]; 01928 max_equal = strlen(prevstr); 01929 for (which = 2; which <= matches; which++) { 01930 for (i = 0; i < max_equal && toupper(prevstr[i]) == toupper(match_list[which][i]); i++) 01931 continue; 01932 max_equal = i; 01933 } 01934 01935 if (!(retstr = ast_malloc(max_equal + 1))) 01936 return NULL; 01937 01938 ast_copy_string(retstr, match_list[1], max_equal + 1); 01939 match_list[0] = retstr; 01940 01941 /* ensure that the array is NULL terminated */ 01942 if (matches + 1 >= match_list_len) { 01943 if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list)))) 01944 return NULL; 01945 } 01946 match_list[matches + 1] = NULL; 01947 01948 return match_list; 01949 }
char* ast_cli_generator | ( | const char * | , | |
const char * | , | |||
int | ||||
) |
Readline madness Useful for readline, that's about it Returns 0 on success, -1 on failure.
Definition at line 1995 of file cli.c.
References __ast_cli_generator().
Referenced by ast_cli_completion_matches(), and ast_cli_generatornummatches().
01996 { 01997 return __ast_cli_generator(text, word, state, 1); 01998 }
int ast_cli_generatornummatches | ( | const char * | , | |
const char * | ||||
) |
Return the number of unique matches for the generator.
Definition at line 1887 of file cli.c.
References ast_cli_generator(), and free.
Referenced by handle_commandnummatches().
01888 { 01889 int matches = 0, i = 0; 01890 char *buf = NULL, *oldbuf = NULL; 01891 01892 while ((buf = ast_cli_generator(text, word, i++))) { 01893 if (!oldbuf || strcmp(buf,oldbuf)) 01894 matches++; 01895 if (oldbuf) 01896 free(oldbuf); 01897 oldbuf = buf; 01898 } 01899 if (oldbuf) 01900 free(oldbuf); 01901 return matches; 01902 }
int ast_cli_register | ( | struct ast_cli_entry * | e | ) |
Registers a command or an array of commands.
e | which cli entry to register Register your own command Returns 0 on success, -1 on failure |
Definition at line 1729 of file cli.c.
References __ast_cli_register().
Referenced by ast_cdr_engine_init(), ast_cli_register_multiple(), dnsmgr_init(), do_reload(), and load_module().
01730 { 01731 return __ast_cli_register(e, NULL); 01732 }
void ast_cli_register_multiple | ( | struct ast_cli_entry * | e, | |
int | len | |||
) |
Register multiple commands.
e | pointer to first cli entry to register | |
len | number of entries to register |
Definition at line 1737 of file cli.c.
References ast_cli_register().
Referenced by __ast_register_translator(), ast_builtins_init(), ast_channels_init(), ast_file_init(), ast_http_init(), ast_image_init(), ast_rtp_init(), ast_test_init(), ast_udptl_init(), ast_utils_init(), astdb_init(), astobj2_init(), crypto_init(), iax_provision_init(), init_framer(), init_logger(), init_manager(), load_module(), load_pbx(), main(), and register_config_cli().
01738 { 01739 int i; 01740 01741 for (i = 0; i < len; i++) 01742 ast_cli_register(e + i); 01743 }
int ast_cli_unregister | ( | struct ast_cli_entry * | e | ) |
Unregisters a command or an array of commands.
e | which cli entry to unregister Unregister your own command. You must pass a completed ast_cli_entry structure Returns 0. |
Definition at line 1723 of file cli.c.
References __ast_cli_unregister().
Referenced by ast_cli_unregister_multiple(), do_reload(), load_module(), and unload_module().
01724 { 01725 return __ast_cli_unregister(e, NULL); 01726 }
void ast_cli_unregister_multiple | ( | struct ast_cli_entry * | e, | |
int | len | |||
) |
Unregister multiple commands.
e | pointer to first cli entry to unregister | |
len | number of entries to unregister |
Definition at line 1745 of file cli.c.
References ast_cli_unregister().
Referenced by __unload_module(), iax_provision_unload(), load_module(), and unload_module().
01746 { 01747 int i; 01748 01749 for (i = 0; i < len; i++) 01750 ast_cli_unregister(e + i); 01751 }
char* ast_complete_channels | ( | const char * | line, | |
const char * | word, | |||
int | pos, | |||
int | state, | |||
int | rpos | |||
) |
Command completion for the list of active channels.
This can be called from a CLI command completion function that wants to complete from the list of active channels. 'rpos' is the required position in the command. This function will return NULL immediately if 'rpos' is not the same as the current position, 'pos'.
Definition at line 1199 of file cli.c.
References ast_channel_unlock, ast_channel_walk_locked(), and ast_strdup.
Referenced by complete_ch_3(), complete_ch_4(), complete_ch_5(), and complete_mixmonitor_cli().
01200 { 01201 struct ast_channel *c = NULL; 01202 int which = 0; 01203 int wordlen; 01204 char notfound = '\0'; 01205 char *ret = ¬found; /* so NULL can break the loop */ 01206 01207 if (pos != rpos) 01208 return NULL; 01209 01210 wordlen = strlen(word); 01211 01212 while (ret == ¬found && (c = ast_channel_walk_locked(c))) { 01213 if (!strncasecmp(word, c->name, wordlen) && ++which > state) 01214 ret = ast_strdup(c->name); 01215 ast_channel_unlock(c); 01216 } 01217 return ret == ¬found ? NULL : ret; 01218 }