home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zcrypt27.zip / crypt.h < prev    next >
C/C++ Source or Header  |  1997-04-22  |  3KB  |  100 lines

  1. /*
  2.    crypt.h (full version) by Info-ZIP.   Last revised:  [see CR_VERSION_DATE]
  3.  
  4.    This header file is not copyrighted, and non-beta versions may be
  5.    distributed without restriction.
  6.  */
  7.  
  8. #ifndef __crypt_h   /* don't include more than once */
  9. #define __crypt_h
  10.  
  11. #ifdef CRYPT
  12. #  undef CRYPT
  13. #endif
  14. #define CRYPT  1    /* full version */
  15.  
  16. #define CR_MAJORVER        2
  17. #define CR_MINORVER        7
  18. #ifdef CR_BETA
  19. #  define CR_BETA_VER      "m BETA"
  20. #  define CR_VERSION_DATE  "13 April 1997"     /* last real code change */
  21. #else
  22. #  define CR_BETA_VER      ""
  23. #  define CR_VERSION_DATE  "22 April 1997"     /* last public release date */
  24. #  define CR_RELEASE
  25. #endif
  26.  
  27. #ifndef __G         /* UnZip only, for now (DLL stuff) */
  28. #  define __G
  29. #  define __G__
  30. #  define __GDEF
  31. #  define __GPRO    void
  32. #  define __GPRO__
  33. #endif
  34.  
  35. #if defined(MSDOS) || defined(OS2) || defined(WIN32)
  36. #  ifndef DOS_OS2_W32
  37. #    define DOS_OS2_W32
  38. #  endif
  39. #endif
  40.  
  41. #if defined(DOS_OS2_W32) || defined(__human68k__)
  42. #  ifndef DOS_H68_OS2_W32
  43. #    define DOS_H68_OS2_W32
  44. #  endif
  45. #endif
  46.  
  47. #if defined(VM_CMS) || defined(MVS)
  48. #  ifndef CMS_MVS
  49. #    define CMS_MVS
  50. #  endif
  51. #endif
  52.  
  53. #ifdef REALLY_SHORT_SYMS
  54. #  define decrypt_byte   dcrbyt
  55. #endif
  56.  
  57. #define PWLEN  80   /* input buffer size for reading encryption key */
  58. #define RAND_HEAD_LEN  12    /* length of encryption random header */
  59.  
  60. /* the crc_32_tab array has to be provided externally for the crypt calculus */
  61. #ifndef UNZIP                   /* UnZip provides this in globals.h */
  62.    extern ulg near *crc_32_tab;
  63. #endif /* !UNZIP */
  64.  
  65. /* encode byte c, using temp t.  Warning: c must not have side effects. */
  66. #define zencode(c,t)  (t=decrypt_byte(__G), update_keys(c), t^(c))
  67.  
  68. /* decode byte c in place */
  69. #define zdecode(c)   update_keys(__G__ c ^= decrypt_byte(__G))
  70.  
  71. int  decrypt_byte OF((__GPRO));
  72. int  update_keys OF((__GPRO__ int c));
  73. void init_keys OF((__GPRO__ char *passwd));
  74.  
  75. #ifdef ZIP
  76.    void crypthead OF((char *, ulg, FILE *));
  77. #  ifdef UTIL
  78.      int zipcloak OF((struct zlist far *, FILE *, FILE *, char *));
  79.      int zipbare OF((__GPRO__ struct zlist far *, FILE *, FILE *, char *));
  80. #  else
  81.      unsigned zfwrite OF((zvoid *, extent, extent, FILE *));
  82.      extern char *key;
  83. #  endif
  84. #endif /* ZIP */
  85.  
  86. #if (defined(UNZIP) && !defined(FUNZIP))
  87.    int  decrypt OF((__GPRO));
  88. #endif
  89.  
  90. #ifdef FUNZIP
  91.    extern int encrypted;
  92. #  ifdef NEXTBYTE
  93. #    undef NEXTBYTE
  94. #  endif
  95. #  define NEXTBYTE \
  96.    (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
  97. #endif /* FUNZIP */
  98.  
  99. #endif /* !__crypt_h */
  100.