Back to index

tetex-bin  3.0
lib_ti.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  ****************************************************************************/
00033 
00034 #include <curses.priv.h>
00035 
00036 #include <term_entry.h>
00037 #include <tic.h>
00038 
00039 MODULE_ID("$Id: lib_ti.c,v 1.23 2003/05/24 21:10:28 tom Exp $")
00040 
00041 NCURSES_EXPORT(int)
00042 tigetflag(NCURSES_CONST char *str)
00043 {
00044     unsigned i;
00045 
00046     T((T_CALLED("tigetflag(%s)"), str));
00047 
00048     if (cur_term != 0) {
00049        TERMTYPE *tp = &(cur_term->type);
00050        for_each_boolean(i, tp) {
00051            const char *capname = ExtBoolname(tp, i, boolnames);
00052            if (!strcmp(str, capname)) {
00053               /* setupterm forces invalid booleans to false */
00054               returnCode(tp->Booleans[i]);
00055            }
00056        }
00057     }
00058 
00059     returnCode(ABSENT_BOOLEAN);
00060 }
00061 
00062 NCURSES_EXPORT(int)
00063 tigetnum(NCURSES_CONST char *str)
00064 {
00065     unsigned i;
00066 
00067     T((T_CALLED("tigetnum(%s)"), str));
00068 
00069     if (cur_term != 0) {
00070        TERMTYPE *tp = &(cur_term->type);
00071        for_each_number(i, tp) {
00072            const char *capname = ExtNumname(tp, i, numnames);
00073            if (!strcmp(str, capname)) {
00074               if (!VALID_NUMERIC(tp->Numbers[i]))
00075                   returnCode(ABSENT_NUMERIC);
00076               returnCode(tp->Numbers[i]);
00077            }
00078        }
00079     }
00080 
00081     returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */
00082 }
00083 
00084 NCURSES_EXPORT(char *)
00085 tigetstr(NCURSES_CONST char *str)
00086 {
00087     unsigned i;
00088 
00089     T((T_CALLED("tigetstr(%s)"), str));
00090 
00091     if (cur_term != 0) {
00092        TERMTYPE *tp = &(cur_term->type);
00093        for_each_string(i, tp) {
00094            const char *capname = ExtStrname(tp, i, strnames);
00095            if (!strcmp(str, capname)) {
00096               /* setupterm forces cancelled strings to null */
00097               returnPtr(tp->Strings[i]);
00098            }
00099        }
00100     }
00101 
00102     returnPtr(CANCELLED_STRING);
00103 }