forked from Radmind/radmind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
applefile.h
92 lines (75 loc) · 2.04 KB
/
applefile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright (c) 2003 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*/
/*
* applesingle format:
* header:
* -magic number (4 bytes)
* -version number (4 bytes)
* -filler (16 bytes)
* -number of entries (2 bytes)
* -x number of entries, with this format:
* id (4 bytes)
* offset (4 bytes)
* length (4 bytes)
* data:
* -finder info
* -rsrc fork
* -data fork
*/
#include <sys/types.h>
#include <sys/param.h>
#include <inttypes.h>
#define AS_HEADERLEN 26
#ifdef __BIG_ENDIAN__
#define AS_MAGIC 0x00051600
#define AS_VERSION 0x00020000
#define AS_NENTRIES 0x0003
#else /* __BIG_ENDIAN__ */
#define AS_MAGIC 0x00160500
#define AS_VERSION 0x00000200
#define AS_NENTRIES 0x0300
#endif /* __BIG_ENDIAN__ */
#define ASEID_DFORK 1
#define ASEID_RFORK 2
#define ASEID_FINFO 9
#define AS_FIE 0 /* for array of ae_entry structs */
#define AS_RFE 1
#define AS_DFE 2
#define FINFOLEN 32
#define FI_CREATOR_OFFSET 4
/* applesingle entry */
struct as_entry {
uint32_t ae_id;
uint32_t ae_offset;
uint32_t ae_length;
};
/* applesingle header */
struct as_header {
uint32_t ah_magic;
uint32_t ah_version;
uint8_t ah_filler[ 16 ];
uint16_t ah_num_entries;
};
#if defined(__APPLE__) && defined(__LP64__) && defined(__GNUC__)
#pragma pack(push)
#pragma pack(4)
#endif /* __APPLE__ && __LP64__ && __GNUC__ */
struct attr_info {
uint32_t ai_size;
uint8_t ai_data[ FINFOLEN ];
off_t ai_rsrc_len;
};
#if defined(__APPLE__) && defined(__LP64__) && defined(__GNUC__)
#pragma pack(pop)
#endif /* __APPLE__ && __LP64__ && __GNUC__ */
struct applefileinfo {
struct attr_info ai; // finder info
struct as_entry as_ents[ 3 ]; // Apple Single entries
// For Finder info, rcrs and data forks
off_t as_size; // Total apple single file size
};
void as_entry_netswap( struct as_entry *e );
void as_entry_hostswap( struct as_entry *e );
off_t ckapplefile( char *applefile, int afd );