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