forked from Mirror/frr
lib: Add ability to know if we have read anything in
When reading the config file add an ability to know if we have properly read in anything. So that a daemon can make fallback plans. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
05d7e026c8
commit
5ede5e4eed
10
lib/vty.c
10
lib/vty.c
|
@ -2462,12 +2462,13 @@ static FILE *vty_use_backup_config(const char *fullpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read up configuration file from file_name. */
|
/* Read up configuration file from file_name. */
|
||||||
void vty_read_config(const char *config_file, char *config_default_dir)
|
bool vty_read_config(const char *config_file, char *config_default_dir)
|
||||||
{
|
{
|
||||||
char cwd[MAXPATHLEN];
|
char cwd[MAXPATHLEN];
|
||||||
FILE *confp = NULL;
|
FILE *confp = NULL;
|
||||||
const char *fullpath;
|
const char *fullpath;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
bool read_success = false;
|
||||||
|
|
||||||
/* If -f flag specified. */
|
/* If -f flag specified. */
|
||||||
if (config_file != NULL) {
|
if (config_file != NULL) {
|
||||||
|
@ -2525,8 +2526,10 @@ void vty_read_config(const char *config_file, char *config_default_dir)
|
||||||
|
|
||||||
if (strstr(config_default_dir, "vtysh") == NULL) {
|
if (strstr(config_default_dir, "vtysh") == NULL) {
|
||||||
ret = stat(integrate_default, &conf_stat);
|
ret = stat(integrate_default, &conf_stat);
|
||||||
if (ret >= 0)
|
if (ret >= 0) {
|
||||||
|
read_success = true;
|
||||||
goto tmp_free_and_out;
|
goto tmp_free_and_out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* VTYSH */
|
#endif /* VTYSH */
|
||||||
confp = fopen(config_default_dir, "r");
|
confp = fopen(config_default_dir, "r");
|
||||||
|
@ -2550,6 +2553,7 @@ void vty_read_config(const char *config_file, char *config_default_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
vty_read_file(confp);
|
vty_read_file(confp);
|
||||||
|
read_success = true;
|
||||||
|
|
||||||
fclose(confp);
|
fclose(confp);
|
||||||
|
|
||||||
|
@ -2558,6 +2562,8 @@ void vty_read_config(const char *config_file, char *config_default_dir)
|
||||||
tmp_free_and_out:
|
tmp_free_and_out:
|
||||||
if (tmp)
|
if (tmp)
|
||||||
XFREE(MTYPE_TMP, tmp);
|
XFREE(MTYPE_TMP, tmp);
|
||||||
|
|
||||||
|
return read_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Small utility function which output log to the VTY. */
|
/* Small utility function which output log to the VTY. */
|
||||||
|
|
|
@ -242,7 +242,7 @@ extern void vty_frame(struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
|
||||||
extern void vty_endframe(struct vty *, const char *);
|
extern void vty_endframe(struct vty *, const char *);
|
||||||
bool vty_set_include(struct vty *vty, const char *regexp);
|
bool vty_set_include(struct vty *vty, const char *regexp);
|
||||||
|
|
||||||
extern void vty_read_config(const char *, char *);
|
extern bool vty_read_config(const char *, char *);
|
||||||
extern void vty_time_print(struct vty *, int);
|
extern void vty_time_print(struct vty *, int);
|
||||||
extern void vty_serv_sock(const char *, unsigned short, const char *);
|
extern void vty_serv_sock(const char *, unsigned short, const char *);
|
||||||
extern void vty_close(struct vty *);
|
extern void vty_close(struct vty *);
|
||||||
|
|
Loading…
Reference in a new issue