150276Speter/****************************************************************************
2262685Sdelphij * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
350276Speter *                                                                          *
450276Speter * Permission is hereby granted, free of charge, to any person obtaining a  *
550276Speter * copy of this software and associated documentation files (the            *
650276Speter * "Software"), to deal in the Software without restriction, including      *
750276Speter * without limitation the rights to use, copy, modify, merge, publish,      *
850276Speter * distribute, distribute with modifications, sublicense, and/or sell       *
950276Speter * copies of the Software, and to permit persons to whom the Software is    *
1050276Speter * furnished to do so, subject to the following conditions:                 *
1150276Speter *                                                                          *
1250276Speter * The above copyright notice and this permission notice shall be included  *
1350276Speter * in all copies or substantial portions of the Software.                   *
1450276Speter *                                                                          *
1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2250276Speter *                                                                          *
2350276Speter * Except as contained in this notice, the name(s) of the above copyright   *
2450276Speter * holders shall not be used in advertising or otherwise to promote the     *
2550276Speter * sale, use or other dealings in this Software without prior written       *
2650276Speter * authorization.                                                           *
2750276Speter ****************************************************************************/
2850276Speter
2950276Speter/****************************************************************************
3050276Speter *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
3150276Speter *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32184989Srafan *     and: Thomas E. Dickey                        1998-on                 *
3350276Speter ****************************************************************************/
3450276Speter
35262685Sdelphij/* $Id: term_entry.h,v 1.44 2013/05/25 20:13:38 tom Exp $ */
3650276Speter
3750276Speter/*
3850276Speter *	term_entry.h -- interface to entry-manipulation code
3950276Speter */
4050276Speter
4176726Speter#ifndef NCURSES_TERM_ENTRY_H_incl
4276726Speter#define NCURSES_TERM_ENTRY_H_incl 1
4350276Speter
4450276Speter#ifdef __cplusplus
4550276Speterextern "C" {
4650276Speter#endif
4750276Speter
4850276Speter#include <term.h>
4950276Speter
50262685Sdelphij    /*
51262685Sdelphij     * see db_iterator.c - this enumeration lists the places searched for a
52262685Sdelphij     * terminal description and defines the order in which they are searched.
53262685Sdelphij     */
54262685Sdelphij    typedef enum {
55262685Sdelphij	dbdTIC = 0,		/* special, used by tic when writing entry */
56262685Sdelphij#if NCURSES_USE_DATABASE
57262685Sdelphij	dbdEnvOnce,		/* the $TERMINFO environment variable */
58262685Sdelphij	dbdHome,		/* $HOME/.terminfo */
59262685Sdelphij	dbdEnvList,		/* the $TERMINFO_DIRS environment variable */
60262685Sdelphij	dbdCfgList,		/* the compiled-in TERMINFO_DIRS value */
61262685Sdelphij	dbdCfgOnce,		/* the compiled-in TERMINFO value */
62262685Sdelphij#endif
63262685Sdelphij#if NCURSES_USE_TERMCAP
64262685Sdelphij	dbdEnvOnce2,		/* the $TERMCAP environment variable */
65262685Sdelphij	dbdEnvList2,		/* the $TERMPATH environment variable */
66262685Sdelphij	dbdCfgList2,		/* the compiled-in TERMPATH */
67262685Sdelphij#endif
68262685Sdelphij	dbdLAST
69262685Sdelphij    } DBDIRS;
70262685Sdelphij
7150276Speter#define MAX_USES	32
7262449Speter#define MAX_CROSSLINKS	16
7350276Speter
74262685Sdelphij    typedef struct entry {
75262685Sdelphij	TERMTYPE tterm;
76262685Sdelphij	unsigned nuses;
77262685Sdelphij	struct {
78262685Sdelphij	    char *name;
79262685Sdelphij	    struct entry *link;
80262685Sdelphij	    long line;
81262685Sdelphij	} uses[MAX_USES];
82262685Sdelphij	int ncrosslinks;
83262685Sdelphij	struct entry *crosslinks[MAX_CROSSLINKS];
84262685Sdelphij	long cstart, cend;
85262685Sdelphij	long startline;
86262685Sdelphij	struct entry *next;
87262685Sdelphij	struct entry *last;
88262685Sdelphij    } ENTRY;
89262685Sdelphij/* *INDENT-OFF* */
9050276Speter#if NCURSES_XNAMES
9150276Speter#define NUM_BOOLEANS(tp) (tp)->num_Booleans
9250276Speter#define NUM_NUMBERS(tp)  (tp)->num_Numbers
9350276Speter#define NUM_STRINGS(tp)  (tp)->num_Strings
9450276Speter#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
9550276Speter#else
9650276Speter#define NUM_BOOLEANS(tp) BOOLCOUNT
9750276Speter#define NUM_NUMBERS(tp)  NUMCOUNT
9850276Speter#define NUM_STRINGS(tp)  STRCOUNT
9950276Speter#define EXT_NAMES(tp,i,limit,index,table) table[i]
10050276Speter#endif
10150276Speter
102262629Sdelphij#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
10350276Speter
10450276Speter#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
10550276Speter#define for_each_number(n,tp)  for(n = 0; n < NUM_NUMBERS(tp);  n++)
10650276Speter#define for_each_string(n,tp)  for(n = 0; n < NUM_STRINGS(tp);  n++)
10750276Speter
108262629Sdelphij#if NCURSES_XNAMES
109262629Sdelphij#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; n < NUM_BOOLEANS(tp); n++)
110262629Sdelphij#define for_each_ext_number(n,tp)  for(n = NUMCOUNT; n < NUM_NUMBERS(tp);  n++)
111262629Sdelphij#define for_each_ext_string(n,tp)  for(n = STRCOUNT; n < NUM_STRINGS(tp);  n++)
112262629Sdelphij#endif
113262629Sdelphij
11450276Speter#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
11550276Speter#define ExtNumname(tp,i,names)  EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
11650276Speter#define ExtStrname(tp,i,names)  EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
11750276Speter
11876726Speterextern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
11976726Speterextern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
12050276Speter#define for_entry_list(qp)	for (qp = _nc_head; qp; qp = qp->next)
12150276Speter
12250276Speter#define MAX_LINE	132
12350276Speter
12450276Speter#define NULLHOOK        (bool(*)(ENTRY *))0
12550276Speter
12650276Speter/*
12750276Speter * Note that WANTED and PRESENT are not simple inverses!  If a capability
12850276Speter * has been explicitly cancelled, it's not considered WANTED.
12950276Speter */
13050276Speter#define WANTED(s)	((s) == ABSENT_STRING)
13150276Speter#define PRESENT(s)	(((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
13250276Speter
13350276Speter#define ANDMISSING(p,q) \
13450276Speter		{if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
13550276Speter
13650276Speter#define PAIRED(p,q) \
13750276Speter		{ \
13850276Speter		if (PRESENT(q) && !PRESENT(p)) \
13950276Speter			_nc_warning(#q " but no " #p); \
14050276Speter		if (PRESENT(p) && !PRESENT(q)) \
14150276Speter			_nc_warning(#p " but no " #q); \
14250276Speter		}
14350276Speter
14450276Speter/* alloc_entry.c: elementary allocation code */
14576726Speterextern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
14676726Speterextern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
14776726Speterextern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
14876726Speterextern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
14976726Speterextern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
15050276Speter
15150276Speter/* alloc_ttype.c: elementary allocation code */
15276726Speterextern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
153262685Sdelphijextern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *);
15450276Speter
15550276Speter/* free_ttype.c: elementary allocation code */
15676726Speterextern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
15750276Speter
15850276Speter/* lib_acs.c */
15976726Speterextern NCURSES_EXPORT(void) _nc_init_acs (void);	/* corresponds to traditional 'init_acs()' */
16050276Speter
161166124Srafan/* lib_termcap.c: trim sgr0 string for termcap users */
162166124Srafanextern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
163166124Srafan
16450276Speter/* parse_entry.c: entry-parsing code */
16550276Speter#if NCURSES_XNAMES
16676726Speterextern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
16776726Speterextern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
16850276Speter#endif
16976726Speterextern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
17076726Speterextern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
17150276Speter
17250276Speter/* write_entry.c: writing an entry to the file system */
17376726Speterextern NCURSES_EXPORT(void) _nc_set_writedir (char *);
17476726Speterextern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
17550276Speter
17650276Speter/* comp_parse.c: entry list handling */
17776726Speterextern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
17876726Speterextern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
179166124Srafanextern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
180166124Srafanextern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
18176726Speterextern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
182166124Srafanextern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
183166124Srafanextern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
18450276Speter
18550276Speter/* trace_xnames.c */
18676726Speterextern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
187262685Sdelphij/* *INDENT-ON* */
18850276Speter
18950276Speter#ifdef __cplusplus
19050276Speter}
19150276Speter#endif
192262685Sdelphij#endif				/* NCURSES_TERM_ENTRY_H_incl */
193