2 * issue.c: issue printing code
4 * Copyright (C) 2003 Bastian Blank <waldi@tuxbox.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Optimize and correcting OCRNL by Vladimir Oleynik <dzo@simtreas.ru>
23 #include <sys/param.h> /* MAXHOSTNAMELEN */
28 #include <sys/utsname.h>
31 #define LOGIN " login: "
33 static const char fmtstr_d[] = "%A, %d %B %Y";
34 static const char fmtstr_t[] = "%H:%M:%S";
36 void print_login_issue(const char *issue_file, const char *tty)
48 puts("\r"); /* start a new line */
50 if ((fd = fopen(issue_file, "r"))) {
51 while ((c = fgetc(fd)) != EOF) {
60 if (c == '\\' || c == '%') {
68 outbuf = uts.nodename;
85 c = getdomainname(buf, sizeof(buf) - 1);
86 buf[c >= 0 ? c : 0] = '\0';
90 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
94 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
98 gethostname(buf, sizeof(buf) - 1);
99 buf[sizeof(buf) - 1] = '\0';
110 fputs(outbuf, stdout);
119 void print_login_prompt(void)
121 char buf[MAXHOSTNAMELEN+1];
123 if(gethostname(buf, MAXHOSTNAMELEN) == 0)
126 fputs(LOGIN, stdout);