summaryrefslogtreecommitdiffstats
path: root/libmsi/streams.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmsi/streams.c')
-rw-r--r--libmsi/streams.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/libmsi/streams.c b/libmsi/streams.c
index dbd8c17..93e05cc 100644
--- a/libmsi/streams.c
+++ b/libmsi/streams.c
@@ -20,18 +20,11 @@
#include <stdarg.h>
-#define COBJMACROS
-
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
#include "libmsi.h"
-#include "objbase.h"
#include "msipriv.h"
#include "query.h"
#include "debug.h"
-#include "unicode.h"
#define NUM_STREAMS_COLS 2
@@ -39,7 +32,7 @@
typedef struct tabSTREAM
{
unsigned str_index;
- IStream *stream;
+ GsfInput *stream;
} STREAM;
typedef struct _LibmsiStreamsView
@@ -66,10 +59,10 @@ static bool streams_set_table_size(LibmsiStreamsView *sv, unsigned size)
return true;
}
-static STREAM *create_stream(LibmsiStreamsView *sv, const WCHAR *name, bool encoded, IStream *stm)
+static STREAM *create_stream(LibmsiStreamsView *sv, const char *name, bool encoded, GsfInput *stm)
{
STREAM *stream;
- WCHAR decoded[MAX_STREAM_NAME_LEN];
+ char decoded[MAX_STREAM_NAME_LEN];
stream = msi_alloc(sizeof(STREAM));
if (!stream)
@@ -78,14 +71,14 @@ static STREAM *create_stream(LibmsiStreamsView *sv, const WCHAR *name, bool enco
if (encoded)
{
decode_streamname(name, decoded);
- TRACE("stream -> %s %s\n", debugstr_w(name), debugstr_w(decoded));
+ TRACE("stream -> %s %s\n", debugstr_a(name), debugstr_a(decoded));
name = decoded;
}
stream->str_index = _libmsi_add_string(sv->db->strings, name, -1, 1, StringNonPersistent);
stream->stream = stm;
if (stream->stream)
- IStream_AddRef(stm);
+ g_object_ref(G_OBJECT(stm));
return stream;
}
@@ -107,7 +100,7 @@ static unsigned streams_view_fetch_int(LibmsiView *view, unsigned row, unsigned
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned streams_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, IStream **stm)
+static unsigned streams_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, GsfInput **stm)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
@@ -116,7 +109,7 @@ static unsigned streams_view_fetch_stream(LibmsiView *view, unsigned row, unsign
if (row >= sv->num_rows)
return LIBMSI_RESULT_FUNCTION_FAILED;
- IStream_AddRef(sv->streams[row]->stream);
+ g_object_ref(G_OBJECT(sv->streams[row]->stream));
*stm = sv->streams[row]->stream;
return LIBMSI_RESULT_SUCCESS;
@@ -135,8 +128,8 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
STREAM *stream = NULL;
- IStream *stm;
- WCHAR *name = NULL;
+ GsfInput *stm;
+ char *name = NULL;
unsigned r;
TRACE("(%p, %d, %p, %08x)\n", view, row, rec, mask);
@@ -144,18 +137,29 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
if (row > sv->num_rows)
return LIBMSI_RESULT_FUNCTION_FAILED;
- r = _libmsi_record_get_IStream(rec, 2, &stm);
+ r = _libmsi_record_get_gsf_input(rec, 2, &stm);
if (r != LIBMSI_RESULT_SUCCESS)
return r;
- name = strdupW(_libmsi_record_get_string_raw(rec, 1));
- if (!name)
- {
- WARN("failed to retrieve stream name\n");
- goto done;
+ if (sv->streams[row]) {
+ if (mask & 1) {
+ FIXME("renaming stream via UPDATE on _Streams table");
+ goto done;
+ }
+
+ stream = sv->streams[row];
+ name = strdup(msi_string_lookup_id(sv->db->strings, stream->str_index));
+ } else {
+ name = strdup(_libmsi_record_get_string_raw(rec, 1));
+ if (!name)
+ {
+ WARN("failed to retrieve stream name\n");
+ goto done;
+ }
+
+ stream = create_stream(sv, name, false, stm);
}
- stream = create_stream(sv, name, false, stm);
if (!stream)
goto done;
@@ -163,7 +167,7 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
if (r != LIBMSI_RESULT_SUCCESS)
{
WARN("failed to create stream: %08x\n", r);
- IStream_Release(stream->stream);
+ g_object_unref(G_OBJECT(stream->stream));
msi_free(stream);
goto done;
}
@@ -173,7 +177,7 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
done:
msi_free(name);
- IStream_Release(stm);
+ g_object_unref(G_OBJECT(stm));
return r;
}
@@ -203,8 +207,8 @@ static unsigned streams_view_insert_row(LibmsiView *view, LibmsiRecord *rec, uns
static unsigned streams_view_delete_row(LibmsiView *view, unsigned row)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
- const WCHAR *name;
- WCHAR *encname;
+ const char *name;
+ char *encname;
unsigned i;
if (row > sv->num_rows)
@@ -254,8 +258,8 @@ static unsigned streams_view_get_dimensions(LibmsiView *view, unsigned *rows, un
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
table_name);
@@ -292,7 +296,7 @@ static unsigned streams_view_delete(LibmsiView *view)
if (sv->streams[i])
{
if (sv->streams[i]->stream)
- IStream_Release(sv->streams[i]->stream);
+ g_object_unref(G_OBJECT(sv->streams[i]->stream));
msi_free(sv->streams[i]);
}
}
@@ -307,7 +311,7 @@ static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col,
unsigned val, unsigned *row, MSIITERHANDLE *handle)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
- unsigned index = PtrToUlong(*handle);
+ unsigned index = (uintptr_t)(*handle);
TRACE("(%p, %d, %d, %p, %p)\n", view, col, val, row, handle);
@@ -325,7 +329,7 @@ static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col,
index++;
}
- *handle = UlongToPtr(++index);
+ *handle = (MSIITERHANDLE)(uintptr_t)++index;
if (index > sv->num_rows)
return LIBMSI_RESULT_NO_MORE_ITEMS;
@@ -355,7 +359,7 @@ static const LibmsiViewOps streams_ops =
NULL,
};
-static unsigned add_stream_to_table(const WCHAR *name, IStream *stm, void *opaque)
+static unsigned add_stream_to_table(const char *name, GsfInput *stm, void *opaque)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)opaque;
STREAM *stream;