150276Speter/**************************************************************************** 2166124Srafan * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 3250276Speter ****************************************************************************/ 3350276Speter 3450276Speter#include <curses.priv.h> 3550276Speter 3650276Speter#include <term_entry.h> 3750276Speter#include <tic.h> 3850276Speter 39166124SrafanMODULE_ID("$Id: lib_ti.c,v 1.23 2003/05/24 21:10:28 tom Exp $") 4050276Speter 4176726SpeterNCURSES_EXPORT(int) 4262449Spetertigetflag(NCURSES_CONST char *str) 4350276Speter{ 44166124Srafan unsigned i; 4550276Speter 4662449Speter T((T_CALLED("tigetflag(%s)"), str)); 4750276Speter 4862449Speter if (cur_term != 0) { 4962449Speter TERMTYPE *tp = &(cur_term->type); 5062449Speter for_each_boolean(i, tp) { 5162449Speter const char *capname = ExtBoolname(tp, i, boolnames); 5262449Speter if (!strcmp(str, capname)) { 5362449Speter /* setupterm forces invalid booleans to false */ 5462449Speter returnCode(tp->Booleans[i]); 5550276Speter } 5650276Speter } 5762449Speter } 5850276Speter 5962449Speter returnCode(ABSENT_BOOLEAN); 6050276Speter} 6150276Speter 6276726SpeterNCURSES_EXPORT(int) 6362449Spetertigetnum(NCURSES_CONST char *str) 6450276Speter{ 65166124Srafan unsigned i; 6650276Speter 6762449Speter T((T_CALLED("tigetnum(%s)"), str)); 6850276Speter 6962449Speter if (cur_term != 0) { 7062449Speter TERMTYPE *tp = &(cur_term->type); 7162449Speter for_each_number(i, tp) { 7262449Speter const char *capname = ExtNumname(tp, i, numnames); 7362449Speter if (!strcmp(str, capname)) { 7462449Speter if (!VALID_NUMERIC(tp->Numbers[i])) 7562449Speter returnCode(ABSENT_NUMERIC); 7662449Speter returnCode(tp->Numbers[i]); 7750276Speter } 7850276Speter } 7962449Speter } 8050276Speter 8162449Speter returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */ 8250276Speter} 8350276Speter 8476726SpeterNCURSES_EXPORT(char *) 8562449Spetertigetstr(NCURSES_CONST char *str) 8650276Speter{ 87166124Srafan unsigned i; 8850276Speter 8962449Speter T((T_CALLED("tigetstr(%s)"), str)); 9050276Speter 9162449Speter if (cur_term != 0) { 9262449Speter TERMTYPE *tp = &(cur_term->type); 9362449Speter for_each_string(i, tp) { 9462449Speter const char *capname = ExtStrname(tp, i, strnames); 9562449Speter if (!strcmp(str, capname)) { 9662449Speter /* setupterm forces cancelled strings to null */ 9762449Speter returnPtr(tp->Strings[i]); 9850276Speter } 9950276Speter } 10062449Speter } 10150276Speter 10262449Speter returnPtr(CANCELLED_STRING); 10350276Speter} 104