term_entry.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /****************************************************************************
  2. * Copyright (c) 1998-2005,2008 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.35 2008/08/16 16:16:03 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. #define MAX_USES 32
  44. #define MAX_CROSSLINKS 16
  45. typedef struct entry {
  46. TERMTYPE tterm;
  47. unsigned nuses;
  48. struct
  49. {
  50. char *name;
  51. struct entry *link;
  52. long line;
  53. }
  54. uses[MAX_USES];
  55. int ncrosslinks;
  56. struct entry *crosslinks[MAX_CROSSLINKS];
  57. long cstart, cend;
  58. long startline;
  59. struct entry *next;
  60. struct entry *last;
  61. }
  62. ENTRY;
  63. #if NCURSES_XNAMES
  64. #define NUM_BOOLEANS(tp) (tp)->num_Booleans
  65. #define NUM_NUMBERS(tp) (tp)->num_Numbers
  66. #define NUM_STRINGS(tp) (tp)->num_Strings
  67. #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
  68. #else
  69. #define NUM_BOOLEANS(tp) BOOLCOUNT
  70. #define NUM_NUMBERS(tp) NUMCOUNT
  71. #define NUM_STRINGS(tp) STRCOUNT
  72. #define EXT_NAMES(tp,i,limit,index,table) table[i]
  73. #endif
  74. #define NUM_EXT_NAMES(tp) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
  75. #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
  76. #define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
  77. #define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
  78. #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
  79. #define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
  80. #define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
  81. extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
  82. extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
  83. #define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
  84. #define MAX_LINE 132
  85. #define NULLHOOK (bool(*)(ENTRY *))0
  86. /*
  87. * Note that WANTED and PRESENT are not simple inverses! If a capability
  88. * has been explicitly cancelled, it's not considered WANTED.
  89. */
  90. #define WANTED(s) ((s) == ABSENT_STRING)
  91. #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
  92. #define ANDMISSING(p,q) \
  93. {if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
  94. #define PAIRED(p,q) \
  95. { \
  96. if (PRESENT(q) && !PRESENT(p)) \
  97. _nc_warning(#q " but no " #p); \
  98. if (PRESENT(p) && !PRESENT(q)) \
  99. _nc_warning(#p " but no " #q); \
  100. }
  101. /* alloc_entry.c: elementary allocation code */
  102. extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
  103. extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
  104. extern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
  105. extern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
  106. extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
  107. /* alloc_ttype.c: elementary allocation code */
  108. extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
  109. extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, TERMTYPE *);
  110. /* free_ttype.c: elementary allocation code */
  111. extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
  112. /* lib_acs.c */
  113. extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
  114. /* lib_termcap.c: trim sgr0 string for termcap users */
  115. extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
  116. /* parse_entry.c: entry-parsing code */
  117. #if NCURSES_XNAMES
  118. extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
  119. extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
  120. #endif
  121. extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
  122. extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
  123. /* write_entry.c: writing an entry to the file system */
  124. extern NCURSES_EXPORT(void) _nc_set_writedir (char *);
  125. extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
  126. /* comp_parse.c: entry list handling */
  127. extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
  128. extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
  129. extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
  130. extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
  131. extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
  132. extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
  133. extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
  134. /* trace_xnames.c */
  135. extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #endif /* NCURSES_TERM_ENTRY_H_incl */