Commit 1085aab7 authored by Arturo Tena/libole2's avatar Arturo Tena/libole2
Browse files

More documentation. Almost done, just missing MsOleStream.

parent 728d40c4
1999-12-17 Arturo Tena <arturo@directmail.org>
* ms-ole-summary.c, ms-ole-summary.h (filetime_to_unixtime,
unixtime_to_filetime): made private. May be a
ms-ole-summary-private.h file is better.
* ms-ole-summary.h: clean up.
* ms-ole.c, ms-ole.h: more documentation.
1999-12-17 Arturo Tena <arturo@directmail.org> 1999-12-17 Arturo Tena <arturo@directmail.org>
* ms-ole.c, ms-ole.h (BLP): made private. * ms-ole.c, ms-ole.h (BLP): made private.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ms-ole.h" #include "ms-ole.h"
#include "ms-ole-summary.h" #include "ms-ole-summary.h"
#define SUMMARY_ID(x) ((x) & 0xff) #define SUMMARY_ID(x) ((x) & 0xff)
typedef struct { typedef struct {
...@@ -786,6 +787,7 @@ ms_ole_summary_get_long (MsOleSummary *si, MsOleSummaryPID id, ...@@ -786,6 +787,7 @@ ms_ole_summary_get_long (MsOleSummary *si, MsOleSummaryPID id,
* *
* Return value: FIXME * Return value: FIXME
**/ **/
glong filetime_to_unixtime (guint32 low_time, guint32 high_time);
glong glong
filetime_to_unixtime (guint32 low_time, guint32 high_time) filetime_to_unixtime (guint32 low_time, guint32 high_time)
{ {
...@@ -864,6 +866,8 @@ filetime_to_unixtime (guint32 low_time, guint32 high_time) ...@@ -864,6 +866,8 @@ filetime_to_unixtime (guint32 low_time, guint32 high_time)
* since January 1, 1601. unixtime is the number of seconds since January 1, * since January 1, 1601. unixtime is the number of seconds since January 1,
* 1970. * 1970.
**/ **/
void unixtime_to_filetime (time_t unix_time, unsigned int *time_high,
unsigned int *time_low);
void void
unixtime_to_filetime (time_t unix_time, unsigned int *time_high, unsigned int *time_low) unixtime_to_filetime (time_t unix_time, unsigned int *time_high, unsigned int *time_low)
{ {
......
...@@ -8,16 +8,19 @@ ...@@ -8,16 +8,19 @@
* Built on work by: * Built on work by:
* Somar Software's CPPSUM (http://www.somar.com) * Somar Software's CPPSUM (http://www.somar.com)
**/ **/
#include <time.h>
#ifndef MS_OLE_SUMMARY_H #ifndef MS_OLE_SUMMARY_H
#define MS_OLE_SUMMARY_H #define MS_OLE_SUMMARY_H
#include <time.h>
/* /*
* MS Ole Property Set IDs * MS Ole Property Set IDs
* The SummaryInformation stream contains the SummaryInformation property set. * The SummaryInformation stream contains the SummaryInformation property set.
* The DocumentSummaryInformation stream contains both the DocumentSummaryInformation * The DocumentSummaryInformation stream contains both the
* and the UserDefined property sets as sections. * DocumentSummaryInformation and the UserDefined property sets as sections.
*/ */
typedef enum { typedef enum {
MS_OLE_PS_SUMMARY_INFO, MS_OLE_PS_SUMMARY_INFO,
...@@ -26,33 +29,33 @@ typedef enum { ...@@ -26,33 +29,33 @@ typedef enum {
} MsOlePropertySetID; } MsOlePropertySetID;
typedef struct { typedef struct {
guint8 class_id[16]; guint8 class_id[16];
GArray *sections; GArray * sections;
GArray *items; GArray * items;
GList *write_items; GList * write_items;
gboolean read_mode; gboolean read_mode;
MsOleStream *s; MsOleStream * s;
MsOlePropertySetID ps_id; MsOlePropertySetID ps_id;
} MsOleSummary; } MsOleSummary;
/* Could store the FID, but why bother ? */
typedef struct { typedef struct {
/* Could store the FID, but why bother ? */ guint32 offset;
guint32 offset; guint32 props;
guint32 props; guint32 bytes;
guint32 bytes; MsOlePropertySetID ps_id;
MsOlePropertySetID ps_id;
} MsOleSummarySection; } MsOleSummarySection;
MsOleSummary * ms_ole_summary_open (MsOle *f); MsOleSummary * ms_ole_summary_open (MsOle *f);
MsOleSummary * ms_ole_docsummary_open (MsOle *f); MsOleSummary * ms_ole_docsummary_open (MsOle *f);
MsOleSummary * ms_ole_summary_open_stream (MsOleStream *s, MsOleSummary * ms_ole_summary_open_stream (MsOleStream *stream,
const MsOlePropertySetID psid); const MsOlePropertySetID psid);
MsOleSummary * ms_ole_summary_create (MsOle *f); MsOleSummary * ms_ole_summary_create (MsOle *f);
MsOleSummary * ms_ole_docsummary_create (MsOle *f); MsOleSummary * ms_ole_docsummary_create (MsOle *f);
MsOleSummary * ms_ole_summary_create_stream (MsOleStream *s, MsOleSummary * ms_ole_summary_create_stream (MsOleStream *s,
const MsOlePropertySetID psid); const MsOlePropertySetID psid);
GArray * ms_ole_summary_get_properties (MsOleSummary *si); GArray * ms_ole_summary_get_properties (MsOleSummary *si);
void ms_ole_summary_close (MsOleSummary *si); void ms_ole_summary_close (MsOleSummary *si);
/* /*
...@@ -69,6 +72,7 @@ typedef enum { ...@@ -69,6 +72,7 @@ typedef enum {
#define MS_OLE_SUMMARY_TYPE(x) ((MsOleSummaryType)((x)>>8)) #define MS_OLE_SUMMARY_TYPE(x) ((MsOleSummaryType)((x)>>8))
/* FIXME MS_OLE_SUMMARY_THUMBNAIL is Preview, no Security, isn't it? */
/* /*
* The MS byte specifies the type, the LS byte is the * The MS byte specifies the type, the LS byte is the
* 'standard' MS PID. * 'standard' MS PID.
...@@ -101,7 +105,6 @@ typedef enum { ...@@ -101,7 +105,6 @@ typedef enum {
/* Short integer properties */ /* Short integer properties */
MS_OLE_SUMMARY_CODEPAGE = 0x4001, MS_OLE_SUMMARY_CODEPAGE = 0x4001,
/* FIXME tenix it is Preview, isn't it? */
/* Security */ /* Security */
MS_OLE_SUMMARY_THUMBNAIL = 0x6011, MS_OLE_SUMMARY_THUMBNAIL = 0x6011,
...@@ -145,54 +148,49 @@ typedef struct { ...@@ -145,54 +148,49 @@ typedef struct {
guint8 *data; guint8 *data;
} MsOleSummaryPreview; } MsOleSummaryPreview;
gchar * ms_ole_summary_get_string (MsOleSummary *si, gchar * ms_ole_summary_get_string (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
gboolean ms_ole_summary_get_boolean (MsOleSummary *si, gboolean ms_ole_summary_get_boolean (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
guint16 ms_ole_summary_get_short (MsOleSummary *si, guint16 ms_ole_summary_get_short (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
guint32 ms_ole_summary_get_long (MsOleSummary *si, guint32 ms_ole_summary_get_long (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
GTimeVal ms_ole_summary_get_time (MsOleSummary *si, GTimeVal ms_ole_summary_get_time (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
MsOleSummaryPreview ms_ole_summary_get_preview (MsOleSummary *si, MsOleSummaryPreview ms_ole_summary_get_preview (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean *available); gboolean *available);
void ms_ole_summary_preview_destroy (MsOleSummaryPreview d); void ms_ole_summary_preview_destroy (MsOleSummaryPreview d);
/* FIXME: The next comment isn't true, is it? /* FIXME The next comment isn't true, is it?
Return TRUE if write is successful */ Return TRUE if write is successful */
void ms_ole_summary_set_string (MsOleSummary *si, void ms_ole_summary_set_string (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
const gchar *str); const gchar *str);
void ms_ole_summary_set_boolean (MsOleSummary *si, void ms_ole_summary_set_boolean (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
gboolean bool); gboolean bool);
void ms_ole_summary_set_short (MsOleSummary *si, void ms_ole_summary_set_short (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
guint16 i); guint16 i);
void ms_ole_summary_set_long (MsOleSummary *si, void ms_ole_summary_set_long (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
guint32 i); guint32 i);
void ms_ole_summary_set_time (MsOleSummary *si, void ms_ole_summary_set_time (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
GTimeVal time); GTimeVal time);
void ms_ole_summary_set_preview (MsOleSummary *si, void ms_ole_summary_set_preview (MsOleSummary *si,
MsOleSummaryPID id, MsOleSummaryPID id,
const MsOleSummaryPreview * const
preview); MsOleSummaryPreview *
preview);
glong filetime_to_unixtime (guint32 low_time,
guint32 high_time); #endif /* MS_OLE_SUMMARY_H */
void unixtime_to_filetime (time_t unix_time,
unsigned int *time_high,
unsigned int *time_low);
#endif
...@@ -123,28 +123,28 @@ write_wrap (int fd, const void *buf, size_t count) ...@@ -123,28 +123,28 @@ write_wrap (int fd, const void *buf, size_t count)
} }
static off_t static off_t
lseek_wrap (int fildes, off_t offset, int whence) lseek_wrap (int fd, off_t offset, int whence)
{ {
return lseek (fildes, offset, whence); return lseek (fd, offset, whence);
} }
static int static int
isregfile_wrap (int fildes) isregfile_wrap (int fd)
{ {
struct stat st; struct stat st;
if (fstat (fildes, &st)) if (fstat (fd, &st))
return 0; return 0;
return S_ISREG(st.st_mode); return S_ISREG(st.st_mode);
} }
static int static int
getfilesize_wrap (int fildes, guint32 *size) getfilesize_wrap (int fd, guint32 *size)
{ {
struct stat st; struct stat st;
if (fstat (fildes, &st)) if (fstat (fd, &st))
return -1; return -1;
*size = st.st_size; *size = st.st_size;
...@@ -1503,13 +1503,13 @@ ms_ole_open_vfs (MsOle **f, const char *name, gboolean try_mmap, ...@@ -1503,13 +1503,13 @@ ms_ole_open_vfs (MsOle **f, const char *name, gboolean try_mmap,
g_free (*f) ; g_free (*f) ;
return MS_OLE_ERR_EXIST; return MS_OLE_ERR_EXIST;
} }
if ((*f)->syswrap->getfilesize(file, &((*f)->length))) { if ((*f)->syswrap->getfilesize( file, &((*f)->length) )) {
printf ("Couldn't get the size of file '%s'\n", name); printf ("Couldn't get the size of file '%s'\n", name);
(*f)->syswrap->close (file) ; (*f)->syswrap->close (file) ;
g_free (*f) ; g_free (*f) ;
return MS_OLE_ERR_EXIST; return MS_OLE_ERR_EXIST;
} }
if ((*f)->length<=0x4c) { /* Bad show */ if ((*f)->length <= 0x4c) { /* Bad show */
#if OLE_DEBUG > 0 #if OLE_DEBUG > 0
printf ("File '%s' too short\n", name); printf ("File '%s' too short\n", name);
#endif #endif
...@@ -1771,7 +1771,7 @@ ms_ole_destroy (MsOle **ptr) ...@@ -1771,7 +1771,7 @@ ms_ole_destroy (MsOle **ptr)
* @ptr: memory area to be dumped. * @ptr: memory area to be dumped.
* @len: how many bytes will be dumped. * @len: how many bytes will be dumped.
* *
* Dump @len bytes from the memory area @ptr. * Dump @len bytes from the memory location given by @ptr.
**/ **/
void void
ms_ole_dump (guint8 const *ptr, guint32 len) ms_ole_dump (guint8 const *ptr, guint32 len)
...@@ -1940,11 +1940,12 @@ free_allocation (MsOle *f, guint32 startblock, gboolean is_big_block_stream) ...@@ -1940,11 +1940,12 @@ free_allocation (MsOle *f, guint32 startblock, gboolean is_big_block_stream)
* *
* Set the stream pointer for @s as many as @bytes bytes according to @type. * Set the stream pointer for @s as many as @bytes bytes according to @type.
* *
* Return value: * Return value: the new position of the stream pointer.
**/ **/
static MsOleSPos static MsOleSPos
ms_ole_lseek (MsOleStream *s, MsOleSPos bytes, MsOleSeek type) ms_ole_lseek (MsOleStream *s, MsOleSPos bytes, MsOleSeek type)
{ {
/* FIXME tenix improve limits detection: avoid gint vs guint limits */
MsOleSPos newpos; MsOleSPos newpos;
g_return_val_if_fail (s, -1); g_return_val_if_fail (s, -1);
...@@ -2471,11 +2472,11 @@ find_in_pps (GList *l, const char *name) ...@@ -2471,11 +2472,11 @@ find_in_pps (GList *l, const char *name)
* @f: ole file hande. * @f: ole file hande.
* @path: path to find. * @path: path to find.
* @file: file to find in path. * @file: file to find in path.
* @create_if_not_found: :-). * @create_if_not_found: create the pps with the given path if not found.
* *
* Locates a stream or storage with the given path. * Locates a stream or storage with the given path.
* *
* Return value: a MsOleErr code. * Return value: a #MsOleErr code.
**/ **/
static MsOleErr static MsOleErr
path_to_pps (PPS **pps, MsOle *f, const char *path, path_to_pps (PPS **pps, MsOle *f, const char *path,
...@@ -2566,6 +2567,8 @@ MsOleErr ...@@ -2566,6 +2567,8 @@ MsOleErr
ms_ole_unlink (MsOle *f, const char *path) ms_ole_unlink (MsOle *f, const char *path)
{ {
g_warning ("Unimplemented"); g_warning ("Unimplemented");
/* FIXME missing implementation, or at least a better error code =-) */
return MS_OLE_ERR_NOTEMPTY; return MS_OLE_ERR_NOTEMPTY;
} }
...@@ -2578,7 +2581,7 @@ ms_ole_unlink (MsOle *f, const char *path) ...@@ -2578,7 +2581,7 @@ ms_ole_unlink (MsOle *f, const char *path)
* *
* Gets the names of the streams and directories in the directory @dirpath. * Gets the names of the streams and directories in the directory @dirpath.
* *
* Returns: a MsOleErr code. * Returns: a #MsOleErr code.
**/ **/
MsOleErr MsOleErr
ms_ole_directory (char ***names, MsOle *f, const char *path) ms_ole_directory (char ***names, MsOle *f, const char *path)
...@@ -2629,7 +2632,7 @@ ms_ole_directory (char ***names, MsOle *f, const char *path) ...@@ -2629,7 +2632,7 @@ ms_ole_directory (char ***names, MsOle *f, const char *path)
* Gets information about the stream or the directory which is in the directory * Gets information about the stream or the directory which is in the directory
* @dirpath and its name is @file. * @dirpath and its name is @file.
* *
* Returns: a MsOleErr code. * Returns: a #MsOleErr code.
**/ **/
MsOleErr MsOleErr
ms_ole_stat (MsOleStat *stat, MsOle *f, const char *path, ms_ole_stat (MsOleStat *stat, MsOle *f, const char *path,
...@@ -2822,7 +2825,7 @@ ms_ole_stream_open (MsOleStream ** const stream, MsOle *f, ...@@ -2822,7 +2825,7 @@ ms_ole_stream_open (MsOleStream ** const stream, MsOle *f,
* *
* Duplicates the stream object @stream. * Duplicates the stream object @stream.
* *
* Return value: a MsOleErr code. * Return value: a #MsOleErr code.
**/ **/
MsOleErr MsOleErr
ms_ole_stream_duplicate (MsOleStream **s, const MsOleStream * const stream) ms_ole_stream_duplicate (MsOleStream **s, const MsOleStream * const stream)
......
...@@ -38,9 +38,9 @@ struct _MsOleSysWrappers { ...@@ -38,9 +38,9 @@ struct _MsOleSysWrappers {
ssize_t (*read) (int fd, void *buf, size_t count); ssize_t (*read) (int fd, void *buf, size_t count);
int (*close) (int fd); int (*close) (int fd);
ssize_t (*write) (int fd, const void *buf, size_t count); ssize_t (*write) (int fd, const void *buf, size_t count);
off_t (*lseek) (int fildes, off_t offset, int whence); off_t (*lseek) (int fd, off_t offset, int whence);
int (*isregfile) (int fildes); int (*isregfile) (int fd);
int (*getfilesize) (int fildes, guint32 *size); int (*getfilesize) (int fd, guint32 *size);
}; };
typedef enum { typedef enum {
...@@ -76,10 +76,11 @@ typedef enum { ...@@ -76,10 +76,11 @@ typedef enum {
MsOleRootT = 5 MsOleRootT = 5
} MsOleType; } MsOleType;
typedef struct { typedef struct _MsOleStat MsOleStat;
struct _MsOleStat {
MsOleType type; MsOleType type;
MsOlePos size; /* Valid only for streams */ MsOlePos size;
} MsOleStat; };
#define ms_ole_open(fs,path) ms_ole_open_vfs ((fs), (path), TRUE, NULL) #define ms_ole_open(fs,path) ms_ole_open_vfs ((fs), (path), TRUE, NULL)
extern MsOleErr ms_ole_open_vfs (MsOle **fs, extern MsOleErr ms_ole_open_vfs (MsOle **fs,
...@@ -146,7 +147,7 @@ struct _MsOleStream ...@@ -146,7 +147,7 @@ struct _MsOleStream
Points to the next byte to read */ Points to the next byte to read */
}; };
#define MS_OLE_GET_GUINT8(p) (*((const guint8 *)(p)+0)) #define MS_OLE_GET_GUINT8(p) (*((const guint8 *)(p) + 0))
#define MS_OLE_GET_GUINT16(p) (guint16)(*((const guint8 *)(p)+0) | \ #define MS_OLE_GET_GUINT16(p) (guint16)(*((const guint8 *)(p)+0) | \
(*((const guint8 *)(p)+1)<<8)) (*((const guint8 *)(p)+1)<<8))
#define MS_OLE_GET_GUINT32(p) (guint32)(*((const guint8 *)(p)+0) | \ #define MS_OLE_GET_GUINT32(p) (guint32)(*((const guint8 *)(p)+0) | \
...@@ -156,7 +157,7 @@ struct _MsOleStream ...@@ -156,7 +157,7 @@ struct _MsOleStream
#define MS_OLE_GET_GUINT64(p) (MS_OLE_GET_GUINT32(p) | \ #define MS_OLE_GET_GUINT64(p) (MS_OLE_GET_GUINT32(p) | \
(((guint32)MS_OLE_GET_GUINT32((const guint8 *)(p)+4))<<32)) (((guint32)MS_OLE_GET_GUINT32((const guint8 *)(p)+4))<<32))
#define MS_OLE_SET_GUINT8(p,n) (*((guint8 *)(p)+0)=n) #define MS_OLE_SET_GUINT8(p,n) (*((guint8 *)(p) + 0) = n)
#define MS_OLE_SET_GUINT16(p,n) ((*((guint8 *)(p)+0)=((n)&0xff)), \ #define MS_OLE_SET_GUINT16(p,n) ((*((guint8 *)(p)+0)=((n)&0xff)), \
(*((guint8 *)(p)+1)=((n)>>8)&0xff)) (*((guint8 *)(p)+1)=((n)>>8)&0xff))
#define MS_OLE_SET_GUINT32(p,n) ((*((guint8 *)(p)+0)=((n))&0xff), \ #define MS_OLE_SET_GUINT32(p,n) ((*((guint8 *)(p)+0)=((n))&0xff), \
......
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