/[gentoo-src]/rc-scripts/src/consoletype.c
Gentoo

Contents of /rc-scripts/src/consoletype.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download) (as text)
Thu Dec 23 19:15:06 2004 UTC (15 years, 5 months ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +6 -5 lines
File MIME type: text/x-csrc
merge freebsd fixes

1 /*
2 * consoletype.c
3 * simple app to figure out whether the current terminal
4 * is serial, console (vt), or remote (pty).
5 *
6 * Copyright 1999-2004 Gentoo Foundation
7 * Distributed under the terms of the GNU General Public License v2
8 * $Header: /var/cvsroot/gentoo-src/rc-scripts/src/consoletype.c,v 1.2 2004/10/06 21:12:49 vapier Exp $
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <sys/ioctl.h>
14 #include <sys/stat.h>
15 #include "headers.h"
16
17 int main(int argc, char *argv[])
18 {
19 unsigned char twelve = 12;
20 int maj;
21 struct stat sb;
22
23 fstat(0, &sb);
24 maj = major(sb.st_rdev);
25 if (maj != 3 && (maj < 136 || maj > 143)) {
26 #if defined(__linux__)
27 if (ioctl (0, TIOCLINUX, &twelve) < 0) {
28 printf("serial\n");
29 return 1;
30 }
31 #endif
32 printf("vt\n");
33 return 0;
34 } else {
35 printf("pty\n");
36 return 2;
37 }
38 }

  ViewVC Help
Powered by ViewVC 1.1.20