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