Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 78136 Details for
Bug 80021
[PATCH] GNU/kFreeBSD support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
consoletype.c
consoletype.c (text/plain), 1.34 KB, created by
SpanKY
on 2006-01-25 21:56:23 UTC
(
hide
)
Description:
consoletype.c
Filename:
MIME Type:
Creator:
SpanKY
Created:
2006-01-25 21:56:23 UTC
Size:
1.34 KB
patch
obsolete
>/* > * consoletype.c > * simple app to figure out whether the current terminal > * is serial, console (vt), or remote (pty). > * > * Copyright 1999-2006 Gentoo Foundation > * Distributed under the terms of the GNU General Public License v2 > */ > >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <string.h> >#include <sys/ioctl.h> >#include <sys/stat.h> >#include "headers.h" > >enum { IS_VT = 0, IS_SERIAL = 1, IS_PTY = 2, IS_UNK = 3 }; >const char * const tty_names[] = { "vt", "serial", "pty", "unknown" }; > >static inline int check_ttyname(void) >{ > char *tty = ttyname(0); > > if (tty == NULL) > return IS_UNK; > > if (strcmp(tty, "/dev/") == 0) > tty += 5; > > if (!strncmp (tty, "ttyS", 4) || !strncmp (tty, "cuaa", 4)) > return IS_SERIAL; > else if (!strncmp (tty, "pts/", 4) || !strncmp (tty, "ttyp", 4)) > return IS_PTY; > else if (!strncmp (tty, "tty", 3)) > return IS_VT; > else > return IS_UNK; >} > >static inline int check_devnode(void) >{ > int maj; > struct stat sb; > > fstat(0, &sb); > maj = major(sb.st_rdev); > if (maj != 3 && (maj < 136 || maj > 143)) { >#if defined(TIOCLINUX) > unsigned char twelve = 12; > if (ioctl (0, TIOCLINUX, &twelve) < 0) > return IS_SERIAL; >#endif > return IS_VT; > } else > return IS_PTY; >} > >int main(int argc, char *argv[]) >{ > int type = check_ttyname(); > if (type == IS_UNK) > type = check_devnode(); > puts(tty_names[type]); > return type; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 80021
:
66374
| 78136