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.8 2022/12/10 23:23:27 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]"
129 ," -e use stderr (default stdout)"
130 ," -n do not initialize terminal"
131 ," -s use setupterm rather than newterm"
132 #if USE_WIDEC_SUPPORT
133 ," -w use term_attrs rather than termattrs"
137 for (n = 0; n < SIZEOF(tbl); ++n)
138 fprintf(stderr, "%s\n", tbl[n]);
139 ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
146 main(int argc, char *argv[])
149 bool no_init = FALSE;
151 #if USE_WIDEC_SUPPORT
157 while ((ch = getopt(argc, argv, OPTS_COMMON "ensw")) != -1) {
168 #if USE_WIDEC_SUPPORT
175 ExitProgram(EXIT_SUCCESS);
177 usage(ch == OPTS_USAGE);
187 setupterm((char *) 0, fileno(my_fp), (int *) 0);
189 newterm((char *) 0, my_fp, stdin);
191 #if USE_WIDEC_SUPPORT
193 test_termattrs((unsigned long) term_attrs());
196 test_termattrs((unsigned long) termattrs());
197 ExitProgram(EXIT_SUCCESS);
204 fprintf(stderr, "This program requires terminfo\n");