/****************************************************************************
- * 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 *
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* 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) *
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.62 2008/06/28 13:33:08 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;
***************************************************************************/
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
/*
* 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;
}
CacheInx = best;
}
- LAST_TRM = cur_term;
+ LAST_TRM = TerminalOf(SP_PARM);
LAST_SEQ = ++CacheSeq;
PC = 0;
if (errcode == 1) {
if (cursor_left)
- if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0)
+ if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0)
backspace_if_not_bs = cursor_left;
/* we're required to export these */
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);
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*/
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)
***************************************************************************/
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)) {
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)
***************************************************************************/
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)) {
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)
***************************************************************************/
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)) {
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)