home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ARCHIVE.HPP < prev    next >
C/C++ Source or Header  |  1997-07-05  |  2KB  |  63 lines

  1. // +++Date last modified: 05-Jul-1997
  2.  
  3. /*
  4. **  ARCHIVE.HPP
  5. **
  6. **   Written by Jari Laaksonen (2:221/360.20), 2 Sep 1994
  7. **   Based on the code by Heinz Ozwirk and David Gersic.
  8. **
  9. **   Free for all participants of the C_ECHO & other conferences where
  10. **   this code is posted. Released to SNIPPETS by the authors.
  11. **
  12. **   See the file WhichArc.DOC about archive types and file offsets
  13. **   for self extracting archives.
  14. */
  15.  
  16. #include <stdio.h>
  17.  
  18. // add new type identifiers here if you need to separate e.g. different
  19. // LHA files. Add your new types also in the Arctypes array in the TEST part
  20. // and give them new descriptions.
  21.  
  22. typedef enum
  23. {
  24.       ERROR = -1, UNKNOWN = 0,
  25.       ARC,      ARC6,     PAK,     ZOO,     HPK,    RAR,    UC2,    SQZ,
  26.       ARJ,      LARC,     LHARC,   LHA,     ZIP,    ZIP2,
  27.       SFXARC,   SFXARC6,  SFXPAK,
  28.       SFXARJ,   SFXLHARC, SFXLHA,  SFXZIP,  SFXZIP2,
  29.       EXE,
  30.       COUNT_ARCTYPES
  31. } ARCTYPE;
  32.  
  33. const int BUFFSIZE = 128;
  34.  
  35. class Archive
  36. {
  37. protected:
  38.       int  type, sfxtype;
  39.       long offset;
  40.       char *fingerprint;
  41.  
  42. public:
  43.       Archive (long offs, char *fp, int t = UNKNOWN, int t2 = UNKNOWN) :
  44.                   offset (offs), fingerprint (fp), type(t), sfxtype (t2) { };
  45.  
  46.       int Scan  (FILE *fp, char *szBuff, long flen);
  47.       virtual int Check (char *szBuff);
  48. };
  49.  
  50. class LhaArchive : public Archive
  51. {
  52. public:
  53.       LhaArchive (long offs, char *fp) : Archive (offs, fp) { };
  54.       int Check (char *szBuff);
  55. };
  56.  
  57. class PakArchive : public Archive
  58. {
  59. public:
  60.       PakArchive (long offs = 0) : Archive (offs, "") { };
  61.       int Check (char *szBuff);
  62. };
  63.