}
/* Configration make from file. */
-void
+int
vtysh_config_from_file (struct vty *vty, FILE *fp)
{
int ret;
struct cmd_element *cmd;
int lineno = 0;
+ int retcode = CMD_SUCCESS;
while (fgets (vty->buf, VTY_BUFSIZ, fp))
{
case CMD_WARNING:
if (vty->type == VTY_FILE)
fprintf (stdout,"line %d: Warning...: %s\n", lineno, vty->buf);
+ retcode = 1; /* once we have an error, we remember & return that */
break;
case CMD_ERR_AMBIGUOUS:
fprintf (stdout,"line %d: %% Ambiguous command: %s\n", lineno, vty->buf);
+ retcode = 1; /* once we have an error, we remember & return that */
break;
case CMD_ERR_NO_MATCH:
fprintf (stdout,"line %d: %% Unknown command: %s", lineno, vty->buf);
+ retcode = 1; /* once we have an error, we remember & return that */
break;
case CMD_ERR_INCOMPLETE:
fprintf (stdout,"line %d: %% Command incomplete: %s\n", lineno, vty->buf);
+ retcode = 1; /* once we have an error, we remember & return that */
break;
case CMD_SUCCESS_DAEMON:
{
}
}
}
+
+ return (retcode);
}
/* We don't care about the point of the cursor when '?' is typed. */
/* vtysh local configuration file. */
#define VTYSH_DEFAULT_CONFIG "vtysh.conf"
+#define QUAGGA_DEFAULT_CONFIG "Quagga.conf"
void vtysh_init_vty (void);
void vtysh_init_cmd (void);
void vtysh_config_write (void);
-void vtysh_config_from_file (struct vty *, FILE *);
+int vtysh_config_from_file (struct vty *, FILE *);
int vtysh_mark_file(const char *filename);
}
/* Read up configuration file from file_name. */
-static void
+static int
vtysh_read_file (FILE *confp)
{
struct vty *vty;
+ int ret;
vty = vty_new ();
vty->fd = 0; /* stdout */
vtysh_execute_no_pager ("configure terminal");
/* Execute configuration file. */
- vtysh_config_from_file (vty, confp);
+ ret = vtysh_config_from_file (vty, confp);
vtysh_execute_no_pager ("end");
vtysh_execute_no_pager ("disable");
vty_close (vty);
+
+ return (ret);
}
/* Read up configuration file from config_default_dir. */
vtysh_read_config (const char *config_default_dir)
{
FILE *confp = NULL;
+ int ret;
host_config_set (config_default_dir);
confp = fopen (config_default_dir, "r");
if (confp == NULL)
return (1);
- vtysh_read_file (confp);
+ ret = vtysh_read_file (confp);
fclose (confp);
- return (0);
+ return (ret);
}
/* We don't write vtysh specific into file from vtysh. vtysh.conf should
/* Configuration file name and directory. */
char config_default[] = SYSCONFDIR VTYSH_DEFAULT_CONFIG;
+char quagga_config_default[] = SYSCONFDIR QUAGGA_DEFAULT_CONFIG;
char history_file[MAXPATHLEN];
/* Flag for indicate executing child command. */
int echo_command = 0;
int no_error = 0;
int markfile = 0;
+ int ret = 0;
char *homedir = NULL;
/* Preserve name of myself. */
{
if (inputfile)
{
- vtysh_read_config(inputfile);
+ ret = vtysh_read_config(inputfile);
}
- return(0);
+ else
+ {
+ ret = vtysh_read_config(quagga_config_default);
+ }
+ exit(ret);
}
/* Ignore error messages */
if (inputfile)
{
- vtysh_read_config(inputfile);
- exit(0);
+ ret = vtysh_read_config(inputfile);
+ exit(ret);
}
/*