home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / ARCH / ZCRYPT21 / CRYPT.H < prev    next >
C/C++ Source or Header  |  1994-01-08  |  3KB  |  105 lines

  1. /*
  2.    crypt.h (full version) by Info-ZIP.       Last revised:  8 Jan 94
  3.  
  4.    This header file is not copyrighted and may be distributed without
  5.    restriction.
  6.  */
  7.  
  8. #ifndef __crypt_h   /* don't include more than once */
  9. #define __crypt_h
  10.  
  11. #ifndef CRYPT
  12. #  define CRYPT     /* full version */
  13. #endif
  14.  
  15. #define PWLEN  80   /* input buffer size for reading encryption key */
  16. #define RAND_HEAD_LEN  12    /* length of encryption random header */
  17.  
  18. /* encode byte c, using temp t.  Warning: c must not have side effects. */
  19. #define zencode(c,t)  (t=decrypt_byte(), update_keys(c), t^(c))
  20.  
  21. /* decode byte c in place */
  22. #define zdecode(c)   update_keys(c ^= decrypt_byte())
  23.  
  24. int  decrypt_byte OF((void));
  25. int  update_keys OF((int c));
  26. void init_keys OF((char *passwd));
  27. void crypthead OF((char *, ulg, FILE *));
  28. char *getp OF((char *m, char *p, int n));
  29. int  decrypt OF((void));
  30.  
  31. #ifdef UTIL
  32.    int zipcloak OF((struct zlist far *, FILE *, FILE *, char *));
  33.    int zipbare OF((struct zlist far *, FILE *, FILE *, char *));
  34. #else /* !UTIL */
  35.    unsigned zfwrite OF((voidp *, extent, extent, FILE *));
  36.    extern char *key;
  37. #endif /* ?UTIL */
  38.  
  39. #ifdef UNZIP
  40.    extern int newzip;
  41. #endif
  42.  
  43. #ifdef FUNZIP
  44.    extern int encrypted;
  45. #  ifdef NEXTBYTE
  46. #    undef NEXTBYTE
  47. #  endif
  48. #  define NEXTBYTE (encrypted? update_keys(getc(in)^decrypt_byte()) : getc(in))
  49. #endif /* FUNZIP */
  50.  
  51. #ifdef VMS
  52. #  define echoff(f)  echo(0)
  53. #  define echon()    echo(1)
  54.    int echo OF((int));
  55. #else
  56.    void echoff OF((int));
  57.    void echon OF((void));
  58. #endif
  59.  
  60. #if defined(MSDOS) || defined(OS2) || defined(__human68k__) || defined(WIN32)
  61. #  ifndef DOS_NT_OS2
  62. #    define DOS_NT_OS2
  63. #  endif
  64. #endif
  65.  
  66. #ifdef TOPS20
  67. #  define decrypt_byte   dcrbyt
  68. #endif
  69.  
  70. #ifdef AMIGA
  71. #  ifndef SIGBREAKF_CTRL_C
  72. #    define SIGBREAKF_CTRL_C (1L << 12)
  73. #  endif
  74. #  if (defined(UNZIP) && !defined(CLIB_EXEC_PROTOS_H))
  75.      void Signal(void *, long), *FindTask(void *);
  76. #  endif
  77. #  ifndef EPIPE
  78. #    define EPIPE  9999     /* (errno == EPIPE) always false */
  79. #  endif
  80.    /* Note: getpid() is only used for random number seeding */
  81. #  define getpid()  (long) FindTask(NULL)       /* more secure than pi */
  82. #  ifdef __SASC_60
  83. #    define echoff(f)  /* rawcon(1) */
  84. #    define echon()    /* rawcon(0) */
  85. #    define ECHO_NEWLINE()   putc('\n', stderr)
  86. #  else
  87. #    define getch getchar
  88. #    ifdef AZTEC_C
  89. #      define echoff(f)      set_raw()
  90. #      define echon()        set_con()
  91. #      define ECHO_NEWLINE() putc('\n', stderr)
  92. #    else
  93. #      define echoff(f)      { fputs("\033[30;40m",stderr);fflush(stderr); }
  94. #      define echon()        { fputs("\033[31;40m",stderr);fflush(stderr); }
  95. #      define ECHO_NEWLINE()
  96. #    endif
  97. #  endif
  98. #endif
  99.  
  100. #ifdef MACOS
  101. #  define getpid()     3141592654L   /* return PI for PID */
  102. #endif
  103.  
  104. #endif /* !__crypt_h */
  105.