#include <curses.priv.h>
#include <tic.h>
MODULE_ID("$Id: lib_ti.c,v 1.8 2023/10/17 09:52:09 nicm Exp $")
#if 0
static bool
same_name(const char *a, const char *b)
{
fprintf(stderr, "compare(%s,%s)\n", a, b);
return !strcmp(a, b);
}
#else
#define same_name(a,b) !strcmp(a,b)
#endif
NCURSES_EXPORT(int)
NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str)
{
int result = ABSENT_BOOLEAN;
T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str));
if (HasTInfoTerminal(SP_PARM)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
struct name_table_entry const *entry_ptr;
int j = -1;
entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE);
if (entry_ptr != 0) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
else {
int i;
for_each_ext_boolean(i, tp) {
const char *capname = ExtBoolname(tp, i, boolnames);
if (same_name(str, capname)) {
j = i;
break;
}
}
}
#endif
if (j >= 0) {
result = tp->Booleans[j];
}
}
returnCode(result);
}
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
tigetflag(const char *str)
{
return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str);
}
#endif
NCURSES_EXPORT(int)
NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str)
{
int result = CANCELLED_NUMERIC;
T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str));
if (HasTInfoTerminal(SP_PARM)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
struct name_table_entry const *entry_ptr;
int j = -1;
entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE);
if (entry_ptr != 0) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
else {
int i;
for_each_ext_number(i, tp) {
const char *capname = ExtNumname(tp, i, numnames);
if (same_name(str, capname)) {
j = i;
break;
}
}
}
#endif
if (j >= 0) {
if (VALID_NUMERIC(tp->Numbers[j]))
result = tp->Numbers[j];
else
result = ABSENT_NUMERIC;
}
}
returnCode(result);
}
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
tigetnum(const char *str)
{
return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str);
}
#endif
NCURSES_EXPORT(char *)
NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx const char *str)
{
char *result = CANCELLED_STRING;
T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str));
if (HasTInfoTerminal(SP_PARM)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
struct name_table_entry const *entry_ptr;
int j = -1;
entry_ptr = _nc_find_type_entry(str, STRING, FALSE);
if (entry_ptr != 0) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
else {
int i;
for_each_ext_string(i, tp) {
const char *capname = ExtStrname(tp, i, strnames);
if (same_name(str, capname)) {
j = i;
break;
}
}
}
#endif
if (j >= 0) {
result = tp->Strings[j];
}
}
returnPtr(result);
}
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(char *)
tigetstr(const char *str)
{
return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str);
}
#endif