kernel - Fix races created by a comedy of circumstansces (3)
[dragonfly.git] / contrib / ncurses / progs / tparm_type.c
blob125e43c26179640b411bc84d9e38e634f1145193
1 /****************************************************************************
2 * Copyright (c) 1998-2013,2015 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey *
31 ****************************************************************************/
33 #include <tparm_type.h>
35 MODULE_ID("$Id: tparm_type.c,v 1.2 2015/04/04 15:01:13 tom Exp $")
38 * Lookup the type of call we should make to tparm(). This ignores the actual
39 * terminfo capability (bad, because it is not extensible), but makes this
40 * code portable to platforms where sizeof(int) != sizeof(char *).
42 TParams
43 tparm_type(const char *name)
45 #define TD(code, longname, ti, tc) \
46 {code, {longname} }, \
47 {code, {ti} }, \
48 {code, {tc} }
49 TParams result = Numbers;
50 /* *INDENT-OFF* */
51 static const struct {
52 TParams code;
53 const char name[12];
54 } table[] = {
55 TD(Num_Str, "pkey_key", "pfkey", "pk"),
56 TD(Num_Str, "pkey_local", "pfloc", "pl"),
57 TD(Num_Str, "pkey_xmit", "pfx", "px"),
58 TD(Num_Str, "plab_norm", "pln", "pn"),
59 TD(Num_Str_Str, "pkey_plab", "pfxl", "xl"),
61 /* *INDENT-ON* */
63 unsigned n;
64 for (n = 0; n < SIZEOF(table); n++) {
65 if (!strcmp(name, table[n].name)) {
66 result = table[n].code;
67 break;
70 return result;