diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-02-13 23:11:45 +0000 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-02-13 23:11:45 +0000 |
commit | 5cae7eea451f2b7d65b5892e2c1dafc70f8b836e (patch) | |
tree | 0fbd9679e9ae28e7d061b5bdda08756077415ecb /lib/vty_cli.h | |
parent | 64be6d766a65dc0749d17f5023d714678e9c96a6 (diff) | |
download | quagga-5cae7eea451f2b7d65b5892e2c1dafc70f8b836e.tar.bz2 quagga-5cae7eea451f2b7d65b5892e2c1dafc70f8b836e.tar.xz |
Second tranche of updates for pipework branch.
modified: bgpd/bgp_connection.c
modified: bgpd/bgp_debug.c
modified: bgpd/bgp_engine.h
modified: bgpd/bgp_main.c
modified: bgpd/bgp_packet.c
modified: bgpd/bgp_peer.c
modified: bgpd/bgp_route.c
modified: bgpd/bgp_routemap.c
modified: bgpd/bgp_session.c
modified: bgpd/bgp_vty.c
modified: bgpd/bgpd.c
modified: bgpd/bgpd.h
modified: configure.ac
modified: isisd/dict.h
modified: isisd/isis_misc.c
modified: isisd/isis_routemap.c
modified: isisd/isis_spf.c
modified: lib/Makefile.am
modified: lib/command.c
modified: lib/command.h
modified: lib/command_execute.h
modified: lib/command_parse.c
modified: lib/command_parse.h
modified: lib/command_queue.c
modified: lib/command_queue.h
modified: lib/elstring.h
modified: lib/heap.c
modified: lib/if.c
modified: lib/if.h
modified: lib/keychain.c
modified: lib/keystroke.c
modified: lib/keystroke.h
modified: lib/list_util.c
modified: lib/list_util.h
modified: lib/log.c
modified: lib/log.h
modified: lib/memory.c
modified: lib/memory.h
modified: lib/memtypes.c
modified: lib/misc.h
modified: lib/mqueue.c
modified: lib/mqueue.h
deleted: lib/node_type.h
modified: lib/pthread_safe.c
modified: lib/qfstring.c
modified: lib/qiovec.c
modified: lib/qiovec.h
modified: lib/qpath.c
modified: lib/qpnexus.c
modified: lib/qpnexus.h
modified: lib/qpselect.c
modified: lib/qpthreads.h
modified: lib/qstring.c
modified: lib/qstring.h
modified: lib/qtime.c
modified: lib/qtime.h
modified: lib/qtimers.c
modified: lib/qtimers.h
modified: lib/routemap.c
modified: lib/symtab.h
modified: lib/thread.h
deleted: lib/uty.h
modified: lib/vector.c
modified: lib/vector.h
modified: lib/version.h.in
modified: lib/vio_fifo.c
modified: lib/vio_fifo.h
modified: lib/vio_lines.c
modified: lib/vio_lines.h
modified: lib/vty.c
modified: lib/vty.h
modified: lib/vty_cli.c
modified: lib/vty_cli.h
modified: lib/vty_io.c
modified: lib/vty_io.h
modified: lib/vty_io_basic.c
modified: lib/vty_io_basic.h
modified: lib/vty_io_file.c
modified: lib/vty_io_file.h
modified: lib/vty_io_shell.c
modified: lib/vty_io_term.c
modified: lib/vty_io_term.h
modified: lib/vty_local.h
modified: lib/vty_pipe.c
modified: lib/workqueue.h
modified: lib/zebra.h
modified: ospf6d/ospf6_lsa.c
modified: ripngd/ripngd.c
modified: tests/test-list_util.c
modified: tests/test-vector.c
modified: vtysh/vtysh.c
modified: vtysh/vtysh_config.c
Diffstat (limited to 'lib/vty_cli.h')
-rw-r--r-- | lib/vty_cli.h | 166 |
1 files changed, 153 insertions, 13 deletions
diff --git a/lib/vty_cli.h b/lib/vty_cli.h index f532616a..94e502f0 100644 --- a/lib/vty_cli.h +++ b/lib/vty_cli.h @@ -24,26 +24,166 @@ #ifndef _ZEBRA_VTY_CLI_H #define _ZEBRA_VTY_CLI_H +#include "misc.h" +#include "vargs.h" + +#include "command_local.h" #include "vty_io.h" +#include "vty_io_basic.h" +#include "vio_fifo.h" +#include "vio_lines.h" +#include "qstring.h" #include "keystroke.h" -extern void uty_cli_init(vty_io vio) ; -extern enum vty_readiness uty_cli_start(vty_io vio) ; -extern void uty_cli_close(vty_io vio) ; +/*------------------------------------------------------------------------------ + * The vty_cli structure pointed to by the vty_io structure. + */ +typedef struct vty_cli* vty_cli ; + +struct vty_cli +{ + vio_vf vf ; /* parent */ + + /* History of commands */ + vector_t hist ; /* embedded */ + int hp ; /* current place in history */ + int h_now ; /* the present moment */ + + /* Window width/height as reported by Telnet. 0 => unknown */ + int width; + int height; + + /* Configure lines. */ + int lines; + bool lines_set ; /* true <=> explicitly set */ + + /* Terminal monitor. */ + bool monitor ; + bool monitor_busy ; + + /* Terminal timeout in seconds -- 0 => none */ + vty_timer_time v_timeout ; + + /* The incoming stuff */ + keystroke_stream key_stream ; + + /* drawn <=> the current prompt and user input occupy the current + * line on the screen. + * + * dirty <=> the last command output did not end with a newline. + * + * If drawn is true, the following are valid: + * + * prompt_len -- the length of the prompt part. + * (will be the "--more--" prompt in cli_more_wait) + * + * extra_len -- the length of any ^X at the cursor position + * (for when blocked waiting for queued command) + * + * echo_suppress -- the user part of the command line is suppressed + * + * NB: echo_suppress is only used for password entry. + */ + bool drawn ; + bool dirty ; + + int prompt_len ; + int extra_len ; + + bool echo_suppress ; + + /* "cache" for prompt -- when node or host name changes, prompt does */ + node_type_t prompt_node ; + name_gen_t prompt_gen ; + qstring_t prompt_for_node ; + + /* password failure count -- main login or enable login. */ + int password_fail ; + + /* State of the CLI + * + * in_progress -- command dispatched + * blocked -- blocked until current command completes + * out_active -- contents of the command FIFO are being written away + * + * more_wait -- is in "--more--" wait state + * more_active -- more_wait and waiting for "--more--" prompt to be + * written away. + */ + bool in_progress ; + bool blocked ; + bool out_active ; + + bool more_wait ; + bool more_active ; + + /* This is used to control command output, so that each write_ready event + * generates at most one tranche of output. + */ + bool out_done ; + + /* This is set only if the "--more--" handling is enabled */ + bool more_enabled ; + + /* Command Line(s) + * + * node -- the node that the CLI is in. This may be some way behind + * the VTY, but is updated when the CLI level command completes. + * + * to_do -- when current command being prepared is completed (by + * CR/LF or otherwise) this says what there now is to be done. + * + * cl -- current command line being prepared. + * + * clx -- current command line being executed. + * + * NB: during command execution vty->buf is set to point at the '\0' + * terminated current command line being executed. + */ + node_type_t node ; + + cmd_do_t to_do ; + + qstring cl ; + qstring clx ; + + cmd_parsed_t parsed ; /* embedded */ + + /* CLI line buffering */ + vio_fifo_t cbuf ; /* embedded */ + + /* CLI line control for command output & "--more--" stuff */ + vio_line_control_t olc ; /* embedded */ +} ; + +extern vty_cli uty_cli_new(vio_vf vf) ; +extern void uty_cli_start(vty_cli cli, node_type_t node) ; + +extern vty_cli uty_cli_close(vty_cli cli, bool final) ; + +extern cmd_return_code_t uty_cli_auth(vty_cli) ; +extern void uty_cli_hist_show(vty_cli cli) ; +extern ulen uty_cli_prompt_len(vty_cli cli) ; -extern enum vty_readiness uty_cli(vty_io vio) ; -extern keystroke_callback uty_cli_iac_callback ; +extern vty_readiness_t uty_cli(vty_cli cli) ; +extern void uty_cli_out_push(vty_cli cli) ; +extern void uty_cli_done_command(vty_cli cli, node_type_t node) ; -extern void uty_cli_hist_add (vty_io vio, const char* cmd_line) ; -extern void uty_cli_enter_more_wait(vty_io vio) ; -extern void uty_cli_exit_more_wait(vty_io vio) ; +extern void uty_cli_out(vty_cli cli, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) ; +extern void uty_cli_out_newline(vty_cli cli) ; +extern void uty_cli_out_clear(vty_cli cli) ; +extern void uty_cli_write(vty_cli cli, const char *this, int len) ; +extern void uty_cli_wipe(vty_cli cli, int len) ; -extern void uty_free_host_name(void) ; -extern void uty_check_host_name(void) ; +extern void uty_cli_set_lines(vty_cli cli, int lines, bool explicit) ; +extern void uty_cli_set_window(vty_cli cli, int width, int height) ; +extern void uty_cli_enter_more_wait(vty_cli cli) ; +extern void uty_cli_exit_more_wait(vty_cli cli) ; -extern bool uty_cli_draw_if_required(vty_io vio) ; +extern bool uty_cli_draw_if_required(vty_cli cli) ; -extern void uty_cli_pre_monitor(vty_io vio, size_t len) ; -extern int uty_cli_post_monitor(vty_io vio, const char* buf, size_t len) ; +extern void uty_cli_pre_monitor(vty_cli cli, size_t len) ; +extern int uty_cli_post_monitor(vty_cli cli, const char* buf, size_t len) ; #endif /* _ZEBRA_VTY_CLI_H */ |