diff options
author | paul <paul> | 2005-03-08 10:43:43 +0000 |
---|---|---|
committer | paul <paul> | 2005-03-08 10:43:43 +0000 |
commit | 3b0c5d9a56560cfbfb1a8f5b9e6cc71025eb5490 (patch) | |
tree | a4b9c7506cb74223635135902e0479fda0b46fe2 /lib/vty.c | |
parent | c3d26c72982bc95906afb58fb46f1268bc915a3b (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.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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); } |