pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / simple / termcap.c
blob95b43ca4d358e2b0f549ec096623a22162d7bf22
1 /* termcap - print termcap settings Author: Terrence Holm */
3 #include <stdlib.h>
4 #include <termcap.h>
5 #include <stdio.h>
7 #define TC_BUFFER 1024 /* Size of termcap(3) buffer */
9 /****************************************************************/
10 /* */
11 /* termcap [ type ] */
12 /* */
13 /* Prints out all of the termcap capabilities as described */
14 /* in termcap(4). If "type" is not supplied then $TERM is */
15 /* used. */
16 /* */
17 /****************************************************************/
19 _PROTOTYPE(int main, (int argc, char **argv));
20 _PROTOTYPE(void Print, (char *comment, char *name));
21 _PROTOTYPE(void Error, (char *message, char *arg));
23 int main(argc, argv)
24 int argc;
25 char *argv[];
28 char *term;
29 char buffer[ TC_BUFFER ];
32 /* Check for an argument */
34 if ( argc > 2 )
35 Error( "Usage: %s [ type ]\n", argv[0] );
37 if ( argc == 2 )
38 term = argv[1];
39 else
40 term = getenv( "TERM" );
42 if ( term == NULL )
43 Error( "termcap: $TERM is not defined\n", "" );
46 /* Read in the termcap entry */
48 if ( tgetent( buffer, term ) != 1 )
49 Error( "termcap: No termcap entry for %s\n", term );
52 /* Print out the entry's contents */
54 printf( "TERM = %s\n\n", term );
56 if ( tgetflag( "am" ) == 1 )
57 printf( "End of line wraps to next line (am)\n" );
59 if ( tgetflag( "bs" ) == 1 )
60 printf( "Ctrl/H performs a backspace (bs)\n" );
62 printf( "Number of columns (co) = %d\n", tgetnum( "co" ) );
63 printf( "Number of lines (li) = %d\n", tgetnum( "li" ) );
65 Print( "Clear to end of line", "ce" );
66 Print( "Clear to end of screen", "cd" );
67 Print( "Clear the whole screen", "cl" );
69 Print( "Start \"stand out\" mode", "so" );
70 Print( "End \"stand out\" mode", "se" );
71 Print( "Start underscore mode", "us" );
72 Print( "End underscore mode", "ue" );
73 Print( "Start blinking mode", "mb" );
74 Print( "Start bold mode", "md" );
75 Print( "Start reverse mode", "mr" );
76 Print( "Return to normal mode", "me" );
78 Print( "Scroll backwards", "sr" );
79 Print( "Cursor motion", "cm" );
81 Print( "Up one line", "up" );
82 Print( "Down one line", "do" );
83 Print( "Left one space", "le" );
84 Print( "Right one space", "nd" );
85 Print( "Move to top left corner", "ho" );
87 Print( "Generated by \"UP\"", "ku" );
88 Print( "Generated by \"DOWN\"", "kd" );
89 Print( "Generated by \"LEFT\"", "kl" );
90 Print( "Generated by \"RIGHT\"", "kr" );
91 Print( "Generated by \"HOME\"", "kh" );
92 Print( "Generated by \"END\"", "k0" );
93 Print( "Generated by \"PGUP\"", "k1" );
94 Print( "Generated by \"PGDN\"", "k2" );
95 Print( "Generated by numeric \"+\"", "k3" );
96 Print( "Generated by numeric \"-\"", "k4" );
97 Print( "Generated by numeric \"5\"", "k5" );
99 return( 0 );
107 /****************************************************************/
108 /* */
109 /* Print( comment, name ) */
110 /* */
111 /* If a termcap entry exists for "name", then */
112 /* print out "comment" and the entry. Control */
113 /* characters are printed as ^x. */
114 /* */
115 /****************************************************************/
118 void Print( comment, name )
119 char *comment;
120 char *name;
123 char entry[ 50 ];
124 char *p = entry;
126 if ( tgetstr( name, &p ) == NULL )
127 return;
129 printf( "%-32s (%s) = ", comment, name );
131 for ( p = entry; *p != '\0'; ++p )
132 if ( *p < ' ' )
133 printf( "^%c", *p + '@' );
134 else if ( *p == '\177' )
135 printf( "^?" );
136 else
137 putchar( *p );
139 putchar( '\n' );
147 /****************************************************************/
148 /* */
149 /* Error( message, arg ) */
150 /* */
151 /* Printf the "message" and abort. */
152 /* */
153 /****************************************************************/
156 void Error( message, arg )
157 char *message;
158 char *arg;
161 fprintf( stderr, message, arg );
162 exit( 1 );