1 2 /* 3 The file is written by Lee Jones. Distribution is unlimited. 4 */ 5 6 /* applefile.h - Data structures used by AppleSingle/AppleDouble 7 * file format 8 * 9 * Written by Lee Jones, 22-Oct-1993 10 * 11 * For definitive information, see "AppleSingle/AppleDouble 12 * Formats for Foreign Files Developer's Note"; Apple Computer 13 * Inc.; (c) 1990. 14 * 15 * Other details were added from: 16 * Inside Macintosh [old version], volumes II to VI, 17 * Apple include files supplied with Think C 5.0.1, 18 * Microsoft MS-DOS Programmer's Reference, version 5, and 19 * Microsoft C 6.00a's dos.h include file. 20 * 21 * I don't have ProDOS or AFP Server documentation so related 22 * entries may be a bit skimpy. 23 * 24 * Edit history: 25 * 26 * when who why 27 * --------- --- ------------------------------------------ 28 * 22-Oct-93 LMJ Pull together from Inside Macintosh, 29 * Developer's Note, etc 30 * 26-Oct-93 LMJ Finish writing first version and list 31 * references 32 * 06-Feb-94 EEF Very minor cleanup 33 */ 34 35 /* REMINDER: the Motorola 680x0 is a big-endian architecture! */ 36 37 typedef Uint32 OSType; /* 32 bit field */ 38 39 /* In the QuickDraw coordinate plane, each coordinate is 40 * -32767..32767. Each point is at the intersection of a 41 * horizontal grid line and a vertical grid line. Horizontal 42 * coordinates increase from left to right. Vertical 43 * coordinates increase from top to bottom. This is the way 44 * both a TV screen and page of English text are scanned: 45 * from top left to bottom right. 46 */ 47 48 struct Point /* spot in QuickDraw 2-D grid */ 49 { 50 Sint16 v; /* vertical coordinate */ 51 Sint16 h; /* horizontal coordinate */ 52 }; /* Point */ 53 54 typedef struct Point Point; 55 56 /* See older Inside Macintosh, Volume II page 84 or Volume IV 57 * page 104. 58 */ 59 60 struct FInfo /* Finder information */ 61 { 62 OSType fdType; /* File type, 4 ASCII chars */ 63 OSType fdCreator; /* File's creator, 4 ASCII chars */ 64 Uint16 fdFlags; /* Finder flag bits */ 65 Point fdLocation; /* file's location in folder */ 66 Sint16 fdFldr; /* file 's folder (aka window) */ 67 }; /* FInfo */ 68 69 typedef struct FInfo FInfo; 70 71 /* 72 * Masks for finder flag bits (field fdFlags in struct 73 * FInfo). 74 */ 75 76 #define F_fOnDesk 0x0001 /* file is on desktop (HFS only) */ 77 #define F_maskColor 0x000E /* color coding (3 bits) */ 78 /* 0x0010 /* reserved (System 7) */ 79 #define F_fSwitchLaunch 0x0020 /* reserved (System 7) */ 80 #define F_fShared 0x0040 /* appl available to multiple users */ 81 #define F_fNoINITs 0x0080 /* file contains no INIT resources */ 82 #define F_fBeenInited 0x0100 /* Finder has loaded bundle res. */ 83 /* 0x0200 /* reserved (System 7) */ 84 #define F_fCustomIcom 0x0400 /* file contains custom icon */ 85 #define F_fStationary 0x0800 /* file is a stationary pad */ 86 #define F_fNameLocked 0x1000 /* file can't be renamed by Finder */ 87 #define F_fHasBundle 0x2000 /* file has a bundle */ 88 #define F_fInvisible 0x4000 /* file's icon is invisible */ 89 #define F_fAlias 0x8000 /* file is an alias file (System 7) */ 90 91 /* See older Inside Macintosh, Volume IV, page 105. 92 */ 93 94 struct FXInfo /* Extended finder information */ 95 96 { 97 Sint16 fdIconID; /* icon ID number */ 98 Sint16 fdUnused[3]; /* spare */ 99 Sint8 fdScript; /* scrip flag and code */ 100 Sint8 fdXFlags; /* reserved */ 101 Sint16 fdComment; /* comment ID number */ 102 Sint32 fdPutAway; /* home directory ID */ 103 }; /* FXInfo */ 104 105 typedef struct FXInfo FXInfo; 106 107 /* Pieces used by AppleSingle & AppleDouble (defined later). */ 108 109 struct ASHeader /* header portion of AppleSingle */ 110 { 111 /* AppleSingle = 0x00051600; AppleDouble = 0x00051607 */ 112 Uint32 magicNum; /* internal file type tag */ 113 Uint32 versionNum; /* format version: 2 = 0x00020000 */ 114 Uint8 filler[16]; /* filler, currently all bits 0 */ 115 Uint16 numEntries; /* number of entries which follow */ 116 }; /* ASHeader */ 117 118 typedef struct ASHeader ASHeader; 119 120 struct ASEntry /* one AppleSingle entry descriptor */ 121 { 122 Uint32 entryID; /* entry type: see list, 0 invalid */ 123 Uint32 entryOffset; /* offset, in octets, from beginning */ 124 /* of file to this entry's data */ 125 Uint32 entryLength; /* length of data in octets */ 126 }; /* ASEntry */ 127 128 typedef struct ASEntry ASEntry; 129 130 /* Apple reserves the range of entry IDs from 1 to 0x7FFFFFFF. 131 * Entry ID 0 is invalid. The rest of the range is available 132 * for applications to define their own entry types. "Apple does 133 * not arbitrate the use of the rest of the range." 134 */ 135 136 #define AS_DATA 1 /* data fork */ 137 #define AS_RESOURCE 2 /* resource fork */ 138 #define AS_REALNAME 3 /* File's name on home file system */ 139 #define AS_COMMENT 4 /* standard Mac comment */ 140 #define AS_ICONBW 5 /* Mac black & white icon */ 141 #define AS_ICONCOLOR 6 /* Mac color icon */ 142 /* 7 /* not used */ 143 #define AS_FILEDATES 8 /* file dates; create, modify, etc */ 144 #define AS_FINDERINFO 9 /* Mac Finder info & extended info */ 145 #define AS_MACINFO 10 /* Mac file info, attributes, etc */ 146 #define AS_PRODOSINFO 11 /* Pro-DOS file info, attrib., etc */ 147 #define AS_MSDOSINFO 12 /* MS-DOS file info, attributes, etc */ 148 #define AS_AFPNAME 13 /* Short name on AFP server */ 149 #define AS_AFPINFO 14 /* AFP file info, attrib., etc */ 150 151 #define AS_AFPDIRID 15 /* AFP directory ID */ 152 153 /* matrix of entry types and their usage: 154 * 155 * Macintosh Pro-DOS MS-DOS AFP server 156 * --------- ------- ------ ---------- 157 * 1 AS_DATA xxx xxx xxx xxx 158 * 2 AS_RESOURCE xxx xxx 159 * 3 AS_REALNAME xxx xxx xxx xxx 160 * 161 * 4 AS_COMMENT xxx 162 * 5 AS_ICONBW xxx 163 * 6 AS_ICONCOLOR xxx 164 * 165 * 8 AS_FILEDATES xxx xxx xxx xxx 166 * 9 AS_FINDERINFO xxx 167 * 10 AS_MACINFO xxx 168 * 169 * 11 AS_PRODOSINFO xxx 170 * 12 AS_MSDOSINFO xxx 171 * 172 * 13 AS_AFPNAME xxx 173 * 14 AS_AFPINFO xxx 174 * 15 AS_AFPDIRID xxx 175 */ 176 177 /* entry ID 1, data fork of file - arbitrary length octet string */ 178 179 /* entry ID 2, resource fork - arbitrary length opaque octet string; 180 * as created and managed by Mac O.S. resoure manager 181 */ 182 183 /* entry ID 3, file's name as created on home file system - arbitrary 184 * length octet string; usually short, printable ASCII 185 */ 186 187 /* entry ID 4, standard Macintosh comment - arbitrary length octet 188 * string; printable ASCII, claimed 200 chars or less 189 */ 190 191 /* This is probably a simple duplicate of the 128 octet bitmap 192 * stored as the 'ICON' resource or the icon element from an 'ICN#' 193 * resource. 194 */ 195 196 struct ASIconBW /* entry ID 5, standard Mac black and white icon */ 197 { 198 Uint32 bitrow[32]; /* 32 rows of 32 1-bit pixels */ 199 }; /* ASIconBW */ 200 201 typedef struct ASIconBW ASIconBW; 202 203 /* entry ID 6, "standard" Macintosh color icon - several competing 204 * color icons are defined. Given the copyright dates 205 * of the Inside Macintosh volumes, the 'cicn' resource predominated 206 * when the AppleSingle Developer's Note was written (most probable 207 * candidate). See Inside Macintosh, Volume V, pages 64 & 80-81 for 208 * a description of 'cicn' resources. 209 * 210 * With System 7, Apple introduced icon families. They consist of: 211 * large (32x32) B&W icon, 1-bit/pixel, type 'ICN#', 212 * small (16x16) B&W icon, 1-bit/pixel, type 'ics#', 213 * large (32x32) color icon, 4-bits/pixel, type 'icl4', 214 * small (16x16) color icon, 4-bits/pixel, type 'ics4', 215 * large (32x32) color icon, 8-bits/pixel, type 'icl8', and 216 * small (16x16) color icon, 8-bits/pixel, type 'ics8'. 217 * If entry ID 6 is one of these, take your pick. See Inside 218 * Macintosh, Volume VI, pages 2-18 to 2-22 and 9-9 to 9-13, for 219 * descriptions. 220 */ 221 222 /* entry ID 7, not used */ 223 224 /* Times are stored as a "signed number of seconds before of after 225 * 12:00 a.m. (midnight), January 1, 2000 Greenwich Mean Time (GMT). 226 * Applications must convert to their native date and time 227 * conventions." Any unknown entries are set to 0x80000000 228 * (earliest reasonable time). 229 */ 230 231 struct ASFileDates /* entry ID 8, file dates info */ 232 { 233 Sint32 create; /* file creation date/time */ 234 Sint32 modify; /* last modification date/time */ 235 Sint32 backup; /* last backup date/time */ 236 Sint32 access; /* last access date/time */ 237 }; /* ASFileDates */ 238 239 typedef struct ASFileDates ASFileDates; 240 241 /* See older Inside Macintosh, Volume II, page 115 for 242 * PBGetFileInfo(), and Volume IV, page 155, for PBGetCatInfo(). 243 */ 244 245 /* entry ID 9, Macintosh Finder info & extended info */ 246 struct ASFinderInfo 247 { 248 FInfo ioFlFndrInfo; /* PBGetFileInfo() or PBGetCatInfo() */ 249 FXInfo ioFlXFndrInfo; /* PBGetCatInfo() (HFS only) */ 250 }; /* ASFinderInfo */ 251 252 typedef struct ASFinderInfo ASFinderInfo; 253 254 struct ASMacInfo /* entry ID 10, Macintosh file information */ 255 { 256 Uint8 filler[3]; /* filler, currently all bits 0 */ 257 Uint8 ioFlAttrib; /* PBGetFileInfo() or PBGetCatInfo() */ 258 }; /* ASMacInfo */ 259 260 typedef struct ASMacInfo ASMacInfo; 261 262 #define AS_PROTECTED 0x0002 /* protected bit */ 263 #define AS_LOCKED 0x0001 /* locked bit */ 264 265 /* NOTE: ProDOS-16 and GS/OS use entire fields. ProDOS-8 uses low 266 * order half of each item (low byte in access & filetype, low word 267 * in auxtype); remainder of each field should be zero filled. 268 */ 269 270 struct ASProdosInfo /* entry ID 11, ProDOS file information */ 271 { 272 Uint16 access; /* access word */ 273 Uint16 filetype; /* file type of original file */ 274 Uint32 auxtype; /* auxiliary type of the orig file */ 275 }; /* ASProDosInfo */ 276 277 typedef struct ASProdosInfo ASProdosInfo; 278 279 /* MS-DOS file attributes occupy 1 octet; since the Developer Note 280 * is unspecific, I've placed them in the low order portion of the 281 * field (based on example of other ASMacInfo & ASProdosInfo). 282 */ 283 284 struct ASMsdosInfo /* entry ID 12, MS-DOS file information */ 285 { 286 Uint8 filler; /* filler, currently all bits 0 */ 287 Uint8 attr; /* _dos_getfileattr(), MS-DOS */ 288 /* interrupt 21h function 4300h */ 289 }; /* ASMsdosInfo */ 290 291 typedef struct ASMsdosInfo ASMsdosInfo; 292 293 #define AS_DOS_NORMAL 0x00 /* normal file (all bits clear) */ 294 #define AS_DOS_READONLY 0x01 /* file is read-only */ 295 #define AS_DOS_HIDDEN 0x02 /* hidden file (not shown by DIR) */ 296 #define AS_DOS_SYSTEM 0x04 /* system file (not shown by DIR) */ 297 #define AS_DOS_VOLID 0x08 /* volume label (only in root dir) */ 298 #define AS_DOS_SUBDIR 0x10 /* file is a subdirectory */ 299 #define AS_DOS_ARCHIVE 0x20 /* new or modified (needs backup) */ 300 301 /* entry ID 13, short file name on AFP server - arbitrary length 302 * octet string; usualy printable ASCII starting with 303 * '!' (0x21) 304 */ 305 306 struct ASAfpInfo /* entry ID 12, AFP server file information */ 307 { 308 Uint8 filler[3]; /* filler, currently all bits 0 */ 309 Uint8 attr; /* file attributes */ 310 }; /* ASAfpInfo */ 311 312 typedef struct ASAfpInfo ASAfpInfo; 313 314 #define AS_AFP_Invisible 0x01 /* file is invisible */ 315 #define AS_AFP_MultiUser 0x02 /* simultaneous access allowed */ 316 #define AS_AFP_System 0x04 /* system file */ 317 #define AS_AFP_BackupNeeded 0x40 /* new or modified (needs backup) */ 318 319 struct ASAfpDirId /* entry ID 15, AFP server directory ID */ 320 { 321 Uint32 dirid; /* file's directory ID on AFP server */ 322 }; /* ASAfpDirId */ 323 324 typedef struct ASAfpDirId ASAfpDirId; 325 326 /* 327 * The format of an AppleSingle/AppleDouble header 328 */ 329 struct AppleSingle /* format of disk file */ 330 { 331 ASHeader header; /* AppleSingle header part */ 332 ASEntry entry[1]; /* array of entry descriptors */ 333 /* Uint8 filedata[]; /* followed by rest of file */ 334 }; /* AppleSingle */ 335 336 typedef struct AppleSingle AppleSingle; 337 338 /* 339 * FINAL REMINDER: the Motorola 680x0 is a big-endian architecture! 340 */ 341 342 /* End of applefile.h */ 343