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