summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vtysh/vtysh.c9
-rw-r--r--vtysh/vtysh.h3
-rw-r--r--vtysh/vtysh_config.c12
-rw-r--r--vtysh/vtysh_main.c14
4 files changed, 28 insertions, 10 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 9af2461448..2d84b020f6 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -675,12 +675,13 @@ vtysh_mark_file (const char *filename)
}
/* 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))
{
@@ -693,15 +694,19 @@ vtysh_config_from_file (struct vty *vty, FILE *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:
{
@@ -726,6 +731,8 @@ vtysh_config_from_file (struct vty *vty, FILE *fp)
}
}
}
+
+ return (retcode);
}
/* We don't care about the point of the cursor when '?' is typed. */
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index a24d615c3f..da6dd2a067 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -36,6 +36,7 @@
/* 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);
@@ -50,7 +51,7 @@ char *vtysh_prompt (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);
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index f435cf8719..6bb8fad42b 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -365,10 +365,11 @@ vtysh_config_dump (FILE *fp)
}
/* 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 */
@@ -379,12 +380,14 @@ vtysh_read_file (FILE *confp)
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. */
@@ -392,16 +395,17 @@ int
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
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index befc86e6e2..d8b769ba20 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -42,6 +42,7 @@ char *progname;
/* 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. */
@@ -232,6 +233,7 @@ main (int argc, char **argv, char **env)
int echo_command = 0;
int no_error = 0;
int markfile = 0;
+ int ret = 0;
char *homedir = NULL;
/* Preserve name of myself. */
@@ -330,9 +332,13 @@ main (int argc, char **argv, char **env)
{
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 */
@@ -357,8 +363,8 @@ main (int argc, char **argv, char **env)
if (inputfile)
{
- vtysh_read_config(inputfile);
- exit(0);
+ ret = vtysh_read_config(inputfile);
+ exit(ret);
}
/*