home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip540.zip / ttyio.h < prev    next >
C/C++ Source or Header  |  1998-11-24  |  4KB  |  187 lines

  1. /*
  2.    ttyio.h
  3.  */
  4.  
  5. #ifndef __ttyio_h   /* don't include more than once */
  6. #define __ttyio_h
  7.  
  8. #ifndef __crypt_h
  9. #  include "crypt.h"  /* ensure that encryption header file has been seen */
  10. #endif
  11.  
  12. #if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
  13. /*
  14.  * Non-echo keyboard/console input support is needed and enabled.
  15.  */
  16.  
  17. #ifndef __G         /* UnZip only, for now (DLL stuff) */
  18. #  define __G
  19. #  define __G__
  20. #  define __GDEF
  21. #  define __GPRO    void
  22. #  define __GPRO__
  23. #endif
  24.  
  25. #ifndef ZCONST      /* UnZip only (until have configure script like Zip) */
  26. #  define ZCONST const
  27. #endif
  28.  
  29. #if (defined(MSDOS) || defined(OS2) || defined(WIN32))
  30. #  ifndef DOS_OS2_W32
  31. #    define DOS_OS2_W32
  32. #  endif
  33. #endif
  34.  
  35. #if (defined(DOS_OS2_W32) || defined(__human68k__))
  36. #  ifndef DOS_H68_OS2_W32
  37. #    define DOS_H68_OS2_W32
  38. #  endif
  39. #endif
  40.  
  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.  
  47. #if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
  48. #  ifndef DOS_FLX_H68_OS2_W32
  49. #    define DOS_FLX_H68_OS2_W32
  50. #  endif
  51. #endif
  52.  
  53. #if (defined(VM_CMS) || defined(MVS))
  54. #  ifndef CMS_MVS
  55. #    define CMS_MVS
  56. #  endif
  57. #endif
  58.  
  59.  
  60. /* Function prototypes */
  61.  
  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.  
  72. #ifdef ATARI
  73. #  define echoff(f)
  74. #  define echon()
  75. #  include <osbind.h>
  76. #  define getch() (Cnecin() & 0x000000ff)
  77. #  define HAVE_WORKING_GETCH
  78. #endif
  79.  
  80. #ifdef MACOS
  81. #  define echoff(f)
  82. #  define echon()
  83. #  define getch() macgetch()
  84. #  define HAVE_WORKING_GETCH
  85. #endif
  86.  
  87. #ifdef QDOS
  88. #  define echoff(f)
  89. #  define echon()
  90. #  define HAVE_WORKING_GETCH
  91. #endif
  92.  
  93. #ifdef RISCOS
  94. #  define echoff(f)
  95. #  define echon()
  96. #  define getch() SWI_OS_ReadC()
  97. #  define HAVE_WORKING_GETCH
  98. #endif
  99.  
  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.  
  124. #ifdef FLEXOS
  125. #  define echoff(f)
  126. #  define echon()
  127. #  define getch() getchar() /* not correct, but may not be on a console */
  128. #  define HAVE_WORKING_GETCH
  129. #endif
  130.  
  131. /* For VM/CMS and MVS, we do not (yet) have any support to switch terminal
  132.  * input echo on and off. The following "fake" definitions allow inclusion
  133.  * of crypt support and UnZip's "pause prompting" features, but without
  134.  * any echo suppression.
  135.  */
  136. #ifdef CMS_MVS
  137. #  define echoff(f)
  138. #  define echon()
  139. #endif
  140.  
  141. /* VMS has a single echo() function in ttyio.c to toggle terminal
  142.  * input echo on and off.
  143.  */
  144. #ifdef VMS
  145. #  define echoff(f)  echo(0)
  146. #  define echon()    echo(1)
  147.    int echo OF((int));
  148. #endif
  149.  
  150. /* For all other systems, ttyio.c supplies the two functions Echoff() and
  151.  * Echon() for suppressing and (re)enabling console input echo.
  152.  */
  153. #ifndef echoff
  154. #  define echoff(f)  Echoff(__G__ f)
  155. #  define echon()    Echon(__G)
  156.    void Echoff OF((__GPRO__ int f));
  157.    void Echon OF((__GPRO));
  158. #endif
  159.  
  160. /* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
  161. #if (defined(UNZIP) && !defined(FUNZIP))
  162. #  ifdef HAVE_WORKING_GETCH
  163. #    define FGETCH(f)  getch()
  164. #  endif
  165. #  ifndef FGETCH
  166.      /* default for all systems where no getch()-like function is available */
  167.      int zgetch OF((__GPRO__ int f));
  168. #    define FGETCH(f)  zgetch(__G__ f)
  169. #  endif
  170. #endif /* UNZIP && !FUNZIP */
  171.  
  172. #if (CRYPT && !defined(WINDLL))
  173.    char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
  174. #endif
  175.  
  176. #else /* !(CRYPT || (UNZIP && !FUNZIP)) */
  177.  
  178. /*
  179.  * No need for non-echo keyboard/console input; provide dummy definitions.
  180.  */
  181. #define echoff(f)
  182. #define echon()
  183.  
  184. #endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
  185.  
  186. #endif /* !__ttyio_h */
  187.