const char *motd;
char *motdfile;
- const char *prog_name;
- const char *prog_version;
- const char *prog_copyright;
+ const struct vty_app_info *app_info;
};
/* There are some command levels which called from command node. */
extern void *tall_vty_cmd_ctx;
-enum node_type (*vty_go_parent_cb)(struct vty *vty);
-
#endif /* _ZEBRA_COMMAND_H */
/* This is called from main when a daemon is invoked with -v or --version. */
void print_version(int print_copyright)
{
- printf("%s version %s\n", host.prog_name, host.prog_version);
+ printf("%s version %s\n", host.app_info->name, host.app_info->version);
if (print_copyright)
- printf("\n%s\n", host.prog_copyright);
+ printf("\n%s\n", host.app_info->copyright);
}
/* Utility function to concatenate argv argument into a single string
{
assert(vty->node > CONFIG_NODE);
- if (vty_go_parent_cb)
- vty_go_parent_cb(vty);
+ if (host.app_info->go_parent_cb)
+ host.app_info->go_parent_cb(vty);
else
vty->node = CONFIG_NODE;
DEFUN(show_version,
show_version_cmd, "show version", SHOW_STR "Displays program version\n")
{
- vty_out(vty, "%s %s (%s).%s", host.prog_name, host.prog_version,
- host.name ? host.name : "", VTY_NEWLINE);
- vty_out(vty, "%s%s", host.prog_copyright, VTY_NEWLINE);
+ vty_out(vty, "%s %s (%s).%s", host.app_info->name,
+ host.app_info->version,
+ host.app_info->name ? host.app_info->name : "", VTY_NEWLINE);
+ vty_out(vty, "%s%s", host.app_info->copyright, VTY_NEWLINE);
return CMD_SUCCESS;
}
/* Config file header print. */
vty_out(file_vty, "!\n! %s (%s) configuration saved from vty\n!",
- host.prog_name, host.prog_version);
+ host.app_info->name, host.app_info->version);
//vty_time_print (file_vty, 1);
vty_out(file_vty, "!\n");
extern void *tall_bsc_ctx;
/* Install vty's own commands like `who' command. */
-void vty_init(const char *name, const char *version, const char *copyright)
+void vty_init(struct vty_app_info *app_info)
{
- tall_vty_ctx = talloc_named_const(NULL, 0, "vty");
+ tall_vty_ctx = talloc_named_const(app_info->tall_ctx, 0, "vty");
tall_vty_vec_ctx = talloc_named_const(tall_vty_ctx, 0, "vty_vector");
tall_vty_cmd_ctx = talloc_named_const(tall_vty_ctx, 0, "vty_command");
cmd_init(1);
- host.prog_name = name;
- host.prog_version = version;
- host.prog_copyright = copyright;
+ host.app_info = app_info;
/* For further configuration read, preserve current directory. */
vty_save_cwd();