Deleted Added
full compact
cdf.h (226048) cdf.h (234250)
1/*-
2 * Copyright (c) 2008 Christos Zoulas
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46#endif
47
48typedef int32_t cdf_secid_t;
49
50#define CDF_LOOP_LIMIT 10000
51
52#define CDF_SECID_NULL 0
53#define CDF_SECID_FREE -1
1/*-
2 * Copyright (c) 2008 Christos Zoulas
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46#endif
47
48typedef int32_t cdf_secid_t;
49
50#define CDF_LOOP_LIMIT 10000
51
52#define CDF_SECID_NULL 0
53#define CDF_SECID_FREE -1
54#define CDF_SECID_END_OF_CHAIN -2
55#define CDF_SECID_SECTOR_ALLOCATION_TABLE -3
54#define CDF_SECID_END_OF_CHAIN -2
55#define CDF_SECID_SECTOR_ALLOCATION_TABLE -3
56#define CDF_SECID_MASTER_SECTOR_ALLOCATION_TABLE -4
57
58typedef struct {
56#define CDF_SECID_MASTER_SECTOR_ALLOCATION_TABLE -4
57
58typedef struct {
59 uint64_t h_magic;
59 uint64_t h_magic;
60#define CDF_MAGIC 0xE11AB1A1E011CFD0LL
60#define CDF_MAGIC 0xE11AB1A1E011CFD0LL
61 uint64_t h_uuid[2];
62 uint16_t h_revision;
63 uint16_t h_version;
64 uint16_t h_byte_order;
65 uint16_t h_sec_size_p2;
66 uint16_t h_short_sec_size_p2;
67 uint8_t h_unused0[10];
68 uint32_t h_num_sectors_in_sat;
69 uint32_t h_secid_first_directory;
70 uint8_t h_unused1[4];
71 uint32_t h_min_size_standard_stream;
72 cdf_secid_t h_secid_first_sector_in_short_sat;
73 uint32_t h_num_sectors_in_short_sat;
74 cdf_secid_t h_secid_first_sector_in_master_sat;
75 uint32_t h_num_sectors_in_master_sat;
76 cdf_secid_t h_master_sat[436/4];
61 uint64_t h_uuid[2];
62 uint16_t h_revision;
63 uint16_t h_version;
64 uint16_t h_byte_order;
65 uint16_t h_sec_size_p2;
66 uint16_t h_short_sec_size_p2;
67 uint8_t h_unused0[10];
68 uint32_t h_num_sectors_in_sat;
69 uint32_t h_secid_first_directory;
70 uint8_t h_unused1[4];
71 uint32_t h_min_size_standard_stream;
72 cdf_secid_t h_secid_first_sector_in_short_sat;
73 uint32_t h_num_sectors_in_short_sat;
74 cdf_secid_t h_secid_first_sector_in_master_sat;
75 uint32_t h_num_sectors_in_master_sat;
76 cdf_secid_t h_master_sat[436/4];
77} cdf_header_t;
78
77} cdf_header_t;
78
79#define CDF_SEC_SIZE(h) (1 << (h)->h_sec_size_p2)
79#define CDF_SEC_SIZE(h) ((size_t)(1 << (h)->h_sec_size_p2))
80#define CDF_SEC_POS(h, secid) (CDF_SEC_SIZE(h) + (secid) * CDF_SEC_SIZE(h))
80#define CDF_SEC_POS(h, secid) (CDF_SEC_SIZE(h) + (secid) * CDF_SEC_SIZE(h))
81#define CDF_SHORT_SEC_SIZE(h) (1 << (h)->h_short_sec_size_p2)
81#define CDF_SHORT_SEC_SIZE(h) ((size_t)(1 << (h)->h_short_sec_size_p2))
82#define CDF_SHORT_SEC_POS(h, secid) ((secid) * CDF_SHORT_SEC_SIZE(h))
83
82#define CDF_SHORT_SEC_POS(h, secid) ((secid) * CDF_SHORT_SEC_SIZE(h))
83
84typedef int32_t cdf_dirid_t;
84typedef int32_t cdf_dirid_t;
85#define CDF_DIRID_NULL -1
86
85#define CDF_DIRID_NULL -1
86
87typedef int64_t cdf_timestamp_t;
87typedef int64_t cdf_timestamp_t;
88#define CDF_BASE_YEAR 1601
89#define CDF_TIME_PREC 10000000
90
91typedef struct {
88#define CDF_BASE_YEAR 1601
89#define CDF_TIME_PREC 10000000
90
91typedef struct {
92 uint16_t d_name[32];
93 uint16_t d_namelen;
94 uint8_t d_type;
92 uint16_t d_name[32];
93 uint16_t d_namelen;
94 uint8_t d_type;
95#define CDF_DIR_TYPE_EMPTY 0
95#define CDF_DIR_TYPE_EMPTY 0
96#define CDF_DIR_TYPE_USER_STORAGE 1
97#define CDF_DIR_TYPE_USER_STREAM 2
98#define CDF_DIR_TYPE_LOCKBYTES 3
99#define CDF_DIR_TYPE_PROPERTY 4
100#define CDF_DIR_TYPE_ROOT_STORAGE 5
101 uint8_t d_color;
96#define CDF_DIR_TYPE_USER_STORAGE 1
97#define CDF_DIR_TYPE_USER_STREAM 2
98#define CDF_DIR_TYPE_LOCKBYTES 3
99#define CDF_DIR_TYPE_PROPERTY 4
100#define CDF_DIR_TYPE_ROOT_STORAGE 5
101 uint8_t d_color;
102#define CDF_DIR_COLOR_READ 0
103#define CDF_DIR_COLOR_BLACK 1
102#define CDF_DIR_COLOR_READ 0
103#define CDF_DIR_COLOR_BLACK 1
104 cdf_dirid_t d_left_child;
105 cdf_dirid_t d_right_child;
106 cdf_dirid_t d_storage;
107 uint64_t d_storage_uuid[2];
108 uint32_t d_flags;
109 cdf_timestamp_t d_created;
110 cdf_timestamp_t d_modified;
111 cdf_secid_t d_stream_first_sector;
112 uint32_t d_size;
113 uint32_t d_unused0;
104 cdf_dirid_t d_left_child;
105 cdf_dirid_t d_right_child;
106 cdf_dirid_t d_storage;
107 uint64_t d_storage_uuid[2];
108 uint32_t d_flags;
109 cdf_timestamp_t d_created;
110 cdf_timestamp_t d_modified;
111 cdf_secid_t d_stream_first_sector;
112 uint32_t d_size;
113 uint32_t d_unused0;
114} cdf_directory_t;
115
116#define CDF_DIRECTORY_SIZE 128
117
118typedef struct {
114} cdf_directory_t;
115
116#define CDF_DIRECTORY_SIZE 128
117
118typedef struct {
119 cdf_secid_t *sat_tab;
120 size_t sat_len;
119 cdf_secid_t *sat_tab;
120 size_t sat_len;
121} cdf_sat_t;
122
123typedef struct {
121} cdf_sat_t;
122
123typedef struct {
124 cdf_directory_t *dir_tab;
125 size_t dir_len;
124 cdf_directory_t *dir_tab;
125 size_t dir_len;
126} cdf_dir_t;
127
128typedef struct {
126} cdf_dir_t;
127
128typedef struct {
129 void *sst_tab;
130 size_t sst_len;
131 size_t sst_dirlen;
129 void *sst_tab;
130 size_t sst_len;
131 size_t sst_dirlen;
132} cdf_stream_t;
133
134typedef struct {
132} cdf_stream_t;
133
134typedef struct {
135 uint32_t cl_dword;
136 uint16_t cl_word[2];
137 uint8_t cl_two[2];
138 uint8_t cl_six[6];
135 uint32_t cl_dword;
136 uint16_t cl_word[2];
137 uint8_t cl_two[2];
138 uint8_t cl_six[6];
139} cdf_classid_t;
140
141typedef struct {
139} cdf_classid_t;
140
141typedef struct {
142 uint16_t si_byte_order;
143 uint16_t si_zero;
144 uint16_t si_os_version;
145 uint16_t si_os;
146 cdf_classid_t si_class;
147 uint32_t si_count;
142 uint16_t si_byte_order;
143 uint16_t si_zero;
144 uint16_t si_os_version;
145 uint16_t si_os;
146 cdf_classid_t si_class;
147 uint32_t si_count;
148} cdf_summary_info_header_t;
149
150#define CDF_SECTION_DECLARATION_OFFSET 0x1c
151
152typedef struct {
148} cdf_summary_info_header_t;
149
150#define CDF_SECTION_DECLARATION_OFFSET 0x1c
151
152typedef struct {
153 cdf_classid_t sd_class;
154 uint32_t sd_offset;
153 cdf_classid_t sd_class;
154 uint32_t sd_offset;
155} cdf_section_declaration_t;
156
157typedef struct {
155} cdf_section_declaration_t;
156
157typedef struct {
158 uint32_t sh_len;
159 uint32_t sh_properties;
158 uint32_t sh_len;
159 uint32_t sh_properties;
160} cdf_section_header_t;
161
162typedef struct {
160} cdf_section_header_t;
161
162typedef struct {
163 uint32_t pi_id;
164 uint32_t pi_type;
165 union {
166 uint16_t _pi_u16;
167 int16_t _pi_s16;
168 uint32_t _pi_u32;
169 int32_t _pi_s32;
170 uint64_t _pi_u64;
171 int64_t _pi_s64;
172 cdf_timestamp_t _pi_tp;
173 struct {
174 uint32_t s_len;
175 const char *s_buf;
176 } _pi_str;
177 } pi_val;
163 uint32_t pi_id;
164 uint32_t pi_type;
165 union {
166 uint16_t _pi_u16;
167 int16_t _pi_s16;
168 uint32_t _pi_u32;
169 int32_t _pi_s32;
170 uint64_t _pi_u64;
171 int64_t _pi_s64;
172 cdf_timestamp_t _pi_tp;
173 float _pi_f;
174 double _pi_d;
175 struct {
176 uint32_t s_len;
177 const char *s_buf;
178 } _pi_str;
179 } pi_val;
178#define pi_u64 pi_val._pi_u64
179#define pi_s64 pi_val._pi_s64
180#define pi_u32 pi_val._pi_u32
181#define pi_s32 pi_val._pi_s32
182#define pi_u16 pi_val._pi_u16
183#define pi_s16 pi_val._pi_s16
180#define pi_u64 pi_val._pi_u64
181#define pi_s64 pi_val._pi_s64
182#define pi_u32 pi_val._pi_u32
183#define pi_s32 pi_val._pi_s32
184#define pi_u16 pi_val._pi_u16
185#define pi_s16 pi_val._pi_s16
186#define pi_f pi_val._pi_f
187#define pi_d pi_val._pi_d
184#define pi_tp pi_val._pi_tp
185#define pi_str pi_val._pi_str
186} cdf_property_info_t;
187
188#define CDF_ROUND(val, by) (((val) + (by) - 1) & ~((by) - 1))
189
190/* Variant type definitions */
191#define CDF_EMPTY 0x00000000
188#define pi_tp pi_val._pi_tp
189#define pi_str pi_val._pi_str
190} cdf_property_info_t;
191
192#define CDF_ROUND(val, by) (((val) + (by) - 1) & ~((by) - 1))
193
194/* Variant type definitions */
195#define CDF_EMPTY 0x00000000
192#define CDF_NULL 0x00000001
196#define CDF_NULL 0x00000001
193#define CDF_SIGNED16 0x00000002
194#define CDF_SIGNED32 0x00000003
195#define CDF_FLOAT 0x00000004
196#define CDF_DOUBLE 0x00000005
197#define CDF_CY 0x00000006
197#define CDF_SIGNED16 0x00000002
198#define CDF_SIGNED32 0x00000003
199#define CDF_FLOAT 0x00000004
200#define CDF_DOUBLE 0x00000005
201#define CDF_CY 0x00000006
198#define CDF_DATE 0x00000007
202#define CDF_DATE 0x00000007
199#define CDF_BSTR 0x00000008
200#define CDF_DISPATCH 0x00000009
201#define CDF_ERROR 0x0000000a
202#define CDF_BOOL 0x0000000b
203#define CDF_VARIANT 0x0000000c
204#define CDF_UNKNOWN 0x0000000d
205#define CDF_DECIMAL 0x0000000e
206#define CDF_SIGNED8 0x00000010
207#define CDF_UNSIGNED8 0x00000011
208#define CDF_UNSIGNED16 0x00000012
203#define CDF_BSTR 0x00000008
204#define CDF_DISPATCH 0x00000009
205#define CDF_ERROR 0x0000000a
206#define CDF_BOOL 0x0000000b
207#define CDF_VARIANT 0x0000000c
208#define CDF_UNKNOWN 0x0000000d
209#define CDF_DECIMAL 0x0000000e
210#define CDF_SIGNED8 0x00000010
211#define CDF_UNSIGNED8 0x00000011
212#define CDF_UNSIGNED16 0x00000012
209#define CDF_UNSIGNED32 0x00000013
213#define CDF_UNSIGNED32 0x00000013
210#define CDF_SIGNED64 0x00000014
211#define CDF_UNSIGNED64 0x00000015
212#define CDF_INT 0x00000016
213#define CDF_UINT 0x00000017
214#define CDF_VOID 0x00000018
215#define CDF_HRESULT 0x00000019
216#define CDF_PTR 0x0000001a
217#define CDF_SAFEARRAY 0x0000001b

