diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/command.c | 2 | ||||
-rw-r--r-- | lib/command.h | 61 | ||||
-rw-r--r-- | lib/command_execute.h | 79 | ||||
-rw-r--r-- | lib/command_queue.c | 1 | ||||
-rw-r--r-- | lib/vty_cli.c | 1 |
6 files changed, 89 insertions, 58 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 09a2e3b8..e88c5998 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -36,7 +36,8 @@ pkginclude_HEADERS = \ command_queue.h qlib_init.h qafi_safi.h \ confirm.h miyagi.h pthread_safe.h list_util.h node_type.h uty.h \ vty_io.h vty_cli.h keystroke.h qstring.h vio_fifo.h vio_lines.h \ - qiovec.h qfstring.h errno_names.h + qiovec.h qfstring.h errno_names.h \ + route_types.h command_execute.h EXTRA_DIST = regex.c regex-gnu.h memtypes.awk route_types.awk route_types.txt diff --git a/lib/command.c b/lib/command.c index f67d0f8b..6fe54d13 100644 --- a/lib/command.c +++ b/lib/command.c @@ -33,7 +33,7 @@ Boston, MA 02111-1307, USA. */ #include "uty.h" #include "qstring.h" #include "command.h" -//#include "lib/route_types.h" +#include "command_execute.h" #include "workqueue.h" #include "command_queue.h" diff --git a/lib/command.h b/lib/command.h index bd1ad99c..1c66c083 100644 --- a/lib/command.h +++ b/lib/command.h @@ -375,6 +375,11 @@ enum { #endif /* HAVE_IPV6 */ /* Prototypes. */ +extern void cmd_init (int); +extern void cmd_terminate (void); + +extern void print_version (const char *); + extern void install_node (struct cmd_node *, int (*) (struct vty *)); extern void install_default (enum node_type); extern void install_element (enum node_type, struct cmd_element *); @@ -385,63 +390,7 @@ extern void sort_node (void); XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */ extern char *argv_concat (const char* const* argv, int argc, int shift); -extern vector cmd_make_strvec (const char *); -extern vector cmd_add_to_strvec (vector v, const char* str) ; -extern void cmd_free_strvec (vector); -extern vector cmd_describe_command (vector, int, int *status); -extern vector cmd_complete_command (vector, int, int *status); -extern const char *cmd_prompt (enum node_type); -extern enum cmd_return_code -config_from_file (struct vty* vty, FILE *fp, struct cmd_element* first_cmd, - qstring buf, bool stop_on_warning) ; -extern enum node_type node_parent (enum node_type); -extern enum cmd_return_code cmd_execute_command (struct vty *vty, - enum cmd_parse_type type, struct cmd_element **cmd) ; -extern enum cmd_return_code cmd_execute_command_strict (struct vty *vty, - enum cmd_parse_type type, struct cmd_element **cmd) ; - -extern cmd_parsed cmd_parse_init_new(cmd_parsed parsed) ; -extern cmd_parsed cmd_parse_reset(cmd_parsed parsed, bool free_structure) ; -extern enum cmd_return_code cmd_parse_command(struct vty* vty, - enum cmd_parse_type type) ; -extern enum cmd_return_code cmd_dispatch(struct vty* vty, bool no_queue) ; - -Inline enum cmd_return_code -cmd_dispatch_call(struct vty* vty) -{ - cmd_parsed parsed = vty->parsed ; - return (*(parsed->cmd->func))(parsed->cmd, vty, - vector_length(&parsed->vline), - (const char * const*)vector_body(&parsed->vline)) ; -} ; - -#define cmd_parse_reset_keep(parsed) cmd_parse_reset(parsed, 0) -#define cmd_parse_reset_free(parsed) cmd_parse_reset(parsed, 1) - -extern void config_replace_string (struct cmd_element *, char *, ...); - -extern void cmd_init (int); -extern void cmd_terminate (void); - -/* Export typical functions. */ -extern struct cmd_element config_end_cmd; -extern struct cmd_element config_exit_cmd; -extern struct cmd_element config_quit_cmd; -extern struct cmd_element config_help_cmd; -extern struct cmd_element config_list_cmd; -extern char *host_config_file (void); -extern void host_config_set (char *); - -extern void print_version (const char *); - /* struct host global, ick */ extern struct host host; -/* "<cr>" global */ -extern char *command_cr; - -#ifdef QDEBUG -extern const char *debug_banner; -#endif - #endif /* _ZEBRA_COMMAND_H */ diff --git a/lib/command_execute.h b/lib/command_execute.h new file mode 100644 index 00000000..a5a807c8 --- /dev/null +++ b/lib/command_execute.h @@ -0,0 +1,79 @@ +/* + * Zebra configuration command interface routine + * Copyright (C) 1997, 98 Kunihiro Ishiguro + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _ZEBRA_COMMAND_EXECUTE_H +#define _ZEBRA_COMMAND_EXECUTE_H + +#include "command.h" + +extern vector cmd_make_strvec (const char *); +extern vector cmd_add_to_strvec (vector v, const char* str) ; +extern void cmd_free_strvec (vector); +extern vector cmd_describe_command (vector, int, int *status); +extern vector cmd_complete_command (vector, int, int *status); +extern const char *cmd_prompt (enum node_type); +extern enum cmd_return_code +config_from_file (struct vty* vty, FILE *fp, struct cmd_element* first_cmd, + qstring buf, bool stop_on_warning) ; +extern enum node_type node_parent (enum node_type); +extern enum cmd_return_code cmd_execute_command (struct vty *vty, + enum cmd_parse_type type, struct cmd_element **cmd) ; +extern enum cmd_return_code cmd_execute_command_strict (struct vty *vty, + enum cmd_parse_type type, struct cmd_element **cmd) ; + +extern cmd_parsed cmd_parse_init_new(cmd_parsed parsed) ; +extern cmd_parsed cmd_parse_reset(cmd_parsed parsed, bool free_structure) ; +extern enum cmd_return_code cmd_parse_command(struct vty* vty, + enum cmd_parse_type type) ; +extern enum cmd_return_code cmd_dispatch(struct vty* vty, bool no_queue) ; + +Inline enum cmd_return_code +cmd_dispatch_call(struct vty* vty) +{ + cmd_parsed parsed = vty->parsed ; + return (*(parsed->cmd->func))(parsed->cmd, vty, + vector_length(&parsed->vline), + (const char * const*)vector_body(&parsed->vline)) ; +} ; + +#define cmd_parse_reset_keep(parsed) cmd_parse_reset(parsed, 0) +#define cmd_parse_reset_free(parsed) cmd_parse_reset(parsed, 1) + +extern void config_replace_string (struct cmd_element *, char *, ...); + +/* Export typical functions. */ +extern struct cmd_element config_end_cmd; +extern struct cmd_element config_exit_cmd; +extern struct cmd_element config_quit_cmd; +extern struct cmd_element config_help_cmd; +extern struct cmd_element config_list_cmd; +extern char *host_config_file (void); +extern void host_config_set (char *); + +/* "<cr>" global */ +extern char *command_cr; + +#ifdef QDEBUG +extern const char *debug_banner; +#endif + +#endif /* _ZEBRA_COMMAND_EXECUTE_H */ diff --git a/lib/command_queue.c b/lib/command_queue.c index ea8ac469..18144844 100644 --- a/lib/command_queue.c +++ b/lib/command_queue.c @@ -25,6 +25,7 @@ #include "qpnexus.h" #include "memory.h" #include "command_queue.h" +#include "command_execute.h" #include "vty.h" #include "uty.h" #include "vector.h" diff --git a/lib/vty_cli.c b/lib/vty_cli.c index 53d64716..ff86b558 100644 --- a/lib/vty_cli.c +++ b/lib/vty_cli.c @@ -31,6 +31,7 @@ #include "vio_lines.h" #include "command.h" +#include "command_execute.h" #include "command_queue.h" #include "memory.h" |