diff options
Diffstat (limited to 'libmsi/storages.c')
-rw-r--r-- | libmsi/storages.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/libmsi/storages.c b/libmsi/storages.c index f154c82..6829849 100644 --- a/libmsi/storages.c +++ b/libmsi/storages.c @@ -20,14 +20,7 @@ #include <stdarg.h> -#define COBJMACROS - -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "ole2.h" #include "libmsi.h" -#include "objbase.h" #include "msipriv.h" #include "query.h" @@ -65,7 +58,7 @@ static bool storages_set_table_size(LibmsiStorageView *sv, unsigned size) return true; } -static STORAGE *create_storage(LibmsiStorageView *sv, const WCHAR *name) +static STORAGE *create_storage(LibmsiStorageView *sv, const char *name) { STORAGE *storage; @@ -95,7 +88,7 @@ static unsigned storages_view_fetch_int(LibmsiView *view, unsigned row, unsigned return LIBMSI_RESULT_SUCCESS; } -static unsigned storages_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, IStream **stm) +static unsigned storages_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, GsfInput **stm) { LibmsiStorageView *sv = (LibmsiStorageView *)view; @@ -119,8 +112,9 @@ static unsigned storages_view_get_row( LibmsiView *view, unsigned row, LibmsiRec static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiRecord *rec, unsigned mask) { LibmsiStorageView *sv = (LibmsiStorageView *)view; - IStream *stm; - WCHAR *name = NULL; + STORAGE *storage; + GsfInput *stm; + char *name = NULL; unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; TRACE("(%p, %p)\n", view, rec); @@ -128,11 +122,21 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco 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 (sv->storages[row]) { + if (mask & 1) { + FIXME("renaming storage via UPDATE on _Storages table\n"); + goto done; + } + + storage = sv->storages[row]; + name = strdup(msi_string_lookup_id(sv->db->strings, storage->str_index)); + } else { + name = strdup(_libmsi_record_get_string_raw(rec, 1)); + } if (!name) { r = LIBMSI_RESULT_OUTOFMEMORY; @@ -140,19 +144,15 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco } msi_create_storage(sv->db, name, stm); - if (r != LIBMSI_RESULT_SUCCESS) - { - IStream_Release(stm); - return r; - } - - sv->storages[row] = create_storage(sv, name); - if (!sv->storages[row]) + storage = create_storage(sv, name); + if (!storage) r = LIBMSI_RESULT_FUNCTION_FAILED; + sv->storages[row] = storage; + done: msi_free(name); - IStream_Release(stm); + g_object_unref(G_OBJECT(stm)); return r; } @@ -175,8 +175,7 @@ static unsigned storages_view_insert_row(LibmsiView *view, LibmsiRecord *rec, un static unsigned storages_view_delete_row(LibmsiView *view, unsigned row) { LibmsiStorageView *sv = (LibmsiStorageView *)view; - const WCHAR *name; - WCHAR *encname; + const char *name; unsigned i; if (row > sv->num_rows) @@ -225,8 +224,8 @@ static unsigned storages_view_get_dimensions(LibmsiView *view, unsigned *rows, u return LIBMSI_RESULT_SUCCESS; } -static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, - unsigned *type, bool *temporary, const WCHAR **table_name ) +static unsigned storages_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); @@ -272,7 +271,7 @@ static unsigned storages_view_find_matching_rows(LibmsiView *view, unsigned col, unsigned val, unsigned *row, MSIITERHANDLE *handle) { LibmsiStorageView *sv = (LibmsiStorageView *)view; - unsigned index = PtrToUlong(*handle); + unsigned index = (uintptr_t)*handle; TRACE("(%d, %d): %d\n", *row, col, val); @@ -290,7 +289,7 @@ static unsigned storages_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; @@ -319,7 +318,7 @@ static const LibmsiViewOps storages_ops = NULL, }; -static unsigned add_storage_to_table(const WCHAR *name, IStorage *stg, void *opaque) +static unsigned add_storage_to_table(const char *name, GsfInfile *stg, void *opaque) { LibmsiStorageView *sv = (LibmsiStorageView *)opaque; STORAGE *storage; |