From 3b0c5d9a56560cfbfb1a8f5b9e6cc71025eb5490 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 8 Mar 2005 10:43:43 +0000 Subject: 2005-03-08 Jeroen Massar * 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. --- lib/vty.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/vty.c') 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); } -- cgit v1.2.1