/*+++* * RCS $Id: _termcap.h,v 1.4 1993/04/07 01:37:41 tom Exp tom $ * title: _termcap.h * abstract: (internal) definitions for termcap library * author: T.R.Hageman, Groningen, The Netherlands. * created: july 1988 * modified: March 1990, added FASTCAP implementation. * description: * Definitions and compilation options for termcap package. * * Compilation options are: * * FASTCAP = 1 - tgetent() builds an entry table ordered on capability * name (and de-escapes the strings on the fly). * tget{flag,num,str}() do a fast binary search in this * table to locate the capability. * _POINTERS - choose between pointer and offset reference to * capability values. * * FASTCAP = 0 - a conventional implementation; just loads the raw * entry and works from there. * HASHED - an earlier attempt to speed things up. * (I'm afraid this is a kludge...) * * if FASTCAP is undefined the compilation mode depends on * the existence of SLOWCAP. * * HARDWIRED = 1 - provides a hard-wired termcap entry for some * small single-user systems (see tgetent.c). * This is the default for {MS,GEM}DOS. * * HARDWIRED = -1 - ``soft hardwire'': like above, but also compiles * conventional tgetent (which is taken if `name' * argument does not match the builtin terminal and * is non-NULL). * * HARDWIRED = 0 - (or undefined) use conventional tgetent. * * TCP - Termcap compatibility options, * can be one or more of: * ARCANE - implement arcane %x sequences in * tgoto(); * EXTENSION - implement Gnu Termcap %x sequences * in tgoto()--lots of wich are ARCANE; * TPARAM - implement Gnu Termcap compatible * tparam() routine; * DYNALLOC - implement Gnu Termcap style dynamic * allocation in tgetent()/tgetstr()/ * tparam(); * BCUP - implement tgoto's BC/UP kludgeridoo; * GNUTERMCAP - all of the above. * * * STACK_DIRECTION = -1, 0, 1 * - optimize parameter passing in tparam() * * TGOTOBUFSIZE - size of result buffer of tgoto(). * * DEBUG - enables debug code (mainly for debugging tgetent). *---*/ #ifndef _IMPLEMENT_TERMCAP_H #define _IMPLEMENT_TERMCAP_H /* Public definitions (including portability macros) */ #ifndef _TERMCAP_H # include "termcap.h" #endif /* Operating System flags */ #ifdef MSDOS /* Microsof C */ # undef MSDOS # define MSDOS 1 #endif #if __MSDOS__ /* Turbo C */ # define MSDOS 1 #endif #if (__TOS__ || __tos__ || TOS) /* Turbo C || Gcc || Lattice C */ # define GEMDOS 1 #endif /* return values for tgetent() */ #define NO_FILE -1 /* Returned if can't open file */ #define NO_ENTRY 0 /* Returned if can't find entry */ #define SUCCESS 1 /* Returned if entry found ok */ #define TRUNCATED 2 /* Returned if entry found but trunc */ /* Compilation options. */ /* Compilation flags for use with TCP; can be ORed together. */ #define ARCANE 0x1 /* implement Arcane %x sequences in tgoto */ #define EXTENSION 0x2 /* implement Gnu termcap extensions in tgoto */ #define TPARAM 0x4 /* implement Gnu termcap compatible tparam() */ #define DYNALLOC 0x8 /* implement Gnu termcap dynamic allocation */ #define BCUP 0x10 /* implement tgoto's BC/UP kludgeridoo */ #define GNUTERMCAP (ARCANE|EXTENSION|TPARAM|DYNALLOC|BCUP) #ifndef TCP # ifndef TINY # define TCP (ARCANE|EXTENSION) # endif #endif /* Which way does the parameter stack grow? If it grows downward, AND if varargs parameters are pushed on the stack, we can access these as a (zero-based) array. (This is an optimization for tparam(); it is OK to leave this undefined if you are not sure of your particular machine.) */ #ifndef STACK_DIRECTION # if (pdp11|m68k|mc68000|i86|i386|i486|GEMDOS|MSDOS) # define STACK_DIRECTION (-1) /* stack grows downward. */ # endif #endif #ifndef TGOTOBUFSIZE /* size of static result buffer for tgoto(). */ # define TGOTOBUFSIZE 32 #endif #ifndef HARDWIRED # if (GEMDOS || MSDOS) # define HARDWIRED 1 /* hardwired entry only. */ # else # define HARDWIRED 0 # endif #endif #if HARDWIRED /* presumes FASTCAP and _POINTERS */ # undef FASTCAP # define FASTCAP 1 # define _POINTERS #endif #ifndef FASTCAP # ifdef SLOWCAP # define FASTCAP 0 # else # define FASTCAP 1 /* FASTCAP is the default if neither */ # endif /* FASTCAP nor SLOWCAP is defined */ #endif #if FASTCAP /* Fast Lookup implementation */ # if pdp11 /* use pointers if sizeof(char *) == sizeof(short), else use offsets */ # define _POINTERS # endif typedef struct { short t_cap; /* numeric repr. of 2-char cap. name */ # ifdef _POINTERS char * t_val; /* pointer to capabilities value */ # else short t_val; /* offset of capabilities value */ # endif /* relative to _tcptable.t_strbase */ } t_entry; typedef struct { t_entry *t_body; /* pointer to actual cap. table */ int t_size; /* size of cap. table */ short t_compiling; /* set by tgetent, cleared otherwise */ # ifndef _POINTERS char *t_strbase; /* base of string buffer */ # endif } t_table; extern t_table _tcptable; # ifdef _POINTERS # define _TCP_SETBASE(base) # define _TCP_VAL(tp) ((tp)->t_val) # define _TCP_OFF(str) (str) # else # define _TCP_SETBASE(base) (_tcptable.t_strbase = (base)) # define _TCP_VAL(tp) (_tcptable.t_strbase + (tp)->t_val) # define _TCP_OFF(str) ((str) - _tcptable.t_strbase) # endif # undef _POINTERS #else /* ! FASTCAP */ extern char *_tcpbuf; /* pointer to termcap entry buffer */ # ifdef HASHED extern void _tcphash __(( void )); # else # define _tcphash() # endif #endif /* !FASTCAP */ extern char *_tcpfind __(( const char *_(cap) )); #ifdef DEBUG # ifndef stdout # include # endif # define DPRINTF(x) printf x #else # define DPRINTF(x) #endif #ifndef NULL # define NULL ((void *) 0) #endif #endif /* _IMPLEMENT_TERMCAP_H */ /*======================================================================* * $Log: _termcap.h,v $ * Revision 1.4 1993/04/07 01:37:41 tom * comment fix; fix typo in RCS Log. * *======================================================================*/