1 /* vi: set sw=4 ts=4: */
3 * issue.c: issue printing code
5 * Copyright (C) 2003 Bastian Blank <waldi@tuxbox.org>
7 * Optimize and correcting OCRNL by Vladimir Oleynik <dzo@simtreas.ru>
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
12 #include <sys/param.h> /* MAXHOSTNAMELEN */
13 #include <sys/utsname.h>
16 #define LOGIN " login: "
18 static const char fmtstr_d[] = "%A, %d %B %Y";
19 static const char fmtstr_t[] = "%H:%M:%S";
21 void print_login_issue(const char *issue_file, const char *tty)
33 puts("\r"); /* start a new line */
35 fd = fopen(issue_file, "r");
38 while ((c = fgetc(fd)) != EOF) {
46 if (c == '\\' || c == '%') {
53 outbuf = uts.nodename;
66 c = getdomainname(buf, sizeof(buf) - 1);
67 buf[c >= 0 ? c : 0] = '\0';
70 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
73 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
76 gethostname(buf, sizeof(buf) - 1);
77 buf[sizeof(buf) - 1] = '\0';
86 fputs(outbuf, stdout);
92 void print_login_prompt(void)
94 char buf[MAXHOSTNAMELEN+1];
96 if (gethostname(buf, MAXHOSTNAMELEN) == 0)