#ifndef LIBRARIES_XADMASTER_H #define LIBRARIES_XADMASTER_H /* $Id: xadmaster.h.in,v 1.24 2005/06/23 14:54:42 stoecker Exp $ xadmaster.library defines and structures XAD library system for archive handling Copyright (C) 1998 and later by Dirk Stöcker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef __cplusplus extern "C" { #endif #include typedef uint32_t xadUINT32; typedef int32_t xadINT32; typedef uint16_t xadUINT16; typedef int16_t xadINT16; typedef uint8_t xadUINT8; typedef int8_t xadINT8; typedef uint64_t xadSize; typedef int64_t xadSignSize; typedef void * xadPTR; typedef unsigned char xadSTRING; typedef xadSTRING * xadSTRPTR; typedef unsigned int xadUINT; typedef int xadINT; typedef xadINT xadERROR; typedef xadINT xadBOOL; #define XADFALSE 0 #define XADTRUE 1 #define XADMEMF_ANY (0) #define XADMEMF_CLEAR (1L << 16) #define XADMEMF_PUBLIC (1L << 0) /* Portable define to put the xadMasterBase parameter as the first * parameter of any function. This macro makes it simpler. */ #define XADM xadMasterBase, typedef xadUINT32 xadTag; struct TagItem { xadTag ti_Tag; xadSize ti_Data; }; #include typedef int xadFileHandle; typedef const struct TagItem * xadTAGPTR; /* is a tag's data a pointer, an int, or a 64-bit size? */ #define TAG_PTR (0x80000000UL) #define TAG_INT (0x40000000UL) #define TAG_SIZ (0x20000000UL) /* end of taglist */ #define TAG_DONE (TAG_INT + 0x10000000UL) /* ignore this tag */ #define TAG_IGNORE (TAG_INT + 0x10000001UL) /* taglist continues at (struct TagItem *) ti_Data */ #define TAG_MORE (TAG_PTR + 0x10000002UL) /* ignore the next [(xadUINT32) ti_Data] tags */ #define TAG_SKIP (TAG_INT + 0x10000003UL) /* a standard callback system */ struct Hook { /* h_MinNode, used for hook linking on Amiga, is not needed by XAD */ xadUINT32 (*h_Entry)(); /* entry point of callback */ /* h_SubEntry, used when h_Entry on Amiga is an asm stub, is not needed */ xadPTR *h_Data; /* data parameter always passed to callback */ }; /* NOTE: Nearly all structures need to be allocated using the xadAllocObject function. */ /************************************************************************ * * * library base structure * * * ************************************************************************/ struct xadMasterBase { xadPTR dummy; }; /************************************************************************ * * * tag-function call flags * * * ************************************************************************/ /* input tags for xadGetInfo, only one can be specified per call */ #define XAD_INSIZE (TAG_SIZ+ 1) /* input data size */ #define XAD_INFILENAME (TAG_PTR+ 2) #define XAD_INFILEHANDLE (TAG_PTR+ 3) #define XAD_INMEMORY (TAG_PTR+ 4) #define XAD_INHOOK (TAG_PTR+ 5) #define XAD_INSPLITTED (TAG_PTR+ 6) /* (V2) */ #define XAD_INDISKARCHIVE (TAG_PTR+ 7) /* (V4) */ #define XAD_INXADSTREAM (TAG_PTR+ 8) /* (V8) */ #define XAD_INDEVICE (TAG_PTR+ 9) /* (V11) */ /* output tags, only one can be specified per call, xadXXXXUnArc */ #define XAD_OUTSIZE (TAG_SIZ+ 10) /* output data size */ #define XAD_OUTFILENAME (TAG_PTR+ 11) #define XAD_OUTFILEHANDLE (TAG_PTR+ 12) #define XAD_OUTMEMORY (TAG_PTR+ 13) #define XAD_OUTHOOK (TAG_PTR+ 14) #define XAD_OUTDEVICE (TAG_PTR+ 15) #define XAD_OUTXADSTREAM (TAG_PTR+ 16) /* (V8) */ /* object allocation tags for xadAllocObjectA */ #define XAD_OBJNAMESIZE (TAG_INT+ 20) /* XADOBJ_FILEINFO, size of needed name space */ #define XAD_OBJCOMMENTSIZE (TAG_INT+ 21) /* XADOBJ_FILEINFO, size of needed comment space */ #define XAD_OBJPRIVINFOSIZE (TAG_INT+ 22) /* XADOBJ_FILEINFO & XADOBJ_DISKINFO, self use size */ #define XAD_OBJBLOCKENTRIES (TAG_INT+ 23) /* XADOBJ_DISKINFO, number of needed entries */ /* tags for xadGetInfo, xadFileUnArc and xadDiskUnArc */ #define XAD_NOEXTERN (TAG_INT+ 50) /* do not use extern clients */ #define XAD_PASSWORD (TAG_PTR+ 51) /* password when needed */ #define XAD_ENTRYNUMBER (TAG_INT+ 52) /* number of wanted entry */ #define XAD_PROGRESSHOOK (TAG_PTR+ 53) /* the progress hook */ #define XAD_OVERWRITE (TAG_INT+ 54) /* overwrite file ? */ #define XAD_MAKEDIRECTORY (TAG_INT+ 55) /* create directory tree */ #define XAD_IGNOREGEOMETRY (TAG_INT+ 56) /* ignore drive geometry ? */ #define XAD_LOWCYLINDER (TAG_INT+ 57) /* lowest cylinder */ #define XAD_HIGHCYLINDER (TAG_INT+ 58) /* highest cylinder */ #define XAD_VERIFY (TAG_INT+ 59) /* verify for disk hook */ #define XAD_NOKILLPARTIAL (TAG_INT+ 60) /* do not delete partial/corrupt files (V3.3) */ #define XAD_FORMAT (TAG_INT+ 61) /* format output device (V5) */ #define XAD_USESECTORLABELS (TAG_INT+ 62) /* sector labels are stored on disk (V9) */ #define XAD_IGNOREFLAGS (TAG_INT+ 63) /* ignore the client, if certain flags are set (V11) */ #define XAD_ONLYFLAGS (TAG_INT+ 64) /* ignore the client, if certain flags are NOT set (V11) */ // GOA #define XAD_CLIENT (TAG_INT+ 65) /* skip the recognition, use this client */ /* input tags for xadConvertDates, only one can be passed */ #define XAD_DATEUNIX (TAG_INT+ 70) /* unix date variable */ #define XAD_DATEAMIGA (TAG_INT+ 71) /* Amiga date variable */ #define XAD_DATEDATESTAMP (TAG_PTR+ 72) /* Amiga struct DateStamp */ #define XAD_DATEXADDATE (TAG_PTR+ 73) /* struct xadDate */ #define XAD_DATECLOCKDATA (TAG_PTR+ 74) /* Amiga struct ClockData */ #define XAD_DATECURRENTTIME (TAG_INT+ 75) /* input is system time */ #define XAD_DATEMSDOS (TAG_INT+ 76) /* MS-DOS packed format (V2) */ #define XAD_DATEMAC (TAG_INT+ 77) /* Mac date variable (V8) */ #define XAD_DATECPM (TAG_PTR+ 78) /* CP/M data structure (V10) */ #define XAD_DATECPM2 (TAG_INT+ 79) /* CP/M data structure type 2 (V10) */ #define XAD_DATEISO9660 (TAG_PTR+300) /* ISO9660 date structure (V11) */ /* output tags, there can be specified multiple tags for one call */ #define XAD_GETDATEUNIX (TAG_PTR+ 80) /* unix date variable */ #define XAD_GETDATEAMIGA (TAG_PTR+ 81) /* Amiga date variable */ #define XAD_GETDATEDATESTAMP (TAG_PTR+ 82) /* Amiga struct DateStamp */ #define XAD_GETDATEXADDATE (TAG_PTR+ 83) /* struct xadDate */ #define XAD_GETDATECLOCKDATA (TAG_PTR+ 84) /* Amiga struct ClockData */ #define XAD_GETDATEMSDOS (TAG_PTR+ 86) /* MS-DOS packed format (V2) */ #define XAD_GETDATEMAC (TAG_PTR+ 87) /* Mac date variable (V8) */ #define XAD_GETDATECPM (TAG_PTR+ 88) /* CP/M data structure (V10) */ #define XAD_GETDATECPM2 (TAG_PTR+ 89) /* CP/M data structure type 2 (V10) */ #define XAD_GETDATEISO9660 (TAG_PTR+320) /* ISO9660 date structure (V11) */ /* following tags need locale.library to be installed on Amiga */ #define XAD_MAKEGMTDATE (TAG_INT+ 90) /* make local to GMT time */ #define XAD_MAKELOCALDATE (TAG_INT+ 91) /* make GMT to local time */ /* tags for xadHookTagAccess (V3) */ #define XAD_USESKIPINFO (TAG_INT+104) /* the hook uses xadSkipInfo (V3) */ #define XAD_SECTORLABELS (TAG_PTR+105) /* pass sector labels with XADAC_WRITE (V9) */ #define XAD_GETCRC16 (TAG_PTR+120) /* pointer to xadUINT16 value (V3) */ #define XAD_GETCRC32 (TAG_PTR+121) /* pointer to xadUINT32 value (V3) */ #define XAD_CRC16ID (TAG_INT+130) /* ID for crc calculation (V3) */ #define XAD_CRC32ID (TAG_INT+131) /* ID for crc calculation (V3) */ /* tags for xadConvertProtection (V4) */ #define XAD_PROTAMIGA (TAG_INT+160) /* Amiga type protection bits (V4) */ #define XAD_PROTUNIX (TAG_INT+161) /* protection bits in UNIX mode (V4) */ #define XAD_PROTMSDOS (TAG_INT+162) /* MSDOS type protection bits (V4) */ #define XAD_PROTFILEINFO (TAG_PTR+163) /* input is a xadFileInfo structure (V11) */ #define XAD_GETPROTAMIGA (TAG_PTR+170) /* return Amiga protection bits (V4) */ #define XAD_GETPROTUNIX (TAG_PTR+171) /* return UNIX protection bits (V11) */ #define XAD_GETPROTMSDOS (TAG_PTR+172) /* return MSDOS protection bits (V11) */ #define XAD_GETPROTFILEINFO (TAG_PTR+173) /* fill xadFileInfo protection fields (V11) */ /* tags for xadGetDiskInfo (V7) */ #define XAD_STARTCLIENT (TAG_PTR+180) /* the client to start with (V7) */ #define XAD_NOEMPTYERROR (TAG_INT+181) /* do not create XADERR_EMPTY (V8) */ /* tags for xadFreeHookAccess (V8) */ #define XAD_WASERROR (TAG_INT+190) /* error occured, call abort method (V8) */ /* tags for miscellaneous stuff */ #define XAD_ARCHIVEINFO (TAG_PTR+200) /* xadArchiveInfo for stream hooks (V8) */ #define XAD_ERRORCODE (TAG_PTR+201) /* error code of function (V12) */ #define XAD_EXTENSION (TAG_PTR+202) /* argument for xadGetDefaultName() (V13) */ /* tags for xadAddFileEntry and xadAddDiskEntry (V10) */ #define XAD_SETINPOS (TAG_SIZ+240) /* set xai_InPos after call (V10) */ #define XAD_INSERTDIRSFIRST (TAG_INT+241) /* insert dirs at list start (V10) */ /* tags for xadConvertName (V12) */ #define XAD_PATHSEPERATOR (TAG_PTR+260) /* xadUINT16 *, default is {'/','\\',0} in source charset (V12) */ #define XAD_CHARACTERSET (TAG_INT+261) /* the characterset of string (V12) */ #define XAD_STRINGSIZE (TAG_INT+262) /* maximum size of following (V12) */ #define XAD_CSTRING (TAG_PTR+263) /* zero-terminated string (V12) */ #define XAD_PSTRING (TAG_PTR+264) /* lengthed Pascal string (V12) */ #define XAD_XADSTRING (TAG_PTR+265) /* an xad string (V12) */ #define XAD_ADDPATHSEPERATOR (TAG_INT+266) /* default is TRUE (V12) */ /* tags for xadGetFilename (V12) */ #define XAD_NOLEADINGPATH (TAG_INT+280) /* default is FALSE (V12) */ #define XAD_NOTRAILINGPATH (TAG_INT+281) /* default is FALSE (V12) */ #define XAD_MASKCHARACTERS (TAG_PTR+282) /* default are #?()[]~%*:|",1-31,127-160 (V12) */ #define XAD_MASKINGCHAR (TAG_INT+283) /* default is '_' (V12) */ #define XAD_REQUIREDBUFFERSIZE (TAG_PTR+284) /* pointer which should hold buf size (V12) */ /* Places 300-339 used for dates! */ /************************************************************************ * * * objects for xadAllocObjectA * * * ************************************************************************/ #define XADOBJ_ARCHIVEINFO 0x0001 /* struct xadArchiveInfo */ #define XADOBJ_FILEINFO 0x0002 /* struct xadFileInfo */ #define XADOBJ_DISKINFO 0x0003 /* struct xadDiskInfo */ #define XADOBJ_HOOKPARAM 0x0004 /* struct HookParam */ #define XADOBJ_DEVICEINFO 0x0005 /* struct xadDeviceInfo */ #define XADOBJ_PROGRESSINFO 0x0006 /* struct xadProgressInfo */ #define XADOBJ_TEXTINFO 0x0007 /* struct xadTextInfo */ #define XADOBJ_SPLITFILE 0x0008 /* struct xadSplitFile (V2) */ #define XADOBJ_SKIPINFO 0x0009 /* struct xadSkipInfo (V3) */ #define XADOBJ_IMAGEINFO 0x000A /* struct xadImageInfo (V4) */ #define XADOBJ_SPECIAL 0x000B /* struct xadSpecial (V11) */ /* result type of xadAllocVec */ #define XADOBJ_MEMBLOCK 0x0100 /* memory of requested size and type */ /* private type */ #define XADOBJ_STRING 0x0101 /* a typed XAD string (V12) */ /************************************************************************ * * * modes for xadCalcCRC126 and xadCalcCRC32 * * * ************************************************************************/ #define XADCRC16_ID1 0xA001 #define XADCRC32_ID1 0xEDB88320 /************************************************************************ * * * hook related stuff * * * ************************************************************************/ #define XADHC_READ 1 /* read data into buffer */ #define XADHC_WRITE 2 /* write buffer data to file/memory */ #define XADHC_SEEK 3 /* seek in file */ #define XADHC_INIT 4 /* initialize the hook */ #define XADHC_FREE 5 /* end up hook work, free stuff */ #define XADHC_ABORT 6 /* an error occured, delete partial stuff */ #define XADHC_FULLSIZE 7 /* complete input size is needed */ #define XADHC_IMAGEINFO 8 /* return disk image info (V4) */ struct xadHookParam { xadUINT32 xhp_Command; xadSignSize xhp_CommandData; xadPTR xhp_BufferPtr; xadSize xhp_BufferSize; xadSize xhp_DataPos; /* current seek position */ xadPTR xhp_PrivatePtr; xadTAGPTR xhp_TagList; /* allows to transport tags to hook (V9) */ }; /* xadHookAccess commands */ #define XADAC_READ 10 /* get data */ #define XADAC_WRITE 11 /* write data */ #define XADAC_COPY 12 /* copy input to output */ #define XADAC_INPUTSEEK 13 /* seek in input file */ #define XADAC_OUTPUTSEEK 14 /* seek in output file */ /************************************************************************ * * * support structures * * * ************************************************************************/ /* Own date structure to cover all possible dates in a human friendly format. xadConvertDates may be used to convert between different date structures and variables. */ struct xadDate { xadUINT32 xd_Micros; /* values 0 to 999999 */ xadINT32 xd_Year; /* values 1 to 2147483648 */ xadUINT8 xd_Month; /* values 1 to 12 */ xadUINT8 xd_WeekDay; /* values 1 to 7 */ xadUINT8 xd_Day; /* values 1 to 31 */ xadUINT8 xd_Hour; /* values 0 to 23 */ xadUINT8 xd_Minute; /* values 0 to 59 */ xadUINT8 xd_Second; /* values 0 to 59 */ }; #define XADDAY_MONDAY 1 /* monday is the first day and */ #define XADDAY_TUESDAY 2 #define XADDAY_WEDNESDAY 3 #define XADDAY_THURSDAY 4 #define XADDAY_FRIDAY 5 #define XADDAY_SATURDAY 6 #define XADDAY_SUNDAY 7 /* sunday the last day of a week */ struct xadDeviceInfo { /* for XAD_OUTDEVICE tag */ xadSTRPTR xdi_DeviceName; /* name of device */ xadUINT32 xdi_Unit; /* unit of device */ xadSTRPTR xdi_DOSName; /* instead of Device+Unit, dos name without ':' */ }; struct xadSplitFile { /* for XAD_INSPLITTED */ struct xadSplitFile *xsf_Next; xadUINT32 xsf_Type; /* XAD_INFILENAME, XAD_INFILEHANDLE, XAD_INMEMORY, XAD_INHOOK */ xadSize xsf_Size; /* necessary for XAD_INMEMORY, useful for others */ xadSize xsf_Data; /* FileName, Filehandle, Hookpointer or Memory */ }; struct xadSkipInfo { struct xadSkipInfo *xsi_Next; xadSize xsi_Position; /* position, where it should be skipped */ xadSize xsi_SkipSize; /* size to skip */ }; struct xadImageInfo { /* for XADHC_IMAGEINFO */ xadUINT32 xii_SectorSize; /* usually 512 */ xadUINT32 xii_FirstSector; /* of the image file */ xadUINT32 xii_NumSectors; /* of the image file */ xadUINT32 xii_TotalSectors; /* of this device type */ }; /* If the image file holds total data of disk xii_TotalSectors equals xii_NumSectors and xii_FirstSector is zero. Addition of xii_FirstSector and xii_NumSectors cannot exceed xii_TotalSectors value! */ /************************************************************************ * * * system information structure * * * ************************************************************************/ struct xadSystemInfo { xadUINT16 xsi_Version; /* master library version */ xadUINT16 xsi_Revision; /* master library revision */ xadSize xsi_RecogSize; /* size for recognition */ }; /************************************************************************ * * * information structures * * * ************************************************************************/ struct xadArchiveInfo { struct xadClient * xai_Client; /* pointer to unarchiving client */ xadPTR xai_PrivateClient; /* private client data */ xadSTRPTR xai_Password; /* password for crypted archives */ xadUINT32 xai_Flags; /* read only XADAIF_ flags */ xadUINT32 xai_LowCyl; /* lowest cylinder to unarchive */ xadUINT32 xai_HighCyl; /* highest cylinder to unarchive */ xadSize xai_InPos; /* input position, read only */ xadSize xai_InSize; /* input size, read only */ xadSize xai_OutPos; /* output position, read only */ xadSize xai_OutSize; /* output file size, read only */ struct xadFileInfo * xai_FileInfo; /* data pointer for file arcs */ struct xadDiskInfo * xai_DiskInfo; /* data pointer for disk arcs */ struct xadFileInfo * xai_CurFile; /* data pointer for current file arc */ struct xadDiskInfo * xai_CurDisk; /* data pointer for current disk arc */ xadERROR xai_LastError; /* last error, when XADAIF_FILECORRUPT (V2) */ xadSize * xai_MultiVolume; /* array of start offsets from parts (V2) */ struct xadSkipInfo * xai_SkipInfo; /* linked list of skip entries (V3) */ struct xadImageInfo *xai_ImageInfo; /* for filesystem clients (V5) */ xadSTRPTR xai_InName; /* Input archive name if available (V7) */ }; /* This structure is nearly complete private to either xadmaster or its clients. An application program may access for reading only xai_Client, xai_Flags, xai_FileInfo and xai_DiskInfo. For xai_Flags only XADAIF_CRYPTED and XADAIF_FILECORRUPT are useful. All the other stuff is private and should not be accessed! */ #define XADAIB_CRYPTED 0 /* archive entries are encrypted */ #define XADAIB_FILECORRUPT 1 /* file is corrupt, but valid entries are in the list */ #define XADAIB_FILEARCHIVE 2 /* unarchive file entry */ #define XADAIB_DISKARCHIVE 3 /* unarchive disk entry */ #define XADAIB_OVERWRITE 4 /* overwrite the file (PRIVATE) */ #define XADAIB_MAKEDIRECTORY 5 /* create directory when missing (PRIVATE) */ #define XADAIB_IGNOREGEOMETRY 6 /* ignore drive geometry (PRIVATE) */ #define XADAIB_VERIFY 7 /* verify is turned on for disk hook (PRIVATE) */ #define XADAIB_NOKILLPARTIAL 8 /* do not delete partial files (PRIVATE) */ #define XADAIB_DISKIMAGE 9 /* is disk image extraction (V5) */ #define XADAIB_FORMAT 10 /* format in disk hook (PRIVATE) */ #define XADAIB_NOEMPTYERROR 11 /* do not create empty error (PRIVATE) */ #define XADAIB_ONLYIN 12 /* in stuff only (PRIVATE) */ #define XADAIB_ONLYOUT 13 /* out stuff only (PRIVATE) */ #define XADAIB_USESECTORLABELS 14 /* use SectorLabels (PRIVATE) */ #define XADAIF_CRYPTED (1<) are currently not supported with normal Amiga filesystem. But the clients support them, if archive format holds such information. The protection bits (all 3 fields) should always be set using the xadConvertProtection procedure. Call it with as much protection information as possible. It extracts the relevant data at best (and also sets the 2 flags). DO NOT USE these fields directly, but always through xadConvertProtection call. */ #define XADFIB_CRYPTED 0 /* entry is crypted */ #define XADFIB_DIRECTORY 1 /* entry is a directory */ #define XADFIB_LINK 2 /* entry is a link */ #define XADFIB_INFOTEXT 3 /* file is an information text */ #define XADFIB_GROUPED 4 /* file is in a crunch group */ #define XADFIB_ENDOFGROUP 5 /* crunch group ends here */ #define XADFIB_NODATE 6 /* no date supported, CURRENT date is set */ #define XADFIB_DELETED 7 /* file is marked as deleted (V3) */ #define XADFIB_SEEKDATAPOS 8 /* before unarchiving the datapos is set (V3) */ #define XADFIB_NOFILENAME 9 /* there was no filename, using internal one (V6) */ #define XADFIB_NOUNCRUNCHSIZE 10 /* file size is unknown and thus set to zero (V6) */ #define XADFIB_PARTIALFILE 11 /* file is only partial (V6) */ #define XADFIB_MACDATA 12 /* file is Apple data fork (V7) */ #define XADFIB_MACRESOURCE 13 /* file is Apple resource fork (V7) */ #define XADFIB_EXTRACTONBUILD 14 /* allows extract file during scanning (V10) */ #define XADFIB_UNIXPROTECTION 15 /* UNIX protection bits are present (V11) */ #define XADFIB_DOSPROTECTION 16 /* MSDOS protection bits are present (V11) */ #define XADFIB_ENTRYMAYCHANGE 17 /* this entry may change until GetInfo is finished (V11) */ #define XADFIB_XADSTRFILENAME 18 /* the xfi_FileName fields is an XAD string (V12) */ #define XADFIB_XADSTRLINKNAME 19 /* the xfi_LinkName fields is an XAD string (V12) */ #define XADFIB_XADSTRCOMMENT 20 /* the xfi_Comment fields is an XAD string (V12) */ #define XADFIF_CRYPTED (1<