10e3d5408SPeter Wemm /**************************************************************************** 215589c42SPeter Wemm * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * 30e3d5408SPeter Wemm * * 40e3d5408SPeter Wemm * Permission is hereby granted, free of charge, to any person obtaining a * 50e3d5408SPeter Wemm * copy of this software and associated documentation files (the * 60e3d5408SPeter Wemm * "Software"), to deal in the Software without restriction, including * 70e3d5408SPeter Wemm * without limitation the rights to use, copy, modify, merge, publish, * 80e3d5408SPeter Wemm * distribute, distribute with modifications, sublicense, and/or sell * 90e3d5408SPeter Wemm * copies of the Software, and to permit persons to whom the Software is * 100e3d5408SPeter Wemm * furnished to do so, subject to the following conditions: * 110e3d5408SPeter Wemm * * 120e3d5408SPeter Wemm * The above copyright notice and this permission notice shall be included * 130e3d5408SPeter Wemm * in all copies or substantial portions of the Software. * 140e3d5408SPeter Wemm * * 150e3d5408SPeter Wemm * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 160e3d5408SPeter Wemm * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 170e3d5408SPeter Wemm * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 180e3d5408SPeter Wemm * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 190e3d5408SPeter Wemm * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 200e3d5408SPeter Wemm * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 210e3d5408SPeter Wemm * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 220e3d5408SPeter Wemm * * 230e3d5408SPeter Wemm * Except as contained in this notice, the name(s) of the above copyright * 240e3d5408SPeter Wemm * holders shall not be used in advertising or otherwise to promote the * 250e3d5408SPeter Wemm * sale, use or other dealings in this Software without prior written * 260e3d5408SPeter Wemm * authorization. * 270e3d5408SPeter Wemm ****************************************************************************/ 280e3d5408SPeter Wemm 290e3d5408SPeter Wemm /**************************************************************************** 300e3d5408SPeter Wemm * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 310e3d5408SPeter Wemm * and: Eric S. Raymond <esr@snark.thyrsus.com> * 320e3d5408SPeter Wemm ****************************************************************************/ 330e3d5408SPeter Wemm 340e3d5408SPeter Wemm #include <curses.priv.h> 350e3d5408SPeter Wemm 360e3d5408SPeter Wemm #include <term_entry.h> 370e3d5408SPeter Wemm #include <tic.h> 380e3d5408SPeter Wemm 397a69bbfbSPeter Wemm MODULE_ID("$Id: lib_ti.c,v 1.22 2000/12/10 02:55:08 tom Exp $") 400e3d5408SPeter Wemm 417a69bbfbSPeter Wemm NCURSES_EXPORT(int) 4215589c42SPeter Wemm tigetflag(NCURSES_CONST char *str) 430e3d5408SPeter Wemm { 440e3d5408SPeter Wemm int i; 450e3d5408SPeter Wemm 460e3d5408SPeter Wemm T((T_CALLED("tigetflag(%s)"), str)); 470e3d5408SPeter Wemm 480e3d5408SPeter Wemm if (cur_term != 0) { 490e3d5408SPeter Wemm TERMTYPE *tp = &(cur_term->type); 500e3d5408SPeter Wemm for_each_boolean(i, tp) { 510e3d5408SPeter Wemm const char *capname = ExtBoolname(tp, i, boolnames); 520e3d5408SPeter Wemm if (!strcmp(str, capname)) { 530e3d5408SPeter Wemm /* setupterm forces invalid booleans to false */ 540e3d5408SPeter Wemm returnCode(tp->Booleans[i]); 550e3d5408SPeter Wemm } 560e3d5408SPeter Wemm } 570e3d5408SPeter Wemm } 580e3d5408SPeter Wemm 590e3d5408SPeter Wemm returnCode(ABSENT_BOOLEAN); 600e3d5408SPeter Wemm } 610e3d5408SPeter Wemm 627a69bbfbSPeter Wemm NCURSES_EXPORT(int) 6315589c42SPeter Wemm tigetnum(NCURSES_CONST char *str) 640e3d5408SPeter Wemm { 650e3d5408SPeter Wemm int i; 660e3d5408SPeter Wemm 670e3d5408SPeter Wemm T((T_CALLED("tigetnum(%s)"), str)); 680e3d5408SPeter Wemm 690e3d5408SPeter Wemm if (cur_term != 0) { 700e3d5408SPeter Wemm TERMTYPE *tp = &(cur_term->type); 710e3d5408SPeter Wemm for_each_number(i, tp) { 720e3d5408SPeter Wemm const char *capname = ExtNumname(tp, i, numnames); 730e3d5408SPeter Wemm if (!strcmp(str, capname)) { 740e3d5408SPeter Wemm if (!VALID_NUMERIC(tp->Numbers[i])) 7515589c42SPeter Wemm returnCode(ABSENT_NUMERIC); 760e3d5408SPeter Wemm returnCode(tp->Numbers[i]); 770e3d5408SPeter Wemm } 780e3d5408SPeter Wemm } 790e3d5408SPeter Wemm } 800e3d5408SPeter Wemm 810e3d5408SPeter Wemm returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */ 820e3d5408SPeter Wemm } 830e3d5408SPeter Wemm 847a69bbfbSPeter Wemm NCURSES_EXPORT(char *) 8515589c42SPeter Wemm tigetstr(NCURSES_CONST char *str) 860e3d5408SPeter Wemm { 870e3d5408SPeter Wemm int i; 880e3d5408SPeter Wemm 890e3d5408SPeter Wemm T((T_CALLED("tigetstr(%s)"), str)); 900e3d5408SPeter Wemm 910e3d5408SPeter Wemm if (cur_term != 0) { 920e3d5408SPeter Wemm TERMTYPE *tp = &(cur_term->type); 930e3d5408SPeter Wemm for_each_string(i, tp) { 940e3d5408SPeter Wemm const char *capname = ExtStrname(tp, i, strnames); 950e3d5408SPeter Wemm if (!strcmp(str, capname)) { 960e3d5408SPeter Wemm /* setupterm forces cancelled strings to null */ 970e3d5408SPeter Wemm returnPtr(tp->Strings[i]); 980e3d5408SPeter Wemm } 990e3d5408SPeter Wemm } 1000e3d5408SPeter Wemm } 1010e3d5408SPeter Wemm 1020e3d5408SPeter Wemm returnPtr(CANCELLED_STRING); 1030e3d5408SPeter Wemm } 104