1 /****************************************************************************
2 * Copyright 2020,2022 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.4 2022/05/15 15:55:30 tom Exp $
32 * Demonstrate the termattrs and term_attrs functions.
37 #include <test.priv.h>
44 test_termattrs(unsigned long value)
46 #define DATA(name) { name, #name }
110 fprintf(my_fp, "Result: %08lX\r\n", value);
111 for (n = 0; n < SIZEOF(table); ++n) {
112 if ((value & table[n].code) != 0) {
113 fprintf(my_fp, "%08lX %08lX %s\r\n",
114 table[n].code, value & table[n].code, table[n].name);
117 fputs("\r\n", my_fp);
123 static const char *tbl[] =
125 "Usage: test_termattrs [options]"
128 ," -e use stderr (default stdout)"
129 ," -n do not initialize terminal"
130 ," -s use setupterm rather than newterm"
131 #if USE_WIDEC_SUPPORT
132 ," -w use term_attrs rather than termattrs"
136 for (n = 0; n < SIZEOF(tbl); ++n)
137 fprintf(stderr, "%s\n", tbl[n]);
138 ExitProgram(EXIT_FAILURE);
142 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
145 bool no_init = FALSE;
147 #if USE_WIDEC_SUPPORT
153 while ((ch = getopt(argc, argv, "ensw")) != -1) {
164 #if USE_WIDEC_SUPPORT
180 setupterm((char *) 0, fileno(my_fp), (int *) 0);
182 newterm((char *) 0, my_fp, stdin);
184 #if USE_WIDEC_SUPPORT
186 test_termattrs((unsigned long) term_attrs());
189 test_termattrs((unsigned long) termattrs());
190 ExitProgram(EXIT_SUCCESS);
195 main(int argc GCC_UNUSED,
196 char *argv[]GCC_UNUSED)
198 fprintf(stderr, "This program requires terminfo\n");