1 /****************************************************************************
2 * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-on *
33 ****************************************************************************/
35 #include <curses.priv.h>
39 MODULE_ID("$Id: lib_ti.c,v 1.29 2010/01/23 17:57:43 tom Exp $")
43 same_name(const char *a
, const char *b
)
45 fprintf(stderr
, "compare(%s,%s)\n", a
, b
);
49 #define same_name(a,b) !strcmp(a,b)
53 NCURSES_SP_NAME(tigetflag
) (NCURSES_SP_DCLx NCURSES_CONST
char *str
)
55 int result
= ABSENT_BOOLEAN
;
58 T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM
, str
));
60 if (HasTInfoTerminal(SP_PARM
)) {
61 TERMTYPE
*tp
= &(TerminalOf(SP_PARM
)->type
);
62 struct name_table_entry
const *entry_ptr
;
64 entry_ptr
= _nc_find_type_entry(str
, BOOLEAN
, FALSE
);
66 j
= entry_ptr
->nte_index
;
71 for_each_ext_boolean(i
, tp
) {
72 const char *capname
= ExtBoolname(tp
, i
, boolnames
);
73 if (same_name(str
, capname
)) {
81 /* note: setupterm forces invalid booleans to false */
82 result
= tp
->Booleans
[j
];
91 tigetflag(NCURSES_CONST
char *str
)
93 return NCURSES_SP_NAME(tigetflag
) (CURRENT_SCREEN
, str
);
98 NCURSES_SP_NAME(tigetnum
) (NCURSES_SP_DCLx NCURSES_CONST
char *str
)
101 int result
= CANCELLED_NUMERIC
; /* Solaris returns a -1 on error */
103 T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM
, str
));
105 if (HasTInfoTerminal(SP_PARM
)) {
106 TERMTYPE
*tp
= &(TerminalOf(SP_PARM
)->type
);
107 struct name_table_entry
const *entry_ptr
;
109 entry_ptr
= _nc_find_type_entry(str
, NUMBER
, FALSE
);
110 if (entry_ptr
!= 0) {
111 j
= entry_ptr
->nte_index
;
116 for_each_ext_number(i
, tp
) {
117 const char *capname
= ExtNumname(tp
, i
, numnames
);
118 if (same_name(str
, capname
)) {
126 if (VALID_NUMERIC(tp
->Numbers
[j
]))
127 result
= tp
->Numbers
[j
];
129 result
= ABSENT_NUMERIC
;
138 tigetnum(NCURSES_CONST
char *str
)
140 return NCURSES_SP_NAME(tigetnum
) (CURRENT_SCREEN
, str
);
144 NCURSES_EXPORT(char *)
145 NCURSES_SP_NAME(tigetstr
) (NCURSES_SP_DCLx NCURSES_CONST
char *str
)
147 char *result
= CANCELLED_STRING
;
150 T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM
, str
));
152 if (HasTInfoTerminal(SP_PARM
)) {
153 TERMTYPE
*tp
= &(TerminalOf(SP_PARM
)->type
);
154 struct name_table_entry
const *entry_ptr
;
156 entry_ptr
= _nc_find_type_entry(str
, STRING
, FALSE
);
157 if (entry_ptr
!= 0) {
158 j
= entry_ptr
->nte_index
;
163 for_each_ext_string(i
, tp
) {
164 const char *capname
= ExtStrname(tp
, i
, strnames
);
165 if (same_name(str
, capname
)) {
173 /* note: setupterm forces cancelled strings to null */
174 result
= tp
->Strings
[j
];
182 NCURSES_EXPORT(char *)
183 tigetstr(NCURSES_CONST
char *str
)
185 return NCURSES_SP_NAME(tigetstr
) (CURRENT_SCREEN
, str
);