summaryrefslogtreecommitdiff
path: root/cdf.h
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2011-10-06 06:01:12 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2011-10-06 06:01:12 +0000
commitdacc26abaa8ab61168c45f0716bea144fa8afd14 (patch)
treed25590ff6bfc3386fbca9494d26b8761e3d33410 /cdf.h
parentb873e82fedb8026ff397a976c38d4182a21da706 (diff)
downloadsrc-test2-dacc26abaa8ab61168c45f0716bea144fa8afd14.tar.gz
src-test2-dacc26abaa8ab61168c45f0716bea144fa8afd14.zip
Notes
Diffstat (limited to 'cdf.h')
-rw-r--r--cdf.h166
1 files changed, 91 insertions, 75 deletions
diff --git a/cdf.h b/cdf.h
index 6fa3fc693917..7f3126b83d42 100644
--- a/cdf.h
+++ b/cdf.h
@@ -24,12 +24,27 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * Info from: http://sc.openoffice.org/compdocfileformat.pdf
+ * Parse Composite Document Files, the format used in Microsoft Office
+ * document files before they switched to zipped XML.
+ * Info from: http://sc.openoffice.org/compdocfileformat.pdf
+ *
+ * N.B. This is the "Composite Document File" format, and not the
+ * "Compound Document Format", nor the "Channel Definition Format".
*/
#ifndef _H_CDF_
#define _H_CDF_
+#ifdef WIN32
+#include <winsock2.h>
+#define timespec timeval
+#define tv_nsec tv_usec
+#endif
+#ifdef __DJGPP__
+#define timespec timeval
+#define tv_nsec tv_usec
+#endif
+
typedef int32_t cdf_secid_t;
#define CDF_LOOP_LIMIT 10000
@@ -41,24 +56,24 @@ typedef int32_t cdf_secid_t;
#define CDF_SECID_MASTER_SECTOR_ALLOCATION_TABLE -4
typedef struct {
- uint64_t h_magic;
+ uint64_t h_magic;
#define CDF_MAGIC 0xE11AB1A1E011CFD0LL
- uint64_t h_uuid[2];
- uint16_t h_revision;
- uint16_t h_version;
- uint16_t h_byte_order;
- uint16_t h_sec_size_p2;
- uint16_t h_short_sec_size_p2;
- uint8_t h_unused0[10];
- uint32_t h_num_sectors_in_sat;
- uint32_t h_secid_first_directory;
- uint8_t h_unused1[4];
- uint32_t h_min_size_standard_stream;
- cdf_secid_t h_secid_first_sector_in_short_sat;
- uint32_t h_num_sectors_in_short_sat;
- cdf_secid_t h_secid_first_sector_in_master_sat;
- uint32_t h_num_sectors_in_master_sat;
- cdf_secid_t h_master_sat[436/4];
+ uint64_t h_uuid[2];
+ uint16_t h_revision;
+ uint16_t h_version;
+ uint16_t h_byte_order;
+ uint16_t h_sec_size_p2;
+ uint16_t h_short_sec_size_p2;
+ uint8_t h_unused0[10];
+ uint32_t h_num_sectors_in_sat;
+ uint32_t h_secid_first_directory;
+ uint8_t h_unused1[4];
+ uint32_t h_min_size_standard_stream;
+ cdf_secid_t h_secid_first_sector_in_short_sat;
+ uint32_t h_num_sectors_in_short_sat;
+ cdf_secid_t h_secid_first_sector_in_master_sat;
+ uint32_t h_num_sectors_in_master_sat;
+ cdf_secid_t h_master_sat[436/4];
} cdf_header_t;
#define CDF_SEC_SIZE(h) (1 << (h)->h_sec_size_p2)
@@ -74,92 +89,92 @@ typedef int64_t cdf_timestamp_t;
#define CDF_TIME_PREC 10000000
typedef struct {
- uint16_t d_name[32];
- uint16_t d_namelen;
- uint8_t d_type;
+ uint16_t d_name[32];
+ uint16_t d_namelen;
+ uint8_t d_type;
#define CDF_DIR_TYPE_EMPTY 0
#define CDF_DIR_TYPE_USER_STORAGE 1
#define CDF_DIR_TYPE_USER_STREAM 2
#define CDF_DIR_TYPE_LOCKBYTES 3
#define CDF_DIR_TYPE_PROPERTY 4
#define CDF_DIR_TYPE_ROOT_STORAGE 5
- uint8_t d_color;
+ uint8_t d_color;
#define CDF_DIR_COLOR_READ 0
#define CDF_DIR_COLOR_BLACK 1
- cdf_dirid_t d_left_child;
- cdf_dirid_t d_right_child;
- cdf_dirid_t d_storage;
- uint64_t d_storage_uuid[2];
- uint32_t d_flags;
- cdf_timestamp_t d_created;
- cdf_timestamp_t d_modified;
- cdf_secid_t d_stream_first_sector;
- uint32_t d_size;
- uint32_t d_unused0;
+ cdf_dirid_t d_left_child;
+ cdf_dirid_t d_right_child;
+ cdf_dirid_t d_storage;
+ uint64_t d_storage_uuid[2];
+ uint32_t d_flags;
+ cdf_timestamp_t d_created;
+ cdf_timestamp_t d_modified;
+ cdf_secid_t d_stream_first_sector;
+ uint32_t d_size;
+ uint32_t d_unused0;
} cdf_directory_t;
#define CDF_DIRECTORY_SIZE 128
typedef struct {
- cdf_secid_t *sat_tab;
- size_t sat_len;
+ cdf_secid_t *sat_tab;
+ size_t sat_len;
} cdf_sat_t;
typedef struct {
- cdf_directory_t *dir_tab;
- size_t dir_len;
+ cdf_directory_t *dir_tab;
+ size_t dir_len;
} cdf_dir_t;
typedef struct {
- void *sst_tab;
- size_t sst_len;
- size_t sst_dirlen;
+ void *sst_tab;
+ size_t sst_len;
+ size_t sst_dirlen;
} cdf_stream_t;
typedef struct {
- uint32_t cl_dword;
- uint16_t cl_word[2];
- uint8_t cl_two[2];
- uint8_t cl_six[6];
+ uint32_t cl_dword;
+ uint16_t cl_word[2];
+ uint8_t cl_two[2];
+ uint8_t cl_six[6];
} cdf_classid_t;
typedef struct {
- uint16_t si_byte_order;
- uint16_t si_zero;
- uint16_t si_os_version;
- uint16_t si_os;
- cdf_classid_t si_class;
- uint32_t si_count;
+ uint16_t si_byte_order;
+ uint16_t si_zero;
+ uint16_t si_os_version;
+ uint16_t si_os;
+ cdf_classid_t si_class;
+ uint32_t si_count;
} cdf_summary_info_header_t;
#define CDF_SECTION_DECLARATION_OFFSET 0x1c
typedef struct {
- cdf_classid_t sd_class;
- uint32_t sd_offset;
+ cdf_classid_t sd_class;
+ uint32_t sd_offset;
} cdf_section_declaration_t;
typedef struct {
- uint32_t sh_len;
- uint32_t sh_properties;
+ uint32_t sh_len;
+ uint32_t sh_properties;
} cdf_section_header_t;
typedef struct {
- uint32_t pi_id;
- uint32_t pi_type;
- union {
- uint16_t _pi_u16;
- int16_t _pi_s16;
- uint32_t _pi_u32;
- int32_t _pi_s32;
- uint64_t _pi_u64;
- int64_t _pi_s64;
- cdf_timestamp_t _pi_tp;
- struct {
- uint32_t s_len;
- const char *s_buf;
- } _pi_str;
- } pi_val;
+ uint32_t pi_id;
+ uint32_t pi_type;
+ union {
+ uint16_t _pi_u16;
+ int16_t _pi_s16;
+ uint32_t _pi_u32;
+ int32_t _pi_s32;
+ uint64_t _pi_u64;
+ int64_t _pi_s64;
+ cdf_timestamp_t _pi_tp;
+ struct {
+ uint32_t s_len;
+ const char *s_buf;
+ } _pi_str;
+ } pi_val;
#define pi_u64 pi_val._pi_u64
#define pi_s64 pi_val._pi_s64
#define pi_u32 pi_val._pi_u32
@@ -226,7 +241,7 @@ typedef struct {
#define CDF_PROPERTY_SUBJECT 0x00000003
#define CDF_PROPERTY_AUTHOR 0x00000004
#define CDF_PROPERTY_KEYWORDS 0x00000005
-#define CDF_PROPERTY_COMMENTS 0x00000006
+#define CDF_PROPERTY_COMMENTS 0x00000006
#define CDF_PROPERTY_TEMPLATE 0x00000007
#define CDF_PROPERTY_LAST_SAVED_BY 0x00000008
#define CDF_PROPERTY_REVISION_NUMBER 0x00000009
@@ -243,9 +258,9 @@ typedef struct {
#define CDF_PROPERTY_LOCALE_ID 0x80000000
typedef struct {
- int i_fd;
- const unsigned char *i_buf;
- size_t i_len;
+ int i_fd;
+ const unsigned char *i_buf;
+ size_t i_len;
} cdf_info_t;
struct timespec;
@@ -276,19 +291,20 @@ int cdf_read_ssat(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
cdf_sat_t *);
int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *);
-int cdf_read_property_info(const cdf_stream_t *, uint32_t,
+int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
cdf_property_info_t **, size_t *, size_t *);
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
const cdf_dir_t *, cdf_stream_t *);
-int cdf_unpack_summary_info(const cdf_stream_t *, cdf_summary_info_header_t *,
- cdf_property_info_t **, size_t *);
+int cdf_unpack_summary_info(const cdf_stream_t *, const cdf_header_t *,
+ cdf_summary_info_header_t *, cdf_property_info_t **, size_t *);
int cdf_print_classid(char *, size_t, const cdf_classid_t *);
int cdf_print_property_name(char *, size_t, uint32_t);
int cdf_print_elapsed_time(char *, size_t, cdf_timestamp_t);
uint16_t cdf_tole2(uint16_t);
uint32_t cdf_tole4(uint32_t);
uint64_t cdf_tole8(uint64_t);
+char *cdf_ctime(const time_t *);
#ifdef CDF_DEBUG
void cdf_dump_header(const cdf_header_t *);