--- 18 unchanged lines hidden (view full) ---

236#define CDF_ILLEGALMASKED 0x00000fff
237#define CDF_TYPEMASK 0x00000fff
238
239#define CDF_PROPERTY_CODE_PAGE 0x00000001
240#define CDF_PROPERTY_TITLE 0x00000002
241#define CDF_PROPERTY_SUBJECT 0x00000003
242#define CDF_PROPERTY_AUTHOR 0x00000004
243#define CDF_PROPERTY_KEYWORDS 0x00000005
214#define CDF_SIGNED64 0x00000014
215#define CDF_UNSIGNED64 0x00000015
216#define CDF_INT 0x00000016
217#define CDF_UINT 0x00000017
218#define CDF_VOID 0x00000018
219#define CDF_HRESULT 0x00000019
220#define CDF_PTR 0x0000001a
221#define CDF_SAFEARRAY 0x0000001b

--- 18 unchanged lines hidden (view full) ---

240#define CDF_ILLEGALMASKED 0x00000fff
241#define CDF_TYPEMASK 0x00000fff
242
243#define CDF_PROPERTY_CODE_PAGE 0x00000001
244#define CDF_PROPERTY_TITLE 0x00000002
245#define CDF_PROPERTY_SUBJECT 0x00000003
246#define CDF_PROPERTY_AUTHOR 0x00000004
247#define CDF_PROPERTY_KEYWORDS 0x00000005
244#define CDF_PROPERTY_COMMENTS 0x00000006
248#define CDF_PROPERTY_COMMENTS 0x00000006
245#define CDF_PROPERTY_TEMPLATE 0x00000007
246#define CDF_PROPERTY_LAST_SAVED_BY 0x00000008
247#define CDF_PROPERTY_REVISION_NUMBER 0x00000009
248#define CDF_PROPERTY_TOTAL_EDITING_TIME 0x0000000a
249#define CDF_PROPERTY_LAST_PRINTED 0X0000000b
250#define CDF_PROPERTY_CREATE_TIME 0x0000000c
251#define CDF_PROPERTY_LAST_SAVED_TIME 0x0000000d
252#define CDF_PROPERTY_NUMBER_OF_PAGES 0x0000000e
253#define CDF_PROPERTY_NUMBER_OF_WORDS 0x0000000f
254#define CDF_PROPERTY_NUMBER_OF_CHARACTERS 0x00000010
255#define CDF_PROPERTY_THUMBNAIL 0x00000011
256#define CDF_PROPERTY_NAME_OF_APPLICATION 0x00000012
257#define CDF_PROPERTY_SECURITY 0x00000013
258#define CDF_PROPERTY_LOCALE_ID 0x80000000
259
260typedef struct {
249#define CDF_PROPERTY_TEMPLATE 0x00000007
250#define CDF_PROPERTY_LAST_SAVED_BY 0x00000008
251#define CDF_PROPERTY_REVISION_NUMBER 0x00000009
252#define CDF_PROPERTY_TOTAL_EDITING_TIME 0x0000000a
253#define CDF_PROPERTY_LAST_PRINTED 0X0000000b
254#define CDF_PROPERTY_CREATE_TIME 0x0000000c
255#define CDF_PROPERTY_LAST_SAVED_TIME 0x0000000d
256#define CDF_PROPERTY_NUMBER_OF_PAGES 0x0000000e
257#define CDF_PROPERTY_NUMBER_OF_WORDS 0x0000000f
258#define CDF_PROPERTY_NUMBER_OF_CHARACTERS 0x00000010
259#define CDF_PROPERTY_THUMBNAIL 0x00000011
260#define CDF_PROPERTY_NAME_OF_APPLICATION 0x00000012
261#define CDF_PROPERTY_SECURITY 0x00000013
262#define CDF_PROPERTY_LOCALE_ID 0x80000000
263
264typedef struct {
261 int i_fd;
262 const unsigned char *i_buf;
263 size_t i_len;
265 int i_fd;
266 const unsigned char *i_buf;
267 size_t i_len;
264} cdf_info_t;
265
266struct timespec;
267int cdf_timestamp_to_timespec(struct timespec *, cdf_timestamp_t);
268int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timespec *);
269int cdf_read_header(const cdf_info_t *, cdf_header_t *);
270void cdf_swap_header(cdf_header_t *);
271void cdf_unpack_header(cdf_header_t *, char *);

--- 50 unchanged lines hidden ---
268} cdf_info_t;
269
270struct timespec;
271int cdf_timestamp_to_timespec(struct timespec *, cdf_timestamp_t);
272int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timespec *);
273int cdf_read_header(const cdf_info_t *, cdf_header_t *);
274void cdf_swap_header(cdf_header_t *);
275void cdf_unpack_header(cdf_header_t *, char *);

--- 50 unchanged lines hidden ---