home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / packery / xpk_develop / include / c / xpk / xpk.h next >
C/C++ Source or Header  |  1996-10-19  |  12KB  |  280 lines

  1. #ifndef XPK_XPK_H
  2. #define XPK_XPK_H
  3.  
  4. /*
  5. **    $VER: xpk/xpk.h 3.10 (26.09.96) by SDI
  6. **
  7. **    (C) Copyright 1991-1996 by 
  8. **          Urban Dominik Mueller, Bryan Ford,
  9. **          Christian Schneider, Christian von Roques,
  10. **        Dirk Stöcker
  11. **        All Rights Reserved
  12. */
  13.  
  14. #include <exec/types.h>
  15.  
  16. #ifndef EXEC_NODES_H
  17.   #include <exec/nodes.h>
  18. #endif
  19.  
  20. #ifndef UTILITY_TAGITEM_H
  21.   #include <utility/tagitem.h>
  22. #endif
  23. #ifndef UTILITY_HOOKS_H
  24.   #include <utility/hooks.h>
  25. #endif
  26.  
  27. #define XPKNAME "xpkmaster.library"
  28.  
  29. /***************************************************************************
  30.  *
  31.  *
  32.  *      The packing/unpacking tags
  33.  *
  34.  */
  35.  
  36. #define XPK_TagBase    (TAG_USER + ('X'<<8) + 'P')
  37. #define XTAG(a)        (XPK_TagBase+a)
  38.  
  39. /* Caller must supply ONE of these to tell Xpk#?ackFile where to get data from */
  40. #define XPK_InName      XTAG(0x01) /* Process an entire named file */
  41. #define XPK_InFH      XTAG(0x02) /* File handle - start from current position */
  42.                      /* If packing partial file, must also supply InLen */
  43. #define XPK_InBuf      XTAG(0x03) /* Single unblocked memory buffer */
  44.                      /* Must also supply InLen */
  45. #define XPK_InHook      XTAG(0x04) /* Call custom Hook to read data */
  46.                      /* If packing, must also supply InLen */
  47.                      /* If unpacking, InLen required only for PPDecrunch */
  48.  
  49. /* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to */
  50. #define XPK_OutName      XTAG(0x10) /* Write (or overwrite) this data file */
  51. #define XPK_OutFH      XTAG(0x11) /* File handle - write from current position on */
  52. #define XPK_OutBuf      XTAG(0x12) /* Unblocked buffer - must also supply OutBufLen */
  53. #define XPK_GetOutBuf      XTAG(0x13) /* Master allocates OutBuf - ti_Data points to buf ptr */
  54. #define XPK_OutHook      XTAG(0x14) /* Callback Hook to get output buffers */
  55.  
  56. /* Other tags for Pack/Unpack */
  57. #define XPK_InLen      XTAG(0x20) /* Length of data in input buffer  */
  58. #define XPK_OutBufLen      XTAG(0x21) /* Length of output buffer         */
  59. #define XPK_GetOutLen      XTAG(0x22) /* ti_Data points to long to receive OutLen    */
  60. #define XPK_GetOutBufLen  XTAG(0x23) /* ti_Data points to long to receive OutBufLen */
  61. #define XPK_Password      XTAG(0x24) /* Password for de/encoding        */
  62. #define XPK_GetError      XTAG(0x25) /* ti_Data points to buffer for error message  */
  63. #define XPK_OutMemType      XTAG(0x26) /* Memory type for output buffer   */
  64. #define XPK_PassThru      XTAG(0x27) /* Bool: Pass through unrecognized formats on unpack */
  65. #define XPK_StepDown      XTAG(0x28) /* Bool: Step down pack method if necessary    */
  66. #define XPK_ChunkHook      XTAG(0x29) /* Call this Hook between chunks   */
  67. #define XPK_PackMethod      XTAG(0x2a) /* Do a FindMethod before packing  */
  68. #define XPK_ChunkSize      XTAG(0x2b) /* Chunk size to try to pack with  */
  69. #define XPK_PackMode      XTAG(0x2c) /* Packing mode for sublib to use  */
  70. #define XPK_NoClobber      XTAG(0x2d) /* Don't overwrite existing files  */
  71. #define XPK_Ignore      XTAG(0x2e) /* Skip this tag                   */
  72. #define XPK_TaskPri      XTAG(0x2f) /* Change priority for (un)packing */
  73. #define XPK_FileName      XTAG(0x30) /* File name for progress report   */
  74. #define XPK_ShortError      XTAG(0x31) /* Output short error messages     */
  75. #define XPK_PackersQuery  XTAG(0x32) /* Query available packers         */
  76. #define XPK_PackerQuery      XTAG(0x33) /* Query properties of a packer    */
  77. #define XPK_ModeQuery      XTAG(0x34) /* Query properties of packmode    */
  78. #define XPK_LossyOK      XTAG(0x35) /* Lossy packing permitted? def.=no*/
  79. #define XPK_NoCRC         XTAG(0x36) /* Ignore checksum                 */
  80.  
  81. #define XPK_MARGIN    256    /* Safety margin for output buffer    */
  82.  
  83. /***************************************************************************
  84.  *
  85.  *
  86.  *     The hook function interface
  87.  *
  88.  */
  89.  
  90. /* Message passed to InHook and OutHook as the ParamPacket */
  91. struct XpkIOMsg {
  92.     ULONG xiom_Type        ; /* Read/Write/Alloc/Free/Abort    */
  93.     APTR  xiom_Ptr        ; /* The mem area to read from/write to */
  94.     ULONG xiom_Size        ; /* The size of the read/write        */
  95.     ULONG xiom_IOError    ; /* The IoErr() that occurred        */
  96.     ULONG xiom_Reserved    ; /* Reserved for future use        */
  97.     ULONG xiom_Private1    ; /* Hook specific, will be set to 0 by */
  98.     ULONG xiom_Private2    ; /* master library before first use    */
  99.     ULONG xiom_Private3    ;
  100.     ULONG xiom_Private4    ;
  101. };
  102.  
  103. /* The values for XpkIoMsg->Type */
  104. #define XIO_READ    1
  105. #define XIO_WRITE   2
  106. #define XIO_FREE    3
  107. #define XIO_ABORT   4
  108. #define XIO_GETBUF  5
  109. #define XIO_SEEK    6
  110. #define XIO_TOTSIZE 7
  111.  
  112. /***************************************************************************
  113.  *
  114.  *
  115.  *      The progress report interface
  116.  *
  117.  */
  118.  
  119. /* Passed to ChunkHook as the ParamPacket */
  120. struct XpkProgress {
  121.   ULONG     xp_Type;        /* Type of report: start/cont/end/abort      */
  122.   STRPTR xp_PackerName;     /* Brief name of packer being used           */
  123.   STRPTR xp_PackerLongName; /* Descriptive name of packer being used       */
  124.   STRPTR xp_Activity;       /* Packing/unpacking message          */
  125.   STRPTR xp_FileName;       /* Name of file being processed, if available */
  126.   ULONG     xp_CCur;           /* Amount of packed data already processed      */
  127.   ULONG     xp_UCur;           /* Amount of unpacked data already processed  */
  128.   ULONG     xp_ULen;        /* Amount of unpacked data in file          */
  129.   ULONG     xp_CF;            /* Compression factor so far          */
  130.   ULONG     xp_Done;           /* Percentage done already              */
  131.   ULONG     xp_Speed;          /* Bytes per second, from beginning of stream */
  132.   ULONG     xp_Reserved[8];    /* For future use                  */
  133. };
  134. #define XPKPROG_START    1
  135. #define XPKPROG_MID    2
  136. #define XPKPROG_END    3
  137.  
  138. /***************************************************************************
  139.  *
  140.  *
  141.  *       The file info block
  142.  *
  143.  */
  144.  
  145. struct XpkFib {
  146.     ULONG    xf_Type        ; /* Unpacked, packed, archive?   */
  147.     ULONG    xf_ULen        ; /* Uncompressed length          */
  148.     ULONG    xf_CLen        ; /* Compressed length            */
  149.     ULONG    xf_NLen        ; /* Next chunk len               */
  150.     ULONG    xf_UCur        ; /* Uncompressed bytes so far    */
  151.     ULONG    xf_CCur        ; /* Compressed bytes so far      */
  152.     ULONG    xf_ID        ; /* 4 letter ID of packer        */
  153.     UBYTE    xf_Packer[6]    ; /* 4 letter name of packer      */
  154.     UWORD    xf_SubVersion    ; /* Required sublib version      */
  155.     UWORD    xf_MasVersion    ; /* Required masterlib version   */
  156.     ULONG    xf_Flags    ; /* Password?                    */
  157.     UBYTE    xf_Head[16]    ; /* First 16 bytes of orig. file */
  158.     LONG    xf_Ratio    ; /* Compression ratio            */
  159.     ULONG    xf_Reserved[8]    ; /* For future use               */
  160. };
  161.  
  162. #define XPKTYPE_UNPACKED 0        /* Not packed                   */
  163. #define XPKTYPE_PACKED   1        /* Packed file                  */
  164. #define XPKTYPE_ARCHIVE  2        /* Archive                      */
  165.  
  166. #define XPKFLAGS_PASSWORD 1       /* Password needed              */
  167. #define XPKFLAGS_NOSEEK   2       /* Chunks are dependent         */
  168. #define XPKFLAGS_NONSTD   4       /* Nonstandard file format      */
  169.  
  170. /***************************************************************************
  171.  *
  172.  *
  173.  *       The error messages
  174.  *
  175.  */
  176.  
  177. #define XPKERR_OK      0
  178. #define XPKERR_NOFUNC       -1    /* This function not implemented    */
  179. #define XPKERR_NOFILES       -2    /* No files allowed for this function    */
  180. #define XPKERR_IOERRIN       -3    /* Input error happened, look at Result2*/
  181. #define XPKERR_IOERROUT       -4    /* Output error happened,look at Result2*/
  182. #define XPKERR_CHECKSUM       -5    /* Check sum test failed        */
  183. #define XPKERR_VERSION       -6    /* Packed file's version newer than lib */
  184. #define XPKERR_NOMEM       -7    /* Out of memory            */
  185. #define XPKERR_LIBINUSE       -8    /* For not-reentrant libraries        */
  186. #define XPKERR_WRONGFORM   -9    /* Was not packed with this library    */
  187. #define XPKERR_SMALLBUF       -10    /* Output buffer too small        */
  188. #define XPKERR_LARGEBUF       -11    /* Input buffer too large        */
  189. #define XPKERR_WRONGMODE   -12    /* This packing mode not supported    */
  190. #define XPKERR_NEEDPASSWD  -13    /* Password needed for decoding        */
  191. #define XPKERR_CORRUPTPKD  -14    /* Packed file is corrupt        */
  192. #define XPKERR_MISSINGLIB  -15    /* Required library is missing        */
  193. #define XPKERR_BADPARAMS   -16    /* Caller's TagList was screwed up    */
  194. #define XPKERR_EXPANSION   -17    /* Would have caused data expansion    */
  195. #define XPKERR_NOMETHOD    -18    /* Can't find requested method        */
  196. #define XPKERR_ABORTED     -19    /* Operation aborted by user        */
  197. #define XPKERR_TRUNCATED   -20    /* Input file is truncated        */
  198. #define XPKERR_WRONGCPU    -21    /* Better CPU required for this library    */
  199. #define XPKERR_PACKED      -22    /* Data are already XPacked        */
  200. #define XPKERR_NOTPACKED   -23    /* Data not packed            */
  201. #define XPKERR_FILEEXISTS  -24    /* File already exists            */
  202. #define XPKERR_OLDMASTLIB  -25    /* Master library too old        */
  203. #define XPKERR_OLDSUBLIB   -26    /* Sub library too old            */
  204. #define XPKERR_NOCRYPT     -27    /* Cannot encrypt            */
  205. #define XPKERR_NOINFO      -28    /* Can't get info on that packer    */
  206. #define XPKERR_LOSSY       -29    /* This compression method is lossy    */
  207. #define XPKERR_NOHARDWARE  -30    /* Compression hardware required    */
  208. #define XPKERR_BADHARDWARE -31    /* Compression hardware failed        */
  209. #define XPKERR_WRONGPW     -32    /* Password was wrong            */
  210.  
  211. #define XPKERRMSGSIZE    80    /* Maximum size of an error message    */
  212.  
  213. /***************************************************************************
  214.  *
  215.  *
  216.  *     The XpkQuery() call
  217.  *
  218.  */
  219.  
  220. struct XpkPackerInfo {
  221.     UBYTE    xpi_Name[24]       ; /* Brief name of the packer          */
  222.     UBYTE    xpi_LongName[32]   ; /* Full name of the packer           */
  223.     UBYTE    xpi_Description[80]; /* One line description of packer    */
  224.     ULONG    xpi_Flags          ; /* Defined below                     */
  225.     ULONG    xpi_MaxChunk       ; /* Max input chunk size for packing  */
  226.     ULONG    xpi_DefChunk       ; /* Default packing chunk size        */
  227.     UWORD    xpi_DefMode        ; /* Default mode on 0..100 scale      */
  228. };
  229.  
  230. /* Defines for Flags */
  231. #define XPKIF_PK_CHUNK   0x00001 /* Library supplies chunk packing       */
  232. #define XPKIF_PK_STREAM  0x00002 /* Library supplies stream packing      */
  233. #define XPKIF_PK_ARCHIVE 0x00004 /* Library supplies archive packing     */
  234. #define XPKIF_UP_CHUNK   0x00008 /* Library supplies chunk unpacking     */
  235. #define XPKIF_UP_STREAM  0x00010 /* Library supplies stream unpacking    */
  236. #define XPKIF_UP_ARCHIVE 0x00020 /* Library supplies archive unpacking   */
  237. #define XPKIF_HOOKIO     0x00080 /* Uses full Hook I/O                   */
  238. #define XPKIF_CHECKING   0x00400 /* Does its own data checking           */
  239. #define XPKIF_PREREADHDR 0x00800 /* Unpacker pre-reads the next chunkhdr */
  240. #define XPKIF_ENCRYPTION 0x02000 /* Sub library supports encryption      */
  241. #define XPKIF_NEEDPASSWD 0x04000 /* Sub library requires encryption      */
  242. #define XPKIF_MODES      0x08000 /* Sub library has different modes      */
  243. #define XPKIF_LOSSY      0x10000 /* Sub library does lossy compression   */
  244.  
  245. struct XpkMode {
  246.   struct XpkMode *xm_Next;   /* Chain to next descriptor for ModeDesc list*/
  247.   ULONG   xm_Upto;         /* Maximum efficiency handled by this mode   */
  248.   ULONG   xm_Flags;         /* Defined below                             */
  249.   ULONG   xm_PackMemory;     /* Extra memory required during packing      */
  250.   ULONG   xm_UnpackMemory;   /* Extra memory during unpacking             */
  251.   ULONG   xm_PackSpeed;      /* Approx packing speed in K per second      */
  252.   ULONG   xm_UnpackSpeed;    /* Approx unpacking speed in K per second    */
  253.   UWORD   xm_Ratio;         /* CF in 0.1% for AmigaVision executable     */
  254.   UWORD   xm_ChunkSize;         /* Desired chunk size in K (!!) for this mode*/
  255.   UBYTE   xm_Description[10];/* 7 character mode description              */
  256. };
  257.  
  258. /* Defines for XpkMode.Flags */
  259. #define XPKMF_A3000SPEED 0x00000001 /* Timings on A3000/25                */
  260. #define XPKMF_PK_NOCPU   0x00000002 /* Packing not heavily CPU dependent  */
  261. #define XPKMF_UP_NOCPU   0x00000004 /* Unpacking... (i.e. hardware modes) */
  262.  
  263. #define MAXPACKERS 100
  264.  
  265. struct XpkPackerList {
  266.     ULONG    xpl_NumPackers;
  267.     UBYTE    xpl_Packer[MAXPACKERS][6];
  268. };
  269.  
  270. /***************************************************************************
  271.  *
  272.  *
  273.  *     The XpkOpen() type calls
  274.  *
  275.  */
  276.  
  277. #define XPKLEN_ONECHUNK 0x7fffffff
  278.  
  279. #endif /* XPK_XPK_H */
  280.