term_entry.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /****************************************************************************
  2. * Copyright (c) 1998-2014,2015 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. * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
  30. * and: Eric S. Raymond <esr@snark.thyrsus.com> *
  31. * and: Thomas E. Dickey 1998-on *
  32. ****************************************************************************/
  33. /* $Id: term_entry.h,v 1.47 2015/08/30 00:41:20 tom Exp $ */
  34. /*
  35. * term_entry.h -- interface to entry-manipulation code
  36. */
  37. #ifndef NCURSES_TERM_ENTRY_H_incl
  38. #define NCURSES_TERM_ENTRY_H_incl 1
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. #include <term.h>
  43. /*
  44. * see db_iterator.c - this enumeration lists the places searched for a
  45. * terminal description and defines the order in which they are searched.
  46. */
  47. typedef enum {
  48. dbdTIC = 0, /* special, used by tic when writing entry */
  49. #if NCURSES_USE_DATABASE
  50. dbdEnvOnce, /* the $TERMINFO environment variable */
  51. dbdHome, /* $HOME/.terminfo */
  52. dbdEnvList, /* the $TERMINFO_DIRS environment variable */
  53. dbdCfgList, /* the compiled-in TERMINFO_DIRS value */
  54. dbdCfgOnce, /* the compiled-in TERMINFO value */
  55. #endif
  56. #if NCURSES_USE_TERMCAP
  57. dbdEnvOnce2, /* the $TERMCAP environment variable */
  58. dbdEnvList2, /* the $TERMPATH environment variable */
  59. dbdCfgList2, /* the compiled-in TERMPATH */
  60. #endif
  61. dbdLAST
  62. } DBDIRS;
  63. #define MAX_USES 32
  64. #define MAX_CROSSLINKS 16
  65. typedef struct entry {
  66. TERMTYPE tterm;
  67. unsigned nuses;
  68. struct {
  69. char *name;
  70. struct entry *link;
  71. long line;
  72. } uses[MAX_USES];
  73. int ncrosslinks;
  74. struct entry *crosslinks[MAX_CROSSLINKS];
  75. long cstart, cend;
  76. long startline;
  77. struct entry *next;
  78. struct entry *last;
  79. } ENTRY;
  80. /* *INDENT-OFF* */
  81. #if NCURSES_XNAMES
  82. #define NUM_BOOLEANS(tp) (tp)->num_Booleans
  83. #define NUM_NUMBERS(tp) (tp)->num_Numbers
  84. #define NUM_STRINGS(tp) (tp)->num_Strings
  85. #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
  86. #else
  87. #define NUM_BOOLEANS(tp) BOOLCOUNT
  88. #define NUM_NUMBERS(tp) NUMCOUNT
  89. #define NUM_STRINGS(tp) STRCOUNT
  90. #define EXT_NAMES(tp,i,limit,index,table) table[i]
  91. #endif
  92. #define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
  93. #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
  94. #define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
  95. #define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
  96. #if NCURSES_XNAMES
  97. #define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
  98. #define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++)
  99. #define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++)
  100. #endif
  101. #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
  102. #define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
  103. #define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
  104. extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
  105. extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
  106. #define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
  107. #define MAX_LINE 132
  108. #define NULLHOOK (bool(*)(ENTRY *))0
  109. /*
  110. * Note that WANTED and PRESENT are not simple inverses! If a capability
  111. * has been explicitly cancelled, it's not considered WANTED.
  112. */
  113. #define WANTED(s) ((s) == ABSENT_STRING)
  114. #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
  115. #define ANDMISSING(p,q) \
  116. {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
  117. #define PAIRED(p,q) \
  118. { \
  119. if (PRESENT(q) && !PRESENT(p)) \
  120. _nc_warning(#q " but no " #p); \
  121. if (PRESENT(p) && !PRESENT(q)) \
  122. _nc_warning(#p " but no " #q); \
  123. }
  124. /* alloc_entry.c: elementary allocation code */
  125. extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
  126. extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
  127. extern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
  128. extern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
  129. extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
  130. /* alloc_ttype.c: elementary allocation code */
  131. extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
  132. extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *);
  133. /* free_ttype.c: elementary allocation code */
  134. extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
  135. /* lib_acs.c */
  136. extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
  137. /* lib_termcap.c: trim sgr0 string for termcap users */
  138. extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
  139. /* parse_entry.c: entry-parsing code */
  140. #if NCURSES_XNAMES
  141. extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
  142. extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
  143. #endif
  144. extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
  145. extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
  146. /* write_entry.c: writing an entry to the file system */
  147. extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
  148. extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
  149. extern NCURSES_EXPORT(int) _nc_write_object(TERMTYPE *, char *, unsigned *, unsigned);
  150. /* comp_parse.c: entry list handling */
  151. extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
  152. extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
  153. extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
  154. extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
  155. extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
  156. extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
  157. extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
  158. /* trace_xnames.c */
  159. extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
  160. /* *INDENT-ON* */
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. #endif /* NCURSES_TERM_ENTRY_H_incl */