summaryrefslogtreecommitdiffstats
path: root/libmsi/libmsi-summary-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmsi/libmsi-summary-info.c')
-rw-r--r--libmsi/libmsi-summary-info.c95
1 files changed, 42 insertions, 53 deletions
diff --git a/libmsi/libmsi-summary-info.c b/libmsi/libmsi-summary-info.c
index 6e237dd..f34e04e 100644
--- a/libmsi/libmsi-summary-info.c
+++ b/libmsi/libmsi-summary-info.c
@@ -24,11 +24,7 @@
#include "libmsi-summary-info.h"
-#define COBJMACROS
-#define NONAMELESSUNION
-
#include "debug.h"
-#include "unicode.h"
#include "libmsi.h"
#include "msipriv.h"
@@ -43,11 +39,11 @@ enum
G_DEFINE_TYPE (LibmsiSummaryInfo, libmsi_summary_info, G_TYPE_OBJECT);
-static const WCHAR szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0};
+static const char szSumInfo[] = "\5SummaryInformation";
static const uint8_t fmtid_SummaryInformation[16] =
{ 0xe0, 0x85, 0x9f, 0xf2, 0xf9, 0x4f, 0x68, 0x10, 0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9};
-static unsigned load_summary_info (LibmsiSummaryInfo *si, IStream *stm);
+static unsigned load_summary_info( LibmsiSummaryInfo *si, GsfInput *stm );
static void
libmsi_summary_info_init (LibmsiSummaryInfo *p)
@@ -121,14 +117,14 @@ libmsi_summary_info_constructed (GObject *object)
{
LibmsiSummaryInfo *self = LIBMSI_SUMMARY_INFO (object);
LibmsiSummaryInfo *p = self;
- IStream *stm = NULL;
+ GsfInput *stm = NULL;
unsigned r;
/* read the stream... if we fail, we'll start with an empty property set */
r = msi_get_raw_stream (p->database, szSumInfo, &stm);
if (r == 0) {
load_summary_info (self, stm);
- IStream_Release( stm );
+ g_object_unref (G_OBJECT (stm));
}
G_OBJECT_CLASS (libmsi_summary_info_parent_class)->constructed (object);
@@ -199,7 +195,7 @@ static unsigned get_property_count( const LibmsiOLEVariant *property )
return n;
}
-static unsigned read_word( uint8_t *data, unsigned *ofs )
+static unsigned read_word( const uint8_t *data, unsigned *ofs )
{
unsigned val = 0;
val = data[*ofs];
@@ -208,7 +204,7 @@ static unsigned read_word( uint8_t *data, unsigned *ofs )
return val;
}
-static unsigned read_dword( uint8_t *data, unsigned *ofs )
+static unsigned read_dword( const uint8_t *data, unsigned *ofs )
{
unsigned val = 0;
val = data[*ofs];
@@ -219,41 +215,41 @@ static unsigned read_dword( uint8_t *data, unsigned *ofs )
return val;
}
-static void parse_filetime( const WCHAR *str, guint64 *ft )
+static void parse_filetime( const char *str, guint64 *ft )
{
struct tm tm;
time_t t;
- const WCHAR *p = str;
- WCHAR *end;
+ const char *p = str;
+ char *end;
/* YYYY/MM/DD hh:mm:ss */
while ( *p == ' ' || *p == '\t' ) p++;
- tm.tm_year = strtolW( p, &end, 10 );
+ tm.tm_year = strtol( p, &end, 10 );
if (*end != '/') return;
p = end + 1;
- tm.tm_mon = strtolW( p, &end, 10 ) - 1;
+ tm.tm_mon = strtol( p, &end, 10 ) - 1;
if (*end != '/') return;
p = end + 1;
- tm.tm_mday = strtolW( p, &end, 10 );
+ tm.tm_mday = strtol( p, &end, 10 );
if (*end != ' ') return;
p = end + 1;
while ( *p == ' ' || *p == '\t' ) p++;
- tm.tm_hour = strtolW( p, &end, 10 );
+ tm.tm_hour = strtol( p, &end, 10 );
if (*end != ':') return;
p = end + 1;
- tm.tm_min = strtolW( p, &end, 10 );
+ tm.tm_min = strtol( p, &end, 10 );
if (*end != ':') return;
p = end + 1;
- tm.tm_sec = strtolW( p, &end, 10 );
+ tm.tm_sec = strtol( p, &end, 10 );
t = mktime(&tm);
@@ -264,7 +260,7 @@ static void parse_filetime( const WCHAR *str, guint64 *ft )
}
/* FIXME: doesn't deal with endian conversion */
-static void read_properties_from_data( LibmsiOLEVariant *prop, uint8_t *data, unsigned sz, uint32_t cProperties )
+static void read_properties_from_data( LibmsiOLEVariant *prop, const uint8_t *data, unsigned sz, uint32_t cProperties )
{
unsigned type;
unsigned i;
@@ -347,9 +343,7 @@ static void read_properties_from_data( LibmsiOLEVariant *prop, uint8_t *data, un
if( type == OLEVT_I2 || type == OLEVT_I4) {
property->intval = atoi( str );
} else if( type == OLEVT_FILETIME) {
- WCHAR *wstr = strdupAtoW(str);
- parse_filetime( wstr, &property->filetime );
- msi_free (wstr);
+ parse_filetime( str, &property->filetime );
}
msi_free (str);
}
@@ -361,40 +355,32 @@ static void read_properties_from_data( LibmsiOLEVariant *prop, uint8_t *data, un
}
}
-static unsigned load_summary_info( LibmsiSummaryInfo *si, IStream *stm )
+static unsigned load_summary_info( LibmsiSummaryInfo *si, GsfInput *stm )
{
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
uint8_t *data = NULL;
unsigned ofs, dwOffset;
- unsigned count, size, cbSection, cProperties;
- HRESULT r;
- STATSTG stat;
+ unsigned cbSection, cProperties;
+ off_t sz;
TRACE("%p %p\n", si, stm);
- r = IStream_Stat(stm, &stat, STATFLAG_NONAME);
- if (FAILED(r))
- return r;
-
- if (stat.cbSize.QuadPart >> 32)
- {
- ERR("Storage is too large\n");
+ sz = gsf_input_size(stm);
+ if (!sz)
return ret;
- }
-
- size = stat.cbSize.QuadPart;
- data = msi_alloc(size);
+ data = g_try_malloc(gsf_input_size(stm));
+ if (!data)
+ return LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
- ofs = 0;
- r = IStream_Read( stm, data, size, &count );
- if( FAILED(r) || count != size )
- return ret;
+ if (!gsf_input_read(stm, sz, data))
+ goto done;
/* process the set header */
+ ofs = 0;
if( read_word( data, &ofs) != 0xfffe )
{
ERR("property set not little-endian\n");
- return ret;
+ goto done;
}
/* process the format header */
@@ -402,7 +388,7 @@ static unsigned load_summary_info( LibmsiSummaryInfo *si, IStream *stm )
/* check the format id is correct */
ofs = 28;
if( memcmp( &fmtid_SummaryInformation, &data[ofs], 16 ) )
- return ret;
+ goto done;
/* seek to the location of the section */
ofs += 16;
@@ -415,7 +401,7 @@ static unsigned load_summary_info( LibmsiSummaryInfo *si, IStream *stm )
if( cProperties > MSI_MAX_PROPS )
{
ERR("too many properties %d\n", cProperties);
- return ret;
+ goto done;
}
/* read all the data in one go */
@@ -423,6 +409,7 @@ static unsigned load_summary_info( LibmsiSummaryInfo *si, IStream *stm )
&data[dwOffset],
cbSection, cProperties );
+done:
msi_free( data );
return ret;
}
@@ -494,7 +481,7 @@ static unsigned write_property_to_data( const LibmsiOLEVariant *prop, uint8_t *d
static unsigned suminfo_persist( LibmsiSummaryInfo *si )
{
int cProperties, cbSection, dwOffset;
- IStream *stm;
+ GsfInput *stm;
uint8_t *data = NULL;
unsigned r, sz;
int i;
@@ -548,7 +535,7 @@ static unsigned suminfo_persist( LibmsiSummaryInfo *si )
r = write_raw_stream_data(si->database, szSumInfo, data, sz, &stm);
if (r == 0) {
- IStream_Release( stm );
+ g_object_unref(G_OBJECT(stm));
}
msi_free( data );
return r;
@@ -556,7 +543,9 @@ static unsigned suminfo_persist( LibmsiSummaryInfo *si )
LibmsiSummaryInfo *_libmsi_get_summary_information( LibmsiDatabase *db, unsigned uiUpdateCount )
{
+ GsfInput *stm = NULL;
LibmsiSummaryInfo *si;
+ unsigned r;
TRACE("%p %d\n", db, uiUpdateCount );
@@ -648,7 +637,7 @@ LibmsiResult libmsi_summary_info_get_property(
len = strlen( prop->strval );
if( szValueBuf )
- strcpynA(szValueBuf, prop->strval, *pcchValueBuf );
+ strcpyn(szValueBuf, prop->strval, *pcchValueBuf );
if (len >= *pcchValueBuf)
ret = LIBMSI_RESULT_MORE_DATA;
*pcchValueBuf = len;
@@ -765,10 +754,10 @@ LibmsiResult libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned u
return _libmsi_summary_info_set_property( si, uiProperty, type, intvalue, pftValue, szValue );
}
-static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid, int *int_value,
+static unsigned parse_prop( const char *prop, const char *value, unsigned *pid, int *int_value,
guint64 *ft_value, char **str_value )
{
- *pid = atoiW( prop );
+ *pid = atoi( prop );
switch (*pid)
{
case LIBMSI_PROPERTY_CODEPAGE:
@@ -776,7 +765,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
case LIBMSI_PROPERTY_RESTRICT:
case LIBMSI_PROPERTY_SECURITY:
case LIBMSI_PROPERTY_VERSION:
- *int_value = atoiW( value );
+ *int_value = atoi( value );
break;
case LIBMSI_PROPERTY_LASTPRINTED:
@@ -794,7 +783,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
case LIBMSI_PROPERTY_UUID:
case LIBMSI_PROPERTY_APPNAME:
case LIBMSI_PROPERTY_TITLE:
- *str_value = strdupWtoA(value);
+ *str_value = strdup(value);
break;
default:
@@ -805,7 +794,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
return LIBMSI_RESULT_SUCCESS;
}
-unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, int num_columns )
+unsigned msi_add_suminfo( LibmsiDatabase *db, char ***records, int num_records, int num_columns )
{
unsigned r = LIBMSI_RESULT_FUNCTION_FAILED;
unsigned i, j;