summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorpaul <paul>2005-03-08 10:43:43 +0000
committerpaul <paul>2005-03-08 10:43:43 +0000
commit3b0c5d9a56560cfbfb1a8f5b9e6cc71025eb5490 (patch)
treea4b9c7506cb74223635135902e0479fda0b46fe2 /lib/vty.c
parentc3d26c72982bc95906afb58fb46f1268bc915a3b (diff)
2005-03-08 Jeroen Massar <jeroen@unfix.org>
* vty.c: (vty_hello) display motd file, if set * command.h: add char *motdfile to struct host * command.c: (config_write_host) write out motdfile config (banner_motd_file_cmd) new command, allow motd to be read from file. (no_banner_motd_cmd) free motdfile string, if needs be. (cmd_init) init (struct host).motdfile. Add new motd file commands.
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/vty.c b/lib/vty.c
index f8e483f6..bb3f14a5 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -216,7 +216,28 @@ vty_time_print (struct vty *vty, int cr)
void
vty_hello (struct vty *vty)
{
- if (host.motd)
+ if (host.motdfile)
+ {
+ FILE *f;
+ char buf[4096];
+ int r;
+ f = fopen (host.motdfile, "r");
+ if (f)
+ {
+ while (!feof (f))
+ {
+ memset (buf, '\0', sizeof (buf));
+ r = fread (&buf, sizeof (buf) - 1, 1, f);
+ if (r < 0)
+ break;
+ vty_out (vty, buf);
+ }
+ fclose (f);
+ }
+ else
+ vty_out (vty, "MOTD file not found\n");
+ }
+ else if (host.motd)
vty_out (vty, host.motd);
}