Standard Command Line Interface. More...
#include "asterisk/linkedlists.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_cli_args |
| struct | ast_cli_entry |
| descriptor for a cli entry. More... | |
Defines | |
| #define | ast_cli_command(fd, s) ast_cli_command_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, s) |
| #define | ast_cli_command_multiple(fd, size, s) ast_cli_command_multiple_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, size, s) |
| #define | AST_CLI_COMPLETE_EOF "_EOF_" |
| #define | AST_CLI_DEFINE(fn, txt,...) { .handler = fn, .summary = txt, ## __VA_ARGS__ } |
| #define | AST_CLI_ONOFF(x) (x) ? "On" : "Off" |
| return On or Off depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point). | |
| #define | AST_CLI_YESNO(x) (x) ? "Yes" : "No" |
| return Yes or No depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point). | |
| #define | AST_MAX_ARGS 64 |
| #define | AST_MAX_CMD_LEN 16 |
| #define | CLI_FAILURE (char *)RESULT_FAILURE |
| #define | CLI_NO_PERMS -1 |
| #define | CLI_SHOWUSAGE (char *)RESULT_SHOWUSAGE |
| #define | CLI_SUCCESS (char *)RESULT_SUCCESS |
| #define | ESS(x) ((x) == 1 ? "" : "s") |
| #define | RESULT_FAILURE 2 |
| #define | RESULT_SHOWUSAGE 1 |
| #define | RESULT_SUCCESS 0 |
Enumerations | |
| enum | ast_cli_command { CLI_INIT = -2, CLI_GENERATE = -3, CLI_HANDLER = -4 } |
| calling arguments for new-style handlers. More... | |
Functions | |
| void | ast_cli (int fd, const char *fmt,...) |
| 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 this command. uid = CLI_NO_PERMS to avoid checking user permissions gid = CLI_NO_PERMS to avoid checking group permissions. | |
| 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, sending output to fd if uid has permissions, uid = CLI_NO_PERMS to avoid checking users permissions. gid = CLI_NO_PERMS to avoid checking group permissions. | |
| char * | ast_cli_complete (const char *word, const char *const choices[], int pos) |
| 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. | |
| 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. | |
| int | 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. | |
| int | 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_command | ( | fd, | |
| s | |||
| ) | ast_cli_command_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, s) |
| #define ast_cli_command_multiple | ( | fd, | |
| size, | |||
| s | |||
| ) | ast_cli_command_multiple_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, size, s) |
| #define AST_CLI_COMPLETE_EOF "_EOF_" |
Definition at line 51 of file cli.h.
Referenced by ast_el_strtoarr(), cli_complete(), and handle_commandmatchesarray().
| #define AST_CLI_DEFINE | ( | fn, | |
| txt, | |||
| ... | |||
| ) | { .handler = fn, .summary = txt, ## __VA_ARGS__ } |
| #define AST_CLI_ONOFF | ( | x | ) | (x) ? "On" : "Off" |
return On or Off depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point).
Definition at line 72 of file cli.h.
Referenced by sip_show_settings().
| #define AST_CLI_YESNO | ( | x | ) | (x) ? "Yes" : "No" |
return Yes or No depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point).
Definition at line 65 of file cli.h.
Referenced by sip_show_users(), _sip_show_peer(), sip_show_user(), sip_show_settings(), sip_show_mwi(), show_channels_cb(), sip_show_channel(), handle_skinny_show_settings(), handle_feature_show(), action_coresettings(), and handle_manager_show_settings().
| #define AST_MAX_ARGS 64 |
Definition at line 49 of file cli.h.
Referenced by handle_cli_check_permissions(), __ast_cli_generator(), and ast_cli_command_full().
| #define AST_MAX_CMD_LEN 16 |
Definition at line 47 of file cli.h.
Referenced by find_best(), and __ast_cli_register().
| #define CLI_FAILURE (char *)RESULT_FAILURE |
Definition at line 45 of file cli.h.
Referenced by meetme_show_cmd(), meetme_cmd(), handle_minivm_list_templates(), handle_minivm_show_users(), handle_minivm_show_zones(), handle_queue_add_member(), handle_queue_remove_member(), handle_queue_pause_member(), handle_queue_set_member_penalty(), res2cli(), show_users_realtime(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_cc_status(), handle_cli_status(), console_answer(), console_sendtext(), console_hangup(), console_dial(), cli_console_autoanswer(), cli_console_flash(), cli_console_dial(), cli_console_hangup(), cli_console_mute(), cli_console_answer(), cli_console_sendtext(), cli_console_active(), dahdi_destroy_channel(), dahdi_restart_cmd(), dahdi_show_channel(), dahdi_show_status(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_set_dnd(), handle_cli_iax2_show_peers(), handle_cli_iax2_set_debug(), console_cmd(), console_autoanswer(), console_do_answer(), console_flash(), console_transfer(), sip_cli_notify(), handle_cli_core_show_channeltype(), handle_load(), handle_verbose(), handle_unload(), handle_chanlist(), handle_softhangup(), handle_cli_check_permissions(), handle_commandmatchesarray(), ast_cli_command_full(), ais_clm_show_members(), handle_cli_data_get(), handle_cli_devstate_change(), cli_odbc_read(), cli_odbc_write(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_logger_reload(), handle_logger_rotate(), handle_show_function(), handle_show_application(), handle_show_dialplan(), handle_debug_dialplan(), handle_show_chanvar(), handle_set_chanvar(), handle_cli_ael_reload(), handle_cli_dialplan_remove_include(), handle_cli_dialplan_remove_extension(), handle_cli_dialplan_add_include(), handle_cli_dialplan_save(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_add_ignorepat(), handle_cli_dialplan_remove_ignorepat(), handle_cli_agi_add_cmd(), handle_cli_agi_show(), handle_redirect(), realtime_ldap_status(), handle_cli_realtime_pgsql_status(), handle_cli_file_convert(), cli_fax_show_sessions(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_cli_delete_pubsub_node(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_test(), handle_cli_ulimit(), cli_realtime_update(), cli_realtime_update2(), cli_realtime_store(), cli_realtime_destroy(), rtp_do_debug_ip(), rtcp_do_debug_ip(), cli_tps_ping(), timing_test(), and handle_cli_core_show_translation().
| #define CLI_NO_PERMS -1 |
Definition at line 37 of file cli.h.
Referenced by cli_has_permissions().
| #define CLI_SHOWUSAGE (char *)RESULT_SHOWUSAGE |
Definition at line 44 of file cli.h.
Referenced by aoc_cli_debug_enable(), meetme_show_cmd(), meetme_cmd(), handle_minivm_list_templates(), handle_minivm_show_users(), handle_minivm_show_zones(), handle_cli_mixmonitor(), handle_cli_osp_show(), __say_cli_init(), __queues_show(), handle_queue_add_member(), handle_queue_remove_member(), handle_queue_pause_member(), handle_queue_set_member_penalty(), handle_queue_rule_show(), handle_queue_reset(), handle_queue_reload(), res2cli(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_voicemail_reload(), handle_show_version_files(), handle_version(), handle_stop_now(), handle_stop_gracefully(), handle_stop_when_convenient(), handle_restart_now(), handle_restart_gracefully(), handle_restart_when_convenient(), handle_abort_shutdown(), handle_cc_status(), handle_cc_kill(), handle_cli_status(), handle_cli_submit(), agent_logoff_cmd(), agents_show(), agents_show_online(), console_autoanswer(), console_answer(), console_sendtext(), console_hangup(), console_dial(), console_mute(), cli_console_autoanswer(), cli_console_flash(), cli_console_dial(), cli_console_hangup(), cli_console_mute(), cli_list_available(), cli_list_devices(), cli_console_answer(), cli_console_sendtext(), cli_console_active(), handle_pri_set_debug_file(), handle_pri_debug(), handle_pri_show_channels(), handle_pri_show_spans(), handle_pri_show_span(), dahdi_destroy_channel(), dahdi_restart_cmd(), dahdi_show_channels(), dahdi_show_channel(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_set_dnd(), handle_ss7_debug(), handle_ss7_block_cic(), handle_ss7_block_linkset(), handle_ss7_unblock_cic(), handle_ss7_unblock_linkset(), handle_ss7_show_linkset(), gtalk_show_channels(), handle_cli_h323_set_trace(), handle_cli_h323_set_debug(), handle_cli_h323_cycle_gk(), handle_cli_h323_hangup(), handle_cli_h323_show_tokens(), handle_cli_h323_show_version(), handle_cli_h323_reload(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_prune_realtime(), handle_cli_iax2_test_losspct(), handle_cli_iax2_show_peer(), handle_cli_iax2_show_stats(), handle_cli_iax2_set_mtu(), handle_cli_iax2_show_users(), handle_cli_iax2_show_threads(), handle_cli_iax2_unregister(), handle_cli_iax2_show_peers(), handle_cli_iax2_show_firmware(), handle_cli_iax2_show_registry(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_netstats(), handle_cli_iax2_set_debug(), handle_cli_iax2_set_debug_trunk(), handle_cli_iax2_set_debug_jb(), handle_cli_iax2_provision(), jingle_show_channels(), locals_show(), handle_mgcp_show_endpoints(), handle_mgcp_audit_endpoint(), handle_mgcp_set_debug(), handle_cli_misdn_set_debug(), handle_cli_misdn_set_crypt_debug(), handle_cli_misdn_port_block(), handle_cli_misdn_port_unblock(), handle_cli_misdn_restart_port(), handle_cli_misdn_restart_pid(), handle_cli_misdn_port_up(), handle_cli_misdn_port_down(), handle_cli_misdn_show_config(), handle_cli_misdn_reload(), handle_cli_misdn_show_channels(), handle_cli_misdn_show_channel(), handle_cli_misdn_set_tics(), handle_cli_misdn_show_stacks(), handle_cli_misdn_show_ports_stats(), handle_cli_misdn_show_port(), handle_cli_misdn_send_facility(), handle_cli_misdn_send_restart(), handle_cli_misdn_send_digit(), handle_cli_misdn_toggle_echocancel(), handle_cli_misdn_send_display(), console_cmd(), console_flash(), console_transfer(), console_active(), sip_show_inuse(), sip_show_tcp(), sip_show_users(), _sip_show_peers(), sip_show_objects(), sip_prune_realtime(), _sip_qualify_peer(), _sip_show_peer(), sip_show_user(), sip_show_registry(), sip_unregister(), sip_show_channelstats(), sip_show_settings(), sip_show_channels(), sip_show_channel(), sip_show_history(), sip_do_debug_ip(), sip_do_debug(), sip_cli_notify(), sip_set_history(), handle_skinny_set_debug(), handle_skinny_reload(), handle_skinny_reset(), _skinny_show_devices(), _skinny_show_device(), _skinny_show_lines(), handle_skinny_show_lines(), _skinny_show_line(), handle_skinny_show_settings(), unistim_info(), unistim_sp(), unistim_do_debug(), unistim_reload(), handle_cli_core_show_channeltypes(), handle_cli_core_show_channeltype(), handle_load(), handle_core_reload(), handle_verbose(), handle_logger_mute(), handle_unload(), handle_showuptime(), handle_modlist(), handle_showcalls(), handle_chanlist(), handle_softhangup(), handle_cli_check_permissions(), handle_commandmatchesarray(), handle_commandnummatches(), handle_commandcomplete(), handle_core_set_debug_channel(), handle_nodebugchan_deprecated(), handle_showchan(), group_show_channels(), ast_cli_command_full(), ais_clm_show_members(), handle_cli_transcoder_show(), handle_cli_config_reload(), handle_cli_data_get(), handle_cli_database_put(), handle_cli_database_get(), handle_cli_database_del(), handle_cli_database_deltree(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_reload(), handle_cli_refresh(), event_dump_cache(), ais_evt_show_event_channels(), handle_parkedcalls(), handle_cli_core_show_file_formats(), show_codecs(), show_codec_n(), handle_cli_devstate_list(), handle_cli_devstate_change(), cli_odbc_read(), cli_odbc_write(), handle_show_http(), iax_show_provisioning(), handle_core_show_image_formats(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_logger_set_level(), handle_showmancmd(), handle_mandebug(), handle_showmanager(), handle_showmanagers(), handle_manager_reload(), handle_manager_show_settings(), handle_show_functions(), handle_show_function(), handle_show_application(), handle_show_hint(), handle_show_dialplan(), handle_debug_dialplan(), handle_show_chanvar(), handle_set_global(), handle_set_chanvar(), handle_set_extenpatternmatchnew(), handle_unset_extenpatternmatchnew(), handle_cli_ael_set_debug(), handle_cli_ael_reload(), handle_cli_dialplan_remove_include(), handle_cli_dialplan_remove_extension(), handle_cli_dialplan_add_include(), handle_cli_dialplan_save(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_add_ignorepat(), handle_cli_dialplan_remove_ignorepat(), handle_cli_dialplan_reload(), dundi_set_debug(), dundi_store_history(), dundi_flush(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_show_peer(), dundi_show_peers(), dundi_show_trans(), dundi_show_entityid(), dundi_show_requests(), dundi_show_mappings(), dundi_show_precache(), handle_cli_agi_add_cmd(), handle_cli_agi_debug(), handle_cli_agi_show(), handle_cli_agi_dump_html(), handle_show_calendar(), orig_app(), orig_exten(), handle_orig(), handle_redirect(), handle_cli_realtime_pgsql_status(), handle_cli_show_sqlite_status(), handle_cli_sqlite_show_tables(), handle_cli_file_convert(), handle_cli_keys_init(), cli_fax_show_version(), cli_fax_set_debug(), cli_fax_show_session(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_cli_delete_pubsub_node(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_do_set_debug(), aji_test(), handle_cli_ulimit(), handle_cli_moh_reload(), handle_cli_moh_show_files(), handle_cli_moh_show_classes(), pktccops_gatedel(), pktccops_gateset(), pktccops_debug(), cli_realtime_load(), cli_realtime_update(), cli_realtime_update2(), cli_realtime_store(), cli_realtime_destroy(), handle_cli_rtp_set_debug(), handle_cli_rtcp_set_debug(), handle_cli_rtcp_set_stats(), handle_cli_stun_set_debug(), cli_tps_ping(), cli_tps_report(), timing_test(), handle_cli_core_show_translation(), and handle_cli_udptl_set_debug().
| #define CLI_SUCCESS (char *)RESULT_SUCCESS |
Definition at line 43 of file cli.h.
Referenced by aoc_cli_debug_enable(), meetme_show_cmd(), meetme_cmd(), sla_show_trunks(), sla_show_stations(), handle_minivm_list_templates(), handle_minivm_show_users(), handle_minivm_show_zones(), handle_minivm_show_settings(), handle_minivm_show_stats(), handle_minivm_reload(), handle_cli_mixmonitor(), handle_cli_osp_show(), __say_cli_init(), __queues_show(), handle_queue_add_member(), handle_queue_remove_member(), handle_queue_pause_member(), handle_queue_set_member_penalty(), handle_queue_rule_show(), handle_queue_reset(), handle_queue_reload(), res2cli(), show_users_realtime(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_voicemail_reload(), handle_show_settings(), handle_show_threads(), handle_show_sysinfo(), handle_show_profile(), handle_clear_profile(), handle_show_version_files(), handle_version(), handle_stop_now(), handle_stop_gracefully(), handle_stop_when_convenient(), handle_restart_now(), handle_restart_gracefully(), handle_restart_when_convenient(), handle_abort_shutdown(), handle_bang(), show_warranty(), show_license(), handle_cc_status(), handle_cc_kill(), handle_cli_status(), handle_cli_submit(), agent_logoff_cmd(), agents_show(), agents_show_online(), console_autoanswer(), console_answer(), console_sendtext(), console_hangup(), console_dial(), console_mute(), cli_console_autoanswer(), cli_console_flash(), cli_console_dial(), cli_console_hangup(), cli_console_mute(), cli_list_available(), cli_list_devices(), cli_console_answer(), cli_console_sendtext(), cli_console_active(), handle_pri_set_debug_file(), handle_pri_debug(), handle_pri_show_channels(), handle_pri_show_spans(), handle_pri_show_span(), handle_pri_show_debug(), handle_pri_version(), dahdi_destroy_channel(), dahdi_restart_cmd(), dahdi_show_channels(), dahdi_show_channel(), handle_dahdi_show_cadences(), dahdi_show_status(), dahdi_show_version(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_set_dnd(), handle_ss7_debug(), handle_ss7_block_cic(), handle_ss7_block_linkset(), handle_ss7_unblock_cic(), handle_ss7_unblock_linkset(), handle_ss7_show_linkset(), handle_ss7_version(), gtalk_show_channels(), handle_cli_h323_set_trace(), handle_cli_h323_set_debug(), handle_cli_h323_cycle_gk(), handle_cli_h323_hangup(), handle_cli_h323_show_tokens(), handle_cli_h323_show_version(), handle_cli_h323_reload(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_prune_realtime(), handle_cli_iax2_test_losspct(), handle_cli_iax2_show_peer(), handle_cli_iax2_show_stats(), handle_cli_iax2_set_mtu(), handle_cli_iax2_show_cache(), handle_cli_iax2_show_users(), handle_cli_iax2_show_threads(), handle_cli_iax2_unregister(), handle_cli_iax2_show_peers(), handle_cli_iax2_show_firmware(), handle_cli_iax2_show_registry(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_netstats(), handle_cli_iax2_set_debug(), handle_cli_iax2_set_debug_trunk(), handle_cli_iax2_set_debug_jb(), handle_cli_iax2_provision(), handle_cli_iax2_reload(), jingle_show_channels(), jingle_do_reload(), locals_show(), handle_mgcp_show_endpoints(), handle_mgcp_audit_endpoint(), handle_mgcp_set_debug(), mgcp_reload(), handle_cli_misdn_set_debug(), handle_cli_misdn_set_crypt_debug(), handle_cli_misdn_port_block(), handle_cli_misdn_port_unblock(), handle_cli_misdn_restart_port(), handle_cli_misdn_restart_pid(), handle_cli_misdn_port_up(), handle_cli_misdn_port_down(), handle_cli_misdn_show_config(), handle_cli_misdn_reload(), handle_cli_misdn_show_channels(), handle_cli_misdn_show_channel(), handle_cli_misdn_set_tics(), handle_cli_misdn_show_stacks(), handle_cli_misdn_show_ports_stats(), handle_cli_misdn_show_port(), handle_cli_misdn_send_facility(), handle_cli_misdn_send_restart(), handle_cli_misdn_send_digit(), handle_cli_misdn_toggle_echocancel(), handle_cli_misdn_send_display(), console_cmd(), console_do_answer(), console_flash(), console_transfer(), console_active(), console_boost(), sip_show_inuse(), sip_show_tcp(), sip_show_users(), _sip_show_peers(), sip_show_objects(), sip_prune_realtime(), sip_show_domains(), _sip_qualify_peer(), _sip_show_peer(), sip_show_user(), sip_show_sched(), sip_show_registry(), sip_unregister(), sip_show_channelstats(), sip_show_settings(), sip_show_mwi(), sip_show_channels(), sip_show_channel(), sip_show_history(), sip_do_debug_ip(), sip_do_debug_peer(), sip_do_debug(), sip_cli_notify(), sip_set_history(), sip_reload(), handle_skinny_set_debug(), handle_skinny_reload(), handle_skinny_reset(), _skinny_show_devices(), _skinny_show_device(), _skinny_show_lines(), _skinny_show_line(), handle_skinny_show_settings(), unistim_info(), unistim_sp(), unistim_do_debug(), unistim_reload(), handle_cli_core_show_channeltypes(), handle_cli_core_show_channeltype(), handle_load(), handle_reload(), handle_core_reload(), handle_verbose(), handle_logger_mute(), handle_unload(), handle_showuptime(), handle_modlist(), handle_chanlist(), handle_softhangup(), handle_cli_show_permissions(), handle_cli_reload_permissions(), handle_cli_check_permissions(), handle_commandmatchesarray(), handle_commandnummatches(), handle_commandcomplete(), handle_core_set_debug_channel(), handle_showchan(), group_show_channels(), handle_cli_wait_fullybooted(), help1(), handle_help(), ais_clm_show_members(), handle_cli_transcoder_show(), handle_cli_core_show_config_mappings(), handle_cli_config_reload(), handle_cli_config_list(), handle_cli_data_get(), handle_cli_data_show_providers(), handle_cli_database_put(), handle_cli_database_get(), handle_cli_database_del(), handle_cli_database_deltree(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_reload(), handle_cli_refresh(), event_dump_cache(), ais_evt_show_event_channels(), handle_feature_show(), handle_features_reload(), handle_parkedcalls(), handle_cli_core_show_file_formats(), show_codecs(), show_codec_n(), handle_cli_devstate_list(), handle_cli_devstate_change(), cli_odbc_read(), cli_odbc_write(), handle_show_http(), iax_show_provisioning(), handle_core_show_image_formats(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_cli_indication_show(), handle_logger_reload(), handle_logger_rotate(), handle_logger_set_level(), handle_logger_show_channels(), handle_showmancmd(), handle_mandebug(), handle_showmanager(), handle_showmanagers(), handle_showmancmds(), handle_showmanconn(), handle_showmaneventq(), handle_manager_reload(), handle_manager_show_settings(), handle_show_functions(), handle_show_function(), handle_show_application(), handle_show_hints(), handle_show_hint(), handle_show_switches(), handle_show_applications(), handle_show_dialplan(), handle_debug_dialplan(), handle_show_globals(), handle_show_chanvar(), handle_set_global(), handle_set_chanvar(), handle_set_extenpatternmatchnew(), handle_unset_extenpatternmatchnew(), handle_cli_ael_set_debug(), handle_cli_ael_reload(), handle_cli_dialplan_remove_include(), handle_cli_dialplan_remove_extension(), handle_cli_dialplan_add_include(), handle_cli_dialplan_save(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_add_ignorepat(), handle_cli_dialplan_remove_ignorepat(), handle_cli_dialplan_reload(), dundi_set_debug(), dundi_store_history(), dundi_flush(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_show_peer(), dundi_show_peers(), dundi_show_trans(), dundi_show_entityid(), dundi_show_requests(), dundi_show_mappings(), dundi_show_precache(), handle_cli_agi_add_cmd(), handle_cli_agi_debug(), help_workhorse(), handle_cli_agi_show(), handle_cli_agi_dump_html(), handle_show_calendars(), handle_show_calendar(), handle_dump_sched(), cli_alias_passthrough(), alias_show(), orig_app(), orig_exten(), handle_redirect(), realtime_ldap_status(), handle_cli_realtime_pgsql_status(), handle_cli_show_sqlite_status(), handle_cli_sqlite_show_tables(), handle_cli_file_convert(), handle_cli_keys_show(), handle_cli_keys_init(), cli_fax_show_version(), cli_fax_set_debug(), cli_fax_show_capabilities(), cli_fax_show_settings(), cli_fax_show_session(), cli_fax_show_stats(), cli_fax_show_sessions(), spandsp_fax_cli_show_capabilities(), spandsp_fax_cli_show_session(), spandsp_fax_cli_show_stats(), spandsp_fax_cli_show_settings(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_cli_delete_pubsub_node(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_do_set_debug(), aji_do_reload(), aji_show_clients(), handle_cli_ulimit(), handle_cli_moh_reload(), handle_cli_moh_show_files(), handle_cli_moh_show_classes(), handle_cli_odbc_show(), handle_show_routes(), pktccops_show_cmtses(), pktccops_show_gates(), pktccops_show_pools(), pktccops_gatedel(), pktccops_gateset(), pktccops_debug(), cli_realtime_load(), cli_realtime_update(), cli_realtime_update2(), cli_realtime_store(), cli_realtime_destroy(), rtp_do_debug_ip(), rtcp_do_debug_ip(), handle_cli_rtp_set_debug(), handle_cli_rtcp_set_debug(), handle_cli_rtcp_set_stats(), handle_cli_stun_set_debug(), cli_tps_ping(), cli_tps_report(), timing_test(), handle_cli_core_show_translation(), and handle_cli_udptl_set_debug().
| #define ESS | ( | x | ) | ((x) == 1 ? "" : "s") |
In many cases we need to print singular or plural words depending on a count. This macro helps us e.g. printf("we have %d object%s", n, ESS(n));
Definition at line 58 of file cli.h.
Referenced by handle_cli_status(), sip_show_channels(), print_uptimestr(), handle_showcalls(), handle_chanlist(), group_show_channels(), handle_parkedcalls(), cli_realtime_update(), cli_realtime_update2(), and cli_realtime_destroy().
| #define RESULT_FAILURE 2 |
Definition at line 41 of file cli.h.
Referenced by set_member_paused(), set_member_penalty(), get_member_penalty(), handle_queue_set_member_penalty(), rpt_do_dump(), rpt_do_stats(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_reload(), rpt_do_restart(), rpt_do_fun(), rpt_do_fun1(), rpt_do_cmd(), handle_gosub(), dahdi_destroy_channel_bynum(), handle_cli_iax2_show_peers(), logger_reload(), handle_answer(), handle_waitfordigit(), handle_sendtext(), handle_recvchar(), handle_sendimage(), handle_controlstreamfile(), handle_streamfile(), handle_getoption(), handle_saynumber(), handle_saydigits(), handle_sayalpha(), handle_saydate(), handle_saytime(), handle_saydatetime(), handle_sayphonetic(), handle_recordfile(), and agi_handle_command().
| #define RESULT_SHOWUSAGE 1 |
Definition at line 40 of file cli.h.
Referenced by rpt_do_debug(), rpt_do_dump(), rpt_do_stats(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_reload(), rpt_do_restart(), rpt_do_fun(), rpt_do_fun1(), rpt_do_cmd(), res2cli(), handle_gosub(), __iax2_show_peers(), handle_cli_iax2_show_peers(), console_key(), console_unkey(), radio_tune(), radio_active(), handle_waitfordigit(), handle_sendtext(), handle_recvchar(), handle_recvtext(), handle_tddmode(), handle_sendimage(), handle_controlstreamfile(), handle_streamfile(), handle_getoption(), handle_saynumber(), handle_saydigits(), handle_sayalpha(), handle_saydate(), handle_saytime(), handle_saydatetime(), handle_sayphonetic(), handle_getdata(), handle_setcontext(), handle_setextension(), handle_setpriority(), handle_recordfile(), handle_autohangup(), handle_hangup(), handle_exec(), handle_channelstatus(), handle_getvariable(), handle_getvariablefull(), handle_verbose(), handle_dbget(), handle_dbput(), handle_dbdel(), handle_dbdeltree(), handle_setmusic(), handle_speechset(), handle_speechloadgrammar(), handle_speechunloadgrammar(), handle_speechactivategrammar(), handle_speechdeactivategrammar(), handle_speechrecognize(), and agi_handle_command().
| #define RESULT_SUCCESS 0 |
Definition at line 39 of file cli.h.
Referenced by set_member_paused(), set_member_penalty(), manager_queues_show(), manager_queue_rule_show(), manager_queues_summary(), manager_queues_status(), handle_queue_pause_member(), handle_queue_set_member_penalty(), rpt_do_debug(), rpt_do_dump(), rpt_do_stats(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_local_nodes(), rpt_do_cmd(), res2cli(), manager_rpt_local_nodes(), handle_gosub(), manager_list_voicemail_users(), dahdi_destroy_channel_bynum(), do_monitor(), dahdi_destroy_channel(), __iax2_show_peers(), manager_iax2_show_netstats(), manager_iax2_show_peer_list(), locals_show(), console_key(), console_unkey(), radio_tune(), radio_set_debug(), radio_set_debug_off(), radio_active(), radio_set_xpmr_debug(), handle_showcalls(), manager_data_get(), manager_parking_status(), logger_reload(), handle_answer(), handle_waitfordigit(), handle_sendtext(), handle_recvchar(), handle_recvtext(), handle_tddmode(), handle_sendimage(), handle_controlstreamfile(), handle_streamfile(), handle_getoption(), handle_saynumber(), handle_saydigits(), handle_sayalpha(), handle_saydate(), handle_saytime(), handle_saydatetime(), handle_sayphonetic(), handle_getdata(), handle_setcontext(), handle_setextension(), handle_setpriority(), handle_recordfile(), handle_autohangup(), handle_hangup(), handle_setcallerid(), handle_channelstatus(), handle_setvariable(), handle_getvariable(), handle_getvariablefull(), handle_verbose(), handle_dbget(), handle_dbput(), handle_dbdel(), handle_dbdeltree(), handle_noop(), handle_setmusic(), handle_speechcreate(), handle_speechset(), handle_speechdestroy(), handle_speechloadgrammar(), handle_speechunloadgrammar(), handle_speechactivategrammar(), handle_speechdeactivategrammar(), handle_speechrecognize(), agi_handle_command(), and cli_fax_show_session().
| enum ast_cli_command |
calling arguments for new-style handlers.
Definition at line 145 of file cli.h.
{
CLI_INIT = -2, /* return the usage string */
CLI_GENERATE = -3, /* behave as 'generator', remap argv to struct ast_cli_args */
CLI_HANDLER = -4, /* run the normal handler */
};
| void ast_cli | ( | int | fd, |
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 102 of file cli.c.
References ast_str_thread_get(), AST_CLI_INITLEN, ast_str_set_va(), AST_DYNSTR_BUILD_FAILED, ast_carefulwrite(), ast_str_buffer(), and ast_str_strlen().
Referenced by aoc_cli_debug_enable(), meetme_show_cmd(), meetme_cmd(), sla_show_trunks(), sla_show_stations(), handle_minivm_list_templates(), handle_minivm_show_users(), handle_minivm_show_zones(), handle_minivm_show_settings(), handle_minivm_show_stats(), handle_minivm_reload(), handle_cli_mixmonitor(), handle_cli_osp_show(), __say_cli_init(), do_print(), handle_queue_add_member(), handle_queue_remove_member(), handle_queue_pause_member(), handle_queue_set_member_penalty(), handle_queue_rule_show(), rpt_do_debug(), rpt_do_dump(), rpt_do_stats(), rpt_do_lstats(), rpt_do_nodes(), rpt_do_local_nodes(), rpt_do_fun(), rpt_do_cmd(), show_users_realtime(), handle_voicemail_show_users(), handle_voicemail_show_zones(), handle_voicemail_reload(), handle_show_settings(), handle_show_threads(), handle_show_sysinfo(), handle_show_profile(), handle_show_version_files(), ast_console_toggle_mute(), handle_version(), handle_stop_when_convenient(), handle_restart_when_convenient(), show_warranty(), show_license(), cc_cli_print_monitor_stats(), print_stats_cb(), cc_cli_output_status(), handle_cli_status(), handle_cli_submit(), print_app(), print_cel_sub(), agent_logoff_cmd(), agents_show(), agents_show_online(), console_autoanswer(), console_answer(), console_sendtext(), console_hangup(), console_dial(), console_mute(), cli_console_autoanswer(), cli_console_flash(), cli_console_dial(), cli_console_hangup(), cli_console_mute(), cli_list_available(), cli_list_devices(), cli_console_answer(), cli_console_sendtext(), cli_console_active(), handle_pri_set_debug_file(), handle_pri_debug(), handle_pri_show_span(), handle_pri_show_debug(), handle_pri_version(), dahdi_show_channels(), dahdi_show_channel(), handle_dahdi_show_cadences(), dahdi_show_status(), dahdi_show_version(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_set_dnd(), handle_ss7_debug(), handle_ss7_block_cic(), handle_ss7_block_linkset(), handle_ss7_unblock_cic(), handle_ss7_unblock_linkset(), handle_ss7_show_linkset(), handle_ss7_version(), gtalk_show_channels(), handle_cli_h323_set_trace(), handle_cli_h323_set_debug(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_prune_realtime(), handle_cli_iax2_show_peer(), handle_cli_iax2_show_stats(), handle_cli_iax2_set_mtu(), handle_cli_iax2_show_cache(), handle_cli_iax2_show_users(), __iax2_show_peers(), handle_cli_iax2_show_threads(), handle_cli_iax2_unregister(), handle_cli_iax2_show_firmware(), handle_cli_iax2_show_registry(), handle_cli_iax2_show_channels(), ast_cli_netstats(), handle_cli_iax2_show_netstats(), handle_cli_iax2_set_debug(), handle_cli_iax2_set_debug_trunk(), handle_cli_iax2_set_debug_jb(), handle_cli_iax2_provision(), jingle_show_channels(), locals_show(), handle_mgcp_show_endpoints(), handle_mgcp_audit_endpoint(), handle_mgcp_set_debug(), handle_cli_misdn_set_debug(), show_config_description(), handle_cli_misdn_show_config(), handle_cli_misdn_reload(), print_bc_info(), handle_cli_misdn_show_channels(), handle_cli_misdn_show_stacks(), handle_cli_misdn_show_ports_stats(), handle_cli_misdn_show_port(), handle_cli_misdn_send_digit(), handle_cli_misdn_toggle_echocancel(), handle_cli_misdn_send_display(), console_cmd(), console_do_answer(), console_flash(), console_transfer(), console_active(), console_boost(), sip_show_inuse(), sip_show_tcp(), sip_show_users(), _sip_show_peers(), peer_dump_func(), dialog_dump_func(), sip_show_objects(), print_group(), sip_prune_realtime(), print_codec_to_cli(), sip_show_domains(), _sip_qualify_peer(), _sip_show_peer(), sip_show_user(), sip_show_sched(), sip_show_registry(), sip_unregister(), show_chanstats_cb(), sip_show_channelstats(), sip_show_settings(), sip_show_mwi(), show_channels_cb(), sip_show_channels(), sip_show_channel(), sip_show_history(), sip_do_debug_ip(), sip_do_debug_peer(), sip_do_debug(), sip_cli_notify(), sip_set_history(), handle_skinny_set_debug(), _skinny_show_devices(), _skinny_show_device(), _skinny_show_lines(), _skinny_show_line(), handle_skinny_show_settings(), unistim_info(), unistim_sp(), unistim_do_debug(), radio_tune(), radio_set_debug(), radio_set_debug_off(), radio_active(), radio_set_xpmr_debug(), tune_txoutput(), tune_rxinput(), tune_rxvoice(), tune_rxctcss(), handle_cli_core_show_channeltypes(), handle_cli_core_show_channeltype(), handle_load(), handle_reload(), handle_verbose(), handle_unload(), modlist_modentry(), print_uptimestr(), handle_modlist(), handle_showcalls(), handle_chanlist(), handle_softhangup(), handle_cli_show_permissions(), handle_cli_check_permissions(), handle_commandmatchesarray(), handle_commandnummatches(), handle_commandcomplete(), channel_set_debug(), handle_core_set_debug_channel(), handle_showchan(), group_show_channels(), handle_cli_wait_fullybooted(), help1(), handle_help(), ast_cli_command_full(), ais_clm_show_members(), handle_cli_transcoder_show(), handle_cli_core_show_config_mappings(), handle_cli_config_list(), data_result_print_cli_node(), data_result_print_cli(), data_provider_print_cli(), handle_cli_database_put(), handle_cli_database_get(), handle_cli_database_del(), handle_cli_database_deltree(), db_show_cb(), handle_cli_database_show(), db_showkey_cb(), handle_cli_database_showkey(), handle_cli_refresh(), dump_raw_ie(), event_dump_cli(), event_dump_cache(), ais_evt_show_event_channels(), handle_feature_show(), handle_parkedcalls(), handle_cli_core_show_file_formats(), show_codecs(), show_codec_n(), handle_cli_devstate_list(), handle_cli_devstate_change(), cli_odbc_read(), cli_odbc_write(), handle_show_http(), iax_show_provisioning(), handle_core_show_image_formats(), handle_cli_indication_show(), handle_logger_reload(), handle_logger_rotate(), handle_logger_set_level(), handle_logger_show_channels(), handle_showmancmd(), handle_mandebug(), handle_showmanager(), handle_showmanagers(), handle_showmancmds(), handle_showmanconn(), handle_showmaneventq(), handle_manager_show_settings(), cli_match_char_tree(), handle_show_functions(), handle_show_function(), print_app_docs(), handle_show_application(), handle_show_hints(), handle_show_hint(), handle_show_switches(), handle_show_applications(), show_dialplan_helper(), show_debug_helper(), handle_show_dialplan(), handle_debug_dialplan(), handle_show_globals(), handle_show_chanvar(), handle_set_global(), handle_set_chanvar(), handle_set_extenpatternmatchnew(), handle_unset_extenpatternmatchnew(), handle_cli_dialplan_remove_include(), handle_cli_dialplan_remove_extension(), handle_cli_dialplan_add_include(), handle_cli_dialplan_save(), handle_cli_dialplan_add_extension(), handle_cli_dialplan_add_ignorepat(), handle_cli_dialplan_remove_ignorepat(), handle_cli_dialplan_reload(), dundi_set_debug(), dundi_store_history(), dundi_flush(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_show_peer(), dundi_show_peers(), dundi_show_trans(), dundi_show_entityid(), dundi_show_requests(), dundi_show_mappings(), dundi_show_precache(), handle_cli_agi_add_cmd(), handle_cli_agi_debug(), help_workhorse(), handle_cli_agi_show(), handle_cli_agi_dump_html(), handle_show_calendars(), handle_show_calendar(), alias_show(), orig_app(), orig_exten(), handle_redirect(), realtime_ldap_status(), handle_cli_realtime_pgsql_cache(), handle_cli_realtime_pgsql_status(), handle_cli_show_sqlite_status(), handle_cli_sqlite_show_tables(), handle_cli_file_convert(), handle_cli_keys_show(), cli_fax_show_version(), cli_fax_set_debug(), cli_fax_show_capabilities(), cli_fax_show_settings(), cli_fax_show_session(), cli_fax_show_stats(), cli_fax_show_sessions(), spandsp_fax_cli_show_capabilities(), spandsp_fax_cli_show_session(), spandsp_fax_cli_show_stats(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_cli_delete_pubsub_node(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_do_set_debug(), aji_do_reload(), aji_show_clients(), aji_show_buddies(), aji_test(), handle_cli_ulimit(), handle_cli_moh_show_files(), handle_cli_moh_show_classes(), handle_cli_odbc_show(), handle_show_routes(), pktccops_show_cmtses(), pktccops_show_gates(), pktccops_show_pools(), pktccops_gatedel(), pktccops_gateset(), pktccops_debug(), cli_realtime_load(), cli_realtime_update(), cli_realtime_update2(), cli_realtime_store(), cli_realtime_destroy(), rtp_do_debug_ip(), rtcp_do_debug_ip(), handle_cli_rtp_set_debug(), handle_cli_rtcp_set_debug(), handle_cli_rtcp_set_stats(), sig_pri_cli_show_channels_header(), sig_pri_cli_show_channels(), sig_pri_cli_show_spans(), sig_pri_cli_show_span(), handle_cli_stun_set_debug(), cli_tps_ping(), cli_tps_report(), timing_test(), handle_cli_core_show_translation(), and handle_cli_udptl_set_debug().
{
int res;
struct ast_str *buf;
va_list ap;
if (!(buf = ast_str_thread_get(&ast_cli_buf, AST_CLI_INITLEN)))
return;
va_start(ap, fmt);
res = ast_str_set_va(&buf, 0, fmt, ap);
va_end(ap);
if (res != AST_DYNSTR_BUILD_FAILED) {
ast_carefulwrite(fd, ast_str_buffer(buf), ast_str_strlen(buf), 100);
}
}
| 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 this command. uid = CLI_NO_PERMS to avoid checking user permissions gid = CLI_NO_PERMS to avoid checking group permissions.
| uid | User ID that is trying to run the command. |
| gid | Group ID that is trying to run the command. |
| fd | pipe |
| s | incoming string |
| 0 | on success |
| -1 | on failure |
Definition at line 2448 of file cli.c.
References args, AST_MAX_ARGS, parse_args(), ast_cli_args::fd, AST_RWLIST_RDLOCK, find_cli(), ast_atomic_fetchadd_int(), ast_cli_entry::inuse, AST_RWLIST_UNLOCK, ast_cli(), find_best(), ast_join(), cli_has_permissions(), ast_free, ast_cli_entry::handler, CLI_HANDLER, CLI_SHOWUSAGE, S_OR, ast_cli_entry::usage, and CLI_FAILURE.
Referenced by ast_cli_command_multiple_full().
{
const char *args[AST_MAX_ARGS + 1];
struct ast_cli_entry *e;
int x;
char *duplicate = parse_args(s, &x, args + 1, AST_MAX_ARGS, NULL);
char tmp[AST_MAX_ARGS + 1];
char *retval = NULL;
struct ast_cli_args a = {
.fd = fd, .argc = x, .argv = args+1 };
if (duplicate == NULL)
return -1;
if (x < 1) /* We need at least one entry, otherwise ignore */
goto done;
AST_RWLIST_RDLOCK(&helpers);
e = find_cli(args + 1, 0);
if (e)
ast_atomic_fetchadd_int(&e->inuse, 1);
AST_RWLIST_UNLOCK(&helpers);
if (e == NULL) {
ast_cli(fd, "No such command '%s' (type 'core show help %s' for other possible commands)\n", s, find_best(args + 1));
goto done;
}
ast_join(tmp, sizeof(tmp), args + 1);
/* Check if the user has rights to run this command. */
if (!cli_has_permissions(uid, gid, tmp)) {
ast_cli(fd, "You don't have permissions to run '%s' command\n", tmp);
ast_free(duplicate);
return 0;
}
/*
* Within the handler, argv[-1] contains a pointer to the ast_cli_entry.
* Remember that the array returned by parse_args is NULL-terminated.
*/
args[0] = (char *)e;
retval = e->handler(e, CLI_HANDLER, &a);
if (retval == CLI_SHOWUSAGE) {
ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n"));
} else {
if (retval == CLI_FAILURE)
ast_cli(fd, "Command '%s' failed.\n", s);
}
ast_atomic_fetchadd_int(&e->inuse, -1);
done:
ast_free(duplicate);
return 0;
}
| 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, sending output to fd if uid has permissions, uid = CLI_NO_PERMS to avoid checking users permissions. gid = CLI_NO_PERMS to avoid checking group permissions.
| uid | User ID that is trying to run the command. |
| gid | Group ID that is trying to run the command. |
| fd | pipe |
| size | is the total size of the string |
| s | incoming string |
| number | of commands executed |
Definition at line 2503 of file cli.c.
References ast_cli_command_full().
Referenced by netconsole().
{
char cmd[512];
int x, y = 0, count = 0;
for (x = 0; x < size; x++) {
cmd[y] = s[x];
y++;
if (s[x] == '\0') {
ast_cli_command_full(uid, gid, fd, cmd);
y = 0;
count++;
}
}
return count;
}
| char* ast_cli_complete | ( | const char * | word, |
| const 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 const char * const choices[] = { "one", "two", "three", NULL }; if (pos == 2) return ast_cli_complete(word, choices, n); else return NULL; }
Definition at line 1518 of file cli.c.
References len(), ast_strlen_zero(), and ast_strdup.
Referenced by complete_meetmecmd(), handle_cc_kill(), handle_cli_iax2_prune_realtime(), sip_prune_realtime(), event_dump_cache(), handle_cli_devstate_change(), handle_show_applications(), handle_orig(), and handle_cli_core_show_translation().
{
int i, which = 0, len;
len = ast_strlen_zero(word) ? 0 : strlen(word);
for (i = 0; choices[i]; i++) {
if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state)
return ast_strdup(choices[i]);
}
return NULL;
}
| 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, followed by a NULL. All strings and the array itself are malloc'ed and must be freed by the caller.
Definition at line 2299 of file cli.c.
References ast_cli_generator(), ast_realloc, ast_malloc, and ast_copy_string().
Referenced by cli_complete(), and handle_commandmatchesarray().
{
char **match_list = NULL, *retstr, *prevstr;
size_t match_list_len, max_equal, which, i;
int matches = 0;
/* leave entry 0 free for the longest common substring */
match_list_len = 1;
while ((retstr = ast_cli_generator(text, word, matches)) != NULL) {
if (matches + 1 >= match_list_len) {
match_list_len <<= 1;
if (!(match_list = ast_realloc(match_list, match_list_len * sizeof(*match_list))))
return NULL;
}
match_list[++matches] = retstr;
}
if (!match_list)
return match_list; /* NULL */
/* Find the longest substring that is common to all results
* (it is a candidate for completion), and store a copy in entry 0.
*/
prevstr = match_list[1];
max_equal = strlen(prevstr);
for (which = 2; which <= matches; which++) {
for (i = 0; i < max_equal && toupper(prevstr[i]) == toupper(match_list[which][i]); i++)
continue;
max_equal = i;
}
if (!(retstr = ast_malloc(max_equal + 1)))
return NULL;
ast_copy_string(retstr, match_list[1], max_equal + 1);
match_list[0] = retstr;
/* ensure that the array is NULL terminated */
if (matches + 1 >= match_list_len) {
if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list))))
return NULL;
}
match_list[matches + 1] = NULL;
return match_list;
}
| char* ast_cli_generator | ( | const char * | , |
| const char * | , | ||
| int | |||
| ) |
Readline madness Useful for readline, that's about it.
| 0 | on success |
| -1 | on failure |
Definition at line 2443 of file cli.c.
References __ast_cli_generator().
Referenced by handle_cli_check_permissions(), ast_cli_generatornummatches(), ast_cli_completion_matches(), and cli_alias_passthrough().
{
return __ast_cli_generator(text, word, state, 1);
}
| int ast_cli_generatornummatches | ( | const char * | , |
| const char * | |||
| ) |
Return the number of unique matches for the generator.
Definition at line 2282 of file cli.c.
References ast_cli_generator(), and ast_free.
Referenced by handle_commandnummatches().
{
int matches = 0, i = 0;
char *buf = NULL, *oldbuf = NULL;
while ((buf = ast_cli_generator(text, word, i++))) {
if (!oldbuf || strcmp(buf,oldbuf))
matches++;
if (oldbuf)
ast_free(oldbuf);
oldbuf = buf;
}
if (oldbuf)
ast_free(oldbuf);
return matches;
}
| 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 |
| 0 | on success |
| -1 | on failure |
Definition at line 2109 of file cli.c.
References __ast_cli_register().
Referenced by load_module(), do_reload(), ast_cdr_engine_init(), ast_cel_engine_init(), ast_cli_register_multiple(), dnsmgr_init(), and load_config().
{
return __ast_cli_register(e, NULL);
}
| int 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 2117 of file cli.c.
References len(), and ast_cli_register().
Referenced by ast_aoc_cli_init(), load_module(), main(), astobj2_init(), ast_cc_init(), ast_channels_init(), ast_builtins_init(), ast_ais_clm_load_module(), register_config_cli(), ast_data_init(), astdb_init(), ast_event_init(), ast_ais_evt_load_module(), ast_features_init(), ast_file_init(), init_framer(), ast_http_init(), iax_provision_init(), ast_image_init(), ast_indications_init(), init_logger(), __init_manager(), load_pbx(), crypto_init(), ast_stun_init(), ast_tps_init(), ast_test_init(), ast_timing_init(), __ast_register_translator(), ast_udptl_init(), and ast_utils_init().
{
int i, res = 0;
for (i = 0; i < len; i++)
res |= ast_cli_register(e + i);
return res;
}
| 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 |
Definition at line 2103 of file cli.c.
References __ast_cli_unregister().
Referenced by unload_module(), do_reload(), load_module(), ast_cli_unregister_multiple(), and alias_destroy().
{
return __ast_cli_unregister(e, NULL);
}
| int 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 2127 of file cli.c.
References len(), and ast_cli_unregister().
Referenced by unload_module(), load_module(), __unload_module(), ast_ais_clm_unload_module(), and iax_provision_unload().
{
int i, res = 0;
for (i = 0; i < len; i++)
res |= ast_cli_unregister(e + i);
return res;
}
| 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 1530 of file cli.c.
References ast_strlen_zero(), ast_channel_iterator_all_new(), ast_channel_iterator_by_name_new(), ast_channel_iterator_next(), ast_channel_lock, ast_strdup, ast_channel::name, ast_channel_unlock, ast_channel_unref, and ast_channel_iterator_destroy().
Referenced by handle_cli_mixmonitor(), complete_ch(), handle_softhangup(), handle_core_set_debug_channel(), handle_showchan(), handle_show_chanvar(), handle_set_chanvar(), handle_cli_agi_add_cmd(), and handle_redirect().
{
struct ast_channel *c = NULL;
int which = 0;
char notfound = '\0';
char *ret = ¬found; /* so NULL can break the loop */
struct ast_channel_iterator *iter;
if (pos != rpos) {
return NULL;
}
if (ast_strlen_zero(word)) {
iter = ast_channel_iterator_all_new();
} else {
iter = ast_channel_iterator_by_name_new(word, strlen(word));
}
if (!iter) {
return NULL;
}
while (ret == ¬found && (c = ast_channel_iterator_next(iter))) {
if (++which > state) {
ast_channel_lock(c);
ret = ast_strdup(c->name);
ast_channel_unlock(c);
}
ast_channel_unref(c);
}
ast_channel_iterator_destroy(iter);
return ret == ¬found ? NULL : ret;
}