1 /* @(#)apple.h 1.8 04/03/02 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson, Copyright 2004 J. Schilling */ 2 /* 3 * Copyright (c) 1997, 1998, 1999, 2000 James Pearson 4 * Copyright (c) 2004 J. Schilling 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; see the file COPYING. If not, write to 18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21 /* 22 * apple.h: cut down macfile.h from CAP distribution 23 */ 24 #ifndef _APPLE_H 25 #define _APPLE_H 26 27 #include "mactypes.h" 28 29 #ifndef O_BINARY 30 #define O_BINARY 0 31 #endif /* O_BINARY */ 32 33 #ifdef _WIN32_TEST 34 #undef UNICODE 35 #include <windows.h> 36 #endif /* _WIN32 */ 37 38 #ifndef MIN 39 #define MIN(a, b) (((a) < (b)) ? (a):(b)) 40 #endif /* MIN */ 41 42 #define CT_SIZE 4 /* Size of type/creator */ 43 #define NUMMAP 512 /* initial number of maps */ 44 #define BLANK " " /* blank type/creator */ 45 #define DEFMATCH "*" /* default mapping extension */ 46 47 typedef struct { 48 char *extn; /* filename extension */ 49 int elen; /* length of extension */ 50 char type[CT_SIZE+1]; /* extension type */ 51 char creator[CT_SIZE+1]; /* extension creator */ 52 unsigned short fdflags; /* finder flags */ 53 } afpmap; 54 55 /* from "data.h" - libhfs routines */ 56 unsigned long d_toutime __PR((unsigned long)); 57 unsigned long d_dtoutime __PR((long)); 58 long d_getl __PR((unsigned char *)); 59 short d_getw __PR((unsigned char *)); 60 61 /* for libfile routines */ 62 int init_magic __PR((char *)); 63 char * get_magic_match __PR((const char *)); 64 65 typedef unsigned char byte; 66 typedef unsigned char word[2]; 67 typedef unsigned char dword[4]; 68 69 #define INFOLEN 32 /* Finder info is 32 bytes */ 70 71 typedef struct { 72 /* base finder information */ 73 char fdType[4]; /* File type [4] */ 74 char fdCreator[4]; /* File creator [8] */ 75 word fdFlags; /* Finder flags [10] */ 76 word fdLocation[2]; /* File's location [14] */ 77 word fdFldr; /* File's window [16] */ 78 /* extended finder information */ 79 word fdIconID; /* Icon ID [18] */ 80 word fdUnused[3]; /* Unused [24] */ 81 byte fdScript; /* Script system used [25] */ 82 byte fdXFlags; /* Reserved [26] */ 83 word fdComment; /* Comment ID [28] */ 84 dword fdPutAway; /* Home directory ID [32] */ 85 } Finfo; 86 87 typedef struct { 88 /* base finder information */ 89 word frRect[4]; /* Folder's rectangle [8] */ 90 word frFlags; /* Finder flags [10] */ 91 word frLocation[2]; /* Folder's location [14] */ 92 word frView; /* Folder's view [16] */ 93 /* extended finder information */ 94 word frScroll[2]; /* Folder's scroll position [20] */ 95 dword frOpenChain; /* ID's of open folders [24] */ 96 byte frScript; /* Script system used [25] */ 97 byte frXFlags; /* Reserved [26] */ 98 word frComment; /* Comment ID [28] */ 99 dword frPutAway; /* Home directory ID [32] */ 100 } Dinfo; 101 102 /****** TYPE_CAP ******/ 103 104 /* 105 * taken from the CAP distribution: 106 * macfile.h - header file with Macintosh file definitions 107 * 108 * AppleTalk package for UNIX (4.2 BSD). 109 * 110 * Copyright (c) 1986, 1987, 1988 by The Trustees of Columbia University in the 111 * City of New York. 112 * 113 * Edit History: 114 * 115 * Sept 1987 Created by Charlie 116 * 117 */ 118 119 120 #ifndef USE_MAC_DATES 121 #define USE_MAC_DATES 122 #endif /* USE_MAC_DATES */ 123 124 #define MAXCLEN 199 /* max size of a comment string */ 125 #define FINFOLEN 32 /* Finder info is 32 bytes */ 126 #define MAXMACFLEN 31 /* max Mac file name length */ 127 128 typedef struct { 129 byte finderinfo[INFOLEN]; /* Finder info */ 130 word fi_attr; /* attributes */ 131 #define FI_MAGIC1 255 132 byte fi_magic1; /* was: length of comment */ 133 #define FI_VERSION 0x10 /* version major 1, minor 0 */ 134 /* if we have more than 8 versions wer're */ 135 /* doiong something wrong anyway */ 136 byte fi_version; /* version number */ 137 #define FI_MAGIC 0xda 138 byte fi_magic; /* magic word check */ 139 byte fi_bitmap; /* bitmap of included info */ 140 #define FI_BM_SHORTFILENAME 0x1 /* is this included? */ 141 #define FI_BM_MACINTOSHFILENAME 0x2 /* is this included? */ 142 byte fi_shortfilename[12+1]; /* possible short file name */ 143 byte fi_macfilename[32+1]; /* possible macintosh file name */ 144 byte fi_comln; /* comment length */ 145 byte fi_comnt[MAXCLEN+1]; /* comment string */ 146 #ifdef USE_MAC_DATES 147 byte fi_datemagic; /* sanity check */ 148 #define FI_MDATE 0x01 /* mtime & utime are valid */ 149 #define FI_CDATE 0x02 /* ctime is valid */ 150 byte fi_datevalid; /* validity flags */ 151 byte fi_ctime[4]; /* mac file create time */ 152 byte fi_mtime[4]; /* mac file modify time */ 153 byte fi_utime[4]; /* (real) time mtime was set */ 154 #endif /* USE_MAC_DATES */ 155 } FileInfo; 156 157 /* Atribute flags */ 158 #define FI_ATTR_SETCLEAR 0x8000 /* set-clear attributes */ 159 #define FI_ATTR_READONLY 0x20 /* file is read-only */ 160 #define FI_ATTR_ROPEN 0x10 /* resource fork in use */ 161 #define FI_ATTR_DOPEN 0x80 /* data fork in use */ 162 #define FI_ATTR_MUSER 0x2 /* multi-user */ 163 #define FI_ATTR_INVISIBLE 0x1 /* invisible */ 164 165 /**** MAC STUFF *****/ 166 167 /* Flags */ 168 #define FNDR_fOnDesk 0x1 169 #define FNDR_fHasBundle 0x2000 170 #define FNDR_fInvisible 0x4000 171 /* locations */ 172 #define FNDR_fTrash -3 /* File in Trash */ 173 #define FNDR_fDesktop -2 /* File on desktop */ 174 #define FNDR_fDisk 0 /* File in disk window */ 175 176 /****** TYPE_ESHARE ******/ 177 178 /* 179 * Information supplied by Jens-Uwe Mager (jum@helios.de) 180 */ 181 182 #define ES_VERSION 0x0102 183 #define ES_MAGIC 0x3681093 184 #define ES_INFOLEN 32 185 #define ES_INFO_SIZE 512 186 187 typedef struct { 188 dword magic; 189 dword serno; /* written only, never read */ 190 word version; 191 word attr; /* invisible... */ 192 word openMax; /* max number of opens */ 193 word filler0; 194 dword backupCleared; /* time backup bit cleared */ 195 dword id; /* dir/file id */ 196 dword createTime; /* unix format */ 197 dword backupTime; /* unix format */ 198 byte finderinfo[INFOLEN]; /* Finder info */ 199 } es_FileInfo; 200 201 /****** TYPE_USHARE ******/ 202 203 /* 204 * similar to the EtherShare layout, but the finder info stuff is different 205 * info provided by: Phil Sylvester <psylvstr@interaccess.com> 206 */ 207 208 typedef struct { 209 byte finderinfo[INFOLEN]; /* Finder info */ 210 dword btime; /* mac file backup time [36]*/ 211 byte unknown2[4]; /* ignore [40] */ 212 dword ctime; /* mac file create time [44]*/ 213 byte unknown3[8]; /* ignore [52] */ 214 dword mtime; /* mac file modify time [56]*/ 215 byte unknown4[456]; /* ignore [512] */ 216 } us_FileInfo; 217 218 /****** TYPE_DOUBLE, TYPE_SINGLE ******/ 219 220 /* 221 * Taken from cvt2cap (c) May 1988, Paul Campbell 222 */ 223 224 typedef struct { 225 dword id; 226 dword offset; 227 dword length; 228 } a_entry; 229 230 typedef struct { 231 dword magic; 232 dword version; 233 char home[16]; 234 word nentries; 235 a_entry entries[1]; 236 } a_hdr; 237 238 #define A_HDR_SIZE 26 239 #define A_ENTRY_SIZE sizeof (a_entry) 240 241 #define A_VERSION1 0x00010000 242 #define A_VERSION2 0x00020000 243 #define APPLE_SINGLE 0x00051600 244 #define APPLE_DOUBLE 0x00051607 245 #define ID_DATA 1 246 #define ID_RESOURCE 2 247 #define ID_NAME 3 248 #define ID_FILEI 7 /* v1 */ 249 #define ID_FILEDATESI 8 /* v2 */ 250 #define ID_FINDER 9 251 252 #define A_DATE 16 253 254 /****** TYPE_MACBIN ******/ 255 /* 256 * taken from capit.c by Nigel Perry, np@doc.ic.ac.uk which is adapted 257 * from unmacbin by John M. Sellens, jmsellens@watdragon.uwaterloo.ca 258 */ 259 260 261 #define MB_NAMELEN 63 /* maximum legal Mac file name length */ 262 #define MB_SIZE 128 263 264 /* 265 * Format of a bin file: 266 * A bin file is composed of 128 byte blocks. The first block is the 267 * info_header (see below). Then comes the data fork, null padded to fill the 268 * last block. Then comes the resource fork, padded to fill the last block. A 269 * proposal to follow with the text of the Get Info box has not been implemented, 270 * to the best of my knowledge. Version, zero1 and zero2 are what the receiving 271 * program looks at to determine if a MacBinary transfer is being initiated. 272 */ 273 typedef struct { /* info file header (128 bytes). Unfortunately, these */ 274 /* longs don't align to word boundaries */ 275 byte version; /* there is only a version 0 at this time */ 276 byte nlen; /* Length of filename. */ 277 byte name[MB_NAMELEN]; /* Filename */ 278 byte type[4]; /* File type. */ 279 byte auth[4]; /* File creator. */ 280 byte flags; /* file flags: LkIvBnSyBzByChIt */ 281 byte zero1; /* Locked, Invisible,Bundle, System */ 282 /* Bozo, Busy, Changed, Init */ 283 byte icon_vert[2]; /* Vertical icon position within window */ 284 byte icon_horiz[2]; /* Horizontal icon postion in window */ 285 byte window_id[2]; /* Window or folder ID. */ 286 byte protect; /* = 1 for protected file, 0 otherwise */ 287 byte zero2; 288 byte dflen[4]; /* Data Fork length (bytes) - most sig. */ 289 byte rflen[4]; /* Resource Fork length byte first */ 290 byte cdate[4]; /* File's creation date. */ 291 byte mdate[4]; /* File's "last modified" date. */ 292 byte ilen[2]; /* GetInfo message length */ 293 byte flags2; /* Finder flags, bits 0-7 */ 294 byte unused[14]; 295 byte packlen[4]; /* length of total files when unpacked */ 296 byte headlen[2]; /* length of secondary header */ 297 byte uploadvers; /* Version of MacBinary II that the uploading program is written for */ 298 byte readvers; /* Minimum MacBinary II version needed to read this file */ 299 byte crc[2]; /* CRC of the previous 124 bytes */ 300 byte padding[2]; /* two trailing unused bytes */ 301 } mb_info; 302 303 /****** TYPE_FE ******/ 304 305 /* Information provided by Mark Weinstein <mrwesq@earthlink.net> */ 306 307 typedef struct { 308 byte nlen; 309 byte name[31]; 310 byte finderinfo[INFOLEN]; /* Finder info */ 311 byte cdate[4]; 312 byte mdate[4]; 313 byte bdate[4]; 314 byte fileid[4]; 315 byte sname[8]; 316 byte ext[3]; 317 byte pad; 318 } fe_info; 319 320 #define FE_SIZE 92 321 322 /****** TYPE_SGI ******/ 323 324 typedef struct { 325 byte unknown1[8]; 326 byte finderinfo[INFOLEN]; /* Finder info */ 327 byte unknown2[214]; 328 byte name[32]; 329 byte unknown3[14]; 330 } sgi_info; 331 332 #define SGI_SIZE 300 333 334 /****** TYPE_SFM ******/ 335 336 /* 337 * Information provided by Lou Rieger <lrieger@meridiancg.com> taken from 338 * an email from Eddie Bowers <eddieb@microsoft.com> 339 */ 340 341 typedef struct { 342 byte afpi_Signature[4]; /* Must be 0x00504641 */ 343 byte afpi_Version[4]; /* Must be 0x00010000 */ 344 byte afpi_Reserved1[4]; 345 byte afpi_BackupTime[4]; /* Backup time for the file/dir */ 346 byte finderinfo[INFOLEN]; /* Finder info */ 347 byte afpi_ProDosInfo[6]; /* ProDos Info */ 348 byte afpi_Reserved2[6]; 349 } sfm_info; 350 351 #define SFM_MAGIC 0x00504641 352 #define SFM_VERSION 0x00010000 353 354 /****** TYPE_DHFS ******/ 355 356 #ifdef IS_MACOS_X 357 358 /* 359 * Code ideas from 'hfstar' by Marcel Weiher marcel@metaobject.com, 360 * another GNU hfstar by Torres Vedras paulotex@yahoo.com and 361 * hfspax by Howard Oakley howard@quercus.demon.co.uk 362 */ 363 364 #include <sys/attr.h> 365 366 typedef struct { 367 unsigned long info_length; 368 #ifndef APPLE_PEARSON_OLD 369 unsigned long objid_low; 370 unsigned long objid_high; 371 #endif 372 struct timespec ctime; 373 struct timespec mtime; 374 byte info[32]; 375 #ifndef APPLE_PEARSON_OLD 376 off_t rsrc_length; 377 #endif 378 } attrinfo; 379 380 #endif /* IS_MACOS_X */ 381 382 #endif /* _APPLE_H */ 383