home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip531.zip / ttyio.h < prev    next >
C/C++ Source or Header  |  1997-04-13  |  4KB  |  163 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(VM_CMS) || defined(MVS))
  42. #  ifndef CMS_MVS
  43. #    define CMS_MVS
  44. #  endif
  45. #endif
  46.  
  47.  
  48. /* Function prototypes */
  49.  
  50. /* The following systems supply a `non-echo' character input function "getch()"
  51.  * (or an alias) and do not need the echoff() / echon() function pair.
  52.  */
  53. #ifdef AMIGA
  54. #  define echoff(f)
  55. #  define echon()
  56.    int Agetch(void);            /* getch() like function, in amiga/filedate.c */
  57. #  define getch() Agetch()
  58. #  define HAVE_WORKING_GETCH
  59. #endif /* AMIGA */
  60.  
  61. #ifdef ATARI
  62. #  define echoff(f)
  63. #  define echon()
  64. #  include <osbind.h>
  65. #  define getch() (Cnecin() & 0x000000ff)
  66. #  define HAVE_WORKING_GETCH
  67. #endif
  68.  
  69. #ifdef MACOS
  70. #  define echoff(f)
  71. #  define echon()
  72. #  define getch() macgetch()
  73. #  define HAVE_WORKING_GETCH
  74. #endif
  75.  
  76. #ifdef QDOS
  77. #  define echoff(f)
  78. #  define echon()
  79. #  define HAVE_WORKING_GETCH
  80. #endif
  81.  
  82. #ifdef RISCOS
  83. #  define echoff(f)
  84. #  define echon()
  85. #  define getch() SWI_OS_ReadC()
  86. #  define HAVE_WORKING_GETCH
  87. #endif
  88.  
  89. #ifdef DOS_H68_OS2_W32
  90. #  define echoff(f)
  91. #  define echon()
  92. #  ifdef __EMX__
  93. #    ifndef getch
  94. #      define getch() _read_kbd(0, 1, 0)
  95. #    endif
  96. #  else /* !__EMX__ */
  97. #    ifdef __GO32__
  98. #      include <pc.h>
  99. #      define getch() getkey()
  100. #    else /* !__GO32__ */
  101. #      include <conio.h>
  102. #    endif /* ?__GO32__ */
  103. #  endif /* ?__EMX__ */
  104. #  define HAVE_WORKING_GETCH
  105. #endif /* DOS_H68_OS2_W32 */
  106.  
  107. /* For VM/CMS and MVS, we do not (yet) have any support to switch terminal
  108.  * input echo on and off. The following "fake" definitions allow inclusion
  109.  * of crypt support and UnZip's "pause prompting" features, but without
  110.  * any echo suppression.
  111.  */
  112. #ifdef CMS_MVS
  113. #  define echoff(f)
  114. #  define echon()
  115. #endif
  116.  
  117. /* VMS has a single echo() function in ttyio.c to toggle terminal
  118.  * input echo on and off.
  119.  */
  120. #ifdef VMS
  121. #  define echoff(f)  echo(0)
  122. #  define echon()    echo(1)
  123.    int echo OF((int));
  124. #endif
  125.  
  126. /* For all other systems, ttyio.c supplies the two functions Echoff() and
  127.  * Echon() for suppressing and (re)enabling console input echo.
  128.  */
  129. #ifndef echoff
  130. #  define echoff(f)  Echoff(__G__ f)
  131. #  define echon()    Echon(__G)
  132.    void Echoff OF((__GPRO__ int f));
  133.    void Echon OF((__GPRO));
  134. #endif
  135.  
  136. /* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
  137. #if (defined(UNZIP) && !defined(FUNZIP))
  138. #  ifdef HAVE_WORKING_GETCH
  139. #    define FGETCH(f)  getch()
  140. #  endif
  141. #  ifndef FGETCH
  142.      /* default for all systems where no getch()-like function is available */
  143.      int zgetch OF((__GPRO__ int f));
  144. #    define FGETCH(f)  zgetch(__G__ f)
  145. #  endif
  146. #endif /* UNZIP && !FUNZIP */
  147.  
  148. #if (CRYPT && !defined(WINDLL))
  149.    char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
  150. #endif
  151.  
  152. #else /* !(CRYPT || (UNZIP && !FUNZIP)) */
  153.  
  154. /*
  155.  * No need for non-echo keyboard/console input; provide dummy definitions.
  156.  */
  157. #define echoff(f)
  158. #define echon()
  159.  
  160. #endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
  161.  
  162. #endif /* !__ttyio_h */
  163.