diff options
author | paul <paul> | 2005-03-08 15:16:57 +0000 |
---|---|---|
committer | paul <paul> | 2005-03-08 15:16:57 +0000 |
commit | b45da6f01612e8ec1938cacfe0ea0ef34ad1afca (patch) | |
tree | 670671d335524f7b44bee3e32bdba1a75aecc7df /lib/vty.c | |
parent | 3b0c5d9a56560cfbfb1a8f5b9e6cc71025eb5490 (diff) |
2005-03-08 Paul Jakma <paul.jakma@sun.com>
* command.c: (banner_motd_file_cmd) use XSTRDUP/XFREE
* vty.c: (vty_hello) suggestions from Andrew, read by line and
stub out trailling non-printable characters on each line thus
allowing us to specify VTY_NEWLINE to vty_out.
Diffstat (limited to 'lib/vty.c')
-rw-r--r-- | lib/vty.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -220,22 +220,23 @@ vty_hello (struct vty *vty) { FILE *f; char buf[4096]; - int r; + f = fopen (host.motdfile, "r"); if (f) { - while (!feof (f)) + while (fgets (buf, sizeof (buf), f)) { - memset (buf, '\0', sizeof (buf)); - r = fread (&buf, sizeof (buf) - 1, 1, f); - if (r < 0) - break; - vty_out (vty, buf); - } + char *s; + /* work backwards and squash all isspace() chars + * we want nul terminated for vty_out */ + for (s = buf+strlen(buf); (s > buf) && isspace(*(s-1)); s--); + *s = '\0'; + vty_out (vty, "%s%s", buf, VTY_NEWLINE); + } fclose (f); } else - vty_out (vty, "MOTD file not found\n"); + vty_out (vty, "MOTD file not found%s", VTY_NEWLINE); } else if (host.motd) vty_out (vty, host.motd); |