X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_ti.c;h=355310ec778cecae99259ae9b96a4aa02ba4559d;hp=7b2b2f910f2d34131dc2d24c203f59549d949384;hb=404cc3f5b0751dd219565139f825c5a4d445f651;hpb=0eb88fc5281804773e2a0c7a488a4452463535ce diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c index 7b2b2f91..355310ec 100644 --- a/ncurses/tinfo/lib_ti.c +++ b/ncurses/tinfo/lib_ti.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -31,71 +31,97 @@ * and: Eric S. Raymond * ****************************************************************************/ - #include #include #include -MODULE_ID("$Id: lib_ti.c,v 1.16 1999/02/28 23:11:28 tom Exp $") +MODULE_ID("$Id: lib_ti.c,v 1.24 2009/04/18 17:37:50 tom Exp $") -int tigetflag(NCURSES_CONST char *str) +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str) { -int i; - - T((T_CALLED("tigetflag(%s)"), str)); - - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); - for_each_boolean(i,tp) { - const char *capname = ExtBoolname(tp, i, boolnames); - if (!strcmp(str, capname)) { - /* setupterm forces invalid booleans to false */ - returnCode(tp->Booleans[i]); - } + unsigned i; + + T((T_CALLED("tigetflag(%p, %s)"), SP_PARM, str)); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + for_each_boolean(i, tp) { + const char *capname = ExtBoolname(tp, i, boolnames); + if (!strcmp(str, capname)) { + /* setupterm forces invalid booleans to false */ + returnCode(tp->Booleans[i]); } } + } - returnCode(ABSENT_BOOLEAN); + returnCode(ABSENT_BOOLEAN); } -int tigetnum(NCURSES_CONST char *str) +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tigetflag(NCURSES_CONST char *str) { -int i; - - T((T_CALLED("tigetnum(%s)"), str)); - - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); - for_each_number(i, tp) { - const char *capname = ExtNumname(tp, i, numnames); - if (!strcmp(str, capname)) { - if (!VALID_NUMERIC(tp->Numbers[i])) - return -1; - returnCode(tp->Numbers[i]); - } + return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) +{ + unsigned i; + + T((T_CALLED("tigetnum(%p, %s)"), SP_PARM, str)); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + for_each_number(i, tp) { + const char *capname = ExtNumname(tp, i, numnames); + if (!strcmp(str, capname)) { + if (!VALID_NUMERIC(tp->Numbers[i])) + returnCode(ABSENT_NUMERIC); + returnCode(tp->Numbers[i]); } } + } + + returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */ +} - returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */ +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tigetnum(NCURSES_CONST char *str) +{ + return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str); } +#endif -char *tigetstr(NCURSES_CONST char *str) +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str) { -int i; - - T((T_CALLED("tigetstr(%s)"), str)); - - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); - for_each_string(i, tp) { - const char *capname = ExtStrname(tp, i, strnames); - if (!strcmp(str, capname)) { - /* setupterm forces cancelled strings to null */ - returnPtr(tp->Strings[i]); - } + unsigned i; + + T((T_CALLED("tigetstr(%p, %s)"), SP_PARM, str)); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + for_each_string(i, tp) { + const char *capname = ExtStrname(tp, i, strnames); + if (!strcmp(str, capname)) { + /* setupterm forces cancelled strings to null */ + returnPtr(tp->Strings[i]); } } + } - returnPtr(CANCELLED_STRING); + returnPtr(CANCELLED_STRING); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +tigetstr(NCURSES_CONST char *str) +{ + return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str); } +#endif