X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_termcap.c;h=af4d8f84bb83c95b5ace405a733c00b0999c4460;hb=d4ede7c5fa6a269d338fea32cd93bf39083dda8c;hp=2d245ffbb61f345db2ca0741134ca3c7c6804f84;hpb=11ca5f62994c7a14c4e500510bd242e1e721f8be;p=ncurses.git diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c index 2d245ffb..af4d8f84 100644 --- a/ncurses/tinfo/lib_termcap.c +++ b/ncurses/tinfo/lib_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,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 * @@ -30,6 +30,7 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * * * * some of the code in here was contributed by: * * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93) * @@ -45,7 +46,11 @@ #include -MODULE_ID("$Id: lib_termcap.c,v 1.63 2008/08/16 19:22:55 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_termcap.c,v 1.67 2009/05/30 20:05:20 tom Exp $") NCURSES_EXPORT_VAR(char *) UP = 0; NCURSES_EXPORT_VAR(char *) BC = 0; @@ -76,16 +81,28 @@ NCURSES_EXPORT_VAR(char *) BC = 0; ***************************************************************************/ NCURSES_EXPORT(int) -tgetent(char *bufp, const char *name) +NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) { - int errcode; + int errcode = ERR; int n; bool found_cache = FALSE; +#ifdef USE_TERM_DRIVER + TERMINAL *termp = 0; +#endif START_TRACE(); T((T_CALLED("tgetent()"))); +#ifdef USE_TERM_DRIVER + _nc_setupterm_ex(&termp, (NCURSES_CONST char *) name, + STDOUT_FILENO, &errcode, TRUE); + + if (termp == 0 || + !((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo) + return (errcode); +#else _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE); +#endif /* * In general we cannot tell if the fixed sgr0 is still used by the @@ -109,9 +126,9 @@ tgetent(char *bufp, const char *name) /* * Also free the terminfo data that we loaded (much bigger leak). */ - if (LAST_TRM != 0 && LAST_TRM != cur_term) { + if (LAST_TRM != 0 && LAST_TRM != TerminalOf(SP_PARM)) { TERMINAL *trm = LAST_TRM; - del_curterm(LAST_TRM); + NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM); for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) if (LAST_TRM == trm) LAST_TRM = 0; @@ -131,7 +148,7 @@ tgetent(char *bufp, const char *name) } CacheInx = best; } - LAST_TRM = cur_term; + LAST_TRM = TerminalOf(SP_PARM); LAST_SEQ = ++CacheSeq; PC = 0; @@ -153,7 +170,7 @@ tgetent(char *bufp, const char *name) if (backspace_if_not_bs != NULL) BC = backspace_if_not_bs; - if ((FIX_SGR0 = _nc_trim_sgr0(&(cur_term->type))) != 0) { + if ((FIX_SGR0 = _nc_trim_sgr0(&(TerminalOf(SP_PARM)->type))) != 0) { if (!strcmp(FIX_SGR0, exit_attribute_mode)) { if (FIX_SGR0 != exit_attribute_mode) { free(FIX_SGR0); @@ -164,8 +181,8 @@ tgetent(char *bufp, const char *name) LAST_BUF = bufp; LAST_USE = TRUE; - SetNoPadding(SP); - (void) baudrate(); /* sets ospeed as a side-effect */ + SetNoPadding(SP_PARM); + (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side-effect */ /* LINT_PREPRO #if 0*/ @@ -177,6 +194,14 @@ tgetent(char *bufp, const char *name) returnCode(errcode); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetent(char *bufp, const char *name) +{ + return NCURSES_SP_NAME(tgetent) (CURRENT_SCREEN, bufp, name); +} +#endif + /*************************************************************************** * * tgetflag(str) @@ -187,13 +212,13 @@ tgetent(char *bufp, const char *name) ***************************************************************************/ NCURSES_EXPORT(int) -tgetflag(NCURSES_CONST char *id) +NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx NCURSES_CONST char *id) { unsigned i; - T((T_CALLED("tgetflag(%s)"), id)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + T((T_CALLED("tgetflag(%p, %s)"), SP_PARM, id)); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_boolean(i, tp) { const char *capname = ExtBoolname(tp, i, boolcodes); if (!strncmp(id, capname, 2)) { @@ -205,6 +230,14 @@ tgetflag(NCURSES_CONST char *id) returnCode(0); /* Solaris does this */ } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetflag(NCURSES_CONST char *id) +{ + return NCURSES_SP_NAME(tgetflag) (CURRENT_SCREEN, id); +} +#endif + /*************************************************************************** * * tgetnum(str) @@ -215,13 +248,13 @@ tgetflag(NCURSES_CONST char *id) ***************************************************************************/ NCURSES_EXPORT(int) -tgetnum(NCURSES_CONST char *id) +NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx NCURSES_CONST char *id) { unsigned i; - T((T_CALLED("tgetnum(%s)"), id)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + T((T_CALLED("tgetnum(%p, %s)"), SP_PARM, id)); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_number(i, tp) { const char *capname = ExtNumname(tp, i, numcodes); if (!strncmp(id, capname, 2)) { @@ -234,6 +267,14 @@ tgetnum(NCURSES_CONST char *id) returnCode(ABSENT_NUMERIC); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetnum(NCURSES_CONST char *id) +{ + return NCURSES_SP_NAME(tgetnum) (CURRENT_SCREEN, id); +} +#endif + /*************************************************************************** * * tgetstr(str, area) @@ -244,14 +285,14 @@ tgetnum(NCURSES_CONST char *id) ***************************************************************************/ NCURSES_EXPORT(char *) -tgetstr(NCURSES_CONST char *id, char **area) +NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx NCURSES_CONST char *id, char **area) { unsigned i; char *result = NULL; T((T_CALLED("tgetstr(%s,%p)"), id, area)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_string(i, tp) { const char *capname = ExtStrname(tp, i, strcodes); if (!strncmp(id, capname, 2)) { @@ -278,6 +319,14 @@ tgetstr(NCURSES_CONST char *id, char **area) returnPtr(result); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +tgetstr(NCURSES_CONST char *id, char **area) +{ + return NCURSES_SP_NAME(tgetstr) (CURRENT_SCREEN, id, area); +} +#endif + #if NO_LEAKS NCURSES_EXPORT(void) _nc_tgetent_leaks(void)