blob: b12710d3d083d7f9885792488978c71b49e9a264 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002 * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29/****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1998-on *
33 ****************************************************************************/
34
Steve Kondikae271bc2015-11-15 02:50:53 +010035/* $Id: term_entry.h,v 1.45 2014/11/01 14:47:00 tom Exp $ */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053036
37/*
38 * term_entry.h -- interface to entry-manipulation code
39 */
40
41#ifndef NCURSES_TERM_ENTRY_H_incl
42#define NCURSES_TERM_ENTRY_H_incl 1
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#include <term.h>
49
Steve Kondikae271bc2015-11-15 02:50:53 +010050 /*
51 * see db_iterator.c - this enumeration lists the places searched for a
52 * terminal description and defines the order in which they are searched.
53 */
54 typedef enum {
55 dbdTIC = 0, /* special, used by tic when writing entry */
56#if NCURSES_USE_DATABASE
57 dbdEnvOnce, /* the $TERMINFO environment variable */
58 dbdHome, /* $HOME/.terminfo */
59 dbdEnvList, /* the $TERMINFO_DIRS environment variable */
60 dbdCfgList, /* the compiled-in TERMINFO_DIRS value */
61 dbdCfgOnce, /* the compiled-in TERMINFO value */
62#endif
63#if NCURSES_USE_TERMCAP
64 dbdEnvOnce2, /* the $TERMCAP environment variable */
65 dbdEnvList2, /* the $TERMPATH environment variable */
66 dbdCfgList2, /* the compiled-in TERMPATH */
67#endif
68 dbdLAST
69 } DBDIRS;
70
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053071#define MAX_USES 32
72#define MAX_CROSSLINKS 16
73
Steve Kondikae271bc2015-11-15 02:50:53 +010074 typedef struct entry {
75 TERMTYPE tterm;
76 unsigned nuses;
77 struct {
78 char *name;
79 struct entry *link;
80 long line;
81 } uses[MAX_USES];
82 int ncrosslinks;
83 struct entry *crosslinks[MAX_CROSSLINKS];
84 long cstart, cend;
85 long startline;
86 struct entry *next;
87 struct entry *last;
88 } ENTRY;
89/* *INDENT-OFF* */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053090#if NCURSES_XNAMES
91#define NUM_BOOLEANS(tp) (tp)->num_Booleans
92#define NUM_NUMBERS(tp) (tp)->num_Numbers
93#define NUM_STRINGS(tp) (tp)->num_Strings
94#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
95#else
96#define NUM_BOOLEANS(tp) BOOLCOUNT
97#define NUM_NUMBERS(tp) NUMCOUNT
98#define NUM_STRINGS(tp) STRCOUNT
99#define EXT_NAMES(tp,i,limit,index,table) table[i]
100#endif
101
Steve Kondikae271bc2015-11-15 02:50:53 +0100102#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530103
104#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
105#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
106#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
107
Steve Kondikae271bc2015-11-15 02:50:53 +0100108#if NCURSES_XNAMES
109#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; n < NUM_BOOLEANS(tp); n++)
110#define for_each_ext_number(n,tp) for(n = NUMCOUNT; n < NUM_NUMBERS(tp); n++)
111#define for_each_ext_string(n,tp) for(n = STRCOUNT; n < NUM_STRINGS(tp); n++)
112#endif
113
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530114#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
115#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
116#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
117
118extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
119extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
120#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
121
122#define MAX_LINE 132
123
124#define NULLHOOK (bool(*)(ENTRY *))0
125
126/*
127 * Note that WANTED and PRESENT are not simple inverses! If a capability
128 * has been explicitly cancelled, it's not considered WANTED.
129 */
130#define WANTED(s) ((s) == ABSENT_STRING)
131#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
132
133#define ANDMISSING(p,q) \
134 {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
135
136#define PAIRED(p,q) \
137 { \
138 if (PRESENT(q) && !PRESENT(p)) \
139 _nc_warning(#q " but no " #p); \
140 if (PRESENT(p) && !PRESENT(q)) \
141 _nc_warning(#p " but no " #q); \
142 }
143
144/* alloc_entry.c: elementary allocation code */
145extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
146extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
147extern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
148extern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
149extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
150
151/* alloc_ttype.c: elementary allocation code */
152extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
Steve Kondikae271bc2015-11-15 02:50:53 +0100153extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530154
155/* free_ttype.c: elementary allocation code */
156extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
157
158/* lib_acs.c */
159extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
160
161/* lib_termcap.c: trim sgr0 string for termcap users */
162extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
163
164/* parse_entry.c: entry-parsing code */
165#if NCURSES_XNAMES
166extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
167extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
168#endif
169extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
170extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
171
172/* write_entry.c: writing an entry to the file system */
Steve Kondikae271bc2015-11-15 02:50:53 +0100173extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530174extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
175
176/* comp_parse.c: entry list handling */
177extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
178extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
179extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
180extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
181extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
182extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
183extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
184
185/* trace_xnames.c */
186extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
Steve Kondikae271bc2015-11-15 02:50:53 +0100187/* *INDENT-ON* */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530188
189#ifdef __cplusplus
190}
191#endif
Steve Kondikae271bc2015-11-15 02:50:53 +0100192#endif /* NCURSES_TERM_ENTRY_H_incl */