1 /* vim: set sw=8 ts=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * ms-biff.h: MS Excel BIFF support for Gnumeric
6 * Jody Goldberg (jody@gnome.org)
7 * Michael Meeks (michael@ximian.com)
9 * (C) 1998-2001 Michael Meeks
10 * (C) 2002-2005 Jody Goldberg
17 typedef enum { MS_BIFF_CRYPTO_NONE
= 0,
20 MS_BIFF_CRYPTO_UNKNOWN
} MsBiffCrypto
;
23 MS_BIFF_V_UNKNOWN
= 0,
27 MS_BIFF_V5
= 5, /* Excel 5.0 */
28 MS_BIFF_V7
= 7, /* Excel 95 */
29 MS_BIFF_V8
= 8 /* Excel 97, 2000, XP, 2003 */
32 /*****************************************************************************/
34 /*****************************************************************************/
37 * Returns query data, it is imperative that copies of
38 * 'data *' should _not_ be kept.
43 gboolean data_malloced
, non_decrypted_data_malloced
;
44 guint8
*data
, *non_decrypted_data
;
49 MsBiffCrypto encryption
;
52 unsigned char md5_digest
[16];
54 gboolean dont_decrypt_next_record
;
57 /* Sets up a query on a stream */
58 BiffQuery
*ms_biff_query_new (GsfInput
*);
59 gboolean
ms_biff_query_set_decrypt (BiffQuery
*q
, MsBiffVersion version
,
60 guint8
const *password
);
61 void ms_biff_query_copy_decrypt (BiffQuery
*dst
, BiffQuery
const *src
);
63 /* Updates the BiffQuery structure with the next BIFF record
64 * returns: TRUE for succes, and FALSE for EOS(tream) */
65 gboolean
ms_biff_query_next (BiffQuery
*);
66 gboolean
ms_biff_query_peek_next (BiffQuery
*, guint16
*opcode
);
67 void ms_biff_query_destroy (BiffQuery
*);
68 void ms_biff_query_dump (BiffQuery
*);
69 guint32
ms_biff_query_bound_check (BiffQuery
*q
,
70 guint32 offset
, unsigned len
);
72 /*****************************************************************************/
74 /*****************************************************************************/
76 typedef struct _BiffPut
{
79 unsigned curpos
; /* Curpos is offset from beginning of header */
82 MsBiffVersion version
;
85 * Records are stored here until committed at which time they may
86 * by split using BIFF_CONTINUE records.
94 /* Sets up a record on a stream */
95 BiffPut
*ms_biff_put_new (GsfOutput
*, MsBiffVersion version
, int codepage
);
96 void ms_biff_put_destroy (BiffPut
*bp
);
99 * If between the 'next' and 'commit' ls / ms_op are changed they will be
102 /* For known length records shorter than 0x2000 bytes. */
103 guint8
*ms_biff_put_len_next (BiffPut
*bp
, guint16 opcode
, guint32 len
);
104 /* For unknown length records */
105 void ms_biff_put_var_next (BiffPut
*bp
, guint16 opcode
);
106 void ms_biff_put_var_write (BiffPut
*bp
, guint8
const *dat
, guint32 len
);
107 /* Seeks to pos bytes after the beggining of the record */
108 void ms_biff_put_var_seekto (BiffPut
*bp
, int pos
);
109 /* Must commit after each record */
110 void ms_biff_put_commit (BiffPut
*bp
);
112 /* convenience routines for simple records */
113 void ms_biff_put_empty (BiffPut
*bp
, guint16 opcode
);
114 void ms_biff_put_2byte (BiffPut
*bp
, guint16 opcode
, guint16 data
);
116 unsigned ms_biff_max_record_len (BiffPut
const *bp
);
118 void ms_biff_put_abs_write (BiffPut
*bp
, gsf_off_t pos
, gconstpointer buf
, gsize size
);
120 #endif /* GNM_BIFF_H */