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