1 /**************************************************************************** 2 * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * 3 * * 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 ****************************************************************************/ 33 34 /* $Id: term_entry.h,v 1.29 2000/03/19 02:04:15 tom Exp $ */ 35 36 /* 37 * term_entry.h -- interface to entry-manipulation code 38 */ 39 40 #ifndef _TERM_ENTRY_H 41 #define _TERM_ENTRY_H 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 #include <term.h> 48 49 #define MAX_USES 32 50 #define MAX_CROSSLINKS 16 51 52 typedef struct entry { 53 TERMTYPE tterm; 54 int nuses; 55 struct 56 { 57 char *name; 58 struct entry *link; 59 long line; 60 } 61 uses[MAX_USES]; 62 int ncrosslinks; 63 struct entry *crosslinks[MAX_CROSSLINKS]; 64 long cstart, cend; 65 long startline; 66 struct entry *next; 67 struct entry *last; 68 } 69 ENTRY; 70 71 #if NCURSES_XNAMES 72 #define NUM_BOOLEANS(tp) (tp)->num_Booleans 73 #define NUM_NUMBERS(tp) (tp)->num_Numbers 74 #define NUM_STRINGS(tp) (tp)->num_Strings 75 #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i] 76 #else 77 #define NUM_BOOLEANS(tp) BOOLCOUNT 78 #define NUM_NUMBERS(tp) NUMCOUNT 79 #define NUM_STRINGS(tp) STRCOUNT 80 #define EXT_NAMES(tp,i,limit,index,table) table[i] 81 #endif 82 83 #define NUM_EXT_NAMES(tp) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings) 84 85 #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++) 86 #define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++) 87 #define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++) 88 89 #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names) 90 #define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names) 91 #define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names) 92 93 extern ENTRY *_nc_head, *_nc_tail; 94 #define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next) 95 96 #define MAX_LINE 132 97 98 #define NULLHOOK (bool(*)(ENTRY *))0 99 100 /* 101 * Note that WANTED and PRESENT are not simple inverses! If a capability 102 * has been explicitly cancelled, it's not considered WANTED. 103 */ 104 #define WANTED(s) ((s) == ABSENT_STRING) 105 #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) 106 107 #define ANDMISSING(p,q) \ 108 {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);} 109 110 #define PAIRED(p,q) \ 111 { \ 112 if (PRESENT(q) && !PRESENT(p)) \ 113 _nc_warning(#q " but no " #p); \ 114 if (PRESENT(p) && !PRESENT(q)) \ 115 _nc_warning(#p " but no " #q); \ 116 } 117 118 /* alloc_entry.c: elementary allocation code */ 119 extern ENTRY *_nc_copy_entry(ENTRY *oldp); 120 extern char *_nc_save_str(const char *const); 121 extern void _nc_init_entry(TERMTYPE *const); 122 extern void _nc_merge_entry(TERMTYPE *const, TERMTYPE *const); 123 extern void _nc_wrap_entry(ENTRY *const); 124 125 /* alloc_ttype.c: elementary allocation code */ 126 extern void _nc_align_termtype(TERMTYPE *, TERMTYPE *); 127 extern void _nc_copy_termtype(TERMTYPE *, TERMTYPE *); 128 129 /* free_ttype.c: elementary allocation code */ 130 extern void _nc_free_termtype(TERMTYPE *); 131 132 /* lib_acs.c */ 133 extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */ 134 135 /* parse_entry.c: entry-parsing code */ 136 #if NCURSES_XNAMES 137 extern bool _nc_user_definable; 138 extern bool _nc_disable_period; 139 #endif 140 extern int _nc_parse_entry(ENTRY *, int, bool); 141 extern int _nc_capcmp(const char *, const char *); 142 143 /* write_entry.c: writing an entry to the file system */ 144 extern void _nc_set_writedir(char *); 145 extern void _nc_write_entry(TERMTYPE *const); 146 147 /* comp_parse.c: entry list handling */ 148 extern void _nc_read_entry_source(FILE*, char*, int, bool, bool (*)(ENTRY*)); 149 extern bool _nc_entry_match(char *, char *); 150 extern int _nc_resolve_uses(bool); 151 extern void _nc_free_entries(ENTRY *); 152 extern void (*_nc_check_termtype)(TERMTYPE *); 153 154 /* trace_xnames.c */ 155 extern void _nc_trace_xnames(TERMTYPE *); 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* _TERM_ENTRY_H */ 162