patch genisoimage multi extent
[platform/upstream/cdrkit.git] / genisoimage / apple.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
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).
6  *
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.
10  *
11  */
12
13 /* @(#)apple.h  1.7 04/03/02 joerg, Copyright 1997, 1998, 1999, 2000 James Pearson */
14 /*
15  *      Copyright (c) 1997, 1998, 1999, 2000 James Pearson
16  *
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)
20  * any later version.
21  *
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.
26  *
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.
30  */
31
32 /*
33  * apple.h:     cut down macfile.h from CAP distribution
34  */
35 #ifndef _APPLE_H
36 #define _APPLE_H
37
38 #include "mactypes.h"
39
40 #ifndef O_BINARY
41 #define O_BINARY 0
42 #endif /* O_BINARY */
43
44 #ifdef  _WIN32_TEST
45 #undef  UNICODE
46 #include <windows.h>
47 #endif /* _WIN32 */
48
49 #ifndef MIN
50 #define MIN(a, b) (((a) < (b)) ? (a):(b))
51 #endif /* MIN */
52
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 */
57
58 typedef struct {
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 */
64 } afpmap;
65
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 *);
71
72 /* for libfile routines */
73 int init_magic(char *);
74 char * get_magic_match(const char *);
75
76 typedef unsigned char byte;
77 typedef unsigned char word[2];
78 typedef unsigned char dword[4];
79
80 #define INFOLEN 32              /* Finder info is 32 bytes */
81
82 typedef struct {
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] */
96 } Finfo;
97
98 typedef struct {
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] */
111 } Dinfo;
112
113 /****** TYPE_CAP ******/
114
115 /*
116  * taken from the CAP distribution:
117  * macfile.h - header file with Macintosh file definitions
118  *
119  * AppleTalk package for UNIX (4.2 BSD).
120  *
121  * Copyright (c) 1986, 1987, 1988 by The Trustees of Columbia University in the
122  * City of New York.
123  *
124  * Edit History:
125  *
126  *  Sept 1987   Created by Charlie
127  *
128  */
129
130
131 #ifndef USE_MAC_DATES
132 #define USE_MAC_DATES
133 #endif /* USE_MAC_DATES */
134
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 */
138
139 typedef struct {
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 */
157 #ifdef  USE_MAC_DATES
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 */
166 } FileInfo;
167
168 /* Atribute flags */
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 */
175
176 /**** MAC STUFF *****/
177
178 /* Flags */
179 #define FNDR_fOnDesk 0x1
180 #define FNDR_fHasBundle 0x2000
181 #define FNDR_fInvisible 0x4000
182 /* locations */
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 */
186
187 /****** TYPE_ESHARE ******/
188
189 /*
190  *      Information supplied by Jens-Uwe Mager (jum@helios.de)
191  */
192
193 #define ES_VERSION      0x0102
194 #define ES_MAGIC        0x3681093
195 #define ES_INFOLEN      32
196 #define ES_INFO_SIZE    512
197
198 typedef struct {
199         dword           magic;
200         dword           serno;                  /* written only, never read */
201         word            version;
202         word            attr;                   /* invisible... */
203         word            openMax;                /* max number of opens */
204         word            filler0;
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 */
210 } es_FileInfo;
211
212 /****** TYPE_USHARE ******/
213
214 /*
215  * similar to the EtherShare layout, but the finder info stuff is different
216  * info provided by: Phil Sylvester <psylvstr@interaccess.com>
217  */
218
219 typedef struct {
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] */
227 } us_FileInfo;
228
229 /****** TYPE_DOUBLE, TYPE_SINGLE ******/
230
231 /*
232  *      Taken from cvt2cap (c) May 1988, Paul Campbell
233  */
234
235 typedef struct {
236         dword id;
237         dword offset;
238         dword length;
239 } a_entry;
240
241 typedef struct {
242         dword   magic;
243         dword   version;
244         char    home[16];
245         word    nentries;
246         a_entry entries[1];
247 } a_hdr;
248
249 #define A_HDR_SIZE      26
250 #define A_ENTRY_SIZE    sizeof (a_entry)
251
252 #define A_VERSION1      0x00010000
253 #define A_VERSION2      0x00020000
254 #define APPLE_SINGLE    0x00051600
255 #define APPLE_DOUBLE    0x00051607
256 #define ID_DATA         1
257 #define ID_RESOURCE     2
258 #define ID_NAME         3
259 #define ID_FILEI        7       /* v1 */
260 #define ID_FILEDATESI   8       /* v2 */
261 #define ID_FINDER       9
262
263 #define A_DATE          16
264
265 /****** TYPE_MACBIN ******/
266 /*
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
269  */
270
271
272 #define MB_NAMELEN 63           /* maximum legal Mac file name length */
273 #define MB_SIZE 128
274
275 /*
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.
283  */
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 */
298         byte zero2;
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 */
305         byte unused[14];
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 */
312 } mb_info;
313
314 /****** TYPE_FE ******/
315
316 /* Information provided by Mark Weinstein <mrwesq@earthlink.net> */
317
318 typedef struct {
319         byte    nlen;
320         byte    name[31];
321         byte    finderinfo[INFOLEN];    /* Finder info */
322         byte    cdate[4];
323         byte    mdate[4];
324         byte    bdate[4];
325         byte    fileid[4];
326         byte    sname[8];
327         byte    ext[3];
328         byte    pad;
329 } fe_info;
330
331 #define FE_SIZE 92
332
333 /****** TYPE_SGI ******/
334
335 typedef struct {
336         byte    unknown1[8];
337         byte    finderinfo[INFOLEN];    /* Finder info */
338         byte    unknown2[214];
339         byte    name[32];
340         byte    unknown3[14];
341 } sgi_info;
342
343 #define SGI_SIZE 300
344
345 /****** TYPE_SFM ******/
346
347 /*
348  * Information provided by Lou Rieger <lrieger@meridiancg.com> taken from
349  * an email from Eddie Bowers <eddieb@microsoft.com>
350  */
351
352 typedef struct {
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];
360 } sfm_info;
361
362 #define SFM_MAGIC       0x00504641
363 #define SFM_VERSION     0x00010000
364
365 /****** TYPE_DHFS ******/
366
367 #ifdef IS_MACOS_X
368
369 /*
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
373  */
374
375 #include <sys/attr.h>
376
377 typedef struct {
378         unsigned long   info_length;
379         struct timespec ctime;
380         struct timespec mtime;
381         byte            info[32];
382 } attrinfo;
383
384 #endif /* IS_MACOS_X */
385
386 #endif /* _APPLE_H */