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 * $Id: login.c,v 1.3 2003/05/13 13:28:25 bug1 Exp $
27 #include <sys/utsname.h>
30 #define LOGIN " login: "
32 static char fmtstr_d[] = { "%A, %d %B %Y" };
33 static char fmtstr_t[] = { "%H:%M:%S" };
35 void print_login_issue(const char *issue_file, const char *tty)
46 puts(""); /* start a new line */
48 if ((fd = fopen(issue_file, "r"))) {
49 while ((c = fgetc(fd)) != EOF) {
50 if (c == '\\' || c == '%') {
55 fputs(uts.sysname, stdout);
59 fputs(uts.nodename, stdout);
63 fputs(uts.release, stdout);
67 fputs(uts.version, stdout);
71 fputs(uts.machine, stdout);
76 getdomainname(buf, sizeof(buf));
77 buf[sizeof(buf) - 1] = '\0';
82 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
87 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
92 gethostname(buf, sizeof(buf));
107 puts(""); /* start a new line */
114 void print_login_prompt(void)
116 char buf[MAXHOSTNAMELEN];
118 gethostname(buf, MAXHOSTNAMELEN);
121 fputs(LOGIN, stdout);