2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)apple.h 1.7 04/03/02 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson */
15 * Copyright (c) 1997, 1998, 1999, 2000 James Pearson
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option)
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; see the file COPYING. If not, write to
29 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 * apple.h: cut down macfile.h from CAP distribution
50 #define MIN(a, b) (((a) < (b)) ? (a):(b))
53 #define CT_SIZE 4 /* Size of type/creator */
54 #define NUMMAP 512 /* initial number of maps */
55 #define BLANK " " /* blank type/creator */
56 #define DEFMATCH "*" /* default mapping extension */
59 char *extn; /* filename extension */
60 int elen; /* length of extension */
61 char type[CT_SIZE+1]; /* extension type */
62 char creator[CT_SIZE+1]; /* extension creator */
63 unsigned short fdflags; /* finder flags */
66 /* from "data.h" - libhfs routines */
67 unsigned long d_toutime(unsigned long);
68 unsigned long d_dtoutime(long);
69 long d_getl(unsigned char *);
70 short d_getw(unsigned char *);
72 /* for libfile routines */
73 int init_magic(char *);
74 char * get_magic_match(const char *);
76 typedef unsigned char byte;
77 typedef unsigned char word[2];
78 typedef unsigned char dword[4];
80 #define INFOLEN 32 /* Finder info is 32 bytes */
83 /* base finder information */
84 char fdType[4]; /* File type [4] */
85 char fdCreator[4]; /* File creator [8] */
86 word fdFlags; /* Finder flags [10] */
87 word fdLocation[2]; /* File's location [14] */
88 word fdFldr; /* File's window [16] */
89 /* extended finder information */
90 word fdIconID; /* Icon ID [18] */
91 word fdUnused[3]; /* Unused [24] */
92 byte fdScript; /* Script system used [25] */
93 byte fdXFlags; /* Reserved [26] */
94 word fdComment; /* Comment ID [28] */
95 dword fdPutAway; /* Home directory ID [32] */
99 /* base finder information */
100 word frRect[4]; /* Folder's rectangle [8] */
101 word frFlags; /* Finder flags [10] */
102 word frLocation[2]; /* Folder's location [14] */
103 word frView; /* Folder's view [16] */
104 /* extended finder information */
105 word frScroll[2]; /* Folder's scroll position [20] */
106 dword frOpenChain; /* ID's of open folders [24] */
107 byte frScript; /* Script system used [25] */
108 byte frXFlags; /* Reserved [26] */
109 word frComment; /* Comment ID [28] */
110 dword frPutAway; /* Home directory ID [32] */
113 /****** TYPE_CAP ******/
116 * taken from the CAP distribution:
117 * macfile.h - header file with Macintosh file definitions
119 * AppleTalk package for UNIX (4.2 BSD).
121 * Copyright (c) 1986, 1987, 1988 by The Trustees of Columbia University in the
126 * Sept 1987 Created by Charlie
131 #ifndef USE_MAC_DATES
132 #define USE_MAC_DATES
133 #endif /* USE_MAC_DATES */
135 #define MAXCLEN 199 /* max size of a comment string */
136 #define FINFOLEN 32 /* Finder info is 32 bytes */
137 #define MAXMACFLEN 31 /* max Mac file name length */
140 byte finderinfo[INFOLEN]; /* Finder info */
141 word fi_attr; /* attributes */
142 #define FI_MAGIC1 255
143 byte fi_magic1; /* was: length of comment */
144 #define FI_VERSION 0x10 /* version major 1, minor 0 */
145 /* if we have more than 8 versions wer're */
146 /* doiong something wrong anyway */
147 byte fi_version; /* version number */
148 #define FI_MAGIC 0xda
149 byte fi_magic; /* magic word check */
150 byte fi_bitmap; /* bitmap of included info */
151 #define FI_BM_SHORTFILENAME 0x1 /* is this included? */
152 #define FI_BM_MACINTOSHFILENAME 0x2 /* is this included? */
153 byte fi_shortfilename[12+1]; /* possible short file name */
154 byte fi_macfilename[32+1]; /* possible macintosh file name */
155 byte fi_comln; /* comment length */
156 byte fi_comnt[MAXCLEN+1]; /* comment string */
158 byte fi_datemagic; /* sanity check */
159 #define FI_MDATE 0x01 /* mtime & utime are valid */
160 #define FI_CDATE 0x02 /* ctime is valid */
161 byte fi_datevalid; /* validity flags */
162 byte fi_ctime[4]; /* mac file create time */
163 byte fi_mtime[4]; /* mac file modify time */
164 byte fi_utime[4]; /* (real) time mtime was set */
165 #endif /* USE_MAC_DATES */
169 #define FI_ATTR_SETCLEAR 0x8000 /* set-clear attributes */
170 #define FI_ATTR_READONLY 0x20 /* file is read-only */
171 #define FI_ATTR_ROPEN 0x10 /* resource fork in use */
172 #define FI_ATTR_DOPEN 0x80 /* data fork in use */
173 #define FI_ATTR_MUSER 0x2 /* multi-user */
174 #define FI_ATTR_INVISIBLE 0x1 /* invisible */
176 /**** MAC STUFF *****/
179 #define FNDR_fOnDesk 0x1
180 #define FNDR_fHasBundle 0x2000
181 #define FNDR_fInvisible 0x4000
183 #define FNDR_fTrash -3 /* File in Trash */
184 #define FNDR_fDesktop -2 /* File on desktop */
185 #define FNDR_fDisk 0 /* File in disk window */
187 /****** TYPE_ESHARE ******/
190 * Information supplied by Jens-Uwe Mager (jum@helios.de)
193 #define ES_VERSION 0x0102
194 #define ES_MAGIC 0x3681093
195 #define ES_INFOLEN 32
196 #define ES_INFO_SIZE 512
200 dword serno; /* written only, never read */
202 word attr; /* invisible... */
203 word openMax; /* max number of opens */
205 dword backupCleared; /* time backup bit cleared */
206 dword id; /* dir/file id */
207 dword createTime; /* unix format */
208 dword backupTime; /* unix format */
209 byte finderinfo[INFOLEN]; /* Finder info */
212 /****** TYPE_USHARE ******/
215 * similar to the EtherShare layout, but the finder info stuff is different
216 * info provided by: Phil Sylvester <psylvstr@interaccess.com>
220 byte finderinfo[INFOLEN]; /* Finder info */
221 dword btime; /* mac file backup time [36]*/
222 byte unknown2[4]; /* ignore [40] */
223 dword ctime; /* mac file create time [44]*/
224 byte unknown3[8]; /* ignore [52] */
225 dword mtime; /* mac file modify time [56]*/
226 byte unknown4[456]; /* ignore [512] */
229 /****** TYPE_DOUBLE, TYPE_SINGLE ******/
232 * Taken from cvt2cap (c) May 1988, Paul Campbell
249 #define A_HDR_SIZE 26
250 #define A_ENTRY_SIZE sizeof (a_entry)
252 #define A_VERSION1 0x00010000
253 #define A_VERSION2 0x00020000
254 #define APPLE_SINGLE 0x00051600
255 #define APPLE_DOUBLE 0x00051607
257 #define ID_RESOURCE 2
259 #define ID_FILEI 7 /* v1 */
260 #define ID_FILEDATESI 8 /* v2 */
265 /****** TYPE_MACBIN ******/
267 * taken from capit.c by Nigel Perry, np@doc.ic.ac.uk which is adapted
268 * from unmacbin by John M. Sellens, jmsellens@watdragon.uwaterloo.ca
272 #define MB_NAMELEN 63 /* maximum legal Mac file name length */
276 * Format of a bin file:
277 * A bin file is composed of 128 byte blocks. The first block is the
278 * info_header (see below). Then comes the data fork, null padded to fill the
279 * last block. Then comes the resource fork, padded to fill the last block. A
280 * proposal to follow with the text of the Get Info box has not been implemented,
281 * to the best of my knowledge. Version, zero1 and zero2 are what the receiving
282 * program looks at to determine if a MacBinary transfer is being initiated.
284 typedef struct { /* info file header (128 bytes). Unfortunately, these */
285 /* longs don't align to word boundaries */
286 byte version; /* there is only a version 0 at this time */
287 byte nlen; /* Length of filename. */
288 byte name[MB_NAMELEN]; /* Filename */
289 byte type[4]; /* File type. */
290 byte auth[4]; /* File creator. */
291 byte flags; /* file flags: LkIvBnSyBzByChIt */
292 byte zero1; /* Locked, Invisible,Bundle, System */
293 /* Bozo, Busy, Changed, Init */
294 byte icon_vert[2]; /* Vertical icon position within window */
295 byte icon_horiz[2]; /* Horizontal icon postion in window */
296 byte window_id[2]; /* Window or folder ID. */
297 byte protect; /* = 1 for protected file, 0 otherwise */
299 byte dflen[4]; /* Data Fork length (bytes) - most sig. */
300 byte rflen[4]; /* Resource Fork length byte first */
301 byte cdate[4]; /* File's creation date. */
302 byte mdate[4]; /* File's "last modified" date. */
303 byte ilen[2]; /* GetInfo message length */
304 byte flags2; /* Finder flags, bits 0-7 */
306 byte packlen[4]; /* length of total files when unpacked */
307 byte headlen[2]; /* length of secondary header */
308 byte uploadvers; /* Version of MacBinary II that the uploading program is written for */
309 byte readvers; /* Minimum MacBinary II version needed to read this file */
310 byte crc[2]; /* CRC of the previous 124 bytes */
311 byte padding[2]; /* two trailing unused bytes */
314 /****** TYPE_FE ******/
316 /* Information provided by Mark Weinstein <mrwesq@earthlink.net> */
321 byte finderinfo[INFOLEN]; /* Finder info */
333 /****** TYPE_SGI ******/
337 byte finderinfo[INFOLEN]; /* Finder info */
345 /****** TYPE_SFM ******/
348 * Information provided by Lou Rieger <lrieger@meridiancg.com> taken from
349 * an email from Eddie Bowers <eddieb@microsoft.com>
353 byte afpi_Signature[4]; /* Must be 0x00504641 */
354 byte afpi_Version[4]; /* Must be 0x00010000 */
355 byte afpi_Reserved1[4];
356 byte afpi_BackupTime[4]; /* Backup time for the file/dir */
357 byte finderinfo[INFOLEN]; /* Finder info */
358 byte afpi_ProDosInfo[6]; /* ProDos Info */
359 byte afpi_Reserved2[6];
362 #define SFM_MAGIC 0x00504641
363 #define SFM_VERSION 0x00010000
365 /****** TYPE_DHFS ******/
370 * Code ideas from 'hfstar' by Marcel Weiher marcel@metaobject.com,
371 * another GNU hfstar by Torres Vedras paulotex@yahoo.com and
372 * hfspax by Howard Oakley howard@quercus.demon.co.uk
375 #include <sys/attr.h>
378 unsigned long info_length;
379 struct timespec ctime;
380 struct timespec mtime;
384 #endif /* IS_MACOS_X */
386 #endif /* _APPLE_H */