home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / HPACK78S.ZIP / system.h < prev    next >
C/C++ Source or Header  |  1992-11-30  |  36KB  |  1,057 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                        System-Specific Information Header                    *
  7. *                            SYSTEM.H  Updated 22/09/92                        *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1989 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. #ifndef _SYSTEM_DEFINED
  19.  
  20. #define _SYSTEM_DEFINED
  21.  
  22. /****************************************************************************
  23. *                                                                            *
  24. *                            Definitions for Amiga                            *
  25. *                                                                            *
  26. ****************************************************************************/
  27.  
  28. #ifdef __AMIGA__
  29.  
  30. #define ARCHIVE_OS        OS_AMIGA
  31.  
  32. /* Maximum Amiga path length (105 chars + null terminator) and filename length
  33.    (30 chars + null delimiter) */
  34.  
  35. #define MAX_PATH        106
  36. #define MAX_FILENAME    31
  37.  
  38. /* The file attribute type */
  39.  
  40. typedef BYTE            ATTR;    /* Attribute data type */
  41.  
  42. /* Mode/attribute bits for hcreat()/hmkdir() */
  43.  
  44. #define CREAT_ATTR        0x0D    /* Read/write/delete permission */
  45. #define MKDIR_ATTR        0        /* hmkdir()'s mode parameter ignored */
  46.  
  47. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  48.    Since the Amiga doesn't distinguish between normal and special files these
  49.    are treated identically */
  50.  
  51. #define FILES            1            /* Match normal files only */
  52. #define ALLFILES        1            /* Match special files as well */
  53. #define FILES_DIRS         2            /* Match normal files and directories */
  54. #define ALLFILES_DIRS    2            /* Match all files and directories */
  55.  
  56. /* The directory seperator (a logical slash), and its stringified equivalent */
  57.  
  58. #define SLASH            '/'
  59. #define SLASH_STR        "/"
  60.  
  61. /* File codes for what we want to match.  Since AmigaDos searches by
  62.    directory rather than filespec we just use null strings */
  63.  
  64. #define MATCH_ALL        ""            /* Just match anything */
  65. #define SLASH_MATCH_ALL    "/"            /* As above with directory delimiter */
  66. #define MATCH_ARCHIVE    ""            /* All archive files */
  67.  
  68. /* The type of case conversion to perform on file and directory names */
  69.  
  70. #define caseConvert(x)    x            /* No conversion */
  71.  
  72. /* The data block used by findFirst()/findNext()/findEnd() */
  73.  
  74. typedef struct {
  75.                LONG fTime;            /* File modification datestamp */
  76.                LONG fSize;            /* File size */
  77.                char fName[ MAX_FILENAME ];    /* File name */
  78.                ATTR fAttr;            /* File attributes */
  79.  
  80.                /* Amiga-specific information */
  81.                void *lock;            /* Dir/file lock (actually a FileLock *) */
  82.                void *infoBlock;        /* Dir/file info (actually a FileInfoBlock *) */
  83.                BOOLEAN isDir;        /* Whether file is directory or not */
  84.                BOOLEAN hasComment;    /* Whether file/dir has attached comment */
  85.                char matchAttr;        /* Attributes to match on */
  86.                } FILEINFO;
  87.  
  88. /* Determine whether a found file is a directory or not (a BOOLEAN set
  89.    up by findFirst()/findNext()).  We can't use a name of isDirectory for
  90.    the member since DICE gets confused with the macro name */
  91.  
  92. #define isDirectory(fileInfo)        fileInfo.isDir
  93.  
  94. /* The type of case conversion to perform on file and directory names */
  95.  
  96. #define caseConvert(x)    x            /* No conversion */
  97. #define caseMatch        toupper        /* Force uppercase */
  98. #define caseStrcmp        stricmp        /* Non-case-sensitive match */
  99. #define caseStrncmp        strnicmp    /* Non-case-sensitive match */
  100.  
  101. /* Whether spaces are legal in filenames */
  102.  
  103. #define SPACE_OK        TRUE
  104.  
  105. /* Dummy routine for isSameFile() - the OS takes care of this for us by
  106.    not letting the file be opened */
  107.  
  108. #define isSameFile(x,y)    FALSE
  109.  
  110. /* Dummy routines for nonportable functions */
  111.  
  112. #define setDirecTime(x,y)    /* Seems impossible to do under AmigaDos */
  113.  
  114. /* Prototypes for extra routines needed by some compilers */
  115.  
  116. #if defined( LATTICE ) && !defined( __SASC )
  117.   void memmove( char *dest, char *src, int length );
  118. #endif /* LATTICE && !__SASC */
  119.  
  120. #endif /* __AMIGA__ */
  121.  
  122. /****************************************************************************
  123. *                                                                            *
  124. *                            Definitions for Apple IIgs                        *
  125. *                                                                            *
  126. ****************************************************************************/
  127.  
  128. #ifdef __IIGS__
  129.  
  130. #define ARCHIVE_OS        OS_IIGS
  131.  
  132. /* Maximum path length and filename length */
  133.  
  134. #define MAX_PATH        255
  135. #define MAX_FILENAME    15
  136.  
  137. /* File attributes */
  138.  
  139. typedef WORD            ATTR;        /* Attribute data type */
  140.  
  141. #define RDONLY            0x01        /* Read only attribute */
  142. #define HIDDEN            0x02        /* Hidden file */
  143. #define DIRECT            0x000F        /* Directories */
  144.  
  145. /* Mode/attribute bits for hcreat()/hmkdir() */
  146.  
  147. #define CREAT_ATTR        1             /* Read/write permission */
  148. #define MKDIR_ATTR        0            /* mkdirs()'s mode parameter ignored */
  149.  
  150. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  151.    On the IIgs invisible files are treated seperately */
  152.  
  153. #define FILES            1            /* Match normal files only */
  154. #define ALLFILES        2            /* Match special files as well */
  155. #define FILES_DIRS         3            /* Match normal files and directories */
  156. #define ALLFILES_DIRS    4            /* Match all files and directories */
  157.  
  158. /* The data block used by findFirst()/findNext()/findEnd() */
  159.  
  160. typedef struct {
  161.                LONG fTime;            /* File modification datestamp */
  162.                LONG fSize;            /* File size */
  163.                char fName[ MAX_FILENAME ];    /* File name */
  164.                ATTR fAttr;            /* File attributes */
  165.  
  166.                /* Apple IIgs-specific information */
  167.                WORD fType;            /* File type */
  168.                LONG fAuxType;        /* Auxiliary file type */
  169. /*               WORD fStorage;        // Storage type */
  170.                LONG fCrtDate;        /* First part of creation time and date */
  171.                LONG fCrtTime;        /* Second part of creation time and date */
  172. /*               LONG fModDate;        // First part of modification time and date */
  173. /*               LONG fModTime;        // Second part of modification time and date */
  174. /*               LONG fOptionList;    // Option list pointer for FST */
  175. /*               LONG fBlocks;        // Number of blocks used by file */
  176.                LONG fResSize;        /* Size of file's resource fork */
  177. /*               LONG fResBlocks;        // Number of blocks used by resource fork */
  178.                } FILEINFO;
  179.  
  180. /* Determine whether a found file is a directory or not */
  181.  
  182. #define isDirectory(fileInfo)        ( fileInfo.fType == DIRECT )
  183.  
  184. /* Dummy routines for nonportable functions */
  185.  
  186. #define setFileTime(x,y)    hputs( "Need to implement setFileTime()" )
  187. #define setDirecTime(x,y)    hputs( "Need to implement setDirTime()" )
  188. #define getCountry()        hputs( "Need to implement getCountry()" )
  189. #define getScreenSize()        hputs( "Need to implement getScreenSize()" )
  190. #define findFirst(x,y,z)    hputs( "Need to implement findFirst()" )
  191. #define findNext(x)            hputs( "Need to implement findNext()" )
  192. #define findEnd(x)            hputs( "Need to implement findEnd()" )
  193.  
  194. #endif /* __IIGS__ */
  195.  
  196. /****************************************************************************
  197. *                                                                            *
  198. *                            Definitions for Archimedes                        *
  199. *                                                                            *
  200. ****************************************************************************/
  201.  
  202. #ifdef __ARC__
  203.  
  204. #define ARCHIVE_OS        OS_ARCHIMEDES
  205.  
  206. /* Maximum path length and filename length.  Note that although we can
  207.    accept as input a filename of up to 31 chars under some IFS's
  208.    supported by the NetFS, we have to truncate to the ADFS limit of 10
  209.    chars on extraction.  This is handled by code in FILESYS.C.  Once
  210.    Risc-OS 3, the System 7 of the Archimedes world, appears, we can use a
  211.    SWI to find out how long filenames can be */
  212.  
  213. #define MAX_PATH        256
  214. #define MAX_FILENAME    32
  215.  
  216. /* The size of the directory buffer used by findFirst/findNext() */
  217.  
  218. #define DIRINFO_SIZE    100        /* Size of one directory entry (generous value) */
  219. #define DIRBUF_ENTRIES    20        /* No.entries in one buffer */
  220.  
  221. /* The file attribute type and various useful attributes */
  222.  
  223. typedef BYTE            ATTR;        /* Attribute data type */
  224.  
  225. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  226.    Since the Arc doesn't distinguish between normal and special files these
  227.    are treated identically */
  228.  
  229. #define FILES            1            /* Match normal files only */
  230. #define ALLFILES        1            /* Match special files as well */
  231. #define FILES_DIRS         2            /* Match normal files and directories */
  232. #define ALLFILES_DIRS    2            /* Match all files and directories */
  233.  
  234. /* Mode/attribute bits for hcreat()/hmkdir() */
  235.  
  236. #define CREAT_ATTR        0            /* Read/write permission */
  237. #define MKDIR_ATTR        0            /* Ignored by hmkdir() */
  238.  
  239. /* The directory seperator (a logical slash), and its stringified equivalent */
  240.  
  241. #define SLASH            '.'            /* I kid you not, it uses dots */
  242. #define SLASH_STR        "."
  243.  
  244. /* The types of files findFirst() can match (when it's not matching a
  245.    literal file or directory name) */
  246.  
  247. #define MATCH_ALL        "*"            /* All files and directories */
  248. #define SLASH_MATCH_ALL    ".*"        /* As above with directory delimiter */
  249. #define MATCH_ARCHIVE    "\x01"        /* All archive files */
  250.  
  251. /* The data block used by findFirst()/findNext() */
  252.  
  253. typedef struct {
  254.                LONG fTime;            /* File modification datestamp */
  255.                LONG fSize;            /* File size */
  256.                char fName[ MAX_FILENAME ];    /* File name */
  257.                ATTR fAttr;            /* File attributes */
  258.  
  259.                /* Arc-specific information */
  260.                int type;            /* File type */
  261.                LONG loadAddr;        /* File load address */
  262.                LONG execAddr;        /* Execute address */
  263.                char matchAttr;        /* File attributes to match on */
  264.                BOOLEAN isDirectory;    /* Whether file is a directory or not */
  265.                BOOLEAN wantArchive;    /* Whether we want an archive filetype */
  266.                long dirPos;            /* Current position in directory.  Force
  267.                                        dirBuffer to be longword-aligned */
  268.                BYTE dirBuffer[ DIRINFO_SIZE * DIRBUF_ENTRIES ];
  269.                int currEntry;        /* Current buffer entry */
  270.                int totalEntries;    /* Total entries in buffer */
  271.                void *nextRecordPtr;    /* Pointer to next record in buffer */
  272.                char dirPath[ MAX_PATH ];        /* Dir.path to search on */
  273.                int dirPathLen;                    /* Length of dir.path */
  274.                char fileSpec[ MAX_FILENAME ];    /* Filespec to search for */
  275.                } FILEINFO;
  276.  
  277. /* Determine whether a found file is a directory or not (a BOOLEAN set up by
  278.    findFirst()/findNext()) */
  279.  
  280. #define isDirectory(fileInfo)    ( fileInfo.isDirectory )
  281.  
  282. /* The type of case conversion to perform on file and directory names */
  283.  
  284. #define caseConvert(x)    x            /* No conversion */
  285. #define caseMatch        toupper        /* Force uppercase */
  286. #define caseStrcmp        stricmp        /* Non-case-sensitive match */
  287. #define caseStrncmp        strnicmp    /* Non-case-sensitive match */
  288.  
  289. /* Whether spaces are legal in filenames */
  290.  
  291. #define SPACE_OK        FALSE
  292.  
  293. /* Dummy routine for isSameFile() - we could use CanonicalizePath() from
  294.    RiscOS 3 but that would make it version-dependant */
  295.  
  296. #define isSameFile(x,y)    FALSE
  297.  
  298. /* Dummy routines for nonportable/unused functions */
  299.  
  300. #define setDirecTime(x,y)    /* Impossible to do */
  301. #define initExtraInfo()        /* Arc files have no memory-held extra info */
  302. #define copyExtraInfo(x,y)
  303. #define endExtraInfo()
  304.  
  305. /* Dummy routine not needed in Arc version */
  306.  
  307. #define findEnd(x)
  308.  
  309. /* Extra routines not part of the Archimedes ANSI libraries */
  310.  
  311. int strnicmp( const char *src, const char *dest, int length );
  312. int stricmp( const char *src, const char *dest );
  313. void strlwr( char *string );
  314.  
  315. #endif /* __ARC__ */
  316.  
  317. /****************************************************************************
  318. *                                                                            *
  319. *                            Definitions for Atari                            *
  320. *                                                                            *
  321. ****************************************************************************/
  322.  
  323. #ifdef __ATARI__
  324.  
  325. #define ARCHIVE_OS        OS_ATARI
  326.  
  327. /* Maximum Gem-DOS path length (63 bytes + null terminator) and filename
  328.    length (8.3 + null delimiter) */
  329.  
  330. #define MAX_PATH        64
  331. #define MAX_FILENAME    13
  332.  
  333. /* The file attribute type and various useful attributes */
  334.  
  335. typedef BYTE            ATTR;    /* Attribute data type */
  336.  
  337. #define HIDDEN            0x02    /* Hidden file */
  338. #define SYSTEM            0x04    /* System file */
  339. #define DIRECT            0x10    /* Directory bit */
  340.  
  341. /* Attributes as used by HPACK.  Gem-DOS distinguishes between normal files
  342.    (DEFAULT and RDONLY) and special files (HIDDEN and SYSTEM) so there
  343.    are two sets of attributes for matching, one for normal files and one
  344.    for special files */
  345.  
  346. #define FILES            0        /* No attributes to match on (will still
  347.                                    match DEFAULT and RDONLY under Gem-DOS) */
  348. #define ALLFILES        ( HIDDEN | SYSTEM )
  349.                                 /* All useful file attribute types. Again
  350.                                    will also match DEFAULT and RDONLY */
  351. #define FILES_DIRS        DIRECT    /* All normal files + directories */
  352. #define ALLFILES_DIRS    ( ALLFILES | DIRECT )
  353.                                 /* All useful file attribute types + dirs */
  354.  
  355. /* Mode/attribute bits for hcreat()/hmkdir() */
  356.  
  357. #define CREAT_ATTR        ( S_IREAD | S_IWRITE )
  358. #define MKDIR_ATTR        0
  359.  
  360. /* The directory seperator (a logical slash), and its stringified equivalent */
  361.  
  362. #define SLASH            '/'
  363. #define SLASH_STR        "/"
  364.  
  365. /* The types of files findFirst() can match (when it's not matching a
  366.    literal file or directory name) */
  367.  
  368. #define MATCH_ALL        "*.*"    /* All files and directories */
  369. #define SLASH_MATCH_ALL    "/*.*"    /* As above with directory delimiter */
  370. #define MATCH_ARCHIVE    "*.HPK"    /* All archive files */
  371.  
  372. /* The data block used by findFirst()/findNext() */
  373.  
  374. typedef struct {
  375.                ATTR fAttr;                    /* File attributes */
  376.                LONG fTime;                    /* File modification datestamp */
  377.                LONG fSize;                    /* File size */
  378.                char fName[ MAX_FILENAME ];    /* File name */
  379.                BYTE dosReserved[ 22 ];        /* Reserved by GemDOS */
  380.                } FILEINFO;
  381.  
  382. /* Determine whether a found file is a directory or not */
  383.  
  384. #define isDirectory(fileInfo)    ( fileInfo.fAttr & DIRECT )
  385.  
  386. /* The type of case conversion to perform on file and directory names.
  387.    In both cases we force uppercase */
  388.  
  389. #define caseConvert        toupper                /* Force uppercase */
  390. #define caseMatch        toupper                /* Force uppercase */
  391. #define caseStrcmp        stricmp                /* Non-case-sensitive match */
  392. #define caseStrncmp        strnicmp            /* Non-case-sensitive match */
  393.  
  394. /* Whether spaces are legal in filenames */
  395.  
  396. #define SPACE_OK        FALSE
  397.  
  398. /* Dummy routines for nonportable/unused functions */
  399.  
  400. #define setDirecTime(x,y)    /* Virtually impossible to do under Gem-DOS */
  401. #define initExtraInfo()        /* Atari files have no extra info */
  402. #define copyExtraInfo(x,y)
  403. #define setExtraInfo(x)
  404. #define endExtraInfo()
  405.  
  406. /* Dummy routine not needed in Atari version */
  407.  
  408. #define findEnd(x)
  409.  
  410. #endif /* __ATARI__ */
  411.  
  412. /****************************************************************************
  413. *                                                                            *
  414. *                            Definitions for Macintosh                        *
  415. *                                                                            *
  416. ****************************************************************************/
  417.  
  418. #ifdef __MAC__
  419.  
  420. #define ARCHIVE_OS        OS_MAC
  421.  
  422. /* Maximum path length and filename length.  Note that although in theory
  423.    Mac paths are limited to 254 characters in length, the way HPACK does it
  424.    allows an unlimited path length - 512 seems like a safe upper limit */
  425.  
  426. #define MAX_PATH        512
  427. #define MAX_FILENAME    31
  428.  
  429. /* The file attribute type and various useful attributes */
  430.  
  431. typedef WORD            ATTR;        /* Attribute data type */
  432.  
  433. /* Mode/attribute bits for hcreat()/hmkdir() */
  434.  
  435. #define CREAT_ATTR        0            /* hcreat()'s mode parameter ignored */
  436. #define MKDIR_ATTR        0            /* hmkdir()'s mode parameter ignored */
  437.  
  438. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  439.    On the Mac invisible files are treated seperately */
  440.  
  441. #define FILES            1            /* Match normal files only */
  442. #define ALLFILES        1            /* Match special files as well */
  443. #define FILES_DIRS         2            /* Match normal files and directories */
  444. #define ALLFILES_DIRS    2            /* Match all files and directories */
  445.  
  446. /* The directory seperator (a logical slash), and its stringified equivalent */
  447.  
  448. #define SLASH            '\x01'
  449. #define SLASH_STR        "\x01"
  450.  
  451. /* File codes for what we want to match */
  452.  
  453. #define MATCH_ALL        "\x02"            /* Just match anything */
  454. #define SLASH_MATCH_ALL    "\x01\x02"        /* As above with directory delimiter */
  455. #define MATCH_ARCHIVE    "\x03"            /* All archive files */
  456.  
  457. /* The data block used by findFirst()/findNext()/findEnd() */
  458.  
  459. typedef struct {
  460.                LONG fTime;            /* File modification datestamp */
  461.                LONG fSize;            /* File size */
  462.                char fName[ MAX_FILENAME ];    /* File name */
  463.                ATTR fAttr;            /* File attributes */
  464.  
  465.                /* Mac-specific information */
  466.                LONG createTime;        /* File creation time */
  467.                LONG backupTime;        /* File backup time */
  468.                LONG type;            /* The file's type */
  469.                LONG creator;        /* The file's creator */
  470.                LONG resSize;        /* Size of the resource fork */
  471.                BYTE versionNumber;    /* Version number of the file */
  472.                int entryNo;            /* Number of this entry in the directory */
  473.                short vRefNum;        /* Ref.no for volume file is on */
  474.                long dirID;            /* Directory ID for dir.file is in */
  475.                char matchAttr;        /* File attributes to match on */
  476.                BOOLEAN isDirectory;    /* Whether the file is a directory or not */
  477.                BOOLEAN matchArchive;/* Whether we want to match only archives */
  478.                } FILEINFO;
  479.  
  480. /* Determine whether a found file is a directory or not (a BOOLEAN set up
  481.    by findFirst()/findNext()) */
  482.  
  483. #define isDirectory(fileInfo)        fileInfo.isDirectory
  484.  
  485. /* The type of case conversion to perform on file and directory names */
  486.  
  487. #define caseConvert(x)    x            /* No conversion */
  488. #define caseMatch        toupper        /* Force uppercase */
  489. #define caseStrcmp        stricmp        /* Non-case-sensitive match */
  490. #define caseStrncmp        strnicmp    /* Non-case-sensitive match */
  491.  
  492. /* Whether spaces are legal in filenames */
  493.  
  494. #define SPACE_OK        TRUE
  495.  
  496. /* Dummy routine for isSameFile() - the OS takes care of this for us by
  497.    not letting the file be opened */
  498.  
  499. #define isSameFile(x,y)    FALSE
  500.  
  501. /* Prototypes for routines the Mac doesn't have */
  502.  
  503. void strlwr( const char *string );
  504. int stricmp( const char *src, const char *dest );
  505. int strnicmp( const char *src, const char *dest, int length );
  506.  
  507. /* Dummy routines for nonportable/nonused functions */
  508.  
  509. #define setDirecTime(dirName,time)    setFileTime( dirName, time )
  510. #define findEnd(x)
  511.  
  512. #define initExtraInfo()        /* Not needed at the moment */
  513. #define endExtraInfo()
  514.  
  515. #endif /* __MAC__ */
  516.  
  517. /****************************************************************************
  518. *                                                                            *
  519. *                            Definitions for MSDOS                            *
  520. *                                                                            *
  521. ****************************************************************************/
  522.  
  523. #ifdef __MSDOS__
  524.  
  525. #define ARCHIVE_OS        OS_MSDOS
  526.  
  527. /* Maximum DOS path length (63 bytes + null terminator) and filename length
  528.    (8.3 + null delimiter) */
  529.  
  530. #define MAX_PATH        64
  531. #define MAX_FILENAME    13
  532.  
  533. /* The file attribute type and various useful attributes */
  534.  
  535. typedef BYTE            ATTR;    /* Attribute data type */
  536.  
  537. #define HIDDEN            0x02    /* Hidden file */
  538. #define SYSTEM            0x04    /* System file */
  539. #define DIRECT            0x10    /* Directory bit */
  540.  
  541. /* Attributes as used by HPACK.  DOS distinguishes between normal files
  542.    (DEFAULT and RDONLY) and special files (HIDDEN and SYSTEM) so there
  543.    are two sets of attributes for matching, one for normal files and one
  544.    for special files */
  545.  
  546. #define FILES            0        /* No attributes to match on (will still
  547.                                    match DEFAULT and RDONLY under DOS) */
  548. #define ALLFILES        ( HIDDEN | SYSTEM )
  549.                                 /* All useful file attribute types. Again
  550.                                    will also match DEFAULT and RDONLY */
  551. #define FILES_DIRS        DIRECT    /* All normal files + directories */
  552. #define ALLFILES_DIRS    ( ALLFILES | DIRECT )
  553.                                 /* All useful file attribute types + dirs */
  554.  
  555. /* Mode/attribute bits for hcreat()/hmkdir() */
  556.  
  557. #define CREAT_ATTR        0        /* Bits to set for hcreat() */
  558. #define MKDIR_ATTR        0        /* Bits to set for hmkdir() */
  559.  
  560. /* The directory seperator (a logical slash), and its stringified equivalent */
  561.  
  562. #define SLASH            '/'
  563. #define SLASH_STR        "/"
  564.  
  565. /* The types of files findFirst() can match (when it's not matching a
  566.    literal file or directory name) */
  567.  
  568. #define MATCH_ALL        "*.*"    /* All files and directories */
  569. #define SLASH_MATCH_ALL    "/*.*"    /* As above with directory delimiter */
  570. #define MATCH_ARCHIVE    "*.HPK"    /* All archive files */
  571.  
  572. /* The data block used by findFirst()/findNext().  Remember to change
  573.    findFirst() in HPACKIO.ASM if this struct is changed */
  574.  
  575. typedef struct {
  576.                BYTE dosReserved[ 21 ];        /* Reserved by DOS */
  577.                ATTR fAttr;                    /* File attributes */
  578.                LONG fTime;                    /* File modification datestamp */
  579.                LONG fSize;                    /* File size */
  580.                char fName[ MAX_FILENAME ];    /* File name */
  581.                } FILEINFO;
  582.  
  583. /* Determine whether a found file is a directory or not */
  584.  
  585. #define isDirectory(fileInfo)    ( fileInfo.fAttr & DIRECT )
  586.  
  587. /* The type of case conversion to perform on file and directory names.
  588.    In both cases we force uppercase */
  589.  
  590. #define caseConvert        toupper                /* Force uppercase */
  591. #define caseMatch        toupper                /* Force uppercase */
  592. #define caseStrcmp        stricmp                /* Non-case-sensitive match */
  593. #define caseStrncmp        strnicmp            /* Non-case-sensitive match */
  594.  
  595. /* Whether spaces are legal in filenames */
  596.  
  597. #define SPACE_OK        FALSE
  598.  
  599. /* Dummy routines for nonportable/unused functions */
  600.  
  601. #define setDirecTime(x,y)    /* Virtually impossible to do under DOS */
  602. #define initExtraInfo()        /* DOS files have no extra info */
  603. #define copyExtraInfo(x,y)
  604. #define setExtraInfo(x)
  605. #define endExtraInfo()
  606.  
  607. /* Dummy routine not needed in MSDOS version */
  608.  
  609. #define findEnd(x)
  610.  
  611. /* Prototype for isDevice() routine */
  612.  
  613. BOOLEAN isDevice( const FD theFD );
  614.  
  615. #endif /* __MSDOS__ */
  616.  
  617. /****************************************************************************
  618. *                                                                            *
  619. *                            Definitions for OS/2                            *
  620. *                                                                            *
  621. ****************************************************************************/
  622.  
  623. #ifdef __OS2__
  624.  
  625. #define ARCHIVE_OS        OS_OS2
  626.  
  627. /* Maximum OS/2 path length and filename length (For HPFS Max) */
  628.  
  629. #define MAX_PATH        260
  630. #define MAX_FILENAME    256
  631.  
  632. /* File attributes */
  633.  
  634. typedef BYTE            ATTR;        /* Attribute data type */
  635.  
  636. #define RDONLY            0x01        /* Read only attribute */
  637. #define HIDDEN            0x02        /* Hidden file */
  638. #define SYSTEM            0x04        /* System file */
  639. #define LABEL            0x08        /* Volume label */
  640. #define DIRECT            0x10        /* Directory */
  641. #define ARCH            0x20        /* Archive bit set */
  642.  
  643. /* Attributes as used by HPACK.  OS/2 distinguishes between normal files
  644.    (DEFAULT and READONLY) and special files (RDONLY and SYSTEM) so there
  645.    are two sets of attributes for matching, one for normal files and one
  646.    for special files */
  647.  
  648. #define FILES            0        /* No attributes to match on (will still
  649.                                    match DEFAULT and RDONLY under OS/2) */
  650. #define ALLFILES        ( HIDDEN | SYSTEM )
  651.                                 /* All useful file attribute types. Again
  652.                                    will also match DEFAULT and RDONLY */
  653. #define FILES_DIRS        DIRECT    /* All normal files + directories */
  654. #define ALLFILES_DIRS    ( ALLFILES | DIRECT )
  655.                                 /* All useful file attribute types + dirs */
  656.  
  657. /* Mode/attribute bits for hcreat()/hmkdir() */
  658.  
  659. #define CREAT_ATTR        ( O_RDWR | S_DENYRDWR )
  660. #define MKDIR_ATTR        0
  661.  
  662. /* The directory seperator (a logical slash), and its stringified equivalent */
  663.  
  664. #define SLASH            '/'
  665. #define SLASH_STR        "/"
  666.  
  667. /* The types of files findFirst() can match (when it's not matching a
  668.    literal file or directory name) */
  669.  
  670. #define MATCH_ALL        "*.*"    /* All files and directories */
  671. #define SLASH_MATCH_ALL    "/*.*"    /* As above with directory delimiter */
  672. #define MATCH_ARCHIVE    "*.HPK"    /* All archive files */
  673.  
  674. /* The data block used by findFirst()/findNext() */
  675.  
  676. typedef struct {
  677.                LONG fTime;                     /* File modification datestamp */
  678.                LONG fSize;                    /* File size */
  679.                char fName[ MAX_FILENAME ];    /* File name */
  680.                ATTR fAttr;                    /* File attributes */
  681.  
  682.                /* OS/2-specific information */
  683.                int hdir;                    /* Dir.handle ret.by DosFindFirst() */
  684.                LONG eaSize;                    /* Size of extended attributes */
  685.                LONG cTime;                    /* File creation datestamp */
  686.                LONG aTime;                    /* File access datestamp */
  687.                } FILEINFO;
  688.  
  689. /* Determine whether a found file is a directory or not */
  690.  
  691. #define isDirectory(fileInfo)    ( fileInfo.fAttr == DIRECT )
  692.  
  693. /* The type of case conversion to perform on file and directory names.
  694.    If this is an HPFS volume, we leave case as is; otherwise, we force
  695.    uppercase.  When performing a match, we force uppercase so as to be
  696.    case-insensitive */
  697.  
  698. extern BOOLEAN isHPFS;        /* Whether this is an HPFS filesystem or not */
  699. extern BOOLEAN destIsHPFS;    /* Whether the destination FS is HPFS or not */
  700.  
  701. #define caseConvert(x)    ( isHPFS ? ( x ) : toupper( x ) )
  702. #define caseMatch        toupper                /* Force uppercase */
  703. #define caseStrcmp        stricmp                /* Non-case-sensitive match */
  704. #define caseStrncmp        strnicmp            /* Non-case-sensitive match */
  705.  
  706. /* Whether spaces are legal in filenames */
  707.  
  708. #define SPACE_OK        destIsHPFS            /* Determine at runtime */
  709.  
  710. /* Dummy routines for nonportable/unused functions */
  711.  
  712. #define setDirecTime(dirName,time)    setFileTime( dirName, time )
  713. #define initExtraInfo()                        /* Done on the fly */
  714. #define endExtraInfo()
  715.  
  716. #ifdef GCC
  717.  
  718. /* Extra routines not part of gcc */
  719.  
  720. int strnicmp( const char *src, const char *dest, int length );
  721. int stricmp( const char *src, const char *dest );
  722. void strlwr( char *string );
  723.  
  724. #endif /* GCC */
  725.  
  726. #endif /* __OS2__ */
  727.  
  728. /****************************************************************************
  729. *                                                                            *
  730. *                            Definitions for UNIX                            *
  731. *                                                                            *
  732. ****************************************************************************/
  733.  
  734. #ifdef __UNIX__
  735.  
  736. #define ARCHIVE_OS        OS_UNIX
  737.  
  738. #include <utime.h>
  739. #include <sys/stat.h>
  740. #if !defined( ISC )
  741.   #include <unistd.h>
  742.   #include <dirent.h>
  743. #endif /* !ISC */
  744. #if defined( AIX) || defined( AIX386 ) || defined( AIX370 )
  745.   #include <limits.h>
  746.   #include <sys/dir.h>
  747. #endif /* AIX || AIX386 || AIX370 */
  748.  
  749. /* Maximum path length (x bytes + null terminator) and filename length
  750.    (y bytes + null terminator) */
  751.  
  752. #if defined( GENERIC ) || defined( IRIX ) || defined( LINUX ) || \
  753.     defined( SUNOS ) || defined( ULTRIX ) || defined( ULTRIX_OLD )
  754.   #define MAX_PATH            ( 256 + 1 )
  755.   #define MAX_FILENAME        ( 128 + 1 )
  756. #elif defined( POSIX )
  757.   #define MAX_PATH          ( _POSIX_PATH_MAX + 1 )
  758.   #define MAX_FILENAME        ( NAME_MAX + 1 )
  759. #elif defined( AIX ) || defined( AIX370 ) || defined( AIX386 )
  760.   #define MAX_PATH            1023
  761.   #define MAX_FILENAME        255
  762. #elif defined( SVR4 )
  763.   #define MAX_PATH            ( 64 + 1 )
  764.   #define MAX_FILENAME        ( 14 + 1 )
  765. #elif defined( MINT )
  766.   #define MAX_PATH            64
  767.   #define MAX_FILENAME        13
  768. #else
  769.   #error Need to define filename/path length in system.h
  770. #endif /* Various mutation-dependant defines */
  771.  
  772. /* The size of the directory buffer used by findFirst/findNext() */
  773.  
  774. #define DIRINFO_SIZE        sizeof( struct direct )
  775. #ifndef POSIX
  776.   #define DIRBUF_ENTRIES    20        /* No.entries in one buffer */
  777. #else
  778.   #define DIRBUF_ENTRIES    _DIRBUF    /* No.entries in one buffer */
  779. #endif /* !POSIX */
  780.  
  781. /* The file attribute type and various useful attributes */
  782.  
  783. typedef WORD            ATTR;        /* Attribute data type */
  784.  
  785. /* Mode/attribute bits for hcreat()/hmkdir() */
  786.  
  787. #define CREAT_ATTR        0644        /* Bits to set for hcreat() */
  788. #define MKDIR_ATTR        0744        /* Bits to set for hmkdir() */
  789.  
  790. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  791.    Since Unix doesn't distinguish between normal and special files these
  792.    are treated identically */
  793.  
  794. #define FILES            1            /* Match normal files only */
  795. #define ALLFILES        1            /* Match special files as well */
  796. #define FILES_DIRS         2            /* Match normal files and directories */
  797. #define ALLFILES_DIRS    2            /* Match all files and directories */
  798.  
  799. /* The directory seperator (a logical slash), and its stringified equivalent */
  800.  
  801. #define SLASH            '/'
  802. #define SLASH_STR        "/"
  803.  
  804. /* The types of files findFirst() can match (when it's not matching a
  805.    literal file or directory name) */
  806.  
  807. #define MATCH_ALL        "."            /* All files and directories */
  808. #define SLASH_MATCH_ALL    "/."        /* As above with directory delimiter */
  809. #define MATCH_ARCHIVE    "."            /* All archive files */
  810.  
  811. /* The data block used by findFirst()/findNext()/findEnd() */
  812.  
  813. typedef struct {
  814.                LONG fTime;            /* File modification datestamp */
  815.                LONG fSize;            /* File size */
  816.                char fName[ MAX_FILENAME ];    /* File name */
  817.                ATTR matchAttr;        /* File attributes to match on */
  818.  
  819.                /* Unix-specific information */
  820.                DIR *dirBuf;            /* Directory buffer. */
  821.                char dName[ MAX_PATH ];    /* Pathname for this dir. */
  822.                struct stat statInfo;/* Info returned by stat() */
  823.                } FILEINFO;
  824.  
  825. /* Determine whether a found file is a directory or not */
  826.  
  827. #define isDirectory(fileInfo)    ( ( fileInfo.statInfo.st_mode & S_IFMT ) == S_IFDIR )
  828.  
  829. /* The type of case conversion to perform on file and directory names.
  830.    In both cases we leave it as is, to be case-insensitive */
  831.  
  832. #define caseConvert(x)    x            /* No conversion */
  833. #define caseMatch(x)    x
  834. #define caseStrcmp        strcmp        /* Case-sensitive string match */
  835. #define caseStrncmp        strncmp        /* Case-sensitive string match */
  836.  
  837. /* Whether spaces are legal in filenames */
  838.  
  839. #if defined( AIX ) || defined( AIX386 ) || defined( AIX370 ) || \
  840.     defined( GENERIC ) || defined( IRIX ) || defined( ULTRIX ) || \
  841.     defined( ULTRIX_OLD )
  842.   #define SPACE_OK        TRUE
  843. #else
  844.   #define SPACE_OK        FALSE
  845. #endif /* Space OK in filenames */
  846.  
  847. /* Prototypes/defines for standard UNIX routines */
  848.  
  849. #define setDirecTime(dirName,time)    setFileTime( dirName, time )
  850.  
  851. /* Dummy routines for nonportable/unused functions */
  852.  
  853. #define initExtraInfo()        /* Unix files have no extra info */
  854. #define copyExtraInfo(x,y)
  855. #define setExtraInfo(x)
  856. #define endExtraInfo()
  857.  
  858. /* Definition profiles for different variants of Unix.  The following can be
  859.    turned on through the use of defines: NEED_MEMMOVE, NEED_MKDIR,
  860.    NEED_RENAME, NEED_STRLWR, NEED_STRNICMP */
  861.  
  862. #if defined( AIX ) || defined( AIX370 ) || defined( AIX386 )
  863.   #define NEED_STRLWR                    /* AIX RS6000, AIX 386, AIX 370 */
  864.   #define NEED_STRNICMP
  865. #elif defined( GENERIC )                /* Generic */
  866.   #define NEED_STRLWR
  867.   #define NEED_STRNICMP
  868. #elif defined( IRIX )                    /* Irix */
  869.   #define NEED_STRLWR
  870.   #define NEED_STRNICMP
  871. #elif defined( ISC )                    /* ISC Unix */
  872. #elif defined( LINUX )                    /* Linux */
  873.   #define NEED_STRLWR
  874.   #define NEED_STRNICMP
  875. #elif defined( MINT )                    /* MiNT */
  876.   #error Need to set up definition profile in system.h
  877. #elif defined( POSIX )                    /* Posix */
  878. #elif defined( SUNOS )                    /* SunOS */
  879.   #define NEED_MEMMOVE
  880.   #define NEED_STRLWR
  881.   #define NEED_STRNICMP
  882. #elif defined( SVR4 )                    /* SVR4 */
  883.   #define NEED_STRLWR
  884.   #define NEED_STRNICMP
  885. #elif defined( ULTRIX )                    /* Ultrix 4.x and above */
  886.   #define NEED_STRLWR
  887.   #define NEED_STRNICMP
  888. #elif defined( ULTRIX_OLD )                /* Ultrix 3.x and below */
  889.   #define NEED_STRLWR
  890.   #define NEED_MEMMOVE
  891.   #define NEED_STRNICMP
  892. #elif defined( ESIX )                    /* Esix */
  893.   #define NEED_HELP
  894. #endif /* Various mutation-specific defines */
  895.  
  896. /* Some prototypes which may be necessary for some versions */
  897.  
  898. #ifdef NEED_RENAME
  899.   int rename( const char *srcName, const char *destName );
  900. #endif /* NEED_RENAME */
  901. #ifdef NEED_STRLWR
  902.   void strlwr( char *string );
  903. #endif /* NEED_STRLWR */
  904. #ifdef NEED_MEMMOVE
  905.   void memmove( char *dest, char *src, int length );
  906. #endif /* NEED_MEMMOVE */
  907. #ifdef NEED_STRNICMP
  908.   int strnicmp( char *src, char *dest, int length );
  909. #endif /* NEED_STRNICMP */
  910.  
  911. #endif /* __UNIX__ */
  912.  
  913. /****************************************************************************
  914. *                                                                            *
  915. *                                Definitions for VMS                            *
  916. *                                                                            *
  917. ****************************************************************************/
  918.  
  919. #ifdef __VMS__
  920.  
  921. #define ARCHIVE_OS        OS_VMS
  922.  
  923. /* Any necessary #include's here */
  924.  
  925. /* Maximum path length (x bytes + null terminator) and filename length
  926.    (y bytes + null terminator) */
  927.  
  928. #define MAX_PATH        -1            /* Whatever it is */
  929. #define MAX_FILENAME    -1
  930.  
  931. /* The file attribute type and various useful attributes */
  932.  
  933. typedef WORD            ATTR;        /* Attribute data type */
  934.  
  935. /* Mode/attribute bits for hcreat()/hmkdir() */
  936.  
  937. #define CREAT_ATTR        -1            /* Bits to set for hcreat() */
  938. #define MKDIR_ATTR        -1            /* Bits to set for hmkdir() */
  939.  
  940. /* The following pseudo-attributes must be sorted out in findFirst/Next().
  941.    Since VMS doesn't distinguish between normal and special files these
  942.    are treated identically */
  943.  
  944. #define FILES            1            /* Match normal files only */
  945. #define ALLFILES        1            /* Match special files as well */
  946. #define FILES_DIRS         2            /* Match normal files and directories */
  947. #define ALLFILES_DIRS    2            /* Match all files and directories */
  948.  
  949. /* The directory seperator (a logical slash), and its stringified equivalent */
  950.  
  951. #define SLASH            '/'
  952. #define SLASH_STR        "/"
  953.  
  954. /* The types of files findFirst() can match (when it's not matching a
  955.    literal file or directory name) */
  956.  
  957. #define MATCH_ALL        "*.*;*"        /* All files and directories */
  958. #define SLASH_MATCH_ALL    "/*.*;*"    /* As above with directory delimiter */
  959. #define MATCH_ARCHIVE    "*.HPK;0"    /* Most recent archive */
  960.  
  961. /* The data block used by findFirst()/findNext()/findEnd() */
  962.  
  963. typedef struct {
  964.                LONG fTime;            /* File modification datestamp */
  965.                LONG fSize;            /* File size */
  966.                char fName[ MAX_FILENAME ];    /* File name */
  967.                ATTR matchAttr;        /* File attributes to match on */
  968.  
  969.                /* VMS-specific information, eg returned attributes, ACL's, etc */
  970.                } FILEINFO;
  971.  
  972. /* Determine whether a found file is a directory or not */
  973.  
  974. #define isDirectory(fileInfo)    ( whatever )
  975.  
  976. /* The type of case conversion to perform on file and directory names.
  977.    In both cases we force uppercase */
  978.  
  979. #define caseConvert        toupper                /* Force uppercase */
  980. #define caseMatch        toupper                /* Force uppercase */
  981. #define caseStrcmp        stricmp                /* Non-case-sensitive match */
  982. #define caseStrncmp        strnicmp            /* Non-case-sensitive match */
  983.  
  984. /* Whether spaces are legal in filenames */
  985.  
  986. #define SPACE_OK        FALSE
  987.  
  988. /* Prototypes/defines for standard VMS routines */
  989.  
  990. #define setDirecTime(dirName,time)    setFileTime( dirName, time )
  991.  
  992. /* Dummy routines for nonportable/unused functions */
  993.  
  994. #define initExtraInfo()        /* VMS files have no extra info */
  995. #define copyExtraInfo(x,y)
  996. #define setExtraInfo(x)
  997. #define endExtraInfo()
  998.  
  999. /* Prototypes for extra routines */
  1000.  
  1001. void rename( const char *srcName, const char *destName );
  1002. void strlwr( char *string );
  1003. void memmove( void *dest, void *src, int length );
  1004. int strnicmp( char *src, char *dest, int length );
  1005.  
  1006. #endif /* __VMS__ */
  1007.  
  1008. /****************************************************************************
  1009. *                                                                            *
  1010. *                     Prototypes for Nonportable Functions                     *
  1011. *                                                                            *
  1012. ****************************************************************************/
  1013.  
  1014. /* All the following are conditional since they may be defined as dummy
  1015.    functions */
  1016.  
  1017. #ifndef setFileTime
  1018.   void setFileTime( const char *fileName, const LONG fileTime );
  1019. #endif /* setFileTime */
  1020. #ifndef setDirecTime
  1021.   void setDirecTime( const char *dirName, const LONG dirTime );
  1022. #endif /* setDirecTime */
  1023. #ifndef getCountry
  1024.   int getCountry( void );
  1025. #endif /* getCountry */
  1026. #ifndef getScreenSize
  1027.   void getScreenSize( void );
  1028. #endif /* getScreenSize */
  1029. #ifndef findFirst
  1030.   BOOLEAN findFirst( const char *filePath, const ATTR fileAttr, FILEINFO *fileInfo );
  1031.   BOOLEAN findNext( FILEINFO *fileInfo );
  1032. #endif /* findFirst */
  1033. #ifndef findEnd
  1034.   void findEnd( FILEINFO *fileInfo );
  1035. #endif /* findEnd */
  1036. #ifndef isSameFile
  1037.   BOOLEAN isSameFile( const char *pathName1, const char *pathName2 );
  1038. #endif /* isSameFile */
  1039. #ifndef initExtraInfo
  1040.   void initExtraInfo( void );
  1041.   void endExtraInfo( void );
  1042. #endif /* initExtraInfo */
  1043. #ifndef copyExtraInfo
  1044.   void copyExtraInfo( const char *srcFilePath, const char *destFilePath );
  1045. #endif /* copyExtraInfo */
  1046. #ifndef setExtraInfo
  1047.   void setExtraInfo( const char *filePath );
  1048. #endif /* setExtraInfo */
  1049.  
  1050. /* Default OS */
  1051.  
  1052. #ifndef ARCHIVE_OS
  1053.   #define ARCHIVE_OS    OS_UNKNOWN
  1054. #endif /* !ARCHIVE_OS */
  1055.  
  1056. #endif /* _SYSTEM_DEFINED */
  1057.