Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtterm / tests / util / termget.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: termget.c /main/3 1995/10/31 12:03:12 rswiston $ */
24 #include <stdio.h>
25 #include <fcntl.h>
26 #include <sys/termios.h>
27
28 FILE *Ptr;
29
30 LogError(Str)
31 char *Str;
32 {
33     fprintf(Ptr, "%s \n", Str);
34 }
35
36 main()
37 {
38   int FilePtr, i, Error=0;
39   struct termios termio_orig;
40
41     Ptr = fopen("term.log", "a");
42     if ((FilePtr = open("/dev/tty", O_RDWR)) < 0) 
43        {LogError("Could not open tty "); exit(-1);}
44     if(tcgetattr(FilePtr, &termio_orig) < 0) 
45        {LogError("tcgetattr failed "); exit(-1);}
46     if (termio_orig.c_cc[VINTR] != '!') 
47        {LogError("intr not set"); Error = 1;}
48     if (termio_orig.c_cc[VQUIT] != '@') 
49        {LogError("quit not set"); Error = 1;}
50     if (termio_orig.c_cc[VERASE] != '#') 
51        {LogError("erase not set"); Error = 1;}
52     if (termio_orig.c_cc[VKILL] != '$') 
53        {LogError("kill not set"); Error = 1;}
54     if (termio_orig.c_cc[VEOF] != '%') 
55        {LogError("eof not set"); Error = 1;}
56     if (termio_orig.c_cc[VEOL] != '^') 
57        {LogError("eol not set"); Error = 1;}
58     if (termio_orig.c_cc[VSWTCH] != '&') 
59        {LogError("swtch not set"); Error = 1;}
60     if (termio_orig.c_cc[VSTART] != '*') 
61        {LogError("start not set"); Error = 1;}
62     if (termio_orig.c_cc[VSTOP] != '(') 
63        {LogError("stop not set"); Error = 1;}
64     if (termio_orig.c_cc[VSUSP] != ')') 
65        {LogError("susp not set"); Error = 1;}
66     if (Error == 1) LogError("Test Failed");
67     else LogError("Test Passed");
68     fclose(Ptr);
69 }
70