Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:23

0001 /****************************************************************************
0002  * Copyright 2018-2021,2022 Thomas E. Dickey                                *
0003  * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
0004  *                                                                          *
0005  * Permission is hereby granted, free of charge, to any person obtaining a  *
0006  * copy of this software and associated documentation files (the            *
0007  * "Software"), to deal in the Software without restriction, including      *
0008  * without limitation the rights to use, copy, modify, merge, publish,      *
0009  * distribute, distribute with modifications, sublicense, and/or sell       *
0010  * copies of the Software, and to permit persons to whom the Software is    *
0011  * furnished to do so, subject to the following conditions:                 *
0012  *                                                                          *
0013  * The above copyright notice and this permission notice shall be included  *
0014  * in all copies or substantial portions of the Software.                   *
0015  *                                                                          *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
0017  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
0018  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
0019  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
0020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
0021  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
0022  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
0023  *                                                                          *
0024  * Except as contained in this notice, the name(s) of the above copyright   *
0025  * holders shall not be used in advertising or otherwise to promote the     *
0026  * sale, use or other dealings in this Software without prior written       *
0027  * authorization.                                                           *
0028  ****************************************************************************/
0029 
0030 /****************************************************************************
0031  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
0032  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
0033  *     and: Thomas E. Dickey                        1998-on                 *
0034  ****************************************************************************/
0035 
0036 /* $Id: term_entry.h,v 1.63 2022/09/24 15:04:59 tom Exp $ */
0037 
0038 /*
0039  *  term_entry.h -- interface to entry-manipulation code
0040  */
0041 
0042 #ifndef NCURSES_TERM_ENTRY_H_incl
0043 #define NCURSES_TERM_ENTRY_H_incl 1
0044 /* *INDENT-OFF* */
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 #include <ncursesw/curses.h>
0051 #include <ncursesw/term.h>
0052 
0053 /*
0054  * These macros may be used by programs that know about TERMTYPE:
0055  */
0056 #if NCURSES_XNAMES
0057 #define NUM_BOOLEANS(tp) (tp)->num_Booleans
0058 #define NUM_NUMBERS(tp)  (tp)->num_Numbers
0059 #define NUM_STRINGS(tp)  (tp)->num_Strings
0060 #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
0061 #else
0062 #define NUM_BOOLEANS(tp) BOOLCOUNT
0063 #define NUM_NUMBERS(tp)  NUMCOUNT
0064 #define NUM_STRINGS(tp)  STRCOUNT
0065 #define EXT_NAMES(tp,i,limit,index,table) table[i]
0066 #endif
0067 
0068 #define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
0069 
0070 #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
0071 #define for_each_number(n,tp)  for(n = 0; n < NUM_NUMBERS(tp);  n++)
0072 #define for_each_string(n,tp)  for(n = 0; n < NUM_STRINGS(tp);  n++)
0073 
0074 #if NCURSES_XNAMES
0075 #define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
0076 #define for_each_ext_number(n,tp)  for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp);  n++)
0077 #define for_each_ext_string(n,tp)  for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp);  n++)
0078 #endif
0079 
0080 #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
0081 #define ExtNumname(tp,i,names)  EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
0082 #define ExtStrname(tp,i,names)  EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
0083 
0084 /*
0085  * The remaining type-definitions and macros are used only internally by the
0086  * ncurses utilities.
0087  */
0088 #ifdef NCURSES_INTERNALS
0089 
0090 /*
0091  * see db_iterator.c - this enumeration lists the places searched for a
0092  * terminal description and defines the order in which they are searched.
0093  */
0094 typedef enum {
0095     dbdTIC = 0,     /* special, used by tic when writing entry */
0096 #if NCURSES_USE_DATABASE
0097     dbdEnvOnce,     /* the $TERMINFO environment variable */
0098     dbdHome,        /* $HOME/.terminfo */
0099     dbdEnvList,     /* the $TERMINFO_DIRS environment variable */
0100     dbdCfgList,     /* the compiled-in TERMINFO_DIRS value */
0101     dbdCfgOnce,     /* the compiled-in TERMINFO value */
0102 #endif
0103 #if NCURSES_USE_TERMCAP
0104     dbdEnvOnce2,        /* the $TERMCAP environment variable */
0105     dbdEnvList2,        /* the $TERMPATH environment variable */
0106     dbdCfgList2,        /* the compiled-in TERMPATH */
0107 #endif
0108     dbdLAST
0109 } DBDIRS;
0110 
0111 #define MAX_USES    32
0112 #define MAX_CROSSLINKS  16
0113 
0114 typedef struct entry ENTRY;
0115 
0116 typedef struct {
0117     char *name;
0118     ENTRY *link;
0119     long line;
0120 } ENTRY_USES;
0121 
0122 struct entry {
0123     TERMTYPE2 tterm;
0124     unsigned nuses;
0125     ENTRY_USES uses[MAX_USES];
0126     int ncrosslinks;
0127     ENTRY *crosslinks[MAX_CROSSLINKS];
0128     long cstart;
0129     long cend;
0130     long startline;
0131     ENTRY *next;
0132     ENTRY *last;
0133 };
0134 
0135 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
0136 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
0137 #define for_entry_list(qp)  for (qp = _nc_head; qp; qp = qp->next)
0138 #define for_entry_list2(qp,q0)  for (qp = q0; qp; qp = qp->next)
0139 
0140 #define MAX_LINE    132
0141 
0142 #define NULLHOOK        (bool(*)(ENTRY *))0
0143 
0144 /*
0145  * Note that WANTED and PRESENT are not simple inverses!  If a capability
0146  * has been explicitly cancelled, it is not considered WANTED.
0147  */
0148 #define WANTED(s)   ((s) == ABSENT_STRING)
0149 #define PRESENT(s)  (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
0150 
0151 #define ANDMISSING(p,q) \
0152         { \
0153         if (PRESENT(p) && !PRESENT(q)) \
0154             _nc_warning(#p " but no " #q); \
0155         }
0156 
0157 #define PAIRED(p,q) \
0158         { \
0159         if (PRESENT(q) && !PRESENT(p)) \
0160             _nc_warning(#q " but no " #p); \
0161         if (PRESENT(p) && !PRESENT(q)) \
0162             _nc_warning(#p " but no " #q); \
0163         }
0164 
0165 /*
0166  * These entrypoints are used only by the ncurses utilities such as tic.
0167  */
0168 
0169 /* alloc_entry.c: elementary allocation code */
0170 extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
0171 extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
0172 extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const);
0173 extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const);
0174 extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
0175 
0176 /* alloc_ttype.c: elementary allocation code */
0177 extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
0178 
0179 /* free_ttype.c: elementary allocation code */
0180 extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *);
0181 extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
0182 
0183 /* lib_termcap.c: trim sgr0 string for termcap users */
0184 extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *);
0185 
0186 /* parse_entry.c: entry-parsing code */
0187 #if NCURSES_XNAMES
0188 extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
0189 extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
0190 #endif
0191 extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
0192 extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
0193 
0194 /* write_entry.c: writing an entry to the file system */
0195 extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
0196 extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const);
0197 extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned);
0198 
0199 /* comp_parse.c: entry list handling */
0200 extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
0201 extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
0202 extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
0203 extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
0204 extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
0205 extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
0206 extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool);
0207 
0208 /* trace_xnames.c */
0209 extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
0210 
0211 #endif /* NCURSES_INTERNALS */
0212 
0213 /*
0214  * These entrypoints were used by tack before 1.08.
0215  */
0216 
0217 #undef  NCURSES_TACK_1_08
0218 #ifdef  NCURSES_INTERNALS
0219 #define NCURSES_TACK_1_08 /* nothing */
0220 #else
0221 #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
0222 #endif
0223 
0224 /* alloc_ttype.c: elementary allocation code */
0225 extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08;
0226 
0227 /* lib_acs.c */
0228 extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08;  /* corresponds to traditional 'init_acs()' */
0229 
0230 /* free_ttype.c: elementary allocation code */
0231 extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08;
0232 
0233 #ifdef __cplusplus
0234 }
0235 #endif
0236 
0237 /* *INDENT-ON* */
0238 
0239 #endif /* NCURSES_TERM_ENTRY_H_incl */