1/* Information pulled from: 2 * "AppleSingle/AppleDouble Formats for Foreign Files Developer's Note" 3 * (c) Apple Computer 1990 4 * File assembled by Rob Braun (bbraun@synack.net) 5 */ 6 7#ifndef __APPLEDOUBLE__ 8#define __APPLEDOUBLE__ 9 10#include <sys/types.h> 11#include <stdint.h> 12 13/* Structure of an AppleSingle file: 14 * ---------------------- 15 * | AppleSingleHeader | 16 * |--------------------| 17 * | ASH.entries # of | 18 * | AppleSingleEntry | 19 * | Descriptors | 20 * | 1 | 21 * | . | 22 * | . | 23 * | n | 24 * |--------------------| 25 * | Datablock 1 | 26 * |--------------------| 27 * | Datablock 2 | 28 * |--------------------| 29 * | Datablock n | 30 * ---------------------- 31 */ 32 33struct AppleSingleHeader { 34 uint32_t magic; /* Magic Number (0x00051600 for AS) */ 35 uint32_t version; /* Version #. 0x00020000 */ 36 char filler[16]; /* All zeros */ 37 uint16_t entries; /* Number of entries in the file */ 38}; 39 40#define XAR_ASH_SIZE 26 /* sizeof(struct AppleSingleHeader) will be wrong 41 * due to padding. */ 42 43#define APPLESINGLE_MAGIC 0x00051600 44#define APPLEDOUBLE_MAGIC 0x00051607 45 46#define APPLESINGLE_VERSION 0x00020000 47#define APPLEDOUBLE_VERSION 0x00020000 48 49struct AppleSingleEntry { 50 uint32_t entry_id; /* What the entry is. See defines below */ 51 uint32_t offset; /* offset of data, offset beginning of file */ 52 uint32_t length; /* length of data. can be 0 */ 53}; 54 55/* Valid entry_id values */ 56/* Entries 1, 3, and 8 are typically created for all files. 57 * Macintosh Icon entries are rare, since those are typically in the resource 58 * fork. 59 */ 60#define AS_ID_DATA 1 /* Data fork */ 61#define AS_ID_RESOURCE 2 /* Resource fork */ 62#define AS_ID_NAME 3 /* Name of the file */ 63#define AS_ID_COMMENT 4 /* Standard Macintosh comment */ 64#define AS_ID_BWICON 5 /* Standard Macintosh B&W icon */ 65#define AS_ID_COLORICON 6 /* Standard Macintosh Color icon */ 66/* There is no 7 */ 67#define AS_ID_DATES 8 /* File creation date, modification date, etc. */ 68#define AS_ID_FINDER 9 /* Finder Information */ 69#define AS_ID_MAC 10 /* Macintosh File information, attributes, etc. */ 70#define AS_ID_PRODOS 11 /* ProDOS file information */ 71#define AS_ID_MSDOS 12 /* MS-DOS file information */ 72#define AS_ID_SHORTNAME 13 /* AFP short name */ 73#define AS_ID_AFPINFO 14 /* AFP file information */ 74#define AS_ID_AFPDIR 15 /* AFP directory id */ 75/* 1-0x7FFFFFFF are reserved by Apple */ 76 77/* File Dates are stored as the # of seconds before or after 78 * 12am Jan 1, 2000 GMT. The default value is 0x80000000. 79 */ 80struct MacTimes { 81 uint32_t creation; 82 uint32_t modification; 83 uint32_t backup; 84 uint32_t access; 85}; 86 87/* Finder Information is two 16 byte quantities. 88 * Newly created files have all 0's in both entries. 89 */ 90 91/* Macintosh File Info entry (10) a 32 bit bitmask. */ 92 93/* Entries can be placed in any order, although Apple recommends: 94 * Place the data block (1) last. 95 * Finder Info, File Dates Info, and Macintosh File Info first. 96 * Allocate resource for entries in 4K blocks. 97 */ 98 99/* AppleDouble files are simply AppleSingle files without the data fork. 100 * The magic number is different as a read optimization. 101 */ 102 103#endif /* __APPLEDOUBLE__ */ 104