ttyio.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. ttyio.h - Zip 3
  3. Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
  4. See the accompanying file LICENSE, version 2005-Feb-10 or later
  5. (the contents of which are also included in zip.h) for terms of use.
  6. If, for some reason, all these files are missing, the Info-ZIP license
  7. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  8. */
  9. /*
  10. ttyio.h
  11. */
  12. #ifndef __ttyio_h /* don't include more than once */
  13. #define __ttyio_h
  14. #ifndef __crypt_h
  15. # include "crypt.h" /* ensure that encryption header file has been seen */
  16. #endif
  17. #if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
  18. /*
  19. * Non-echo keyboard/console input support is needed and enabled.
  20. */
  21. #ifndef __G /* UnZip only, for now (DLL stuff) */
  22. # define __G
  23. # define __G__
  24. # define __GDEF
  25. # define __GPRO void
  26. # define __GPRO__
  27. #endif
  28. #ifndef ZCONST /* UnZip only (until have configure script like Zip) */
  29. # define ZCONST const
  30. #endif
  31. #if (defined(MSDOS) || defined(OS2) || defined(WIN32))
  32. # ifndef DOS_OS2_W32
  33. # define DOS_OS2_W32
  34. # endif
  35. #endif
  36. #if (defined(DOS_OS2_W32) || defined(__human68k__))
  37. # ifndef DOS_H68_OS2_W32
  38. # define DOS_H68_OS2_W32
  39. # endif
  40. #endif
  41. #if (defined(DOS_OS2_W32) || defined(FLEXOS))
  42. # ifndef DOS_FLX_OS2_W32
  43. # define DOS_FLX_OS2_W32
  44. # endif
  45. #endif
  46. #if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
  47. # ifndef DOS_FLX_H68_OS2_W32
  48. # define DOS_FLX_H68_OS2_W32
  49. # endif
  50. #endif
  51. #if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX))
  52. # ifndef ATH_BEO_UNX
  53. # define ATH_BEO_UNX
  54. # endif
  55. #endif
  56. #if (defined(VM_CMS) || defined(MVS))
  57. # ifndef CMS_MVS
  58. # define CMS_MVS
  59. # endif
  60. #endif
  61. /* Function prototypes */
  62. /* The following systems supply a `non-echo' character input function "getch()"
  63. * (or an alias) and do not need the echoff() / echon() function pair.
  64. */
  65. #ifdef AMIGA
  66. # define echoff(f)
  67. # define echon()
  68. # define getch() Agetch()
  69. # define HAVE_WORKING_GETCH
  70. #endif /* AMIGA */
  71. #ifdef ATARI
  72. # define echoff(f)
  73. # define echon()
  74. # include <osbind.h>
  75. # define getch() (Cnecin() & 0x000000ff)
  76. # define HAVE_WORKING_GETCH
  77. #endif
  78. #ifdef MACOS
  79. # define echoff(f)
  80. # define echon()
  81. # define getch() macgetch()
  82. # define HAVE_WORKING_GETCH
  83. #endif
  84. #ifdef NLM
  85. # define echoff(f)
  86. # define echon()
  87. # define HAVE_WORKING_GETCH
  88. #endif
  89. #ifdef QDOS
  90. # define echoff(f)
  91. # define echon()
  92. # define HAVE_WORKING_GETCH
  93. #endif
  94. #ifdef RISCOS
  95. # define echoff(f)
  96. # define echon()
  97. # define getch() SWI_OS_ReadC()
  98. # define HAVE_WORKING_GETCH
  99. #endif
  100. #ifdef DOS_H68_OS2_W32
  101. # define echoff(f)
  102. # define echon()
  103. # ifdef WIN32
  104. # ifndef getch
  105. # define getch() getch_win32()
  106. # endif
  107. # else /* !WIN32 */
  108. # ifdef __EMX__
  109. # ifndef getch
  110. # define getch() _read_kbd(0, 1, 0)
  111. # endif
  112. # else /* !__EMX__ */
  113. # ifdef __GO32__
  114. # include <pc.h>
  115. # define getch() getkey()
  116. # else /* !__GO32__ */
  117. # include <conio.h>
  118. # endif /* ?__GO32__ */
  119. # endif /* ?__EMX__ */
  120. # endif /* ?WIN32 */
  121. # define HAVE_WORKING_GETCH
  122. #endif /* DOS_H68_OS2_W32 */
  123. #ifdef FLEXOS
  124. # define echoff(f)
  125. # define echon()
  126. # define getch() getchar() /* not correct, but may not be on a console */
  127. # define HAVE_WORKING_GETCH
  128. #endif
  129. /* For VM/CMS and MVS, we do not (yet) have any support to switch terminal
  130. * input echo on and off. The following "fake" definitions allow inclusion
  131. * of crypt support and UnZip's "pause prompting" features, but without
  132. * any echo suppression.
  133. */
  134. #ifdef CMS_MVS
  135. # define echoff(f)
  136. # define echon()
  137. #endif
  138. #ifdef TANDEM
  139. # define echoff(f)
  140. # define echon()
  141. # define getch() zgetch() /* defined in TANDEMC */
  142. # define HAVE_WORKING_GETCH
  143. #endif
  144. /* The THEOS C runtime library supplies the function conmask() to toggle
  145. * terminal input echo on (conmask("e")) and off (conmask("n")). But,
  146. * since THEOS C RTL also contains a working non-echo getch() function,
  147. * the echo toggles are not needed.
  148. */
  149. #ifdef THEOS
  150. # define echoff(f)
  151. # define echon()
  152. # define HAVE_WORKING_GETCH
  153. #endif
  154. /* VMS has a single echo() function in ttyio.c to toggle terminal
  155. * input echo on and off.
  156. */
  157. #ifdef VMS
  158. # define echoff(f) echo(0)
  159. # define echon() echo(1)
  160. # define getch() tt_getch()
  161. # define FGETCH(f) tt_getch()
  162. int echo OF((int));
  163. int tt_getch OF((void));
  164. #endif
  165. /* For all other systems, ttyio.c supplies the two functions Echoff() and
  166. * Echon() for suppressing and (re)enabling console input echo.
  167. */
  168. #ifndef echoff
  169. # define echoff(f) Echoff(__G__ f)
  170. # define echon() Echon(__G)
  171. void Echoff OF((__GPRO__ int f));
  172. void Echon OF((__GPRO));
  173. #endif
  174. /* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
  175. #if (defined(UNZIP) && !defined(FUNZIP))
  176. # ifdef HAVE_WORKING_GETCH
  177. # define FGETCH(f) getch()
  178. # endif
  179. # ifndef FGETCH
  180. /* default for all systems where no getch()-like function is available */
  181. int zgetch OF((__GPRO__ int f));
  182. # define FGETCH(f) zgetch(__G__ f)
  183. # endif
  184. #endif /* UNZIP && !FUNZIP */
  185. #if (CRYPT && !defined(WINDLL))
  186. char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
  187. #endif
  188. #else /* !(CRYPT || (UNZIP && !FUNZIP)) */
  189. /*
  190. * No need for non-echo keyboard/console input; provide dummy definitions.
  191. */
  192. #define echoff(f)
  193. #define echon()
  194. #endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
  195. #endif /* !__ttyio_h */