From: Donald Sharp Date: Tue, 8 May 2018 00:02:39 +0000 (-0400) Subject: lib: Add ability to know if we have read anything in X-Git-Tag: frr-6.1-dev~262^2~9 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5ede5e4eedf47c856f45849e9f8360fda4e40b92;p=matthieu%2Ffrr.git 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 --- diff --git a/lib/vty.c b/lib/vty.c index 280b2ace51..e9d1f2e323 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2462,12 +2462,13 @@ static FILE *vty_use_backup_config(const char *fullpath) } /* 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]; FILE *confp = NULL; const char *fullpath; char *tmp = NULL; + bool read_success = false; /* If -f flag specified. */ 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) { ret = stat(integrate_default, &conf_stat); - if (ret >= 0) + if (ret >= 0) { + read_success = true; goto tmp_free_and_out; + } } #endif /* VTYSH */ 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); + read_success = true; fclose(confp); @@ -2558,6 +2562,8 @@ void vty_read_config(const char *config_file, char *config_default_dir) tmp_free_and_out: if (tmp) XFREE(MTYPE_TMP, tmp); + + return read_success; } /* Small utility function which output log to the VTY. */ diff --git a/lib/vty.h b/lib/vty.h index d14ddf5908..b55abf2204 100644 --- a/lib/vty.h +++ b/lib/vty.h @@ -242,7 +242,7 @@ extern void vty_frame(struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3); extern void vty_endframe(struct vty *, const char *); 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_serv_sock(const char *, unsigned short, const char *); extern void vty_close(struct vty *);