1 /****************************************************************************
2 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 2017 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 * $Id: test_termattrs.c,v 1.3 2020/02/02 23:34:34 tom Exp $
32 * Demonstrate the termattrs and term_attrs functions.
36 #include <test.priv.h>
43 test_termattrs(unsigned long value)
45 #define DATA(name) { name, #name }
109 fprintf(my_fp, "Result: %08lX\r\n", value);
110 for (n = 0; n < SIZEOF(table); ++n) {
111 if ((value & table[n].code) != 0) {
112 fprintf(my_fp, "%08lX %08lX %s\r\n",
113 table[n].code, value & table[n].code, table[n].name);
116 fputs("\r\n", my_fp);
122 static const char *tbl[] =
124 "Usage: test_termattrs [options]"
127 ," -e use stderr (default stdout)"
128 ," -n do not initialize terminal"
129 ," -s use setupterm rather than newterm"
130 #if USE_WIDEC_SUPPORT
131 ," -w use term_attrs rather than termattrs"
135 for (n = 0; n < SIZEOF(tbl); ++n)
136 fprintf(stderr, "%s\n", tbl[n]);
137 ExitProgram(EXIT_FAILURE);
141 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
144 bool no_init = FALSE;
146 #if USE_WIDEC_SUPPORT
152 while ((ch = getopt(argc, argv, "ensw")) != -1) {
163 #if USE_WIDEC_SUPPORT
179 setupterm((char *) 0, fileno(my_fp), (int *) 0);
181 newterm((char *) 0, my_fp, stdin);
183 #if USE_WIDEC_SUPPORT
185 test_termattrs((unsigned long) term_attrs());
188 test_termattrs((unsigned long) termattrs());
189 ExitProgram(EXIT_SUCCESS);
194 main(int argc GCC_UNUSED,
195 char *argv[]GCC_UNUSED)
197 fprintf(stderr, "This program requires terminfo\n");