Commit 13da21d5 authored by Michael Meeks's avatar Michael Meeks
Browse files

OLE2 library re-written, block based back-end completely discarded.

Seems to work for me :-), faster & cleaner hopefully.
parent 10c2fb14
1999-05-20 Michael Meeks <michael@imaginator.com>
* ole.c (main): Change ole_new to ole_open.
(list_files): Added assertion.
* boot.c (excel_load): Same.
1999-05-19 Michael Meeks <michael@imaginator.com>
* ole.c (main): Add New OLE file creation support.
* ms-excel-read.c (ms_excel_set_cell_xf): Cleaned silly
debug.
......
......@@ -30,7 +30,7 @@ excel_probe (const char *filename)
MS_OLE *f;
int res;
f = ms_ole_new (filename);
f = ms_ole_open (filename);
res = f != NULL;
......@@ -45,7 +45,7 @@ excel_load (const char *filename)
Workbook *wb;
MS_OLE *f;
f = ms_ole_new (filename);
f = ms_ole_open (filename);
if (!f)
return NULL;
......
1999-05-20 Michael Meeks <michael@imaginator.com>
* ms-ole.c: Whole Block structure totaly re-written for the
third time ! Lots cleaner, and should support non-mmapped
architectures with time.
1999-05-19 Michael Meeks <michael@imaginator.com>
* ms-ole.c (ms_ole_write_sb): Fix fatal bug with converting a
SB -> a BB file when mmap moves memory invalidating src ptr.
(ms_ole_create): Init header to UNUSED_BLOCK.
1999-05-18 Michael Meeks <michael@imaginator.com>
* ms-ole.c (init_pps): Constricted name writing further.
......
......@@ -7,3 +7,5 @@ Much useful information will be gleaned from the work on wine by.
Marcus Meissner, Francis Beaudet, Sylvain St-Germain
and Thuy Nguyen
This code is now being re-written for the 3rd and hopefully
final time.
This diff is collapsed.
......@@ -9,27 +9,23 @@
#include <glib.h>
typedef guint32 BBPtr ;
typedef guint32 SBPtr ;
/* Whether to use memory mapped IO */
#define OLE_MMAP 1
/* Block pointer */
typedef guint32 BLP;
/* Forward declarations of types */
typedef struct _MS_OLE MS_OLE;
typedef struct _MS_OLE_HEADER MS_OLE_HEADER;
typedef struct _MS_OLE_STREAM MS_OLE_STREAM;
typedef struct _MS_OLE_DIRECTORY MS_OLE_DIRECTORY;
struct _MS_OLE_HEADER
{
/* sbd = Small Block Depot ( made up of BB's BTW ) */
BBPtr sbd_startblock ;
GArray *sbd_list;
BBPtr sbf_startblock ; /* Identifies the stream containing all small blocks are in. */
GArray *sbf_list;
BBPtr root_startblock ;
GArray *root_list;
};
typedef enum { MS_OLE_SEEK_SET, MS_OLE_SEEK_CUR } ms_ole_seek_t;
#ifdef G_HAVE_GINT64
typedef guint32 ms_ole_pos_t;
#else
typedef guint32 ms_ole_pos_t;
#endif
typedef guint32 PPS_IDX ;
typedef enum _PPS_TYPE { MS_OLE_PPS_STORAGE = 1,
......@@ -48,29 +44,34 @@ struct _MS_OLE
* To be considered private
**/
char mode;
MS_OLE_HEADER header ; /* For speed cut down dereferences */
int file_descriptor ;
GArray *bb; /* Big blocks status */
#ifndef OLE_MMAP
GPtrArray *bbptr; /* Pointers to blocks NULL if not read in */
#endif
GArray *sb; /* Small block status */
GArray *sbf; /* The small block file */
GPtrArray *pps; /* Property Storage -> struct _PPS */
};
/* Create new OLE file */
extern MS_OLE *ms_ole_create (const char *name) ;
/* Open existing OLE file */
extern MS_OLE *ms_ole_new (const char *name) ;
extern MS_OLE *ms_ole_open (const char *name) ;
/* Get a root directory handle */
extern MS_OLE_DIRECTORY *ms_ole_get_root (MS_OLE *);
extern void ms_ole_destroy (MS_OLE *ptr) ;
struct _MS_OLE_DIRECTORY
{
char *name ;
PPS_TYPE type ;
guint32 length ;
PPS_IDX pps ;
char *name;
ms_ole_pos_t length;
PPS_TYPE type;
PPS_IDX pps;
/* Brain damaged linked list workaround */
PPS_IDX primary_entry ;
PPS_IDX primary_entry ;
/* Private */
MS_OLE *file ;
MS_OLE *file ;
};
extern MS_OLE_DIRECTORY *ms_ole_directory_new (MS_OLE *) ;
......@@ -83,13 +84,6 @@ extern MS_OLE_DIRECTORY *ms_ole_directory_create (MS_OLE_DIRECTORY *d,
extern void ms_ole_directory_unlink (MS_OLE_DIRECTORY *) ;
extern void ms_ole_directory_destroy (MS_OLE_DIRECTORY *) ;
typedef enum { MS_OLE_SEEK_SET, MS_OLE_SEEK_CUR } ms_ole_seek_t;
#ifdef G_HAVE_GINT64
typedef guint32 ms_ole_pos_t;
#else
typedef guint32 ms_ole_pos_t;
#endif
struct _MS_OLE_STREAM
{
GArray *blocks; /* A list of the blocks in the file if NULL: no file */
......@@ -131,3 +125,5 @@ extern void ms_ole_stream_close (MS_OLE_STREAM *) ;
extern void dump (guint8 *ptr, guint32 len) ;
#endif
......@@ -129,6 +129,7 @@ static void
list_files (MS_OLE *ole)
{
MS_OLE_DIRECTORY *dir = ms_ole_directory_new (ole);
g_assert (dir);
while (ms_ole_directory_next(dir)) {
printf ("'%25s' : type %d, length %d bytes\n", dir->name, dir->type, dir->length);
}
......@@ -510,9 +511,13 @@ int main (int argc, char **argv)
syntax_error(0);
printf ("Ole file '%s'\n", argv[1]);
ole = ms_ole_new (argv[1]);
ole = ms_ole_open (argv[1]);
if (!ole) {
printf ("Creating new file '%s'\n", argv[1]);
ole = ms_ole_create (argv[1]);
}
if (!ole)
syntax_error ("Can't open file");
syntax_error ("Can't open file or create new one");
if (argc<=2)
syntax_error ("Need command or -i");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment