Back to index

tetex-bin  3.0
term_entry.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  *     and: Thomas E. Dickey                        1998-2004               *
00033  ****************************************************************************/
00034 
00035 /* $Id: term_entry.h,v 1.33 2004/07/05 11:51:16 tom Exp $ */
00036 
00037 /*
00038  *     term_entry.h -- interface to entry-manipulation code
00039  */
00040 
00041 #ifndef NCURSES_TERM_ENTRY_H_incl
00042 #define NCURSES_TERM_ENTRY_H_incl 1
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 #include <term.h>
00049 
00050 #define MAX_USES     32
00051 #define MAX_CROSSLINKS      16
00052 
00053 typedef struct entry {
00054        TERMTYPE      tterm;
00055        int           nuses;
00056        struct
00057         {
00058            char             *name;
00059            struct entry     *link;
00060            long             line;
00061         }
00062        uses[MAX_USES];
00063        int           ncrosslinks;
00064        struct entry  *crosslinks[MAX_CROSSLINKS];
00065        long          cstart, cend;
00066        long          startline;
00067        struct entry  *next;
00068        struct entry  *last;
00069 }
00070 ENTRY;
00071 
00072 #if NCURSES_XNAMES
00073 #define NUM_BOOLEANS(tp) (tp)->num_Booleans
00074 #define NUM_NUMBERS(tp)  (tp)->num_Numbers
00075 #define NUM_STRINGS(tp)  (tp)->num_Strings
00076 #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
00077 #else
00078 #define NUM_BOOLEANS(tp) BOOLCOUNT
00079 #define NUM_NUMBERS(tp)  NUMCOUNT
00080 #define NUM_STRINGS(tp)  STRCOUNT
00081 #define EXT_NAMES(tp,i,limit,index,table) table[i]
00082 #endif
00083 
00084 #define NUM_EXT_NAMES(tp) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
00085 
00086 #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
00087 #define for_each_number(n,tp)  for(n = 0; n < NUM_NUMBERS(tp);  n++)
00088 #define for_each_string(n,tp)  for(n = 0; n < NUM_STRINGS(tp);  n++)
00089 
00090 #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
00091 #define ExtNumname(tp,i,names)  EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
00092 #define ExtStrname(tp,i,names)  EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
00093 
00094 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
00095 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
00096 #define for_entry_list(qp)  for (qp = _nc_head; qp; qp = qp->next)
00097 
00098 #define MAX_LINE     132
00099 
00100 #define NULLHOOK        (bool(*)(ENTRY *))0
00101 
00102 /*
00103  * Note that WANTED and PRESENT are not simple inverses!  If a capability
00104  * has been explicitly cancelled, it's not considered WANTED.
00105  */
00106 #define WANTED(s)    ((s) == ABSENT_STRING)
00107 #define PRESENT(s)   (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
00108 
00109 #define ANDMISSING(p,q) \
00110               {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
00111 
00112 #define PAIRED(p,q) \
00113               { \
00114               if (PRESENT(q) && !PRESENT(p)) \
00115                      _nc_warning(#q " but no " #p); \
00116               if (PRESENT(p) && !PRESENT(q)) \
00117                      _nc_warning(#p " but no " #q); \
00118               }
00119 
00120 /* alloc_entry.c: elementary allocation code */
00121 extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
00122 extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
00123 extern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
00124 extern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
00125 extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
00126 
00127 /* alloc_ttype.c: elementary allocation code */
00128 extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
00129 extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, TERMTYPE *);
00130 
00131 /* free_ttype.c: elementary allocation code */
00132 extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
00133 
00134 /* lib_acs.c */
00135 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
00136 
00137 /* parse_entry.c: entry-parsing code */
00138 #if NCURSES_XNAMES
00139 extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
00140 extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
00141 #endif
00142 extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
00143 extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
00144 
00145 /* write_entry.c: writing an entry to the file system */
00146 extern NCURSES_EXPORT(void) _nc_set_writedir (char *);
00147 extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
00148 
00149 /* comp_parse.c: entry list handling */
00150 extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
00151 extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
00152 extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
00153 extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
00154 extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
00155 extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
00156 extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
00157 
00158 /* trace_xnames.c */
00159 extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
00160 
00161 #ifdef __cplusplus
00162 }
00163 #endif
00164 
00165 #endif /* NCURSES_TERM_ENTRY_H_incl */