MKterm.h.awk.in 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. # vile:awkmode
  2. BEGIN {
  3. print "/****************************************************************************"
  4. print " * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *"
  5. print " * *"
  6. print " * Permission is hereby granted, free of charge, to any person obtaining a *"
  7. print " * copy of this software and associated documentation files (the *"
  8. print " * \"Software\"), to deal in the Software without restriction, including *"
  9. print " * without limitation the rights to use, copy, modify, merge, publish, *"
  10. print " * distribute, distribute with modifications, sublicense, and/or sell *"
  11. print " * copies of the Software, and to permit persons to whom the Software is *"
  12. print " * furnished to do so, subject to the following conditions: *"
  13. print " * *"
  14. print " * The above copyright notice and this permission notice shall be included *"
  15. print " * in all copies or substantial portions of the Software. *"
  16. print " * *"
  17. print " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS *"
  18. print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *"
  19. print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *"
  20. print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *"
  21. print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *"
  22. print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *"
  23. print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *"
  24. print " * *"
  25. print " * Except as contained in this notice, the name(s) of the above copyright *"
  26. print " * holders shall not be used in advertising or otherwise to promote the *"
  27. print " * sale, use or other dealings in this Software without prior written *"
  28. print " * authorization. *"
  29. print " ****************************************************************************/"
  30. print ""
  31. print "/****************************************************************************/"
  32. print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */"
  33. print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */"
  34. print "/* and: Thomas E. Dickey 1995-on */"
  35. print "/****************************************************************************/"
  36. print ""
  37. print "/* $Id: MKterm.h.awk.in,v 1.50 2008/05/24 23:13:59 tom Exp $ */"
  38. print ""
  39. print "/*"
  40. print "** term.h -- Definition of struct term"
  41. print "*/"
  42. print ""
  43. print "#ifndef NCURSES_TERM_H_incl"
  44. print "#define NCURSES_TERM_H_incl 1"
  45. print ""
  46. print "#undef NCURSES_VERSION"
  47. print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
  48. print ""
  49. print "#include <ncurses_dll.h>"
  50. print ""
  51. print "#ifdef __cplusplus"
  52. print "extern \"C\" {"
  53. print "#endif"
  54. print ""
  55. print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
  56. print " * definition (based on the system for which this was configured)."
  57. print " */"
  58. print ""
  59. print "#undef NCURSES_CONST"
  60. print "#define NCURSES_CONST @NCURSES_CONST@"
  61. print ""
  62. print "#undef NCURSES_SBOOL"
  63. print "#define NCURSES_SBOOL @NCURSES_SBOOL@"
  64. print ""
  65. print "#undef NCURSES_XNAMES"
  66. print "#define NCURSES_XNAMES @NCURSES_XNAMES@"
  67. print ""
  68. print "/* We will use these symbols to hide differences between"
  69. print " * termios/termio/sgttyb interfaces."
  70. print " */"
  71. print "#undef TTY"
  72. print "#undef SET_TTY"
  73. print "#undef GET_TTY"
  74. print ""
  75. print "/* Assume POSIX termio if we have the header and function */"
  76. print "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
  77. print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
  78. print ""
  79. print "#undef TERMIOS"
  80. print "#define TERMIOS 1"
  81. print ""
  82. print "#include <termios.h>"
  83. print "#define TTY struct termios"
  84. print ""
  85. print "#else /* !HAVE_TERMIOS_H */"
  86. print ""
  87. print "/* #if HAVE_TERMIO_H */"
  88. print "#if @HAVE_TERMIO_H@"
  89. print ""
  90. print "#undef TERMIOS"
  91. print "#define TERMIOS 1"
  92. print ""
  93. print "#include <termio.h>"
  94. print "#define TTY struct termio"
  95. print ""
  96. print "/* Add definitions to make termio look like termios."
  97. print " * But ifdef it, since there are some implementations"
  98. print " * that try to do this for us in a fake <termio.h>."
  99. print " */"
  100. print "#ifndef TCSANOW"
  101. print "#define TCSANOW TCSETA"
  102. print "#endif"
  103. print "#ifndef TCSADRAIN"
  104. print "#define TCSADRAIN TCSETAW"
  105. print "#endif"
  106. print "#ifndef TCSAFLUSH"
  107. print "#define TCSAFLUSH TCSETAF"
  108. print "#endif"
  109. print "#ifndef tcsetattr"
  110. print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
  111. print "#endif"
  112. print "#ifndef tcgetattr"
  113. print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
  114. print "#endif"
  115. print "#ifndef cfgetospeed"
  116. print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
  117. print "#endif"
  118. print "#ifndef TCIFLUSH "
  119. print "#define TCIFLUSH 0"
  120. print "#endif"
  121. print "#ifndef TCOFLUSH "
  122. print "#define TCOFLUSH 1"
  123. print "#endif"
  124. print "#ifndef TCIOFLUSH "
  125. print "#define TCIOFLUSH 2"
  126. print "#endif"
  127. print "#ifndef tcflush"
  128. print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
  129. print "#endif"
  130. print ""
  131. print "#else /* !HAVE_TERMIO_H */"
  132. print ""
  133. print "#undef TERMIOS"
  134. print "#include <sgtty.h>"
  135. print "#include <sys/ioctl.h>"
  136. print "#define TTY struct sgttyb"
  137. print ""
  138. print "#endif /* HAVE_TERMIO_H */"
  139. print ""
  140. print "#endif /* HAVE_TERMIOS_H */"
  141. print ""
  142. print "#ifdef TERMIOS"
  143. print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
  144. print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
  145. print "#else"
  146. print "#define GET_TTY(fd, buf) gtty(fd, buf)"
  147. print "#define SET_TTY(fd, buf) stty(fd, buf)"
  148. print "#endif"
  149. print ""
  150. print "#define NAMESIZE 256"
  151. print ""
  152. print "#define CUR cur_term->type."
  153. print ""
  154. }
  155. $2 == "%%-STOP-HERE-%%" {
  156. print ""
  157. printf "#define BOOLWRITE %d\n", BoolCount
  158. printf "#define NUMWRITE %d\n", NumberCount
  159. printf "#define STRWRITE %d\n", StringCount
  160. print ""
  161. print "/* older synonyms for some capabilities */"
  162. print "#define beehive_glitch no_esc_ctlc"
  163. print "#define teleray_glitch dest_tabs_magic_smso"
  164. print "#define micro_char_size micro_col_size"
  165. print ""
  166. print "#ifdef __INTERNAL_CAPS_VISIBLE"
  167. }
  168. /^#/ {next;}
  169. $1 == "acs_chars" {acsindex = StringCount}
  170. $3 == "bool" {
  171. printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
  172. }
  173. $3 == "num" {
  174. printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
  175. }
  176. $3 == "str" {
  177. printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
  178. }
  179. END {
  180. print "#endif /* __INTERNAL_CAPS_VISIBLE */"
  181. print ""
  182. print ""
  183. print "/*"
  184. print " * Predefined terminfo array sizes"
  185. print " */"
  186. printf "#define BOOLCOUNT %d\n", BoolCount
  187. printf "#define NUMCOUNT %d\n", NumberCount
  188. printf "#define STRCOUNT %d\n", StringCount
  189. print ""
  190. print "/* used by code for comparing entries */"
  191. print "#define acs_chars_index ", acsindex
  192. print ""
  193. print "typedef struct termtype { /* in-core form of terminfo data */"
  194. print " char *term_names; /* str_table offset of term names */"
  195. print " char *str_table; /* pointer to string table */"
  196. print " NCURSES_SBOOL *Booleans; /* array of boolean values */"
  197. print " short *Numbers; /* array of integer values */"
  198. print " char **Strings; /* array of string offsets */"
  199. print ""
  200. print "#if NCURSES_XNAMES"
  201. print " char *ext_str_table; /* pointer to extended string table */"
  202. print " char **ext_Names; /* corresponding names */"
  203. print ""
  204. print " unsigned short num_Booleans;/* count total Booleans */"
  205. print " unsigned short num_Numbers; /* count total Numbers */"
  206. print " unsigned short num_Strings; /* count total Strings */"
  207. print ""
  208. print " unsigned short ext_Booleans;/* count extensions to Booleans */"
  209. print " unsigned short ext_Numbers; /* count extensions to Numbers */"
  210. print " unsigned short ext_Strings; /* count extensions to Strings */"
  211. print "#endif /* NCURSES_XNAMES */"
  212. print ""
  213. print "} TERMTYPE;"
  214. print ""
  215. print "typedef struct term { /* describe an actual terminal */"
  216. print " TERMTYPE type; /* terminal type description */"
  217. print " short Filedes; /* file description being written to */"
  218. print " TTY Ottyb, /* original state of the terminal */"
  219. print " Nttyb; /* current state of the terminal */"
  220. print " int _baudrate; /* used to compute padding */"
  221. print " char * _termname; /* used for termname() */"
  222. print "} TERMINAL;"
  223. print ""
  224. print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
  225. print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
  226. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
  227. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
  228. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
  229. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
  230. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
  231. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
  232. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
  233. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
  234. print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
  235. print ""
  236. print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())"
  237. print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())"
  238. print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())"
  239. print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
  240. print "#define numnames NCURSES_PUBLIC_VAR(numnames())"
  241. print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())"
  242. print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())"
  243. print "#define strnames NCURSES_PUBLIC_VAR(strnames())"
  244. print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())"
  245. print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())"
  246. print ""
  247. print "#else"
  248. print ""
  249. print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
  250. print ""
  251. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
  252. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
  253. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
  254. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
  255. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
  256. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
  257. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
  258. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
  259. print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
  260. print ""
  261. print "#endif"
  262. print ""
  263. print "/* internals */"
  264. print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
  265. print "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
  266. print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
  267. print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
  268. print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
  269. print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
  270. print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
  271. print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
  272. print ""
  273. print "/* entry points */"
  274. print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
  275. print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
  276. print ""
  277. print "/* miscellaneous entry points */"
  278. print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
  279. print "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
  280. print ""
  281. print "/* terminfo entry points, also declared in curses.h */"
  282. print "#if !defined(__NCURSES_H)"
  283. print "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
  284. print "extern NCURSES_EXPORT_VAR(char) ttytype[];"
  285. print "extern NCURSES_EXPORT(int) putp (const char *);"
  286. print "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
  287. print "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
  288. print ""
  289. print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
  290. print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */"
  291. print "#else"
  292. print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */"
  293. print "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */"
  294. print "#endif"
  295. print ""
  296. print "#endif /* __NCURSES_H */"
  297. print ""
  298. print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
  299. print "#if !defined(NCURSES_TERMCAP_H_incl)"
  300. print "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
  301. print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
  302. print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
  303. print "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
  304. print "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
  305. print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
  306. print "#endif /* NCURSES_TERMCAP_H_incl */"
  307. print ""
  308. print "#ifdef __cplusplus"
  309. print "}"
  310. print "#endif"
  311. print ""
  312. print "#endif /* NCURSES_TERM_H_incl */"
  313. }