From 6412e07644f467021e89e06c813e6aaa5fb10da2 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 30 Nov 2012 12:44:02 +0100 Subject: introduce LibmsiResult --- libmsi/alter.c | 42 +++--- libmsi/create.c | 26 ++-- libmsi/database.c | 234 +++++++++++++++++----------------- libmsi/delete.c | 28 ++-- libmsi/distinct.c | 40 +++--- libmsi/drop.c | 16 +-- libmsi/handle.c | 4 +- libmsi/insert.c | 44 +++---- libmsi/msiquery.c | 146 ++++++++++----------- libmsi/record.c | 120 +++++++++--------- libmsi/select.c | 82 ++++++------ libmsi/sql-parser.y | 30 ++--- libmsi/storages.c | 72 +++++------ libmsi/streams.c | 64 +++++----- libmsi/string.c | 38 +++--- libmsi/suminfo.c | 72 +++++------ libmsi/table.c | 360 ++++++++++++++++++++++++++-------------------------- libmsi/update.c | 28 ++-- libmsi/where.c | 224 ++++++++++++++++---------------- 19 files changed, 835 insertions(+), 835 deletions(-) (limited to 'libmsi') diff --git a/libmsi/alter.c b/libmsi/alter.c index 8281b9e..3523036 100644 --- a/libmsi/alter.c +++ b/libmsi/alter.c @@ -47,7 +47,7 @@ static unsigned alter_view_fetch_int( LibmsiView *view, unsigned row, unsigned c TRACE("%p %d %d %p\n", av, row, col, val ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned alter_view_fetch_stream( LibmsiView *view, unsigned row, unsigned col, IStream **stm) @@ -56,7 +56,7 @@ static unsigned alter_view_fetch_stream( LibmsiView *view, unsigned row, unsigne TRACE("%p %d %d %p\n", av, row, col, stm ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned alter_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord **rec ) @@ -71,7 +71,7 @@ static unsigned alter_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord static unsigned count_iter(LibmsiRecord *row, void *param) { (*(unsigned *)param)++; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static bool check_column_exists(LibmsiDatabase *db, const WCHAR *table, const WCHAR *column) @@ -88,20 +88,20 @@ static bool check_column_exists(LibmsiDatabase *db, const WCHAR *table, const WC }; r = _libmsi_query_open(db, &view, query, table, column); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return false; r = _libmsi_query_execute(view, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = _libmsi_query_fetch(view, &rec); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) msiobj_release(&rec->hdr); done: msiobj_release(&view->hdr); - return (r == ERROR_SUCCESS); + return (r == LIBMSI_RESULT_SUCCESS); } static unsigned alter_add_column(LibmsiAlterView *av) @@ -119,21 +119,21 @@ static unsigned alter_add_column(LibmsiAlterView *av) }; r = table_view_create(av->db, szColumns, &columns); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; if (check_column_exists(av->db, av->colinfo->table, av->colinfo->column)) { columns->ops->delete(columns); - return ERROR_BAD_QUERY_SYNTAX; + return LIBMSI_RESULT_BAD_QUERY_SYNTAX; } r = _libmsi_query_open(av->db, &view, query, av->colinfo->table, av->colinfo->column); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { r = _libmsi_query_iterate_records(view, NULL, count_iter, &colnum); msiobj_release(&view->hdr); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { columns->ops->delete(columns); return r; @@ -166,7 +166,7 @@ static unsigned alter_view_execute( LibmsiView *view, LibmsiRecord *record ) if (av->colinfo) return alter_add_column(av); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned alter_view_close( LibmsiView *view ) @@ -175,7 +175,7 @@ static unsigned alter_view_close( LibmsiView *view ) TRACE("%p\n", av ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned alter_view_get_dimensions( LibmsiView *view, unsigned *rows, unsigned *cols ) @@ -184,7 +184,7 @@ static unsigned alter_view_get_dimensions( LibmsiView *view, unsigned *rows, uns TRACE("%p %p %p\n", av, rows, cols ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned alter_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, @@ -194,7 +194,7 @@ static unsigned alter_view_get_column_info( LibmsiView *view, unsigned n, const TRACE("%p %d %p %p %p %p\n", av, n, name, type, temporary, table_name ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned alter_view_modify( LibmsiView *view, LibmsiModify eModifyMode, @@ -204,7 +204,7 @@ static unsigned alter_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", av, eModifyMode, rec ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned alter_view_delete( LibmsiView *view ) @@ -216,7 +216,7 @@ static unsigned alter_view_delete( LibmsiView *view ) av->table->ops->delete( av->table ); msi_free( av ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned alter_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -224,7 +224,7 @@ static unsigned alter_view_find_matching_rows( LibmsiView *view, unsigned col, { TRACE("%p, %d, %u, %p\n", view, col, val, *handle); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static const LibmsiViewOps alter_ops = @@ -259,10 +259,10 @@ unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR * av = alloc_msiobject( sizeof *av , NULL); if( !av ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = table_view_create( db, name, &av->table ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msi_free( av ); return r; @@ -279,5 +279,5 @@ unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR * *view = &av->view; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/create.c b/libmsi/create.c index 66a20f5..b3cacc0 100644 --- a/libmsi/create.c +++ b/libmsi/create.c @@ -53,7 +53,7 @@ static unsigned create_view_fetch_int( LibmsiView *view, unsigned row, unsigned TRACE("%p %d %d %p\n", cv, row, col, val ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned create_view_execute( LibmsiView *view, LibmsiRecord *record ) @@ -65,7 +65,7 @@ static unsigned create_view_execute( LibmsiView *view, LibmsiRecord *record ) cv->bIsTemp?"temporary":"permanent"); if (cv->bIsTemp && !cv->hold) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; return msi_create_table( cv->db, cv->name, cv->col_info, persist ); } @@ -76,7 +76,7 @@ static unsigned create_view_close( LibmsiView *view ) TRACE("%p\n", cv); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned create_view_get_dimensions( LibmsiView *view, unsigned *rows, unsigned *cols ) @@ -85,7 +85,7 @@ static unsigned create_view_get_dimensions( LibmsiView *view, unsigned *rows, un TRACE("%p %p %p\n", cv, rows, cols ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned create_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, @@ -95,7 +95,7 @@ static unsigned create_view_get_column_info( LibmsiView *view, unsigned n, const TRACE("%p %d %p %p %p %p\n", cv, n, name, type, temporary, table_name ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned create_view_modify( LibmsiView *view, LibmsiModify eModifyMode, @@ -105,7 +105,7 @@ static unsigned create_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", cv, eModifyMode, rec ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned create_view_delete( LibmsiView *view ) @@ -117,7 +117,7 @@ static unsigned create_view_delete( LibmsiView *view ) msiobj_release( &cv->db->hdr ); msi_free( cv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static const LibmsiViewOps create_ops = @@ -151,9 +151,9 @@ static unsigned check_columns( const column_info *col_info ) for( c1 = col_info; c1; c1 = c1->next ) for( c2 = c1->next; c2; c2 = c2->next ) if (!strcmpW( c1->column, c2->column )) - return ERROR_BAD_QUERY_SYNTAX; + return LIBMSI_RESULT_BAD_QUERY_SYNTAX; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *table, @@ -168,12 +168,12 @@ unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR TRACE("%p\n", cv ); r = check_columns( col_info ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; cv = alloc_msiobject( sizeof *cv, NULL ); if( !cv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; for( col = col_info; col; col = col->next ) { @@ -189,7 +189,7 @@ unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR if ( !temp && tempprim ) { msi_free( cv ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* fill the structure */ @@ -202,5 +202,5 @@ unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR cv->hold = hold; *view = (LibmsiView*) cv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/database.c b/libmsi/database.c index 824d263..a3bc8da 100644 --- a/libmsi/database.c +++ b/libmsi/database.c @@ -88,20 +88,20 @@ static unsigned find_open_stream( LibmsiDatabase *db, IStorage *stg, const WCHAR TRACE("found %s\n", debugstr_w(name)); *stm = stream->stm; CoTaskMemFree( stat.pwcsName ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } CoTaskMemFree( stat.pwcsName ); } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } unsigned msi_clone_open_stream( LibmsiDatabase *db, IStorage *stg, const WCHAR *name, IStream **stm ) { IStream *stream; - if (find_open_stream( db, stg, name, &stream ) == ERROR_SUCCESS) + if (find_open_stream( db, stg, name, &stream ) == LIBMSI_RESULT_SUCCESS) { HRESULT r; LARGE_INTEGER pos; @@ -110,7 +110,7 @@ unsigned msi_clone_open_stream( LibmsiDatabase *db, IStorage *stg, const WCHAR * if( FAILED( r ) ) { WARN("failed to clone stream r = %08x!\n", r); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } pos.QuadPart = 0; @@ -118,13 +118,13 @@ unsigned msi_clone_open_stream( LibmsiDatabase *db, IStorage *stg, const WCHAR * if( FAILED( r ) ) { IStream_Release( *stm ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream **stm ) @@ -136,8 +136,8 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream ** decode_streamname( stname, decoded ); TRACE("%s -> %s\n", debugstr_w(stname), debugstr_w(decoded)); - if (msi_clone_open_stream( db, db->storage, stname, stm ) == ERROR_SUCCESS) - return ERROR_SUCCESS; + if (msi_clone_open_stream( db, db->storage, stname, stm ) == LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_SUCCESS; r = IStorage_OpenStream( db->storage, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); @@ -162,7 +162,7 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream ** { LibmsiStream *stream; - if (!(stream = msi_alloc( sizeof(LibmsiStream) ))) return ERROR_NOT_ENOUGH_MEMORY; + if (!(stream = msi_alloc( sizeof(LibmsiStream) ))) return LIBMSI_RESULT_NOT_ENOUGH_MEMORY; stream->stg = stg; IStorage_AddRef( stg ); stream->stm = *stm; @@ -170,7 +170,7 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream ** list_add_tail( &db->streams, &stream->entry ); } - return SUCCEEDED(r) ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED; + return SUCCEEDED(r) ? LIBMSI_RESULT_SUCCESS : LIBMSI_RESULT_FUNCTION_FAILED; } static void free_transforms( LibmsiDatabase *db ) @@ -296,12 +296,12 @@ static HRESULT db_initialize( IStorage *stg, const GUID *clsid ) return S_OK; } -unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, LibmsiDatabase **pdb) +LibmsiResult libmsi_database_open(const char *szDBPath, const char *szPersist, LibmsiDatabase **pdb) { IStorage *stg = NULL; HRESULT r; LibmsiDatabase *db = NULL; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; WCHAR *szwDBPath; const char *szMode; STATSTG stat; @@ -311,7 +311,7 @@ unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, Libms TRACE("%s %p\n",debugstr_a(szDBPath),szPersist ); if( !pdb ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if (szPersist - LIBMSI_DB_OPEN_PATCHFILE >= LIBMSI_DB_OPEN_READONLY && szPersist - LIBMSI_DB_OPEN_PATCHFILE <= LIBMSI_DB_OPEN_CREATEDIRECT) @@ -325,7 +325,7 @@ unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, Libms if( !IS_INTMSIDBOPEN(szPersist) ) { if (!CopyFileA( szDBPath, szPersist, false )) - return ERROR_OPEN_FAILED; + return LIBMSI_RESULT_OPEN_FAILED; szDBPath = szPersist; szPersist = LIBMSI_DB_OPEN_TRANSACT; @@ -369,14 +369,14 @@ unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, Libms else { ERR("unknown flag %p\n",szPersist); - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; } msi_free(szwDBPath); if( FAILED( r ) || !stg ) { WARN("open failed r = %08x for %s\n", r, debugstr_a(szDBPath)); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } r = IStorage_Stat( stg, &stat, STATFLAG_NONAME ); @@ -399,7 +399,7 @@ unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, Libms { ERR("storage GUID is not the MSI patch GUID %s\n", debugstr_guid(&stat.clsid) ); - ret = ERROR_OPEN_FAILED; + ret = LIBMSI_RESULT_OPEN_FAILED; goto end; } @@ -438,7 +438,7 @@ unsigned libmsi_database_open(const char *szDBPath, const char *szPersist, Libms if( !db->strings ) goto end; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; msiobj_addref( &db->hdr ); IStorage_AddRef( stg ); @@ -710,7 +710,7 @@ done: static unsigned msi_add_table_to_db(LibmsiDatabase *db, WCHAR **columns, WCHAR **types, WCHAR **labels, unsigned num_labels, unsigned num_columns) { - unsigned r = ERROR_OUTOFMEMORY; + unsigned r = LIBMSI_RESULT_OUTOFMEMORY; unsigned size; LibmsiQuery *view; WCHAR *create_sql = NULL; @@ -735,7 +735,7 @@ static unsigned msi_add_table_to_db(LibmsiDatabase *db, WCHAR **columns, WCHAR * strcatW(create_sql, postlude); r = _libmsi_database_open_query( db, create_sql, &view ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = _libmsi_query_execute(view, NULL); @@ -784,7 +784,7 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types, *rec = libmsi_record_create(num_columns); if (!*rec) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; for (i = 0; i < num_columns; i++) { @@ -803,22 +803,22 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types, unsigned r; char *file = msi_import_stream_filename(path, data[i]); if (!file) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = _libmsi_record_load_stream_from_file(*rec, i + 1, file); msi_free (file); - if (r != ERROR_SUCCESS) - return ERROR_FUNCTION_FAILED; + if (r != LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_FUNCTION_FAILED; } break; default: ERR("Unhandled column type: %c\n", types[i][0]); msiobj_release(&(*rec)->hdr); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned msi_add_records_to_table(LibmsiDatabase *db, WCHAR **columns, WCHAR **types, @@ -837,25 +837,25 @@ static unsigned msi_add_records_to_table(LibmsiDatabase *db, WCHAR **columns, WC }; r = _libmsi_query_open(db, &view, select, labels[0]); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; - while (_libmsi_query_fetch(view, &rec) != ERROR_NO_MORE_ITEMS) + while (_libmsi_query_fetch(view, &rec) != LIBMSI_RESULT_NO_MORE_ITEMS) { r = _libmsi_query_modify(view, LIBMSI_MODIFY_DELETE, rec); msiobj_release(&rec->hdr); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; } for (i = 0; i < num_records; i++) { r = construct_record(num_columns, types, records[i], path, &rec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = _libmsi_query_modify(view, LIBMSI_MODIFY_INSERT, rec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msiobj_release(&rec->hdr); goto done; @@ -871,7 +871,7 @@ done: static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, const char *file) { - unsigned r = ERROR_OUTOFMEMORY; + unsigned r = LIBMSI_RESULT_OUTOFMEMORY; unsigned len, i; unsigned num_labels, num_types; unsigned num_columns, num_records = 0; @@ -892,12 +892,12 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, TRACE("%p %s %s\n", db, debugstr_a(folder), debugstr_a(file) ); if( folder == NULL || file == NULL ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; len = strlen(folder) + 1 + strlen(file) + 1; path = msi_alloc( len ); if (!path) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; strcpy( path, folder ); strcat( path, "\\" ); @@ -921,14 +921,14 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, if (num_columns != num_types) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } records = msi_alloc(sizeof(WCHAR **)); if (!records) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto done; } @@ -941,7 +941,7 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, temp_records = msi_realloc(records, (num_records + 1) * sizeof(WCHAR **)); if (!temp_records) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto done; } records = temp_records; @@ -950,9 +950,9 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, if (!strcmpW(labels[0], suminfo)) { r = msi_add_suminfo( db, records, num_records, num_columns ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } } @@ -961,9 +961,9 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder, if (!table_view_exists(db, labels[0])) { r = msi_add_table_to_db( db, columns, types, labels, num_labels, num_columns ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } } @@ -986,14 +986,14 @@ done: return r; } -unsigned libmsi_database_import(LibmsiDatabase *db, const char *szFolder, const char *szFilename) +LibmsiResult libmsi_database_import(LibmsiDatabase *db, const char *szFolder, const char *szFilename) { unsigned r; TRACE("%x %s %s\n",db,debugstr_a(szFolder), debugstr_a(szFilename)); if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &db->hdr ); r = _libmsi_database_import( db, szFolder, szFilename ); @@ -1003,7 +1003,7 @@ unsigned libmsi_database_import(LibmsiDatabase *db, const char *szFolder, const static unsigned msi_export_record( int fd, LibmsiRecord *row, unsigned start ) { - unsigned i, count, len, r = ERROR_SUCCESS; + unsigned i, count, len, r = LIBMSI_RESULT_SUCCESS; const char *sep; char *buffer; unsigned sz; @@ -1011,14 +1011,14 @@ static unsigned msi_export_record( int fd, LibmsiRecord *row, unsigned start ) len = 0x100; buffer = msi_alloc( len ); if ( !buffer ) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; count = libmsi_record_get_field_count( row ); for ( i=start; i<=count; i++ ) { sz = len; r = libmsi_record_get_string( row, i, buffer, &sz ); - if (r == ERROR_MORE_DATA) + if (r == LIBMSI_RESULT_MORE_DATA) { char *p = msi_realloc( buffer, sz + 1 ); if (!p) @@ -1028,20 +1028,20 @@ static unsigned msi_export_record( int fd, LibmsiRecord *row, unsigned start ) } sz = len; r = libmsi_record_get_string( row, i, buffer, &sz ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; /* TODO full_write */ if (write( fd, buffer, sz ) != sz) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; break; } sep = (i < count) ? "\t" : "\r\n"; if (write( fd, sep, strlen(sep) ) != strlen(sep)) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; break; } } @@ -1064,9 +1064,9 @@ static unsigned msi_export_forcecodepage( int fd, unsigned codepage ) sz = strlen(data) + 1; if (write( fd, data, sz ) != sz) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table, @@ -1090,11 +1090,11 @@ static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table, } r = _libmsi_query_open( db, &view, query, table ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { /* write out row 1, the column names */ r = _libmsi_query_get_column_info(view, LIBMSI_COL_INFO_NAMES, &rec); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { msi_export_record( fd, rec, 1 ); msiobj_release( &rec->hdr ); @@ -1102,7 +1102,7 @@ static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table, /* write out row 2, the column types */ r = _libmsi_query_get_column_info(view, LIBMSI_COL_INFO_TYPES, &rec); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { msi_export_record( fd, rec, 1 ); msiobj_release( &rec->hdr ); @@ -1110,7 +1110,7 @@ static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table, /* write out row 3, the table name + keys */ r = _libmsi_database_get_primary_keys( db, table, &rec ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { _libmsi_record_set_stringW( rec, 0, table ); msi_export_record( fd, rec, 0 ); @@ -1141,13 +1141,13 @@ done: * * row4 : data data data ... data */ -unsigned libmsi_database_export( LibmsiDatabase *db, const char *szTable, +LibmsiResult libmsi_database_export( LibmsiDatabase *db, const char *szTable, int fd ) { WCHAR *path = NULL; WCHAR *file = NULL; WCHAR *table = NULL; - unsigned r = ERROR_OUTOFMEMORY; + unsigned r = LIBMSI_RESULT_OUTOFMEMORY; TRACE("%x %s %d\n", db, debugstr_a(szTable), fd); @@ -1159,7 +1159,7 @@ unsigned libmsi_database_export( LibmsiDatabase *db, const char *szTable, } if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref ( &db->hdr ); r = _libmsi_database_export( db, table, fd ); @@ -1221,11 +1221,11 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie unsigned r, i, count; r = _libmsi_query_get_column_info(dbview, LIBMSI_COL_INFO_NAMES, &dbrec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = _libmsi_query_get_column_info(mergeview, LIBMSI_COL_INFO_NAMES, &mergerec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; count = libmsi_record_get_field_count(dbrec); @@ -1236,7 +1236,7 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie if (strcmpW( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) )) { - r = ERROR_DATATYPE_MISMATCH; + r = LIBMSI_RESULT_DATATYPE_MISMATCH; goto done; } } @@ -1246,11 +1246,11 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie dbrec = mergerec = NULL; r = _libmsi_query_get_column_info(dbview, LIBMSI_COL_INFO_TYPES, &dbrec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = _libmsi_query_get_column_info(mergeview, LIBMSI_COL_INFO_TYPES, &mergerec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; count = libmsi_record_get_field_count(dbrec); @@ -1262,7 +1262,7 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie if (!merge_type_match(_libmsi_record_get_string_raw(dbrec, i), _libmsi_record_get_string_raw(mergerec, i))) { - r = ERROR_DATATYPE_MISMATCH; + r = LIBMSI_RESULT_DATATYPE_MISMATCH; break; } } @@ -1281,17 +1281,17 @@ static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *me unsigned r, i, count; r = _libmsi_database_get_primary_keys(db, table, &dbrec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = _libmsi_database_get_primary_keys(mergedb, table, &mergerec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; count = libmsi_record_get_field_count(dbrec); if (count != libmsi_record_get_field_count(mergerec)) { - r = ERROR_DATATYPE_MISMATCH; + r = LIBMSI_RESULT_DATATYPE_MISMATCH; goto done; } @@ -1299,7 +1299,7 @@ static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *me { if (strcmpW( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) )) { - r = ERROR_DATATYPE_MISMATCH; + r = LIBMSI_RESULT_DATATYPE_MISMATCH; goto done; } } @@ -1320,7 +1320,7 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r int cmp; r = _libmsi_query_get_column_info(view, LIBMSI_COL_INFO_NAMES, &colnames); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return NULL; do @@ -1333,7 +1333,7 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r msiobj_release(&colnames->hdr); r = _libmsi_record_get_stringW(rec, i, NULL, &sz); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return NULL; sz++; @@ -1360,7 +1360,7 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r r = _libmsi_record_get_stringW(rec, i, val, &sz); } - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("failed to get string!\n"); msi_free(val); @@ -1391,7 +1391,7 @@ static WCHAR *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view, 'W','H','E','R','E',' ','%','s',0}; r = _libmsi_database_get_primary_keys(merge, table, &keys); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return NULL; clause = msi_alloc_zero(sizeof(WCHAR)); @@ -1444,45 +1444,45 @@ static unsigned merge_diff_row(LibmsiRecord *rec, void *param) LibmsiQuery *dbview = NULL; LibmsiRecord *row = NULL; WCHAR *query = NULL; - unsigned r = ERROR_SUCCESS; + unsigned r = LIBMSI_RESULT_SUCCESS; if (table_view_exists(data->db, table->name)) { query = create_diff_row_query(data->merge, data->curview, table->name, rec); if (!query) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; r = _libmsi_database_open_query(data->db, query, &dbview); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = _libmsi_query_execute(dbview, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = _libmsi_query_fetch(dbview, &row); - if (r == ERROR_SUCCESS && !_libmsi_record_compare(rec, row)) + if (r == LIBMSI_RESULT_SUCCESS && !_libmsi_record_compare(rec, row)) { table->numconflicts++; goto done; } - else if (r != ERROR_NO_MORE_ITEMS) + else if (r != LIBMSI_RESULT_NO_MORE_ITEMS) goto done; - r = ERROR_SUCCESS; + r = LIBMSI_RESULT_SUCCESS; } mergerow = msi_alloc(sizeof(MERGEROW)); if (!mergerow) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto done; } mergerow->data = _libmsi_record_clone(rec); if (!mergerow->data) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; msi_free(mergerow); goto done; } @@ -1502,7 +1502,7 @@ static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCH LibmsiRecord *prec = NULL; r = _libmsi_database_get_primary_keys(db, table, &prec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; count = libmsi_record_get_field_count(prec); @@ -1510,7 +1510,7 @@ static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCH *labels = msi_alloc((*numlabels)*sizeof(WCHAR *)); if (!*labels) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto end; } @@ -1531,14 +1531,14 @@ static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsi LibmsiRecord *prec = NULL; r = _libmsi_query_get_column_info(query, LIBMSI_COL_INFO_NAMES, &prec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; count = libmsi_record_get_field_count(prec); *columns = msi_alloc(count*sizeof(WCHAR *)); if (!*columns) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto end; } @@ -1560,14 +1560,14 @@ static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned LibmsiRecord *prec = NULL; r = _libmsi_query_get_column_info(query, LIBMSI_COL_INFO_TYPES, &prec); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; count = libmsi_record_get_field_count(prec); *types = msi_alloc(count*sizeof(WCHAR *)); if (!*types) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto end; } @@ -1643,23 +1643,23 @@ static unsigned msi_get_merge_table (LibmsiDatabase *db, const WCHAR *name, MERG if (!table) { *ptable = NULL; - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; } r = msi_get_table_labels(db, name, &table->labels, &table->numlabels); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; r = _libmsi_query_open(db, &mergeview, query, name); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; r = msi_get_query_columns(mergeview, &table->columns, &table->numcolumns); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; r = msi_get_query_types(mergeview, &table->types, &table->numtypes); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; list_init(&table->rows); @@ -1669,7 +1669,7 @@ static unsigned msi_get_merge_table (LibmsiDatabase *db, const WCHAR *name, MERG msiobj_release(&mergeview->hdr); *ptable = table; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; err: msiobj_release(&mergeview->hdr); @@ -1693,32 +1693,32 @@ static unsigned merge_diff_tables(LibmsiRecord *rec, void *param) name = _libmsi_record_get_string_raw(rec, 1); r = _libmsi_query_open(data->merge, &mergeview, query, name); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; if (table_view_exists(data->db, name)) { r = _libmsi_query_open(data->db, &dbview, query, name); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = merge_verify_colnames(dbview, mergeview); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = merge_verify_primary_keys(data->db, data->merge, name); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; } r = msi_get_merge_table(data->merge, name, &table); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; data->curtable = table; data->curview = mergeview; r = _libmsi_query_iterate_records(mergeview, NULL, merge_diff_row, data); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { free_merge_table(table); goto done; @@ -1743,7 +1743,7 @@ static unsigned gather_merge_data(LibmsiDatabase *db, LibmsiDatabase *merge, unsigned r; r = _libmsi_database_open_query(merge, query, &view); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; data.db = db; @@ -1764,24 +1764,24 @@ static unsigned merge_table(LibmsiDatabase *db, MERGETABLE *table) { r = msi_add_table_to_db(db, table->columns, table->types, table->labels, table->numlabels, table->numcolumns); - if (r != ERROR_SUCCESS) - return ERROR_FUNCTION_FAILED; + if (r != LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_FUNCTION_FAILED; } LIST_FOR_EACH_ENTRY(row, &table->rows, MERGEROW, entry) { r = table_view_create(db, table->name, &tv); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = tv->ops->insert_row(tv, row->data, -1, false); tv->ops->delete(tv); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error, @@ -1808,17 +1808,17 @@ static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error, if (!table_view_exists(db, error)) { r = _libmsi_query_open(db, &view, create, error); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = _libmsi_query_execute(view, NULL); msiobj_release(&view->hdr); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; } r = _libmsi_query_open(db, &view, insert, error, table, numconflicts); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = _libmsi_query_execute(view, NULL); @@ -1826,7 +1826,7 @@ static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error, return r; } -unsigned libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge, +LibmsiResult libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge, const char *szTableName) { struct list tabledata = LIST_INIT(tabledata); @@ -1840,16 +1840,16 @@ unsigned libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge, debugstr_a(szTableName)); if (szTableName && !*szTableName) - return ERROR_INVALID_TABLE; + return LIBMSI_RESULT_INVALID_TABLE; if (!db || !merge) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; szwTableName = strdupAtoW(szTableName); msiobj_addref( &db->hdr ); msiobj_addref( &merge->hdr ); r = gather_merge_data(db, merge, &tabledata); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; conflicts = false; @@ -1861,13 +1861,13 @@ unsigned libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge, r = update_merge_errors(db, szwTableName, table->name, table->numconflicts); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } else { r = merge_table(db, table); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } } @@ -1880,7 +1880,7 @@ unsigned libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge, } if (conflicts) - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; done: msiobj_release(&db->hdr); @@ -1895,7 +1895,7 @@ LibmsiDBState libmsi_database_get_state( LibmsiDatabase *db ) TRACE("%d\n", db); if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &db->hdr ); if (db->mode != LIBMSI_DB_OPEN_READONLY ) diff --git a/libmsi/delete.c b/libmsi/delete.c index 5bb1e29..98dd8ae 100644 --- a/libmsi/delete.c +++ b/libmsi/delete.c @@ -59,7 +59,7 @@ static unsigned delete_view_fetch_int( LibmsiView *view, unsigned row, unsigned TRACE("%p %d %d %p\n", dv, row, col, val ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned delete_view_fetch_stream( LibmsiView *view, unsigned row, unsigned col, IStream **stm) @@ -68,7 +68,7 @@ static unsigned delete_view_fetch_stream( LibmsiView *view, unsigned row, unsign TRACE("%p %d %d %p\n", dv, row, col, stm ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned delete_view_execute( LibmsiView *view, LibmsiRecord *record ) @@ -79,14 +79,14 @@ static unsigned delete_view_execute( LibmsiView *view, LibmsiRecord *record ) TRACE("%p %p\n", dv, record); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = dv->table->ops->execute( dv->table, record ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; r = dv->table->ops->get_dimensions( dv->table, &rows, &cols ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; TRACE("deleting %d rows\n", rows); @@ -95,7 +95,7 @@ static unsigned delete_view_execute( LibmsiView *view, LibmsiRecord *record ) for ( i=0; itable->ops->delete_row( dv->table, i ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned delete_view_close( LibmsiView *view ) @@ -105,7 +105,7 @@ static unsigned delete_view_close( LibmsiView *view ) TRACE("%p\n", dv ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return dv->table->ops->close( dv->table ); } @@ -117,7 +117,7 @@ static unsigned delete_view_get_dimensions( LibmsiView *view, unsigned *rows, un TRACE("%p %p %p\n", dv, rows, cols ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; *rows = 0; @@ -132,7 +132,7 @@ static unsigned delete_view_get_column_info( LibmsiView *view, unsigned n, const TRACE("%p %d %p %p %p %p\n", dv, n, name, type, temporary, table_name ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return dv->table->ops->get_column_info( dv->table, n, name, type, temporary, table_name); @@ -145,7 +145,7 @@ static unsigned delete_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", dv, eModifyMode, rec ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned delete_view_delete( LibmsiView *view ) @@ -159,7 +159,7 @@ static unsigned delete_view_delete( LibmsiView *view ) msi_free( dv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned delete_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -167,7 +167,7 @@ static unsigned delete_view_find_matching_rows( LibmsiView *view, unsigned col, { TRACE("%p, %d, %u, %p\n", view, col, val, *handle); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } @@ -202,7 +202,7 @@ unsigned delete_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView * dv = alloc_msiobject( sizeof *dv, NULL ); if( !dv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* fill the structure */ dv->view.ops = &delete_ops; @@ -211,5 +211,5 @@ unsigned delete_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView * *view = &dv->view; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/distinct.c b/libmsi/distinct.c index b0cbf44..47c4b17 100644 --- a/libmsi/distinct.c +++ b/libmsi/distinct.c @@ -95,10 +95,10 @@ static unsigned distinct_view_fetch_int( LibmsiView *view, unsigned row, unsigne TRACE("%p %d %d %p\n", dv, row, col, val ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( row >= dv->row_count ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; row = dv->translation[ row ]; @@ -114,19 +114,19 @@ static unsigned distinct_view_execute( LibmsiView *view, LibmsiRecord *record ) TRACE("%p %p\n", dv, record); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = dv->table->ops->execute( dv->table, record ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; r = dv->table->ops->get_dimensions( dv->table, &r_count, &c_count ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; dv->translation = msi_alloc( r_count*sizeof(unsigned) ); if( !dv->translation ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* build it */ for( i=0; itable->ops->fetch_int( dv->table, i, j, &val ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { ERR("Failed to fetch int at %d %d\n", i, j ); distinct_free( rowset ); @@ -148,7 +148,7 @@ static unsigned distinct_view_execute( LibmsiView *view, LibmsiRecord *record ) { ERR("Failed to insert at %d %d\n", i, j ); distinct_free( rowset ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } if( j != c_count ) x = &(*x)->nextcol; @@ -164,7 +164,7 @@ static unsigned distinct_view_execute( LibmsiView *view, LibmsiRecord *record ) distinct_free( rowset ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned distinct_view_close( LibmsiView *view ) @@ -174,7 +174,7 @@ static unsigned distinct_view_close( LibmsiView *view ) TRACE("%p\n", dv ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; msi_free( dv->translation ); dv->translation = NULL; @@ -190,12 +190,12 @@ static unsigned distinct_view_get_dimensions( LibmsiView *view, unsigned *rows, TRACE("%p %p %p\n", dv, rows, cols ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( rows ) { if( !dv->translation ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; *rows = dv->row_count; } @@ -210,7 +210,7 @@ static unsigned distinct_view_get_column_info( LibmsiView *view, unsigned n, con TRACE("%p %d %p %p %p %p\n", dv, n, name, type, temporary, table_name ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return dv->table->ops->get_column_info( dv->table, n, name, type, temporary, table_name ); @@ -224,7 +224,7 @@ static unsigned distinct_view_modify( LibmsiView *view, LibmsiModify eModifyMode TRACE("%p %d %p\n", dv, eModifyMode, rec ); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return dv->table->ops->modify( dv->table, eModifyMode, rec, row ); } @@ -242,7 +242,7 @@ static unsigned distinct_view_delete( LibmsiView *view ) msiobj_release( &dv->db->hdr ); msi_free( dv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned distinct_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -254,12 +254,12 @@ static unsigned distinct_view_find_matching_rows( LibmsiView *view, unsigned col TRACE("%p, %d, %u, %p\n", view, col, val, *handle); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = dv->table->ops->find_matching_rows( dv->table, col, val, row, handle ); if( *row > dv->row_count ) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *row = dv->translation[ *row ]; @@ -297,7 +297,7 @@ unsigned distinct_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView TRACE("%p\n", dv ); r = table->ops->get_dimensions( table, NULL, &count ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { ERR("can't get table dimensions\n"); return r; @@ -305,7 +305,7 @@ unsigned distinct_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView dv = alloc_msiobject( sizeof *dv, NULL ); if( !dv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* fill the structure */ dv->view.ops = &distinct_ops; @@ -316,5 +316,5 @@ unsigned distinct_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView dv->row_count = 0; *view = (LibmsiView*) dv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/drop.c b/libmsi/drop.c index 59a057d..c16821f 100644 --- a/libmsi/drop.c +++ b/libmsi/drop.c @@ -49,10 +49,10 @@ static unsigned drop_view_execute(LibmsiView *view, LibmsiRecord *record) TRACE("%p %p\n", dv, record); if( !dv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = dv->table->ops->execute(dv->table, record); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; return dv->table->ops->drop(dv->table); @@ -64,7 +64,7 @@ static unsigned drop_view_close(LibmsiView *view) TRACE("%p\n", dv); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned drop_view_get_dimensions(LibmsiView *view, unsigned *rows, unsigned *cols) @@ -73,7 +73,7 @@ static unsigned drop_view_get_dimensions(LibmsiView *view, unsigned *rows, unsig TRACE("%p %p %p\n", dv, rows, cols); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned drop_view_delete( LibmsiView *view ) @@ -87,7 +87,7 @@ static unsigned drop_view_delete( LibmsiView *view ) msi_free( dv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static const LibmsiViewOps drop_ops = @@ -122,10 +122,10 @@ unsigned drop_view_create(LibmsiDatabase *db, LibmsiView **view, const WCHAR *na dv = alloc_msiobject(sizeof *dv, NULL); if(!dv) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = table_view_create(db, name, &dv->table); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msi_free( dv ); return r; @@ -136,5 +136,5 @@ unsigned drop_view_create(LibmsiDatabase *db, LibmsiView **view, const WCHAR *na *view = (LibmsiView *)dv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/handle.c b/libmsi/handle.c index 77cf782..4667d00 100644 --- a/libmsi/handle.c +++ b/libmsi/handle.c @@ -80,12 +80,12 @@ int msiobj_release( LibmsiObject *obj ) /*********************************************************** * libmsi_unref [MSI.@] */ -unsigned libmsi_unref(void *obj) +LibmsiResult libmsi_unref(void *obj) { TRACE("%x\n",obj); if( obj ) msiobj_release( obj ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/insert.c b/libmsi/insert.c index be1d13a..6ce752f 100644 --- a/libmsi/insert.c +++ b/libmsi/insert.c @@ -53,7 +53,7 @@ static unsigned insert_view_fetch_int( LibmsiView *view, unsigned row, unsigned TRACE("%p %d %d %p\n", iv, row, col, val ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* @@ -133,7 +133,7 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values) const WCHAR *b; r = iv->table->ops->get_dimensions(iv->table, NULL, &col_count); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; val_count = libmsi_record_get_field_count(*values); @@ -142,23 +142,23 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values) * to avoid unnecessary copying */ if (col_count == val_count && msi_columns_in_order(iv, col_count)) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; padded = libmsi_record_create(col_count); if (!padded) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; for (colidx = 1; colidx <= val_count; colidx++) { r = iv->sv->ops->get_column_info(iv->sv, colidx, &a, NULL, NULL, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; for (i = 1; i <= col_count; i++) { r = iv->table->ops->get_column_info(iv->table, i, &b, NULL, NULL, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto err; if (!strcmpW( a, b )) @@ -170,7 +170,7 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values) } msiobj_release(&(*values)->hdr); *values = padded; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; err: msiobj_release(&padded->hdr); @@ -182,14 +182,14 @@ static bool row_has_null_primary_keys(LibmsiInsertView *iv, LibmsiRecord *row) unsigned r, i, col_count, type; r = iv->table->ops->get_dimensions( iv->table, NULL, &col_count ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return false; for (i = 1; i <= col_count; i++) { r = iv->table->ops->get_column_info(iv->table, i, NULL, &type, NULL, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return false; if (!(type & MSITYPE_KEY)) @@ -213,7 +213,7 @@ static unsigned insert_view_execute( LibmsiView *view, LibmsiRecord *record ) sv = iv->sv; if( !sv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = sv->ops->execute( sv, 0 ); TRACE("sv execute returned %x\n", r); @@ -233,7 +233,7 @@ static unsigned insert_view_execute( LibmsiView *view, LibmsiRecord *record ) goto err; r = msi_arrange_record( iv, &values ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) goto err; /* rows with NULL primary keys are inserted at the beginning of the table */ @@ -259,7 +259,7 @@ static unsigned insert_view_close( LibmsiView *view ) sv = iv->sv; if( !sv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return sv->ops->close( sv ); } @@ -273,7 +273,7 @@ static unsigned insert_view_get_dimensions( LibmsiView *view, unsigned *rows, un sv = iv->sv; if( !sv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return sv->ops->get_dimensions( sv, rows, cols ); } @@ -288,7 +288,7 @@ static unsigned insert_view_get_column_info( LibmsiView *view, unsigned n, const sv = iv->sv; if( !sv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return sv->ops->get_column_info( sv, n, name, type, temporary, table_name ); } @@ -299,7 +299,7 @@ static unsigned insert_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", iv, eModifyMode, rec ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned insert_view_delete( LibmsiView *view ) @@ -315,7 +315,7 @@ static unsigned insert_view_delete( LibmsiView *view ) msiobj_release( &iv->db->hdr ); msi_free( iv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned insert_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -323,7 +323,7 @@ static unsigned insert_view_find_matching_rows( LibmsiView *view, unsigned col, { TRACE("%p, %d, %u, %p\n", view, col, val, *handle); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } @@ -369,14 +369,14 @@ unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR /* there should be one value for each column */ if ( count_column_info( columns ) != count_column_info(values) ) - return ERROR_BAD_QUERY_SYNTAX; + return LIBMSI_RESULT_BAD_QUERY_SYNTAX; r = table_view_create( db, table, &tv ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; r = select_view_create( db, &sv, tv, columns ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { if( tv ) tv->ops->delete( tv ); @@ -385,7 +385,7 @@ unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR iv = alloc_msiobject( sizeof *iv, NULL ); if( !iv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* fill the structure */ iv->view.ops = &insert_ops; @@ -397,5 +397,5 @@ unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR iv->sv = sv; *view = (LibmsiView*) iv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/msiquery.c b/libmsi/msiquery.c index c1dfb27..b5c3b76 100644 --- a/libmsi/msiquery.c +++ b/libmsi/msiquery.c @@ -61,7 +61,7 @@ unsigned _libmsi_view_find_column( LibmsiView *table, const WCHAR *name, const W unsigned i, count, r; r = table->ops->get_dimensions( table, NULL, &count ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; for( i=1; i<=count; i++ ) @@ -70,7 +70,7 @@ unsigned _libmsi_view_find_column( LibmsiView *table, const WCHAR *name, const W r = table->ops->get_column_info( table, i, &col_name, NULL, NULL, &haystack_table_name ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; x = strcmpW( name, col_name ); if( table_name ) @@ -78,13 +78,13 @@ unsigned _libmsi_view_find_column( LibmsiView *table, const WCHAR *name, const W if( !x ) { *n = i; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; } -unsigned libmsi_database_open_query(LibmsiDatabase *db, +LibmsiResult libmsi_database_open_query(LibmsiDatabase *db, const char *szQuery, LibmsiQuery **pQuery) { unsigned r; @@ -96,13 +96,13 @@ unsigned libmsi_database_open_query(LibmsiDatabase *db, { szwQuery = strdupAtoW( szQuery ); if( !szwQuery ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } else szwQuery = NULL; if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &db->hdr); r = _libmsi_database_open_query( db, szwQuery, pQuery ); @@ -121,19 +121,19 @@ unsigned _libmsi_database_open_query(LibmsiDatabase *db, TRACE("%s %p\n", debugstr_w(szQuery), pView); if( !szQuery) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* pre allocate a handle to hold a pointer to the view */ query = alloc_msiobject( sizeof (LibmsiQuery), _libmsi_query_destroy ); if( !query ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; msiobj_addref( &db->hdr ); query->db = db; list_init( &query->mem ); r = _libmsi_parse_sql( db, szQuery, &query->view, &query->mem ); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) { msiobj_addref( &query->hdr ); *pView = query; @@ -175,7 +175,7 @@ unsigned _libmsi_query_iterate_records( LibmsiQuery *view, unsigned *count, unsigned r, n = 0, max = 0; r = _libmsi_query_execute( view, NULL ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; if( count ) @@ -185,12 +185,12 @@ unsigned _libmsi_query_iterate_records( LibmsiQuery *view, unsigned *count, for( n = 0; (max == 0) || (n < max); n++ ) { r = _libmsi_query_fetch( view, &rec ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) break; if (func) r = func( rec, param ); msiobj_release( &rec->hdr ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) break; } @@ -199,8 +199,8 @@ unsigned _libmsi_query_iterate_records( LibmsiQuery *view, unsigned *count, if( count ) *count = n; - if( r == ERROR_NO_MORE_ITEMS ) - r = ERROR_SUCCESS; + if( r == LIBMSI_RESULT_NO_MORE_ITEMS ) + r = LIBMSI_RESULT_SUCCESS; return r; } @@ -231,7 +231,7 @@ LibmsiRecord *_libmsi_query_get_record( LibmsiDatabase *db, const WCHAR *fmt, .. r = _libmsi_database_open_query(db, query, &view); msi_free(query); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) { _libmsi_query_execute( view, NULL ); _libmsi_query_fetch( view, &rec ); @@ -252,14 +252,14 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li return ret; if (!col_count) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= row_count) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *rec = libmsi_record_create(col_count); if (!*rec) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; for (i = 1; i <= col_count; i++) { @@ -275,7 +275,7 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li IStream *stm = NULL; ret = view->ops->fetch_stream(view, row, i, &stm); - if ((ret == ERROR_SUCCESS) && stm) + if ((ret == LIBMSI_RESULT_SUCCESS) && stm) { _libmsi_record_set_IStream(*rec, i, stm); IStream_Release(stm); @@ -316,22 +316,22 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li } } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned _libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **prec) +LibmsiResult _libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **prec) { LibmsiView *view; - unsigned r; + LibmsiResult r; TRACE("%p %p\n", query, prec ); view = query->view; if( !view ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = msi_view_get_row(query->db, view, query->row, prec); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { query->row ++; _libmsi_record_set_int_ptr(*prec, 0, (intptr_t)query); @@ -340,25 +340,25 @@ unsigned _libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **prec) return r; } -unsigned libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **record) +LibmsiResult libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **record) { unsigned ret; TRACE("%d %p\n", query, record); if( !record ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; *record = 0; if( !query ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &query->hdr); ret = _libmsi_query_fetch( query, record ); msiobj_release( &query->hdr ); return ret; } -unsigned libmsi_query_close(LibmsiQuery *query) +LibmsiResult libmsi_query_close(LibmsiQuery *query) { LibmsiView *view; unsigned ret; @@ -366,21 +366,21 @@ unsigned libmsi_query_close(LibmsiQuery *query) TRACE("%p\n", query ); if( !query ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &query->hdr ); view = query->view; if( !view ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !view->ops->close ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; ret = view->ops->close( view ); msiobj_release( &query->hdr ); return ret; } -unsigned _libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec ) +LibmsiResult _libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec ) { LibmsiView *view; @@ -388,22 +388,22 @@ unsigned _libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec ) view = query->view; if( !view ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !view->ops->execute ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; query->row = 0; return view->ops->execute( view, rec ); } -unsigned libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec) +LibmsiResult libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec) { - unsigned ret; + LibmsiResult ret; TRACE("%d %d\n", query, rec); if( !query ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &query->hdr ); if( rec ) @@ -457,33 +457,33 @@ static unsigned msi_set_record_type_string( LibmsiRecord *rec, unsigned field, unsigned _libmsi_query_get_column_info( LibmsiQuery *query, LibmsiColInfo info, LibmsiRecord **prec ) { - unsigned r = ERROR_FUNCTION_FAILED, i, count = 0, type; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED, i, count = 0, type; LibmsiRecord *rec; LibmsiView *view = query->view; const WCHAR *name; bool temporary; if( !view ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !view->ops->get_dimensions ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = view->ops->get_dimensions( view, NULL, &count ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; if( !count ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; rec = libmsi_record_create( count ); if( !rec ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; for( i=0; iops->get_column_info( view, i+1, &name, &type, &temporary, NULL ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) continue; if (info == LIBMSI_COL_INFO_NAMES) _libmsi_record_set_stringW( rec, i+1, name ); @@ -491,23 +491,23 @@ unsigned _libmsi_query_get_column_info( LibmsiQuery *query, LibmsiColInfo info, msi_set_record_type_string( rec, i+1, type, temporary ); } *prec = rec; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned libmsi_query_get_column_info(LibmsiQuery *query, LibmsiColInfo info, LibmsiRecord **prec) +LibmsiResult libmsi_query_get_column_info(LibmsiQuery *query, LibmsiColInfo info, LibmsiRecord **prec) { unsigned r; TRACE("%d %d %p\n", query, info, prec); if( !prec ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( info != LIBMSI_COL_INFO_NAMES && info != LIBMSI_COL_INFO_TYPES ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( !query ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref ( &query->hdr ); r = _libmsi_query_get_column_info( query, info, prec ); @@ -522,31 +522,31 @@ unsigned _libmsi_query_modify( LibmsiQuery *query, LibmsiModify mode, LibmsiReco unsigned r; if ( !query || !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; view = query->view; if ( !view || !view->ops->modify) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if ( mode == LIBMSI_MODIFY_UPDATE && _libmsi_record_get_int_ptr( rec, 0 ) != (intptr_t)query ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = view->ops->modify( view, mode, rec, query->row ); - if (mode == LIBMSI_MODIFY_DELETE && r == ERROR_SUCCESS) + if (mode == LIBMSI_MODIFY_DELETE && r == LIBMSI_RESULT_SUCCESS) query->row--; return r; } -unsigned libmsi_query_modify( LibmsiQuery *query, LibmsiModify eModifyMode, +LibmsiResult libmsi_query_modify( LibmsiQuery *query, LibmsiModify eModifyMode, LibmsiRecord *rec) { - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; TRACE("%d %x %d\n", query, eModifyMode, rec); if( !query ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &query->hdr); @@ -597,7 +597,7 @@ unsigned _libmsi_database_apply_transform( LibmsiDatabase *db, const char *szTransformFile, int iErrorCond ) { HRESULT r; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; IStorage *stg = NULL; STATSTG stat; WCHAR *szwTransformFile = NULL; @@ -633,20 +633,20 @@ end: return ret; } -unsigned libmsi_database_apply_transform( LibmsiDatabase *db, +LibmsiResult libmsi_database_apply_transform( LibmsiDatabase *db, const char *szTransformFile, int iErrorCond) { unsigned r; msiobj_addref( &db->hdr ); if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; r = _libmsi_database_apply_transform( db, szTransformFile, iErrorCond ); msiobj_release( &db->hdr ); return r; } -unsigned libmsi_database_commit( LibmsiDatabase *db ) +LibmsiResult libmsi_database_commit( LibmsiDatabase *db ) { unsigned r; @@ -654,24 +654,24 @@ unsigned libmsi_database_commit( LibmsiDatabase *db ) msiobj_addref( &db->hdr ); if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; if (db->mode == LIBMSI_DB_OPEN_READONLY) { msiobj_release( &db->hdr ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } /* FIXME: lock the database */ r = _libmsi_database_commit_tables( db ); - if (r != ERROR_SUCCESS) ERR("Failed to commit tables!\n"); + if (r != LIBMSI_RESULT_SUCCESS) ERR("Failed to commit tables!\n"); /* FIXME: unlock the database */ msiobj_release( &db->hdr ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { msi_free( db->deletefile ); db->deletefile = NULL; @@ -710,7 +710,7 @@ static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param ) } } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db, @@ -726,17 +726,17 @@ unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db, unsigned r; if (!table_view_exists( db, table )) - return ERROR_INVALID_TABLE; + return LIBMSI_RESULT_INVALID_TABLE; r = _libmsi_query_open( db, &query, sql, table ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; /* count the number of primary key records */ info.n = 0; info.rec = 0; r = _libmsi_query_iterate_records( query, 0, msi_primary_key_iterator, &info ); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) { TRACE("Found %d primary keys\n", info.n ); @@ -744,7 +744,7 @@ unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db, info.rec = libmsi_record_create( info.n ); info.n = 0; r = _libmsi_query_iterate_records( query, 0, msi_primary_key_iterator, &info ); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) *prec = info.rec; else msiobj_release( &info.rec->hdr ); @@ -754,7 +754,7 @@ unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db, return r; } -unsigned libmsi_database_get_primary_keys(LibmsiDatabase *db, +LibmsiResult libmsi_database_get_primary_keys(LibmsiDatabase *db, const char *table, LibmsiRecord **prec) { WCHAR *szwTable = NULL; @@ -766,11 +766,11 @@ unsigned libmsi_database_get_primary_keys(LibmsiDatabase *db, { szwTable = strdupAtoW( table ); if( !szwTable ) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; } if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &db->hdr ); r = _libmsi_database_get_primary_keys( db, szwTable, prec ); diff --git a/libmsi/record.c b/libmsi/record.c index 046df72..8583ac8 100644 --- a/libmsi/record.c +++ b/libmsi/record.c @@ -123,10 +123,10 @@ static bool expr_int_from_string( const WCHAR *str, int *out ) unsigned _libmsi_record_copy_field( LibmsiRecord *in_rec, unsigned in_n, LibmsiRecord *out_rec, unsigned out_n ) { - unsigned r = ERROR_SUCCESS; + unsigned r = LIBMSI_RESULT_SUCCESS; if ( in_n > in_rec->count || out_n > out_rec->count ) - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; else if ( in_rec != out_rec || in_n != out_n ) { WCHAR *str; @@ -148,7 +148,7 @@ unsigned _libmsi_record_copy_field( LibmsiRecord *in_rec, unsigned in_n, case LIBMSI_FIELD_TYPE_WSTR: str = strdupW( in->u.szwVal ); if ( !str ) - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; else out->u.szwVal = str; break; @@ -159,7 +159,7 @@ unsigned _libmsi_record_copy_field( LibmsiRecord *in_rec, unsigned in_n, default: ERR("invalid field type %d\n", in->type); } - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) out->type = in->type; } @@ -221,14 +221,14 @@ int libmsi_record_get_integer( const LibmsiRecord *rec, unsigned iField) return MSI_NULL_INTEGER; } -unsigned libmsi_record_clear_data( LibmsiRecord *rec ) +LibmsiResult libmsi_record_clear_data( LibmsiRecord *rec ) { unsigned i; TRACE("%d\n", rec ); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &rec->hdr ); for( i=0; i<=rec->count; i++) @@ -239,7 +239,7 @@ unsigned libmsi_record_clear_data( LibmsiRecord *rec ) } msiobj_release( &rec->hdr ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_record_set_int_ptr( LibmsiRecord *rec, unsigned iField, intptr_t pVal ) @@ -247,30 +247,30 @@ unsigned _libmsi_record_set_int_ptr( LibmsiRecord *rec, unsigned iField, intptr_ TRACE("%p %u %ld\n", rec, iField, pVal); if( iField > rec->count ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; _libmsi_free_field( &rec->fields[iField] ); rec->fields[iField].type = LIBMSI_FIELD_TYPE_INTPTR; rec->fields[iField].u.pVal = pVal; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned libmsi_record_set_int( LibmsiRecord *rec, unsigned iField, int iVal ) +LibmsiResult libmsi_record_set_int( LibmsiRecord *rec, unsigned iField, int iVal ) { TRACE("%p %u %d\n", rec, iField, iVal); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; if( iField > rec->count ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; _libmsi_free_field( &rec->fields[iField] ); rec->fields[iField].type = LIBMSI_FIELD_TYPE_INT; rec->fields[iField].u.iVal = iVal; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } bool libmsi_record_is_null( const LibmsiRecord *rec, unsigned iField ) @@ -288,7 +288,7 @@ bool libmsi_record_is_null( const LibmsiRecord *rec, unsigned iField ) return r; } -unsigned libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, +LibmsiResult libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, char *szValue, unsigned *pcchValue) { unsigned len=0, ret; @@ -297,7 +297,7 @@ unsigned libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; if( iField > rec->count ) { @@ -305,10 +305,10 @@ unsigned libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, szValue[0] = 0; *pcchValue = 0; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; switch( rec->fields[iField].type ) { case LIBMSI_FIELD_TYPE_INT: @@ -333,12 +333,12 @@ unsigned libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, szValue[0] = 0; break; default: - ret = ERROR_INVALID_PARAMETER; + ret = LIBMSI_RESULT_INVALID_PARAMETER; break; } if( szValue && *pcchValue <= len ) - ret = ERROR_MORE_DATA; + ret = LIBMSI_RESULT_MORE_DATA; *pcchValue = len; return ret; @@ -370,10 +370,10 @@ unsigned _libmsi_record_get_stringW(const LibmsiRecord *rec, unsigned iField, szValue[0] = 0; *pcchValue = 0; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; switch( rec->fields[iField].type ) { case LIBMSI_FIELD_TYPE_INT: @@ -396,7 +396,7 @@ unsigned _libmsi_record_get_stringW(const LibmsiRecord *rec, unsigned iField, } if( szValue && *pcchValue <= len ) - ret = ERROR_MORE_DATA; + ret = LIBMSI_RESULT_MORE_DATA; *pcchValue = len; return ret; @@ -437,14 +437,14 @@ unsigned libmsi_record_get_field_size(const LibmsiRecord *rec, unsigned iField) return 0; } -unsigned libmsi_record_set_string( LibmsiRecord *rec, unsigned iField, const char *szValue ) +LibmsiResult libmsi_record_set_string( LibmsiRecord *rec, unsigned iField, const char *szValue ) { WCHAR *str; TRACE("%d %d %s\n", rec, iField, debugstr_a(szValue)); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; str = strdupAtoW( szValue ); return _libmsi_record_set_stringW( rec, iField, str ); @@ -457,7 +457,7 @@ unsigned _libmsi_record_set_stringW( LibmsiRecord *rec, unsigned iField, const W TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue)); if( iField > rec->count ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; _libmsi_free_field( &rec->fields[iField] ); @@ -507,14 +507,14 @@ static unsigned _libmsi_addstream_from_file(const char *szFile, IStream **pstm) } CloseHandle(handle); if( !hGlob ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* make a stream out of it, and set the correct file size */ hr = CreateStreamOnHGlobal(hGlob, true, pstm); if( FAILED( hr ) ) { GlobalFree(hGlob); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* set the correct size - CreateStreamOnHGlobal screws it up */ @@ -523,19 +523,19 @@ static unsigned _libmsi_addstream_from_file(const char *szFile, IStream **pstm) TRACE("read %s, %d bytes into IStream %p\n", debugstr_a(szFile), sz, *pstm); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_record_load_stream(LibmsiRecord *rec, unsigned iField, IStream *stream) { if ( (iField == 0) || (iField > rec->count) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; _libmsi_free_field( &rec->fields[iField] ); rec->fields[iField].type = LIBMSI_FIELD_TYPE_STREAM; rec->fields[iField].u.stream = stream; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_record_load_stream_from_file(LibmsiRecord *rec, unsigned iField, const char *szFilename) @@ -544,7 +544,7 @@ unsigned _libmsi_record_load_stream_from_file(LibmsiRecord *rec, unsigned iField HRESULT r; if( (iField == 0) || (iField > rec->count) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* no filename means we should seek back to the start of the stream */ if( !szFilename ) @@ -553,39 +553,39 @@ unsigned _libmsi_record_load_stream_from_file(LibmsiRecord *rec, unsigned iField ULARGE_INTEGER cur; if( rec->fields[iField].type != LIBMSI_FIELD_TYPE_STREAM ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; stm = rec->fields[iField].u.stream; if( !stm ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; ofs.QuadPart = 0; r = IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur ); if( FAILED( r ) ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } else { /* read the file into a stream and save the stream in the record */ r = _libmsi_addstream_from_file(szFilename, &stm); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; /* if all's good, store it in the record */ _libmsi_record_load_stream(rec, iField, stm); } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned libmsi_record_load_stream(LibmsiRecord *rec, unsigned iField, const char *szFilename) +LibmsiResult libmsi_record_load_stream(LibmsiRecord *rec, unsigned iField, const char *szFilename) { unsigned ret; TRACE("%d %d %s\n", rec, iField, debugstr_a(szFilename)); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &rec->hdr ); ret = _libmsi_record_load_stream_from_file( rec, iField, szFilename ); @@ -602,23 +602,23 @@ unsigned _libmsi_record_save_stream(const LibmsiRecord *rec, unsigned iField, ch TRACE("%p %d %p %p\n", rec, iField, buf, sz); if( !sz ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( iField > rec->count) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if ( rec->fields[iField].type == LIBMSI_FIELD_TYPE_NULL ) { *sz = 0; - return ERROR_INVALID_DATA; + return LIBMSI_RESULT_INVALID_DATA; } if( rec->fields[iField].type != LIBMSI_FIELD_TYPE_STREAM ) - return ERROR_INVALID_DATATYPE; + return LIBMSI_RESULT_INVALID_DATATYPE; stm = rec->fields[iField].u.stream; if( !stm ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* if there's no buffer pointer, calculate the length to the end */ if( !buf ) @@ -634,7 +634,7 @@ unsigned _libmsi_record_save_stream(const LibmsiRecord *rec, unsigned iField, ch IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur ); *sz = end.QuadPart - cur.QuadPart; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } /* read the data */ @@ -643,22 +643,22 @@ unsigned _libmsi_record_save_stream(const LibmsiRecord *rec, unsigned iField, ch if( FAILED( r ) ) { *sz = 0; - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } *sz = count; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned libmsi_record_save_stream(LibmsiRecord *rec, unsigned iField, char *buf, unsigned *sz) +LibmsiResult libmsi_record_save_stream(LibmsiRecord *rec, unsigned iField, char *buf, unsigned *sz) { unsigned ret; TRACE("%d %d %p %p\n", rec, iField, buf, sz); if( !rec ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &rec->hdr ); ret = _libmsi_record_save_stream( rec, iField, buf, sz ); @@ -671,7 +671,7 @@ unsigned _libmsi_record_set_IStream( LibmsiRecord *rec, unsigned iField, IStream TRACE("%p %d %p\n", rec, iField, stm); if( iField > rec->count ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; _libmsi_free_field( &rec->fields[iField] ); @@ -679,7 +679,7 @@ unsigned _libmsi_record_set_IStream( LibmsiRecord *rec, unsigned iField, IStream rec->fields[iField].u.stream = stm; IStream_AddRef( stm ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_record_get_IStream( const LibmsiRecord *rec, unsigned iField, IStream **pstm) @@ -687,15 +687,15 @@ unsigned _libmsi_record_get_IStream( const LibmsiRecord *rec, unsigned iField, I TRACE("%p %d %p\n", rec, iField, pstm); if( iField > rec->count ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; if( rec->fields[iField].type != LIBMSI_FIELD_TYPE_STREAM ) - return ERROR_INVALID_FIELD; + return LIBMSI_RESULT_INVALID_FIELD; *pstm = rec->fields[iField].u.stream; IStream_AddRef( *pstm ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned msi_dump_stream_to_file( IStream *stm, const WCHAR *name ) @@ -709,7 +709,7 @@ static unsigned msi_dump_stream_to_file( IStream *stm, const WCHAR *name ) stgm = STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_FAILIFTHERE; r = SHCreateStreamOnFileW( name, stgm, &out ); if( FAILED( r ) ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; pos.QuadPart = 0; r = IStream_Seek( stm, pos, STREAM_SEEK_END, &size ); @@ -726,8 +726,8 @@ static unsigned msi_dump_stream_to_file( IStream *stm, const WCHAR *name ) end: IStream_Release( out ); if( FAILED( r ) ) - return ERROR_FUNCTION_FAILED; - return ERROR_SUCCESS; + return LIBMSI_RESULT_FUNCTION_FAILED; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *rec, unsigned iField, const WCHAR *name ) @@ -738,7 +738,7 @@ unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *rec, unsigned i TRACE("%p %u %s\n", rec, iField, debugstr_w(name)); r = _libmsi_record_get_IStream( rec, iField, &stm ); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) { r = msi_dump_stream_to_file( stm, name ); IStream_Release( stm ); @@ -772,7 +772,7 @@ LibmsiRecord *_libmsi_record_clone(LibmsiRecord *rec) else { r = _libmsi_record_copy_field(rec, i, clone, i); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msiobj_release(&clone->hdr); return NULL; @@ -836,7 +836,7 @@ WCHAR *msi_dup_record_field( LibmsiRecord *rec, int field ) if (libmsi_record_is_null( rec, field )) return NULL; r = _libmsi_record_get_stringW( rec, field, NULL, &sz ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return NULL; sz++; @@ -844,7 +844,7 @@ WCHAR *msi_dup_record_field( LibmsiRecord *rec, int field ) if (!str) return NULL; str[0] = 0; r = _libmsi_record_get_stringW( rec, field, str, &sz ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("failed to get string!\n"); msi_free( str ); diff --git a/libmsi/select.c b/libmsi/select.c index 641faa9..e88d144 100644 --- a/libmsi/select.c +++ b/libmsi/select.c @@ -53,16 +53,16 @@ static unsigned select_view_fetch_int( LibmsiView *view, unsigned row, unsigned TRACE("%p %d %d %p\n", sv, row, col, val ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !col || col > sv->num_cols ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; col = sv->cols[ col - 1 ]; if( !col ) { *val = 0; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } return sv->table->ops->fetch_int( sv->table, row, col, val ); } @@ -74,16 +74,16 @@ static unsigned select_view_fetch_stream( LibmsiView *view, unsigned row, unsign TRACE("%p %d %d %p\n", sv, row, col, stm ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !col || col > sv->num_cols ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; col = sv->cols[ col - 1 ]; if( !col ) { *stm = NULL; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } return sv->table->ops->fetch_stream( sv->table, row, col, stm ); } @@ -95,7 +95,7 @@ static unsigned select_view_get_row( LibmsiView *view, unsigned row, LibmsiRecor TRACE("%p %d %p\n", sv, row, rec ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return msi_view_get_row(sv->db, view, row, rec); } @@ -103,17 +103,17 @@ static unsigned select_view_get_row( LibmsiView *view, unsigned row, LibmsiRecor static unsigned select_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord *rec, unsigned mask ) { LibmsiSelectView *sv = (LibmsiSelectView*)view; - unsigned i, expanded_mask = 0, r = ERROR_SUCCESS, col_count = 0; + unsigned i, expanded_mask = 0, r = LIBMSI_RESULT_SUCCESS, col_count = 0; LibmsiRecord *expanded; TRACE("%p %d %p %08x\n", sv, row, rec, mask ); if ( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* test if any of the mask bits are invalid */ if ( mask >= (1<num_cols) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* find the number of columns in the table below */ r = sv->table->ops->get_dimensions( sv->table, NULL, &col_count ); @@ -123,19 +123,19 @@ static unsigned select_view_set_row( LibmsiView *view, unsigned row, LibmsiRecor /* expand the record to the right size for the underlying table */ expanded = libmsi_record_create( col_count ); if ( !expanded ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* move the right fields across */ for ( i=0; inum_cols; i++ ) { r = _libmsi_record_copy_field( rec, i+1, expanded, sv->cols[ i ] ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; expanded_mask |= (1<<(sv->cols[i]-1)); } /* set the row in the underlying table */ - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) r = sv->table->ops->set_row( sv->table, row, expanded, expanded_mask ); msiobj_release( &expanded->hdr ); @@ -151,11 +151,11 @@ static unsigned select_view_insert_row( LibmsiView *view, LibmsiRecord *record, TRACE("%p %p\n", sv, record ); if ( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* rearrange the record to suit the table */ r = sv->table->ops->get_dimensions( sv->table, NULL, &table_cols ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; outrec = libmsi_record_create( table_cols + 1 ); @@ -163,7 +163,7 @@ static unsigned select_view_insert_row( LibmsiView *view, LibmsiRecord *record, for (i=0; inum_cols; i++) { r = _libmsi_record_copy_field( record, i+1, outrec, sv->cols[i] ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto fail; } @@ -182,7 +182,7 @@ static unsigned select_view_execute( LibmsiView *view, LibmsiRecord *record ) TRACE("%p %p\n", sv, record); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return sv->table->ops->execute( sv->table, record ); } @@ -194,7 +194,7 @@ static unsigned select_view_close( LibmsiView *view ) TRACE("%p\n", sv ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return sv->table->ops->close( sv->table ); } @@ -206,7 +206,7 @@ static unsigned select_view_get_dimensions( LibmsiView *view, unsigned *rows, un TRACE("%p %p %p\n", sv, rows, cols ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( cols ) *cols = sv->num_cols; @@ -222,10 +222,10 @@ static unsigned select_view_get_column_info( LibmsiView *view, unsigned n, const TRACE("%p %d %p %p %p %p\n", sv, n, name, type, temporary, table_name ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !n || n > sv->num_cols ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; n = sv->cols[ n - 1 ]; if( !n ) @@ -234,7 +234,7 @@ static unsigned select_view_get_column_info( LibmsiView *view, unsigned n, const if (type) *type = MSITYPE_UNKNOWN | MSITYPE_VALID; if (temporary) *temporary = false; if (table_name) *table_name = szEmpty; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } return sv->table->ops->get_column_info( sv->table, n, name, type, temporary, table_name ); @@ -248,11 +248,11 @@ static unsigned msi_select_update(LibmsiView *view, LibmsiRecord *rec, unsigned LibmsiRecord *mod; r = select_view_get_dimensions(view, NULL, &num_columns); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = sv->table->ops->get_row(sv->table, row - 1, &mod); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; for (i = 0; i < num_columns; i++) @@ -260,7 +260,7 @@ static unsigned msi_select_update(LibmsiView *view, LibmsiRecord *rec, unsigned col = sv->cols[i]; r = select_view_get_column_info(view, i + 1, NULL, &type, NULL, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("Failed to get column information: %d\n", r); goto done; @@ -269,7 +269,7 @@ static unsigned msi_select_update(LibmsiView *view, LibmsiRecord *rec, unsigned if (MSITYPE_IS_BINARY(type)) { ERR("Cannot modify binary data!\n"); - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } else if (type & MSITYPE_STRING) @@ -283,7 +283,7 @@ static unsigned msi_select_update(LibmsiView *view, LibmsiRecord *rec, unsigned r = libmsi_record_set_int(mod, col, val); } - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("Failed to modify record: %d\n", r); goto done; @@ -305,7 +305,7 @@ static unsigned select_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p %d\n", sv, eModifyMode, rec, row ); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (eModifyMode == LIBMSI_MODIFY_UPDATE) return msi_select_update(view, rec, row); @@ -325,7 +325,7 @@ static unsigned select_view_delete( LibmsiView *view ) msi_free( sv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned select_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -336,10 +336,10 @@ static unsigned select_view_find_matching_rows( LibmsiView *view, unsigned col, TRACE("%p, %d, %u, %p\n", view, col, val, *handle); if( !sv->table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( (col==0) || (col>sv->num_cols) ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; col = sv->cols[ col - 1 ]; @@ -380,24 +380,24 @@ static unsigned select_view_add_column( LibmsiSelectView *sv, const WCHAR *name, debugstr_w( name )); if( sv->view.ops != &select_ops ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; table = sv->table; if( !table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !table->ops->get_dimensions ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( !table->ops->get_column_info ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if( sv->num_cols >= sv->max_cols ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if ( !name[0] ) n = 0; else { r = _libmsi_view_find_column( table, name, table_name, &n ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; } @@ -407,7 +407,7 @@ static unsigned select_view_add_column( LibmsiSelectView *sv, const WCHAR *name, sv->num_cols++; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static int select_count_columns( const column_info *col ) @@ -422,7 +422,7 @@ unsigned select_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView * const column_info *columns ) { LibmsiSelectView *sv = NULL; - unsigned count = 0, r = ERROR_SUCCESS; + unsigned count = 0, r = LIBMSI_RESULT_SUCCESS; TRACE("%p\n", sv ); @@ -430,7 +430,7 @@ unsigned select_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView * sv = alloc_msiobject( sizeof *sv + count*sizeof (unsigned), NULL ); if( !sv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* fill the structure */ sv->view.ops = &select_ops; @@ -447,7 +447,7 @@ unsigned select_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView * columns = columns->next; } - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) *view = &sv->view; else msi_free( sv ); diff --git a/libmsi/sql-parser.y b/libmsi/sql-parser.y index 9fef336..fe8ff56 100644 --- a/libmsi/sql-parser.y +++ b/libmsi/sql-parser.y @@ -298,7 +298,7 @@ onedrop: unsigned r; r = drop_view_create( sql->db, &drop, $3 ); - if( r != ERROR_SUCCESS || !$$ ) + if( r != LIBMSI_RESULT_SUCCESS || !$$ ) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, drop ); @@ -419,7 +419,7 @@ oneselect: unsigned r; r = distinct_view_create( sql->db, &distinct, $3 ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, distinct ); @@ -436,7 +436,7 @@ selectfrom: if( $1 ) { r = select_view_create( sql->db, &select, $2, $1 ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, select ); @@ -478,7 +478,7 @@ from: unsigned r; r = table_view_create( sql->db, $2, &table ); - if( r != ERROR_SUCCESS || !$$ ) + if( r != LIBMSI_RESULT_SUCCESS || !$$ ) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, table ); @@ -490,7 +490,7 @@ from: if( $4 ) { r = $1->ops->sort( $1, $4 ); - if ( r != ERROR_SUCCESS) + if ( r != LIBMSI_RESULT_SUCCESS) YYABORT; } @@ -507,7 +507,7 @@ unorderdfrom: unsigned r; r = where_view_create( sql->db, &where, $2, NULL ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, where ); @@ -519,7 +519,7 @@ unorderdfrom: unsigned r; r = where_view_create( sql->db, &where, $2, $4 ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) YYABORT; PARSER_BUBBLE_UP_VIEW( sql, $$, where ); @@ -730,7 +730,7 @@ table: id: TK_ID { - if ( sql_unescape_string( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ ) + if ( sql_unescape_string( info, &$1, &$$ ) != LIBMSI_RESULT_SUCCESS || !$$ ) YYABORT; } ; @@ -738,7 +738,7 @@ id: string: TK_STRING { - if ( sql_unescape_string( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ ) + if ( sql_unescape_string( info, &$1, &$$ ) != LIBMSI_RESULT_SUCCESS || !$$ ) YYABORT; } ; @@ -829,7 +829,7 @@ unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR * /* match quotes */ if( ( (p[0]=='`') && (p[len-1]!='`') ) || ( (p[0]=='\'') && (p[len-1]!='\'') ) ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* if there's quotes, remove them */ if( ( (p[0]=='`') && (p[len-1]=='`') ) || @@ -840,11 +840,11 @@ unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR * } *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) ); if( !*str ) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; memcpy( *str, p, len*sizeof(WCHAR) ); (*str)[len]=0; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } INT sql_atoi( void *info ) @@ -936,7 +936,7 @@ static struct expr * build_expr_sval( void *info, const struct sql_str *str ) if( e ) { e->type = EXPR_SVAL; - if( sql_unescape_string( info, str, (WCHAR **)&e->u.sval ) != ERROR_SUCCESS ) + if( sql_unescape_string( info, str, (WCHAR **)&e->u.sval ) != LIBMSI_RESULT_SUCCESS ) return NULL; /* e will be freed by query destructor */ } return e; @@ -1010,7 +1010,7 @@ unsigned _libmsi_parse_sql( LibmsiDatabase *db, const WCHAR *command, LibmsiView sql.command = command; sql.n = 0; sql.len = 0; - sql.r = ERROR_BAD_QUERY_SYNTAX; + sql.r = LIBMSI_RESULT_BAD_QUERY_SYNTAX; sql.view = phview; sql.mem = mem; @@ -1027,5 +1027,5 @@ unsigned _libmsi_parse_sql( LibmsiDatabase *db, const WCHAR *command, LibmsiView return sql.r; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/storages.c b/libmsi/storages.c index a6dc32f..8673812 100644 --- a/libmsi/storages.c +++ b/libmsi/storages.c @@ -90,14 +90,14 @@ static unsigned storages_view_fetch_int(LibmsiView *view, unsigned row, unsigned TRACE("(%p, %d, %d, %p)\n", view, row, col, val); if (col != 1) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= sv->num_rows) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *val = sv->storages[row]->str_index; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, IStream **stm) @@ -107,9 +107,9 @@ static unsigned storages_view_fetch_stream(LibmsiView *view, unsigned row, unsig TRACE("(%p, %d, %d, %p)\n", view, row, col, stm); if (row >= sv->num_rows) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; - return ERROR_INVALID_DATA; + return LIBMSI_RESULT_INVALID_DATA; } static unsigned storages_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord **rec ) @@ -118,7 +118,7 @@ static unsigned storages_view_get_row( LibmsiView *view, unsigned row, LibmsiRec FIXME("%p %d %p\n", sv, row, rec); - return ERROR_CALL_NOT_IMPLEMENTED; + return LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; } static HRESULT stream_to_storage(IStream *stm, IStorage **stg) @@ -177,19 +177,19 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco IStream *stm; WCHAR *name = NULL; HRESULT hr; - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; TRACE("(%p, %p)\n", view, rec); if (row > sv->num_rows) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = _libmsi_record_get_IStream(rec, 2, &stm); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = stream_to_storage(stm, &stg); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { IStream_Release(stm); return r; @@ -198,7 +198,7 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco name = strdupW(_libmsi_record_get_string_raw(rec, 1)); if (!name) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto done; } @@ -207,20 +207,20 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco 0, 0, &substg); if (FAILED(hr)) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } hr = IStorage_CopyTo(stg, 0, NULL, NULL, substg); if (FAILED(hr)) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } sv->storages[row] = create_storage(sv, name, stg); if (!sv->storages[row]) - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; done: msi_free(name); @@ -237,7 +237,7 @@ static unsigned storages_view_insert_row(LibmsiView *view, LibmsiRecord *rec, un LibmsiStorageView *sv = (LibmsiStorageView *)view; if (!storages_set_table_size(sv, ++sv->num_rows)) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (row == -1) row = sv->num_rows - 1; @@ -250,19 +250,19 @@ static unsigned storages_view_insert_row(LibmsiView *view, LibmsiRecord *rec, un static unsigned storages_view_delete_row(LibmsiView *view, unsigned row) { FIXME("(%p %d): stub!\n", view, row); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_execute(LibmsiView *view, LibmsiRecord *record) { TRACE("(%p, %p)\n", view, record); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_close(LibmsiView *view) { TRACE("(%p)\n", view); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_get_dimensions(LibmsiView *view, unsigned *rows, unsigned *cols) @@ -274,7 +274,7 @@ static unsigned storages_view_get_dimensions(LibmsiView *view, unsigned *rows, u if (cols) *cols = NUM_STORAGES_COLS; if (rows) *rows = sv->num_rows; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, @@ -284,7 +284,7 @@ static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, con table_name); if (n == 0 || n > NUM_STORAGES_COLS) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; switch (n) { @@ -300,7 +300,7 @@ static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, con } if (table_name) *table_name = szStorages; if (temporary) *temporary = false; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_find_row(LibmsiStorageView *sv, LibmsiRecord *rec, unsigned *row) @@ -310,7 +310,7 @@ static unsigned storages_find_row(LibmsiStorageView *sv, LibmsiRecord *rec, unsi str = _libmsi_record_get_string_raw(rec, 1); r = _libmsi_id_from_stringW(sv->db->strings, str, &id); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; for (i = 0; i < sv->num_rows; i++) @@ -320,11 +320,11 @@ static unsigned storages_find_row(LibmsiStorageView *sv, LibmsiRecord *rec, unsi if (data == id) { *row = i; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned storages_modify_update(LibmsiView *view, LibmsiRecord *rec) @@ -333,8 +333,8 @@ static unsigned storages_modify_update(LibmsiView *view, LibmsiRecord *rec) unsigned r, row; r = storages_find_row(sv, rec, &row); - if (r != ERROR_SUCCESS) - return ERROR_FUNCTION_FAILED; + if (r != LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_FUNCTION_FAILED; return storages_view_set_row(view, row, rec, 0); } @@ -345,7 +345,7 @@ static unsigned storages_modify_assign(LibmsiView *view, LibmsiRecord *rec) unsigned r, row; r = storages_find_row(sv, rec, &row); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) return storages_modify_update(view, rec); return storages_view_insert_row(view, rec, -1, false); @@ -381,11 +381,11 @@ static unsigned storages_view_modify(LibmsiView *view, LibmsiModify eModifyMode, case LIBMSI_MODIFY_VALIDATE_FIELD: case LIBMSI_MODIFY_VALIDATE_DELETE: FIXME("%p %d %p - mode not implemented\n", view, eModifyMode, rec ); - r = ERROR_CALL_NOT_IMPLEMENTED; + r = LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; break; default: - r = ERROR_INVALID_DATA; + r = LIBMSI_RESULT_INVALID_DATA; } return r; @@ -409,7 +409,7 @@ static unsigned storages_view_delete(LibmsiView *view) sv->storages = NULL; msi_free(sv); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned storages_view_find_matching_rows(LibmsiView *view, unsigned col, @@ -421,7 +421,7 @@ static unsigned storages_view_find_matching_rows(LibmsiView *view, unsigned col, TRACE("(%d, %d): %d\n", *row, col, val); if (col == 0 || col > NUM_STORAGES_COLS) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; while (index < sv->num_rows) { @@ -436,9 +436,9 @@ static unsigned storages_view_find_matching_rows(LibmsiView *view, unsigned col, *handle = UlongToPtr(++index); if (index >= sv->num_rows) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static const LibmsiViewOps storages_ops = @@ -531,7 +531,7 @@ unsigned storages_view_create(LibmsiDatabase *db, LibmsiView **view) sv = alloc_msiobject( sizeof(LibmsiStorageView), NULL ); if (!sv) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; sv->view.ops = &storages_ops; sv->db = db; @@ -540,11 +540,11 @@ unsigned storages_view_create(LibmsiDatabase *db, LibmsiView **view) if (rows < 0) { msi_free( sv ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } sv->num_rows = rows; *view = (LibmsiView *)sv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/streams.c b/libmsi/streams.c index aee73e1..a8025f5 100644 --- a/libmsi/streams.c +++ b/libmsi/streams.c @@ -94,14 +94,14 @@ static unsigned streams_view_fetch_int(LibmsiView *view, unsigned row, unsigned TRACE("(%p, %d, %d, %p)\n", view, row, col, val); if (col != 1) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= sv->num_rows) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *val = sv->streams[row]->str_index; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_fetch_stream(LibmsiView *view, unsigned row, unsigned col, IStream **stm) @@ -111,12 +111,12 @@ static unsigned streams_view_fetch_stream(LibmsiView *view, unsigned row, unsign TRACE("(%p, %d, %d, %p)\n", view, row, col, stm); if (row >= sv->num_rows) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; IStream_AddRef(sv->streams[row]->stream); *stm = sv->streams[row]->stream; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord **rec ) @@ -139,15 +139,15 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor uint16_t *data = NULL; HRESULT hr; unsigned count; - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; TRACE("(%p, %d, %p, %08x)\n", view, row, rec, mask); if (row > sv->num_rows) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = _libmsi_record_get_IStream(rec, 2, &stm); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; hr = IStream_Stat(stm, &stat, STATFLAG_NONAME); @@ -185,7 +185,7 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor msi_destroy_stream(sv->db, encname); r = write_stream_data(sv->db->storage, name, data, count, false); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { WARN("failed to write stream data: %d\n", r); goto done; @@ -223,7 +223,7 @@ static unsigned streams_view_insert_row(LibmsiView *view, LibmsiRecord *rec, uns TRACE("(%p, %p, %d, %d)\n", view, rec, row, temporary); if (!streams_set_table_size(sv, ++sv->num_rows)) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (row == -1) row = sv->num_rows - 1; @@ -240,19 +240,19 @@ static unsigned streams_view_insert_row(LibmsiView *view, LibmsiRecord *rec, uns static unsigned streams_view_delete_row(LibmsiView *view, unsigned row) { FIXME("(%p %d): stub!\n", view, row); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_execute(LibmsiView *view, LibmsiRecord *record) { TRACE("(%p, %p)\n", view, record); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_close(LibmsiView *view) { TRACE("(%p)\n", view); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_get_dimensions(LibmsiView *view, unsigned *rows, unsigned *cols) @@ -264,7 +264,7 @@ static unsigned streams_view_get_dimensions(LibmsiView *view, unsigned *rows, un if (cols) *cols = NUM_STREAMS_COLS; if (rows) *rows = sv->num_rows; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, @@ -274,7 +274,7 @@ static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, cons table_name); if (n == 0 || n > NUM_STREAMS_COLS) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; switch (n) { @@ -290,7 +290,7 @@ static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, cons } if (table_name) *table_name = szStreams; if (temporary) *temporary = false; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_find_row(LibmsiStreamsView *sv, LibmsiRecord *rec, unsigned *row) @@ -300,7 +300,7 @@ static unsigned streams_find_row(LibmsiStreamsView *sv, LibmsiRecord *rec, unsig str = _libmsi_record_get_string_raw(rec, 1); r = _libmsi_id_from_stringW(sv->db->strings, str, &id); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; for (i = 0; i < sv->num_rows; i++) @@ -310,11 +310,11 @@ static unsigned streams_find_row(LibmsiStreamsView *sv, LibmsiRecord *rec, unsig if (data == id) { *row = i; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned streams_modify_update(LibmsiView *view, LibmsiRecord *rec) @@ -323,8 +323,8 @@ static unsigned streams_modify_update(LibmsiView *view, LibmsiRecord *rec) unsigned r, row; r = streams_find_row(sv, rec, &row); - if (r != ERROR_SUCCESS) - return ERROR_FUNCTION_FAILED; + if (r != LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_FUNCTION_FAILED; return streams_view_set_row(view, row, rec, 0); } @@ -335,7 +335,7 @@ static unsigned streams_modify_assign(LibmsiView *view, LibmsiRecord *rec) unsigned r, row; r = streams_find_row(sv, rec, &row); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) return streams_modify_update(view, rec); return streams_view_insert_row(view, rec, -1, false); @@ -371,11 +371,11 @@ static unsigned streams_view_modify(LibmsiView *view, LibmsiModify eModifyMode, case LIBMSI_MODIFY_VALIDATE_FIELD: case LIBMSI_MODIFY_VALIDATE_DELETE: FIXME("%p %d %p - mode not implemented\n", view, eModifyMode, rec ); - r = ERROR_CALL_NOT_IMPLEMENTED; + r = LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; break; default: - r = ERROR_INVALID_DATA; + r = LIBMSI_RESULT_INVALID_DATA; } return r; @@ -401,7 +401,7 @@ static unsigned streams_view_delete(LibmsiView *view) msi_free(sv->streams); msi_free(sv); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col, @@ -413,7 +413,7 @@ static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col, TRACE("(%p, %d, %d, %p, %p)\n", view, col, val, row, handle); if (col == 0 || col > NUM_STREAMS_COLS) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; while (index < sv->num_rows) { @@ -429,9 +429,9 @@ static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col, *handle = UlongToPtr(++index); if (index > sv->num_rows) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static const LibmsiViewOps streams_ops = @@ -505,7 +505,7 @@ static int add_streams_to_table(LibmsiStreamsView *sv) r = msi_get_raw_stream(sv->db, stat.pwcsName, &stream->stream); CoTaskMemFree(stat.pwcsName); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { WARN("unable to get stream %u\n", r); count = -1; @@ -534,7 +534,7 @@ unsigned streams_view_create(LibmsiDatabase *db, LibmsiView **view) sv = alloc_msiobject( sizeof(LibmsiStreamsView), NULL ); if (!sv) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; sv->view.ops = &streams_ops; sv->db = db; @@ -542,11 +542,11 @@ unsigned streams_view_create(LibmsiDatabase *db, LibmsiView **view) if (rows < 0) { msi_free( sv ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } sv->num_rows = rows; *view = (LibmsiView *)sv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/string.c b/libmsi/string.c index d13d6ff..bcf3d5f 100644 --- a/libmsi/string.c +++ b/libmsi/string.c @@ -228,7 +228,7 @@ static void set_st_entry( string_table *st, unsigned n, WCHAR *str, uint16_t ref static unsigned _libmsi_id_from_string( const string_table *st, const char *buffer, unsigned *id ) { unsigned sz; - unsigned r = ERROR_INVALID_PARAMETER; + unsigned r = LIBMSI_RESULT_INVALID_PARAMETER; WCHAR *str; TRACE("Finding string %s in string table\n", debugstr_a(buffer) ); @@ -236,7 +236,7 @@ static unsigned _libmsi_id_from_string( const string_table *st, const char *buff if( buffer[0] == 0 ) { *id = 0; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } sz = MultiByteToWideChar( st->codepage, 0, buffer, -1, NULL, 0 ); @@ -244,7 +244,7 @@ static unsigned _libmsi_id_from_string( const string_table *st, const char *buff return r; str = msi_alloc( sz*sizeof(WCHAR) ); if( !str ) - return ERROR_NOT_ENOUGH_MEMORY; + return LIBMSI_RESULT_NOT_ENOUGH_MEMORY; MultiByteToWideChar( st->codepage, 0, buffer, -1, str, sz ); r = _libmsi_id_from_stringW( st, str, id ); @@ -270,7 +270,7 @@ static int msi_addstring( string_table *st, unsigned n, const char *data, int le } else { - if( ERROR_SUCCESS == _libmsi_id_from_string( st, data, &n ) ) + if( LIBMSI_RESULT_SUCCESS == _libmsi_id_from_string( st, data, &n ) ) { if (persistence == StringPersistent) st->strings[n].persistent_refcount += refcount; @@ -314,7 +314,7 @@ int _libmsi_add_string( string_table *st, const WCHAR *data, int len, uint16_t r if( !data[0] ) return 0; - if( _libmsi_id_from_stringW( st, data, &n ) == ERROR_SUCCESS ) + if( _libmsi_id_from_stringW( st, data, &n ) == LIBMSI_RESULT_SUCCESS ) { if (persistence == StringPersistent) st->strings[n].persistent_refcount += refcount; @@ -378,17 +378,17 @@ static unsigned _libmsi_string_id( const string_table *st, unsigned id, char *bu str = msi_string_lookup_id( st, id ); if( !str ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; lenW = strlenW( str ); len = WideCharToMultiByte( st->codepage, 0, str, lenW, NULL, 0, NULL, NULL ); if( *sz < len ) { *sz = len; - return ERROR_MORE_DATA; + return LIBMSI_RESULT_MORE_DATA; } *sz = WideCharToMultiByte( st->codepage, 0, str, lenW, buffer, *sz, NULL, NULL ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } /* @@ -414,11 +414,11 @@ unsigned _libmsi_id_from_stringW( const string_table *st, const WCHAR *str, unsi else { *id = st->sorted[i]; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; } static void string_totalsize( const string_table *st, unsigned *datasize, unsigned *poolsize ) @@ -464,12 +464,12 @@ HRESULT msi_init_string_table( IStorage *stg ) /* create the StringPool stream... add the zero string to it*/ ret = write_stream_data(stg, szStringPool, zero, sizeof zero, true); - if (ret != ERROR_SUCCESS) + if (ret != LIBMSI_RESULT_SUCCESS) return E_FAIL; /* create the StringData stream... make it zero length */ ret = write_stream_data(stg, szStringData, NULL, 0, true); - if (ret != ERROR_SUCCESS) + if (ret != LIBMSI_RESULT_SUCCESS) return E_FAIL; return S_OK; @@ -484,10 +484,10 @@ string_table *msi_load_string_table( IStorage *stg, unsigned *bytes_per_strref ) unsigned i, count, offset, len, n, refs; r = read_stream_data( stg, szStringPool, true, (uint8_t **)&pool, &poolsize ); - if( r != ERROR_SUCCESS) + if( r != LIBMSI_RESULT_SUCCESS) goto end; r = read_stream_data( stg, szStringData, true, (uint8_t **)&data, &datasize ); - if( r != ERROR_SUCCESS) + if( r != LIBMSI_RESULT_SUCCESS) goto end; if ( (poolsize > 4) && (pool[3] & 0x80) ) @@ -560,7 +560,7 @@ end: unsigned msi_save_string_table( const string_table *st, IStorage *storage, unsigned *bytes_per_strref ) { unsigned i, datasize = 0, poolsize = 0, sz, used, r, codepage, n; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; char *data = NULL; uint8_t *pool = NULL; @@ -613,7 +613,7 @@ unsigned msi_save_string_table( const string_table *st, IStorage *storage, unsig sz = datasize - used; r = _libmsi_string_id( st, n, data+used, &sz ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { ERR("failed to fetch string\n"); sz = 0; @@ -667,7 +667,7 @@ unsigned msi_save_string_table( const string_table *st, IStorage *storage, unsig if( r ) goto err; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; err: msi_free( data ); @@ -686,7 +686,7 @@ unsigned msi_set_string_table_codepage( string_table *st, unsigned codepage ) if (validate_codepage( codepage )) { st->codepage = codepage; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } diff --git a/libmsi/suminfo.c b/libmsi/suminfo.c index 5e4b068..874f22e 100644 --- a/libmsi/suminfo.c +++ b/libmsi/suminfo.c @@ -156,11 +156,11 @@ static unsigned propvar_changetype(PROPVARIANT *changed, PROPVARIANT *property, if (!pPropVariantChangeType) { ERR("PropVariantChangeType function missing!\n"); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } hr = pPropVariantChangeType(changed, property, 0, vt); - return (hr == S_OK) ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED; + return (hr == S_OK) ? LIBMSI_RESULT_SUCCESS : LIBMSI_RESULT_FUNCTION_FAILED; } /* FIXME: doesn't deal with endian conversion */ @@ -239,7 +239,7 @@ static void read_properties_from_data( PROPVARIANT *prop, uint8_t *data, unsigne static unsigned load_summary_info( LibmsiSummaryInfo *si, IStream *stm ) { - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; PROPERTYSETHEADER set_hdr; FORMATIDOFFSET format_hdr; PROPERTYSECTIONHEADER section_hdr; @@ -366,7 +366,7 @@ static unsigned write_property_to_data( const PROPVARIANT *prop, uint8_t *data ) static unsigned save_summary_info( const LibmsiSummaryInfo * si, IStream *stm ) { - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; PROPERTYSETHEADER set_hdr; FORMATIDOFFSET format_hdr; PROPERTYSECTIONHEADER section_hdr; @@ -429,7 +429,7 @@ static unsigned save_summary_info( const LibmsiSummaryInfo * si, IStream *stm ) if( FAILED(r) || count != sz ) return ret; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } LibmsiSummaryInfo *_libmsi_get_summary_information( IStorage *stg, unsigned uiUpdateCount ) @@ -461,53 +461,53 @@ LibmsiSummaryInfo *_libmsi_get_summary_information( IStorage *stg, unsigned uiUp return si; } -unsigned libmsi_database_get_summary_info( LibmsiDatabase *db, +LibmsiResult libmsi_database_get_summary_info( LibmsiDatabase *db, unsigned uiUpdateCount, LibmsiSummaryInfo **psi ) { LibmsiSummaryInfo *si; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; TRACE("%d %d %p\n", db, uiUpdateCount, psi); if( !psi ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( !db ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &db->hdr); si = _libmsi_get_summary_information( db->storage, uiUpdateCount ); if (si) { *psi = si; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; } msiobj_release( &db->hdr ); return ret; } -unsigned libmsi_summary_info_get_property_count(LibmsiSummaryInfo *si, unsigned *pCount) +LibmsiResult libmsi_summary_info_get_property_count(LibmsiSummaryInfo *si, unsigned *pCount) { TRACE("%d %p\n", si, pCount); if( !si ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &si->hdr ); if( pCount ) *pCount = get_property_count( si->property ); msiobj_release( &si->hdr ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } -unsigned libmsi_summary_info_get_property( +LibmsiResult libmsi_summary_info_get_property( LibmsiSummaryInfo *si, unsigned uiProperty, unsigned *puiDataType, int *piValue, uint64_t *pftValue, char *szValueBuf, unsigned *pcchValueBuf) { PROPVARIANT *prop; - unsigned ret = ERROR_SUCCESS; + unsigned ret = LIBMSI_RESULT_SUCCESS; TRACE("%d %d %p %p %p %p %p\n", si, uiProperty, puiDataType, piValue, pftValue, szValueBuf, pcchValueBuf); @@ -515,11 +515,11 @@ unsigned libmsi_summary_info_get_property( if ( uiProperty >= MSI_MAX_PROPS ) { if (puiDataType) *puiDataType = VT_EMPTY; - return ERROR_UNKNOWN_PROPERTY; + return LIBMSI_RESULT_UNKNOWN_PROPERTY; } if( !si ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &si->hdr ); prop = &si->property[uiProperty]; @@ -546,7 +546,7 @@ unsigned libmsi_summary_info_get_property( if( szValueBuf ) strcpynA(szValueBuf, prop->pszVal, *pcchValueBuf ); if (len >= *pcchValueBuf) - ret = ERROR_MORE_DATA; + ret = LIBMSI_RESULT_MORE_DATA; *pcchValueBuf = len; } break; @@ -604,7 +604,7 @@ WCHAR *msi_get_suminfo_product( IStorage *stg ) return prod; } -unsigned libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiProperty, +LibmsiResult libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiProperty, unsigned uiDataType, int iValue, uint64_t* pftValue, const char *szValue ) { PROPVARIANT *prop; @@ -616,17 +616,17 @@ unsigned libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiPro pftValue, szValue ); if( !si ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; type = get_type( uiProperty ); if( type == VT_EMPTY || type != uiDataType ) - return ERROR_DATATYPE_MISMATCH; + return LIBMSI_RESULT_DATATYPE_MISMATCH; if( uiDataType == VT_LPSTR && !szValue ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( uiDataType == VT_FILETIME && !pftValue ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; msiobj_addref( &si->hdr); @@ -634,7 +634,7 @@ unsigned libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiPro if( prop->vt == VT_EMPTY ) { - ret = ERROR_FUNCTION_FAILED; + ret = LIBMSI_RESULT_FUNCTION_FAILED; if( !si->update_count ) goto end; @@ -642,7 +642,7 @@ unsigned libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiPro } else if( prop->vt != type ) { - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; goto end; } @@ -667,7 +667,7 @@ unsigned libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned uiPro break; } - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; end: msiobj_release( &si->hdr ); return ret; @@ -675,7 +675,7 @@ end: static unsigned suminfo_persist( LibmsiSummaryInfo *si ) { - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; IStream *stm = NULL; unsigned grfMode; HRESULT r; @@ -768,15 +768,15 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid default: WARN("unhandled prop id %u\n", *pid); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, int num_columns ) { - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; unsigned i, j; LibmsiSummaryInfo *si; @@ -784,7 +784,7 @@ unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, if (!si) { ERR("no summary information!\n"); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } for (i = 0; i < num_records; i++) @@ -797,11 +797,11 @@ unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, char *str_value = NULL; r = parse_prop( records[i][j], records[i][j + 1], &pid, &int_value, &ft_value, &str_value ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto end; r = libmsi_summary_info_set_property( si, pid, get_type(pid), int_value, &ft_value, str_value ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto end; msi_free(str_value); @@ -809,21 +809,21 @@ unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, } end: - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) r = suminfo_persist( si ); msiobj_release( &si->hdr ); return r; } -unsigned libmsi_summary_info_persist( LibmsiSummaryInfo *si ) +LibmsiResult libmsi_summary_info_persist( LibmsiSummaryInfo *si ) { unsigned ret; TRACE("%d\n", si ); if( !si ) - return ERROR_INVALID_HANDLE; + return LIBMSI_RESULT_INVALID_HANDLE; msiobj_addref( &si->hdr); ret = suminfo_persist( si ); diff --git a/libmsi/table.c b/libmsi/table.c index ef04aaf..c9b6532 100644 --- a/libmsi/table.c +++ b/libmsi/table.c @@ -284,7 +284,7 @@ unsigned read_stream_data( IStorage *stg, const WCHAR *stname, bool table, uint8_t **pdata, unsigned *psz ) { HRESULT r; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; VOID *data; unsigned sz, count; IStream *stm = NULL; @@ -322,7 +322,7 @@ unsigned read_stream_data( IStorage *stg, const WCHAR *stname, bool table, if( !data ) { WARN("couldn't allocate memory r=%08x!\n", r); - ret = ERROR_NOT_ENOUGH_MEMORY; + ret = LIBMSI_RESULT_NOT_ENOUGH_MEMORY; goto end; } @@ -336,7 +336,7 @@ unsigned read_stream_data( IStorage *stg, const WCHAR *stname, bool table, *pdata = data; *psz = sz; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; end: IStream_Release( stm ); @@ -348,7 +348,7 @@ unsigned write_stream_data( IStorage *stg, const WCHAR *stname, const void *data, unsigned sz, bool bTable ) { HRESULT r; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; unsigned count; IStream *stm = NULL; ULARGE_INTEGER size; @@ -396,7 +396,7 @@ unsigned write_stream_data( IStorage *stg, const WCHAR *stname, } } - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; end: IStream_Release( stm ); @@ -453,7 +453,7 @@ static unsigned read_table_from_storage( LibmsiDatabase *db, LibmsiTable *t, ISt /* if we can't read the table, just assume that it's empty */ read_stream_data( stg, t->name, true, &rawdata, &rawsize ); if( !rawdata ) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; TRACE("Read %d bytes\n", rawsize ); @@ -514,10 +514,10 @@ static unsigned read_table_from_storage( LibmsiDatabase *db, LibmsiTable *t, ISt } msi_free( rawdata ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; err: msi_free( rawdata ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } void free_cached_tables( LibmsiDatabase *db ) @@ -576,7 +576,7 @@ static unsigned get_defaulttablecolumns( LibmsiDatabase *db, const WCHAR *name, p = _Columns_cols; n = 4; } - else return ERROR_FUNCTION_FAILED; + else return LIBMSI_RESULT_FUNCTION_FAILED; for (i = 0; i < n; i++) { @@ -585,7 +585,7 @@ static unsigned get_defaulttablecolumns( LibmsiDatabase *db, const WCHAR *name, } table_calc_column_offsets( db, colinfo, n ); *sz = n; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName, LibmsiColumnInfo *colinfo, unsigned *sz ); @@ -598,26 +598,26 @@ static unsigned table_get_column_info( LibmsiDatabase *db, const WCHAR *name, Li /* get the number of columns in this table */ column_count = 0; r = get_tablecolumns( db, name, NULL, &column_count ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; *pcount = column_count; /* if there's no columns, there's no table */ if (!column_count) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; TRACE("table %s found\n", debugstr_w(name)); columns = msi_alloc( column_count * sizeof(LibmsiColumnInfo) ); if (!columns) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = get_tablecolumns( db, name, columns, &column_count ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msi_free( columns ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } *pcols = columns; return r; @@ -633,13 +633,13 @@ static unsigned get_table( LibmsiDatabase *db, const WCHAR *name, LibmsiTable ** if (table) { *table_ret = table; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } /* nonexistent tables should be interpreted as empty tables */ table = msi_alloc( sizeof(LibmsiTable) + strlenW( name ) * sizeof(WCHAR) ); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; table->row_count = 0; table->data = NULL; @@ -653,20 +653,20 @@ static unsigned get_table( LibmsiDatabase *db, const WCHAR *name, LibmsiTable ** table->persistent = LIBMSI_CONDITION_NONE; r = table_get_column_info( db, name, &table->colinfo, &table->col_count ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { free_table( table ); return r; } r = read_table_from_storage( db, table, db->storage ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { free_table( table ); return r; } list_add_head( &db->tables, &table->entry ); *table_ret = table; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned read_table_int( uint8_t *const *data, unsigned row, unsigned col, unsigned bytes ) @@ -688,19 +688,19 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName, /* first check if there is a default table with that name */ r = get_defaulttablecolumns( db, szTableName, colinfo, sz ); - if (r == ERROR_SUCCESS && *sz) + if (r == LIBMSI_RESULT_SUCCESS && *sz) return r; r = get_table( db, szColumns, &table ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("couldn't load _Columns table\n"); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* convert table and column names to IDs from the string table */ r = _libmsi_id_from_stringW( db->strings, szTableName, &table_id ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { WARN("Couldn't find id for %s\n", debugstr_w(szTableName)); return r; @@ -749,11 +749,11 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName, { ERR("missing column in table %s\n", debugstr_w(szTableName)); msi_free_colinfo( colinfo, maxcount ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } table_calc_column_offsets( db, colinfo, n ); *sz = n; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *col_info, @@ -771,12 +771,12 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c if( table_view_exists(db, name ) ) { WARN("table %s exists\n", debugstr_w(name)); - return ERROR_BAD_QUERY_SYNTAX; + return LIBMSI_RESULT_BAD_QUERY_SYNTAX; } table = msi_alloc( sizeof (LibmsiTable) + strlenW(name)*sizeof (WCHAR) ); if( !table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; table->ref_count = 1; table->row_count = 0; @@ -794,7 +794,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c if (!table->colinfo) { free_table( table ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } for( i = 0, col = col_info; col; i++, col = col->next ) @@ -891,7 +891,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c nField++; } if( !col ) - r = ERROR_SUCCESS; + r = LIBMSI_RESULT_SUCCESS; } err: @@ -901,7 +901,7 @@ err: if( tv ) tv->ops->delete( tv ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) list_add_head( &db->tables, &table->entry ); else free_table( table ); @@ -913,11 +913,11 @@ static unsigned save_table( LibmsiDatabase *db, const LibmsiTable *t, unsigned b { uint8_t *rawdata = NULL; unsigned rawsize, i, j, row_size, row_count; - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; /* Nothing to do for non-persistent tables */ if( t->persistent == LIBMSI_CONDITION_FALSE ) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; TRACE("Saving %s\n", debugstr_w( t->name ) ); @@ -935,7 +935,7 @@ static unsigned save_table( LibmsiDatabase *db, const LibmsiTable *t, unsigned b rawdata = msi_alloc_zero( rawsize ); if( !rawdata ) { - r = ERROR_NOT_ENOUGH_MEMORY; + r = LIBMSI_RESULT_NOT_ENOUGH_MEMORY; goto err; } @@ -1021,14 +1021,14 @@ bool table_view_exists( LibmsiDatabase *db, const WCHAR *name ) return true; r = _libmsi_id_from_stringW( db->strings, name, &table_id ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { TRACE("Couldn't find id for %s\n", debugstr_w(name)); return false; } r = get_table( db, szTables, &table ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { ERR("table %s not available\n", debugstr_w(szTables)); return false; @@ -1062,27 +1062,27 @@ static unsigned table_view_fetch_int( LibmsiView *view, unsigned row, unsigned c unsigned offset, n; if( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( (col==0) || (col>tv->num_cols) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* how many rows are there ? */ if( row >= tv->table->row_count ) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; if( tv->columns[col-1].offset >= tv->row_size ) { ERR("Stuffed up %d >= %d\n", tv->columns[col-1].offset, tv->row_size ); ERR("%p %p\n", tv, tv->columns ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } n = bytes_per_column( tv->db, &tv->columns[col - 1], LONG_STR_BYTES ); if (n != 2 && n != 3 && n != 4) { ERR("oops! what is %d bytes per column?\n", n ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } offset = tv->columns[col-1].offset; @@ -1090,7 +1090,7 @@ static unsigned table_view_fetch_int( LibmsiView *view, unsigned row, unsigned c /* TRACE("Data [%d][%d] = %d\n", row, col, *val ); */ - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR **pstname ) @@ -1108,7 +1108,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR stname = msi_alloc( len*sizeof(WCHAR) ); if ( !stname ) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto err; } @@ -1122,7 +1122,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR WCHAR number[0x20]; r = table_view_fetch_int( view, row, i+1, &ival ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) goto err; if ( tv->columns[i].type & MSITYPE_STRING ) @@ -1130,7 +1130,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR sval = msi_string_lookup_id( tv->db->strings, ival ); if ( !sval ) { - r = ERROR_INVALID_PARAMETER; + r = LIBMSI_RESULT_INVALID_PARAMETER; goto err; } } @@ -1149,7 +1149,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR break; default: ERR( "oops - unknown column width %d\n", n ); - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto err; } sval = number; @@ -1159,7 +1159,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR p = msi_realloc ( stname, len*sizeof(WCHAR) ); if ( !p ) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto err; } stname = p; @@ -1172,7 +1172,7 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR } *pstname = stname; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; err: msi_free( stname ); @@ -1193,10 +1193,10 @@ static unsigned table_view_fetch_stream( LibmsiView *view, unsigned row, unsigne WCHAR *full_name = NULL; if( !view->ops->fetch_int ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; r = msi_stream_name( tv, row, &full_name ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) { ERR("fetching stream, error = %d\n", r); return r; @@ -1217,19 +1217,19 @@ static unsigned table_view_set_int( LibmsiTableView *tv, unsigned row, unsigned unsigned offset, n, i; if( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( (col==0) || (col>tv->num_cols) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( row >= tv->table->row_count ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( tv->columns[col-1].offset >= tv->row_size ) { ERR("Stuffed up %d >= %d\n", tv->columns[col-1].offset, tv->row_size ); ERR("%p %p\n", tv, tv->columns ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } msi_free( tv->columns[col-1].hash_table ); @@ -1239,14 +1239,14 @@ static unsigned table_view_set_int( LibmsiTableView *tv, unsigned row, unsigned if ( n != 2 && n != 3 && n != 4 ) { ERR("oops! what is %d bytes per column?\n", n ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } offset = tv->columns[col-1].offset; for ( i = 0; i < n; i++ ) tv->table->data[row][offset + i] = (val >> i * 8) & 0xff; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord **rec ) @@ -1254,7 +1254,7 @@ static unsigned table_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord LibmsiTableView *tv = (LibmsiTableView *)view; if (!tv->table) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; return msi_view_get_row(tv->db, view, row, rec); } @@ -1274,18 +1274,18 @@ static unsigned _libmsi_add_stream( LibmsiDatabase *db, const WCHAR *name, IStre rec = libmsi_record_create( 2 ); if ( !rec ) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; r = _libmsi_record_set_stringW( rec, 1, name ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) goto err; r = _libmsi_record_set_IStream( rec, 2, data ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) goto err; r = _libmsi_database_open_query( db, insert, &query ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) goto err; r = _libmsi_query_execute( query, rec ); @@ -1304,7 +1304,7 @@ static unsigned get_table_value_from_record( LibmsiTableView *tv, LibmsiRecord * if ( (iField <= 0) || (iField > tv->num_cols) || libmsi_record_is_null( rec, iField ) ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; columninfo = tv->columns[ iField - 1 ]; @@ -1318,8 +1318,8 @@ static unsigned get_table_value_from_record( LibmsiTableView *tv, LibmsiRecord * if (sval) { r = _libmsi_id_from_stringW(tv->db->strings, sval, pvalue); - if (r != ERROR_SUCCESS) - return ERROR_NOT_FOUND; + if (r != LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_NOT_FOUND; } else *pvalue = 0; } @@ -1329,7 +1329,7 @@ static unsigned get_table_value_from_record( LibmsiTableView *tv, LibmsiRecord * if ( *pvalue & 0xffff0000 ) { ERR("field %u value %d out of range\n", iField, *pvalue - 0x8000); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } } else @@ -1338,20 +1338,20 @@ static unsigned get_table_value_from_record( LibmsiTableView *tv, LibmsiRecord * *pvalue = ival ^ 0x80000000; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord *rec, unsigned mask ) { LibmsiTableView *tv = (LibmsiTableView*)view; - unsigned i, val, r = ERROR_SUCCESS; + unsigned i, val, r = LIBMSI_RESULT_SUCCESS; if ( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; /* test if any of the mask bits are invalid */ if ( mask >= (1<num_cols) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; for ( i = 0; i < tv->num_cols; i++ ) { @@ -1374,15 +1374,15 @@ static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord IStream *stm; WCHAR *stname; - if ( r != ERROR_SUCCESS ) - return ERROR_FUNCTION_FAILED; + if ( r != LIBMSI_RESULT_SUCCESS ) + return LIBMSI_RESULT_FUNCTION_FAILED; r = _libmsi_record_get_IStream( rec, i + 1, &stm ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) return r; r = msi_stream_name( tv, row, &stname ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) { IStream_Release( stm ); return r; @@ -1392,14 +1392,14 @@ static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord IStream_Release( stm ); msi_free ( stname ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) return r; } else if ( tv->columns[i].type & MSITYPE_STRING ) { unsigned x; - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) { const WCHAR *sval = _libmsi_record_get_string_raw( rec, i + 1 ); val = _libmsi_add_string( tv->db->strings, sval, -1, 1, @@ -1414,13 +1414,13 @@ static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord } else { - if ( r != ERROR_SUCCESS ) - return ERROR_FUNCTION_FAILED; + if ( r != LIBMSI_RESULT_SUCCESS ) + return LIBMSI_RESULT_FUNCTION_FAILED; } } r = table_view_set_int( tv, row, i+1, val ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) break; } return r; @@ -1439,11 +1439,11 @@ static unsigned table_create_new_row( LibmsiView *view, unsigned *num, bool temp TRACE("%p %s\n", view, temporary ? "true" : "false"); if( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; row = msi_alloc_zero( tv->row_size ); if( !row ) - return ERROR_NOT_ENOUGH_MEMORY; + return LIBMSI_RESULT_NOT_ENOUGH_MEMORY; row_count = &tv->table->row_count; data_ptr = &tv->table->data; @@ -1459,7 +1459,7 @@ static unsigned table_create_new_row( LibmsiView *view, unsigned *num, bool temp if( !p ) { msi_free( row ); - return ERROR_NOT_ENOUGH_MEMORY; + return LIBMSI_RESULT_NOT_ENOUGH_MEMORY; } sz = (*row_count + 1) * sizeof (bool); @@ -1471,7 +1471,7 @@ static unsigned table_create_new_row( LibmsiView *view, unsigned *num, bool temp { msi_free( row ); msi_free( p ); - return ERROR_NOT_ENOUGH_MEMORY; + return LIBMSI_RESULT_NOT_ENOUGH_MEMORY; } *data_ptr = p; @@ -1482,7 +1482,7 @@ static unsigned table_create_new_row( LibmsiView *view, unsigned *num, bool temp (*row_count)++; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_execute( LibmsiView *view, LibmsiRecord *record ) @@ -1493,14 +1493,14 @@ static unsigned table_view_execute( LibmsiView *view, LibmsiRecord *record ) TRACE("There are %d columns\n", tv->num_cols ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_close( LibmsiView *view ) { TRACE("%p\n", view ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_get_dimensions( LibmsiView *view, unsigned *rows, unsigned *cols) @@ -1514,11 +1514,11 @@ static unsigned table_view_get_dimensions( LibmsiView *view, unsigned *rows, uns if( rows ) { if( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; *rows = tv->table->row_count; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_get_column_info( LibmsiView *view, @@ -1530,20 +1530,20 @@ static unsigned table_view_get_column_info( LibmsiView *view, TRACE("%p %d %p %p\n", tv, n, name, type ); if( ( n == 0 ) || ( n > tv->num_cols ) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( name ) { *name = tv->columns[n-1].colname; if( !*name ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } if( table_name ) { *table_name = tv->columns[n-1].tablename; if( !*table_name ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } if( type ) @@ -1552,7 +1552,7 @@ static unsigned table_view_get_column_info( LibmsiView *view, if( temporary ) *temporary = tv->columns[n-1].temporary; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned msi_table_find_row( LibmsiTableView *tv, LibmsiRecord *rec, unsigned *row, unsigned *column ); @@ -1577,7 +1577,7 @@ static unsigned table_validate_new( LibmsiTableView *tv, LibmsiRecord *rec, unsi if (str == NULL || str[0] == 0) { if (column) *column = i; - return ERROR_INVALID_DATA; + return LIBMSI_RESULT_INVALID_DATA; } } else @@ -1588,17 +1588,17 @@ static unsigned table_validate_new( LibmsiTableView *tv, LibmsiRecord *rec, unsi if (n == MSI_NULL_INTEGER) { if (column) *column = i; - return ERROR_INVALID_DATA; + return LIBMSI_RESULT_INVALID_DATA; } } } /* check there's no duplicate keys */ r = msi_table_find_row( tv, rec, &row, column ); - if (r == ERROR_SUCCESS) - return ERROR_FUNCTION_FAILED; + if (r == LIBMSI_RESULT_SUCCESS) + return LIBMSI_RESULT_FUNCTION_FAILED; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static int compare_record( LibmsiTableView *tv, unsigned row, LibmsiRecord *rec ) @@ -1610,11 +1610,11 @@ static int compare_record( LibmsiTableView *tv, unsigned row, LibmsiRecord *rec if (!(tv->columns[i].type & MSITYPE_KEY)) continue; r = get_table_value_from_record( tv, rec, i + 1, &ivalue ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return 1; r = table_view_fetch_int( &tv->view, row, i + 1, &x ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { WARN("table_view_fetch_int should not fail here %u\n", r); return -1; @@ -1668,15 +1668,15 @@ static unsigned table_view_insert_row( LibmsiView *view, LibmsiRecord *rec, unsi /* check that the key is unique - can we find a matching row? */ r = table_validate_new( tv, rec, NULL ); - if( r != ERROR_SUCCESS ) - return ERROR_FUNCTION_FAILED; + if( r != LIBMSI_RESULT_SUCCESS ) + return LIBMSI_RESULT_FUNCTION_FAILED; if (row == -1) row = find_insert_index( tv, rec ); r = table_create_new_row( view, &row, temporary ); TRACE("insert_row returned %08x\n", r); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; /* shift the rows to make room for the new row */ @@ -1700,14 +1700,14 @@ static unsigned table_view_delete_row( LibmsiView *view, unsigned row ) TRACE("%p %d\n", tv, row); if ( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; r = table_view_get_dimensions( view, &num_rows, &num_cols ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) return r; if ( row >= num_rows ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; num_rows = tv->table->row_count; tv->table->row_count--; @@ -1727,7 +1727,7 @@ static unsigned table_view_delete_row( LibmsiView *view, unsigned row ) msi_free(tv->table->data[num_rows - 1]); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned msi_table_update(LibmsiView *view, LibmsiRecord *rec, unsigned row) @@ -1740,18 +1740,18 @@ static unsigned msi_table_update(LibmsiView *view, LibmsiRecord *rec, unsigned r */ if (!tv->table) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; r = msi_table_find_row(tv, rec, &new_row, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("can't find row to modify\n"); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* the row cannot be changed */ if (row != new_row + 1) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return table_view_set_row(view, new_row, rec, (1 << tv->num_cols) - 1); } @@ -1762,10 +1762,10 @@ static unsigned msi_table_assign(LibmsiView *view, LibmsiRecord *rec) unsigned r, row; if (!tv->table) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; r = msi_table_find_row(tv, rec, &row, NULL); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) return table_view_set_row(view, row, rec, (1 << tv->num_cols) - 1); else return table_view_insert_row( view, rec, -1, false ); @@ -1777,7 +1777,7 @@ static unsigned modify_delete_row( LibmsiView *view, LibmsiRecord *rec ) unsigned row, r; r = msi_table_find_row(tv, rec, &row, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; return table_view_delete_row(view, row); @@ -1789,7 +1789,7 @@ static unsigned msi_refresh_record( LibmsiView *view, LibmsiRecord *rec, unsigne unsigned r, i, count; r = table_view_get_row(view, row - 1, &curr); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; /* Close the original record */ @@ -1800,7 +1800,7 @@ static unsigned msi_refresh_record( LibmsiView *view, LibmsiRecord *rec, unsigne _libmsi_record_copy_field(curr, i + 1, rec, i + 1); msiobj_release(&curr->hdr); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_modify( LibmsiView *view, LibmsiModify eModifyMode, @@ -1818,24 +1818,24 @@ static unsigned table_view_modify( LibmsiView *view, LibmsiModify eModifyMode, break; case LIBMSI_MODIFY_VALIDATE_NEW: r = table_validate_new( tv, rec, &column ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { tv->view.error = LIBMSI_DB_ERROR_DUPLICATEKEY; tv->view.error_column = tv->columns[column].colname; - r = ERROR_INVALID_DATA; + r = LIBMSI_RESULT_INVALID_DATA; } break; case LIBMSI_MODIFY_INSERT: r = table_validate_new( tv, rec, NULL ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; r = table_view_insert_row( view, rec, -1, false ); break; case LIBMSI_MODIFY_INSERT_TEMPORARY: r = table_validate_new( tv, rec, NULL ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; r = table_view_insert_row( view, rec, -1, true ); break; @@ -1855,10 +1855,10 @@ static unsigned table_view_modify( LibmsiView *view, LibmsiModify eModifyMode, case LIBMSI_MODIFY_MERGE: /* check row that matches this record */ r = msi_table_find_row( tv, rec, &frow, &column ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { r = table_validate_new( tv, rec, NULL ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) r = table_view_insert_row( view, rec, -1, false ); } break; @@ -1868,11 +1868,11 @@ static unsigned table_view_modify( LibmsiView *view, LibmsiModify eModifyMode, case LIBMSI_MODIFY_VALIDATE_FIELD: case LIBMSI_MODIFY_VALIDATE_DELETE: FIXME("%p %d %p - mode not implemented\n", view, eModifyMode, rec ); - r = ERROR_CALL_NOT_IMPLEMENTED; + r = LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; break; default: - r = ERROR_INVALID_DATA; + r = LIBMSI_RESULT_INVALID_DATA; } return r; @@ -1889,7 +1889,7 @@ static unsigned table_view_delete( LibmsiView *view ) msi_free( tv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -1901,10 +1901,10 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, TRACE("%p, %d, %u, %p\n", view, col, val, *handle); if( !tv->table ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( (col==0) || (col > tv->num_cols) ) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; if( !tv->columns[col-1].hash_table ) { @@ -1917,7 +1917,7 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, { ERR("Stuffed up %d >= %d\n", tv->columns[col-1].offset, tv->row_size ); ERR("%p %p\n", tv, tv->columns ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* allocate contiguous memory for the table and its entries so we @@ -1925,7 +1925,7 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, hash_table = msi_alloc(LibmsiTable_HASH_TABLE_SIZE * sizeof(LibmsiColumnHashEntry*) + num_rows * sizeof(LibmsiColumnHashEntry)); if (!hash_table) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; memset(hash_table, 0, LibmsiTable_HASH_TABLE_SIZE * sizeof(LibmsiColumnHashEntry*)); tv->columns[col-1].hash_table = hash_table; @@ -1936,7 +1936,7 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, { unsigned row_value; - if (view->ops->fetch_int( view, i, col, &row_value ) != ERROR_SUCCESS) + if (view->ops->fetch_int( view, i, col, &row_value ) != LIBMSI_RESULT_SUCCESS) continue; new_entry->next = NULL; @@ -1964,11 +1964,11 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, *handle = entry; if (!entry) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *row = entry->row; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned table_view_add_ref(LibmsiView *view) @@ -1996,21 +1996,21 @@ static unsigned table_view_remove_column(LibmsiView *view, const WCHAR *table, u rec = libmsi_record_create(2); if (!rec) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; _libmsi_record_set_stringW(rec, 1, table); libmsi_record_set_int(rec, 2, number); r = table_view_create(tv->db, szColumns, &columns); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = msi_table_find_row((LibmsiTableView *)columns, rec, &row, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = table_view_delete_row(columns, row); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; msi_update_table_columns(tv->db, table); @@ -2038,7 +2038,7 @@ static unsigned table_view_release(LibmsiView *view) { r = table_view_remove_column(view, tv->table->colinfo[i].tablename, tv->table->colinfo[i].number); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } } @@ -2068,7 +2068,7 @@ static unsigned table_view_add_column(LibmsiView *view, const WCHAR *table, unsi rec = libmsi_record_create(4); if (!rec) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; _libmsi_record_set_stringW(rec, 1, table); libmsi_record_set_int(rec, 2, number); @@ -2076,7 +2076,7 @@ static unsigned table_view_add_column(LibmsiView *view, const WCHAR *table, unsi libmsi_record_set_int(rec, 4, type); r = table_view_insert_row(&tv->view, rec, -1, false); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; msi_update_table_columns(tv->db, table); @@ -2113,26 +2113,26 @@ static unsigned table_view_drop(LibmsiView *view) { r = table_view_remove_column(view, tv->table->colinfo[i].tablename, tv->table->colinfo[i].number); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; } rec = libmsi_record_create(1); if (!rec) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; _libmsi_record_set_stringW(rec, 1, tv->name); r = table_view_create(tv->db, szTables, &tables); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = msi_table_find_row((LibmsiTableView *)tables, rec, &row, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; r = table_view_delete_row(tables, row); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto done; list_remove(&tv->table->entry); @@ -2183,10 +2183,10 @@ unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView ** sz = sizeof *tv + strlenW(name)*sizeof name[0] ; tv = alloc_msiobject( sz, NULL ); if( !tv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = get_table( db, name, &tv->table ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { msi_free( tv ); WARN("table not found\n"); @@ -2207,7 +2207,7 @@ unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView ** *view = (LibmsiView*) tv; strcpyW( tv->name, name ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned _libmsi_database_commit_tables( LibmsiDatabase *db ) @@ -2219,7 +2219,7 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db ) TRACE("%p\n",db); r = msi_save_string_table( db->strings, db->storage, &bytes_per_strref ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { WARN("failed to save string table r=%08x\n",r); return r; @@ -2228,7 +2228,7 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db ) LIST_FOR_EACH_ENTRY( table, &db->tables, LibmsiTable, entry ) { r = save_table( db, table, bytes_per_strref ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { WARN("failed to save table %s (r=%08x)\n", debugstr_w(table->name), r); @@ -2240,7 +2240,7 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db ) if (FAILED( hr )) { WARN("failed to commit changes 0x%08x\n", hr); - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; } return r; } @@ -2256,7 +2256,7 @@ LibmsiCondition _libmsi_database_is_table_persistent( LibmsiDatabase *db, const return LIBMSI_CONDITION_ERROR; r = get_table( db, table, &t ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return LIBMSI_CONDITION_NONE; return t->persistent; @@ -2286,7 +2286,7 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms stname = msi_alloc( len*sizeof(WCHAR) ); if ( !stname ) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto err; } @@ -2299,7 +2299,7 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms sval = msi_dup_record_field( rec, i + 1 ); if ( !sval ) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto err; } @@ -2307,7 +2307,7 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms p = msi_realloc ( stname, len*sizeof(WCHAR) ); if ( !p ) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto err; } stname = p; @@ -2324,7 +2324,7 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms *pstname = encode_streamname( false, stname ); msi_free( stname ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; err: msi_free ( stname ); @@ -2366,12 +2366,12 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableView *tv, const ofs += bytes_per_column( tv->db, &columns[i], bytes_per_strref ); r = msi_record_encoded_stream_name( tv, rec, &encname ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) return NULL; r = IStorage_OpenStream( stg, encname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) { msi_free( encname ); return NULL; @@ -2472,7 +2472,7 @@ static unsigned* msi_record_to_row( const LibmsiTableView *tv, LibmsiRecord *rec /* if there's no matching string in the string table, these keys can't match any record, so fail now. */ - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { msi_free( data ); return NULL; @@ -2497,7 +2497,7 @@ static unsigned* msi_record_to_row( const LibmsiTableView *tv, LibmsiRecord *rec static unsigned msi_row_matches( LibmsiTableView *tv, unsigned row, const unsigned *data, unsigned *column ) { - unsigned i, r, x, ret = ERROR_FUNCTION_FAILED; + unsigned i, r, x, ret = LIBMSI_RESULT_FUNCTION_FAILED; for( i=0; inum_cols; i++ ) { @@ -2506,7 +2506,7 @@ static unsigned msi_row_matches( LibmsiTableView *tv, unsigned row, const unsign /* turn the transform column value into a row value */ r = table_view_fetch_int( &tv->view, row, i+1, &x ); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) { ERR("table_view_fetch_int shouldn't fail here\n"); break; @@ -2515,18 +2515,18 @@ static unsigned msi_row_matches( LibmsiTableView *tv, unsigned row, const unsign /* if this key matches, move to the next column */ if ( x != data[i] ) { - ret = ERROR_FUNCTION_FAILED; + ret = LIBMSI_RESULT_FUNCTION_FAILED; break; } if (column) *column = i; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; } return ret; } static unsigned msi_table_find_row( LibmsiTableView *tv, LibmsiRecord *rec, unsigned *row, unsigned *column ) { - unsigned i, r = ERROR_FUNCTION_FAILED, *data; + unsigned i, r = LIBMSI_RESULT_FUNCTION_FAILED, *data; data = msi_record_to_row( tv, rec ); if( !data ) @@ -2534,7 +2534,7 @@ static unsigned msi_table_find_row( LibmsiTableView *tv, LibmsiRecord *rec, unsi for( i = 0; i < tv->table->row_count; i++ ) { r = msi_row_matches( tv, i, data, column ); - if( r == ERROR_SUCCESS ) + if( r == LIBMSI_RESULT_SUCCESS ) { *row = i; break; @@ -2562,7 +2562,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, const WCHAR *name; if (!transform) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; name = transform->name; @@ -2574,16 +2574,16 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, if ( !rawdata ) { TRACE("table %s empty\n", debugstr_w(name) ); - return ERROR_INVALID_TABLE; + return LIBMSI_RESULT_INVALID_TABLE; } /* create a table view */ r = table_view_create( db, name, (LibmsiView**) &tv ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) goto err; r = tv->view.ops->execute( &tv->view, NULL ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) goto err; TRACE("name = %s columns = %u row_size = %u raw size = %u\n", @@ -2677,27 +2677,27 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, if (TRACE_ON(msidb)) dump_record( rec ); r = msi_table_find_row( tv, rec, &row, NULL ); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) { if (!mask) { TRACE("deleting row [%d]:\n", row); r = table_view_delete_row( &tv->view, row ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) WARN("failed to delete row %u\n", r); } else if (mask & 1) { TRACE("modifying full row [%d]:\n", row); r = table_view_set_row( &tv->view, row, rec, (1 << tv->num_cols) - 1 ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) WARN("failed to modify row %u\n", r); } else { TRACE("modifying masked row [%d]:\n", row); r = table_view_set_row( &tv->view, row, rec, mask ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) WARN("failed to modify row %u\n", r); } } @@ -2705,7 +2705,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, { TRACE("inserting row\n"); r = table_view_insert_row( &tv->view, rec, -1, false ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) WARN("failed to insert row %u\n", r); } @@ -2724,7 +2724,7 @@ err: if( tv ) tv->view.ops->delete( &tv->view ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } /* @@ -2741,7 +2741,7 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg ) HRESULT r; STATSTG stat; string_table *strings; - unsigned ret = ERROR_FUNCTION_FAILED; + unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED; unsigned bytes_per_strref; TRACE("%p %p\n", db, stg ); @@ -2792,11 +2792,11 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg ) /* load the table */ r = table_view_create( db, transform->name, (LibmsiView**) &tv ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) continue; r = tv->view.ops->execute( &tv->view, NULL ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { tv->view.ops->delete( &tv->view ); continue; @@ -2810,14 +2810,14 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg ) * the table metadata is correct, and empty tables exist. */ ret = msi_table_load_transform( db, stg, strings, tables, bytes_per_strref ); - if (ret != ERROR_SUCCESS && ret != ERROR_INVALID_TABLE) + if (ret != LIBMSI_RESULT_SUCCESS && ret != LIBMSI_RESULT_INVALID_TABLE) goto end; ret = msi_table_load_transform( db, stg, strings, columns, bytes_per_strref ); - if (ret != ERROR_SUCCESS && ret != ERROR_INVALID_TABLE) + if (ret != LIBMSI_RESULT_SUCCESS && ret != LIBMSI_RESULT_INVALID_TABLE) goto end; - ret = ERROR_SUCCESS; + ret = LIBMSI_RESULT_SUCCESS; while ( !list_empty( &transforms ) ) { @@ -2825,7 +2825,7 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg ) if ( strcmpW( transform->name, szColumns ) && strcmpW( transform->name, szTables ) && - ret == ERROR_SUCCESS ) + ret == LIBMSI_RESULT_SUCCESS ) { ret = msi_table_load_transform( db, stg, strings, transform, bytes_per_strref ); } @@ -2835,7 +2835,7 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg ) msi_free( transform ); } - if ( ret == ERROR_SUCCESS ) + if ( ret == LIBMSI_RESULT_SUCCESS ) append_storage_to_db( db, stg ); end: diff --git a/libmsi/update.c b/libmsi/update.c index 0f9979d..accf3dd 100644 --- a/libmsi/update.c +++ b/libmsi/update.c @@ -50,7 +50,7 @@ static unsigned update_view_fetch_int( LibmsiView *view, unsigned row, unsigned TRACE("%p %d %d %p\n", uv, row, col, val ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned update_view_execute( LibmsiView *view, LibmsiRecord *record ) @@ -89,7 +89,7 @@ static unsigned update_view_execute( LibmsiView *view, LibmsiRecord *record ) wv = uv->wv; if( !wv ) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } @@ -105,14 +105,14 @@ static unsigned update_view_execute( LibmsiView *view, LibmsiRecord *record ) values = msi_query_merge_record( col_count, uv->vals, record ); if (!values) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto done; } for ( i=0; iops->set_row( wv, i, values, (1 << col_count) - 1 ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } @@ -133,7 +133,7 @@ static unsigned update_view_close( LibmsiView *view ) wv = uv->wv; if( !wv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return wv->ops->close( wv ); } @@ -147,7 +147,7 @@ static unsigned update_view_get_dimensions( LibmsiView *view, unsigned *rows, un wv = uv->wv; if( !wv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return wv->ops->get_dimensions( wv, rows, cols ); } @@ -162,7 +162,7 @@ static unsigned update_view_get_column_info( LibmsiView *view, unsigned n, const wv = uv->wv; if( !wv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return wv->ops->get_column_info( wv, n, name, type, temporary, table_name ); } @@ -174,7 +174,7 @@ static unsigned update_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", uv, eModifyMode, rec ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned update_view_delete( LibmsiView *view ) @@ -190,14 +190,14 @@ static unsigned update_view_delete( LibmsiView *view ) msiobj_release( &uv->db->hdr ); msi_free( uv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned update_view_find_matching_rows( LibmsiView *view, unsigned col, unsigned val, unsigned *row, MSIITERHANDLE *handle ) { TRACE("%p %d %d %p\n", view, col, val, *handle ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } @@ -237,12 +237,12 @@ unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *table else r = table_view_create( db, table, &wv ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; /* then select the columns we want */ r = select_view_create( db, &sv, wv, columns ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) { wv->ops->delete( wv ); return r; @@ -252,7 +252,7 @@ unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *table if( !uv ) { wv->ops->delete( wv ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } /* fill the structure */ @@ -263,5 +263,5 @@ unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *table uv->wv = sv; *view = (LibmsiView*) uv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/where.c b/libmsi/where.c index 2689e6b..094ec41 100644 --- a/libmsi/where.c +++ b/libmsi/where.c @@ -101,24 +101,24 @@ static unsigned init_reorder(LibmsiWhereView *wv) { LibmsiRowEntry **new = msi_alloc_zero(sizeof(LibmsiRowEntry *) * INITIAL_REORDER_SIZE); if (!new) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; free_reorder(wv); wv->reorder = new; wv->reorder_size = INITIAL_REORDER_SIZE; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static inline unsigned find_row(LibmsiWhereView *wv, unsigned row, unsigned *(values[])) { if (row >= wv->row_count) - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; *values = wv->reorder[row]->values; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned add_row(LibmsiWhereView *wv, unsigned vals[]) @@ -133,7 +133,7 @@ static unsigned add_row(LibmsiWhereView *wv, unsigned vals[]) new_reorder = msi_realloc_zero(wv->reorder, sizeof(LibmsiRowEntry *) * wv->reorder_size, sizeof(LibmsiRowEntry *) * newsize); if (!new_reorder) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; wv->reorder = new_reorder; wv->reorder_size = newsize; @@ -142,14 +142,14 @@ static unsigned add_row(LibmsiWhereView *wv, unsigned vals[]) new = msi_alloc(FIELD_OFFSET( LibmsiRowEntry, values[wv->table_count] )); if (!new) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; wv->reorder[wv->row_count++] = new; memcpy(new->values, vals, wv->table_count * sizeof(unsigned)); new->wv = wv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static JOINTABLE *find_table(LibmsiWhereView *wv, unsigned col, unsigned *table_col) @@ -184,7 +184,7 @@ static unsigned parse_column(LibmsiWhereView *wv, union ext_column *column, { r = table->view->ops->get_column_info(table->view, 1, NULL, NULL, NULL, &table_name); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; if (strcmpW(table_name, column->unparsed.table) != 0) continue; @@ -196,20 +196,20 @@ static unsigned parse_column(LibmsiWhereView *wv, union ext_column *column, r = table->view->ops->get_column_info(table->view, i, &col_name, column_type, NULL, NULL); - if(r != ERROR_SUCCESS ) + if(r != LIBMSI_RESULT_SUCCESS ) return r; if(strcmpW(col_name, column->unparsed.column)) continue; column->parsed.column = i; column->parsed.table = table; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } while ((table = table->next)); WARN("Couldn't find column %s.%s\n", debugstr_w( column->unparsed.table ), debugstr_w( column->unparsed.column ) ); - return ERROR_BAD_QUERY_SYNTAX; + return LIBMSI_RESULT_BAD_QUERY_SYNTAX; } static unsigned where_view_fetch_int( LibmsiView *view, unsigned row, unsigned col, unsigned *val ) @@ -222,15 +222,15 @@ static unsigned where_view_fetch_int( LibmsiView *view, unsigned row, unsigned c TRACE("%p %d %d %p\n", wv, row, col, val ); if( !wv->tables ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = find_row(wv, row, &rows); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; table = find_table(wv, col, &col); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return table->view->ops->fetch_int(table->view, rows[table->table_index], col, val); } @@ -245,15 +245,15 @@ static unsigned where_view_fetch_stream( LibmsiView *view, unsigned row, unsigne TRACE("%p %d %d %p\n", wv, row, col, stm ); if( !wv->tables ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = find_row(wv, row, &rows); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; table = find_table(wv, col, &col); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return table->view->ops->fetch_stream( table->view, rows[table->table_index], col, stm ); } @@ -265,7 +265,7 @@ static unsigned where_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord TRACE("%p %d %p\n", wv, row, rec ); if (!wv->tables) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return msi_view_get_row( wv->db, view, row, rec ); } @@ -281,14 +281,14 @@ static unsigned where_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord TRACE("%p %d %p %08x\n", wv, row, rec, mask ); if( !wv->tables ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = find_row(wv, row, &rows); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; if (mask >= 1 << wv->col_count) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; do { @@ -299,10 +299,10 @@ static unsigned where_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord continue; r = table->view->ops->get_column_info(table->view, i + 1, NULL, &type, NULL, NULL ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; if (type & MSITYPE_KEY) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } mask_copy >>= table->col_count; } @@ -325,18 +325,18 @@ static unsigned where_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord reduced = libmsi_record_create(col_count); if (!reduced) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; for (i = 1; i <= col_count; i++) { r = _libmsi_record_copy_field(rec, i + offset, reduced, i); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } offset += col_count; - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) r = table->view->ops->set_row(table->view, rows[table->table_index], reduced, reduced_mask); msiobj_release(&reduced->hdr); @@ -354,14 +354,14 @@ static unsigned where_view_delete_row(LibmsiView *view, unsigned row) TRACE("(%p %d)\n", view, row); if (!wv->tables) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = find_row(wv, row, &rows); - if ( r != ERROR_SUCCESS ) + if ( r != LIBMSI_RESULT_SUCCESS ) return r; if (wv->table_count > 1) - return ERROR_CALL_NOT_IMPLEMENTED; + return LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; return wv->tables->view->ops->delete_row(wv->tables->view, rows[0]); } @@ -373,39 +373,39 @@ static int expr_eval_binary( LibmsiWhereView *wv, const unsigned rows[], int lval, rval; rl = where_view_evaluate(wv, rows, expr->left, &lval, record); - if (rl != ERROR_SUCCESS && rl != ERROR_CONTINUE) + if (rl != LIBMSI_RESULT_SUCCESS && rl != LIBMSI_RESULT_CONTINUE) return rl; rr = where_view_evaluate(wv, rows, expr->right, &rval, record); - if (rr != ERROR_SUCCESS && rr != ERROR_CONTINUE) + if (rr != LIBMSI_RESULT_SUCCESS && rr != LIBMSI_RESULT_CONTINUE) return rr; - if (rl == ERROR_CONTINUE || rr == ERROR_CONTINUE) + if (rl == LIBMSI_RESULT_CONTINUE || rr == LIBMSI_RESULT_CONTINUE) { if (rl == rr) { *val = true; - return ERROR_CONTINUE; + return LIBMSI_RESULT_CONTINUE; } if (expr->op == OP_AND) { - if ((rl == ERROR_CONTINUE && !rval) || (rr == ERROR_CONTINUE && !lval)) + if ((rl == LIBMSI_RESULT_CONTINUE && !rval) || (rr == LIBMSI_RESULT_CONTINUE && !lval)) { *val = false; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } else if (expr->op == OP_OR) { - if ((rl == ERROR_CONTINUE && rval) || (rr == ERROR_CONTINUE && lval)) + if ((rl == LIBMSI_RESULT_CONTINUE && rval) || (rr == LIBMSI_RESULT_CONTINUE && lval)) { *val = true; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } *val = true; - return ERROR_CONTINUE; + return LIBMSI_RESULT_CONTINUE; } switch( expr->op ) @@ -436,10 +436,10 @@ static int expr_eval_binary( LibmsiWhereView *wv, const unsigned rows[], break; default: ERR("Unknown operator %d\n", expr->op ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static inline unsigned expr_fetch_value(const union ext_column *expr, const unsigned rows[], unsigned *val) @@ -449,7 +449,7 @@ static inline unsigned expr_fetch_value(const union ext_column *expr, const unsi if( rows[table->table_index] == INVALID_ROW_INDEX ) { *val = 1; - return ERROR_CONTINUE; + return LIBMSI_RESULT_CONTINUE; } return table->view->ops->fetch_int(table->view, rows[table->table_index], expr->parsed.column, val); @@ -463,7 +463,7 @@ static unsigned expr_eval_unary( LibmsiWhereView *wv, const unsigned rows[], unsigned lval; r = expr_fetch_value(&expr->left->u.column, rows, &lval); - if(r != ERROR_SUCCESS) + if(r != LIBMSI_RESULT_SUCCESS) return r; switch( expr->op ) @@ -476,9 +476,9 @@ static unsigned expr_eval_unary( LibmsiWhereView *wv, const unsigned rows[], break; default: ERR("Unknown operator %d\n", expr->op ); - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned expr_eval_string( LibmsiWhereView *wv, const unsigned rows[], @@ -486,13 +486,13 @@ static unsigned expr_eval_string( LibmsiWhereView *wv, const unsigned rows[], const LibmsiRecord *record, const WCHAR **str ) { - unsigned val = 0, r = ERROR_SUCCESS; + unsigned val = 0, r = LIBMSI_RESULT_SUCCESS; switch( expr->type ) { case EXPR_COL_NUMBER_STRING: r = expr_fetch_value(&expr->u.column, rows, &val); - if (r == ERROR_SUCCESS) + if (r == LIBMSI_RESULT_SUCCESS) *str = msi_string_lookup_id(wv->db->strings, val); else *str = NULL; @@ -508,7 +508,7 @@ static unsigned expr_eval_string( LibmsiWhereView *wv, const unsigned rows[], default: ERR("Invalid expression type\n"); - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; *str = NULL; break; } @@ -524,10 +524,10 @@ static unsigned expr_eval_strcmp( LibmsiWhereView *wv, const unsigned rows[], co *val = true; r = expr_eval_string(wv, rows, expr->left, record, &l_str); - if (r == ERROR_CONTINUE) + if (r == LIBMSI_RESULT_CONTINUE) return r; r = expr_eval_string(wv, rows, expr->right, record, &r_str); - if (r == ERROR_CONTINUE) + if (r == LIBMSI_RESULT_CONTINUE) return r; if( l_str == r_str || @@ -543,7 +543,7 @@ static unsigned expr_eval_strcmp( LibmsiWhereView *wv, const unsigned rows[], co *val = ( expr->op == OP_EQ && ( sr == 0 ) ) || ( expr->op == OP_NE && ( sr != 0 ) ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned where_view_evaluate( LibmsiWhereView *wv, const unsigned rows[], @@ -554,28 +554,28 @@ static unsigned where_view_evaluate( LibmsiWhereView *wv, const unsigned rows[], if( !cond ) { *val = true; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } switch( cond->type ) { case EXPR_COL_NUMBER: r = expr_fetch_value(&cond->u.column, rows, &tval); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; *val = tval - 0x8000; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; case EXPR_COL_NUMBER32: r = expr_fetch_value(&cond->u.column, rows, &tval); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; *val = tval - 0x80000000; return r; case EXPR_UVAL: *val = cond->u.uval; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; case EXPR_COMPLEX: return expr_eval_binary(wv, rows, &cond->u.expr, val, record); @@ -588,20 +588,20 @@ static unsigned where_view_evaluate( LibmsiWhereView *wv, const unsigned rows[], case EXPR_WILDCARD: *val = libmsi_record_get_integer( record, ++wv->rec_index ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; default: ERR("Invalid expression type\n"); break; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned check_condition( LibmsiWhereView *wv, LibmsiRecord *record, JOINTABLE **tables, unsigned table_rows[] ) { - unsigned r = ERROR_FUNCTION_FAILED; + unsigned r = LIBMSI_RESULT_FUNCTION_FAILED; int val; for (table_rows[(*tables)->table_index] = 0; @@ -611,19 +611,19 @@ static unsigned check_condition( LibmsiWhereView *wv, LibmsiRecord *record, JOIN val = 0; wv->rec_index = 0; r = where_view_evaluate( wv, table_rows, wv->cond, &val, record ); - if (r != ERROR_SUCCESS && r != ERROR_CONTINUE) + if (r != LIBMSI_RESULT_SUCCESS && r != LIBMSI_RESULT_CONTINUE) break; if (val) { if (*(tables + 1)) { r = check_condition(wv, record, tables + 1, table_rows); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; } else { - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; add_row (wv, table_rows); } @@ -652,7 +652,7 @@ static int compare_entry( const void *left, const void *right ) r = column->parsed.table->view->ops->fetch_int(column->parsed.table->view, le->values[column->parsed.table->table_index], column->parsed.column, &l_val); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { order->error = r; return 0; @@ -661,7 +661,7 @@ static int compare_entry( const void *left, const void *right ) r = column->parsed.table->view->ops->fetch_int(column->parsed.table->view, re->values[column->parsed.table->table_index], column->parsed.column, &r_val); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { order->error = r; return 0; @@ -774,10 +774,10 @@ static unsigned where_view_execute( LibmsiView *view, LibmsiRecord *record ) TRACE("%p %p\n", wv, record); if( !table ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; r = init_reorder(wv); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; do @@ -785,7 +785,7 @@ static unsigned where_view_execute( LibmsiView *view, LibmsiRecord *record ) table->view->ops->execute(table->view, NULL); r = table->view->ops->get_dimensions(table->view, &table->row_count, NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("failed to get table dimensions\n"); return r; @@ -793,7 +793,7 @@ static unsigned where_view_execute( LibmsiView *view, LibmsiRecord *record ) /* each table must have at least one row */ if (table->row_count == 0) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } while ((table = table->next)); @@ -806,7 +806,7 @@ static unsigned where_view_execute( LibmsiView *view, LibmsiRecord *record ) r = check_condition(wv, record, ordered_tables, rows); if (wv->order_info) - wv->order_info->error = ERROR_SUCCESS; + wv->order_info->error = LIBMSI_RESULT_SUCCESS; qsort(wv->reorder, wv->row_count, sizeof(LibmsiRowEntry *), compare_entry); @@ -826,13 +826,13 @@ static unsigned where_view_close( LibmsiView *view ) TRACE("%p\n", wv ); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; do table->view->ops->close(table->view); while ((table = table->next)); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned where_view_get_dimensions( LibmsiView *view, unsigned *rows, unsigned *cols ) @@ -842,19 +842,19 @@ static unsigned where_view_get_dimensions( LibmsiView *view, unsigned *rows, uns TRACE("%p %p %p\n", wv, rows, cols ); if(!wv->tables) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (rows) { if (!wv->reorder) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; *rows = wv->row_count; } if (cols) *cols = wv->col_count; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned where_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name, @@ -866,11 +866,11 @@ static unsigned where_view_get_column_info( LibmsiView *view, unsigned n, const TRACE("%p %d %p %p %p %p\n", wv, n, name, type, temporary, table_name ); if(!wv->tables) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; table = find_table(wv, n, &n); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; return table->view->ops->get_column_info(table->view, n, name, type, temporary, table_name); @@ -883,7 +883,7 @@ static unsigned join_find_row( LibmsiWhereView *wv, LibmsiRecord *rec, unsigned str = _libmsi_record_get_string_raw( rec, 1 ); r = _libmsi_id_from_stringW( wv->db->strings, str, &id ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; for (i = 0; i < wv->row_count; i++) @@ -893,11 +893,11 @@ static unsigned join_find_row( LibmsiWhereView *wv, LibmsiRecord *rec, unsigned if (data == id) { *row = i; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; } static unsigned join_modify_update( LibmsiView *view, LibmsiRecord *rec ) @@ -908,11 +908,11 @@ static unsigned join_modify_update( LibmsiView *view, LibmsiRecord *rec ) r = join_find_row( wv, rec, &row ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; r = msi_view_get_row( wv->db, view, row, ¤t ); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) return r; assert(libmsi_record_get_field_count(rec) == libmsi_record_get_field_count(current)); @@ -937,13 +937,13 @@ static unsigned where_view_modify( LibmsiView *view, LibmsiModify eModifyMode, TRACE("%p %d %p\n", wv, eModifyMode, rec); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (!table->next) { unsigned *rows; - if (find_row(wv, row - 1, &rows) == ERROR_SUCCESS) + if (find_row(wv, row - 1, &rows) == LIBMSI_RESULT_SUCCESS) row = rows[0] + 1; else row = -1; @@ -967,16 +967,16 @@ static unsigned where_view_modify( LibmsiView *view, LibmsiModify eModifyMode, case LIBMSI_MODIFY_VALIDATE_DELETE: case LIBMSI_MODIFY_VALIDATE_FIELD: case LIBMSI_MODIFY_VALIDATE_NEW: - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; break; case LIBMSI_MODIFY_REFRESH: - r = ERROR_CALL_NOT_IMPLEMENTED; + r = LIBMSI_RESULT_CALL_NOT_IMPLEMENTED; break; default: WARN("%p %d %p %u - unknown mode\n", view, eModifyMode, rec, row ); - r = ERROR_INVALID_PARAMETER; + r = LIBMSI_RESULT_INVALID_PARAMETER; break; } @@ -1011,7 +1011,7 @@ static unsigned where_view_delete( LibmsiView *view ) msiobj_release( &wv->db->hdr ); msi_free( wv ); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } static unsigned where_view_find_matching_rows( LibmsiView *view, unsigned col, @@ -1023,25 +1023,25 @@ static unsigned where_view_find_matching_rows( LibmsiView *view, unsigned col, TRACE("%p, %d, %u, %p\n", view, col, val, *handle); if (!wv->tables) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; if (col == 0 || col > wv->col_count) - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; for (i = PtrToUlong(*handle); i < wv->row_count; i++) { - if (view->ops->fetch_int( view, i, col, &row_value ) != ERROR_SUCCESS) + if (view->ops->fetch_int( view, i, col, &row_value ) != LIBMSI_RESULT_SUCCESS) continue; if (row_value == val) { *row = i; *handle = UlongToPtr(i + 1); - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } } - return ERROR_NO_MORE_ITEMS; + return LIBMSI_RESULT_NO_MORE_ITEMS; } static unsigned where_view_sort(LibmsiView *view, column_info *columns) @@ -1056,7 +1056,7 @@ static unsigned where_view_sort(LibmsiView *view, column_info *columns) TRACE("%p %p\n", view, columns); if (!table) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; while (column) { @@ -1065,11 +1065,11 @@ static unsigned where_view_sort(LibmsiView *view, column_info *columns) } if (count == 0) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; orderinfo = msi_alloc(sizeof(LibmsiOrderInfo) + (count - 1) * sizeof(union ext_column)); if (!orderinfo) - return ERROR_OUTOFMEMORY; + return LIBMSI_RESULT_OUTOFMEMORY; orderinfo->col_count = count; @@ -1081,13 +1081,13 @@ static unsigned where_view_sort(LibmsiView *view, column_info *columns) orderinfo->columns[i].unparsed.table = column->table; r = parse_column(wv, &orderinfo->columns[i], NULL); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) goto error; } wv->order_info = orderinfo; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; error: msi_free(orderinfo); return r; @@ -1130,7 +1130,7 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c *valid = false; r = parse_column(wv, &cond->u.column, &type); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) break; if (type&MSITYPE_STRING) @@ -1145,12 +1145,12 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c } case EXPR_COMPLEX: r = where_view_verify_condition( wv, cond->u.expr.left, valid ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; if( !*valid ) - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; r = where_view_verify_condition( wv, cond->u.expr.right, valid ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; /* check the type of the comparison */ @@ -1166,7 +1166,7 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c break; default: *valid = false; - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; } /* FIXME: check we're comparing a string to a column */ @@ -1179,10 +1179,10 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c if ( cond->u.expr.left->type != EXPR_COLUMN ) { *valid = false; - return ERROR_INVALID_PARAMETER; + return LIBMSI_RESULT_INVALID_PARAMETER; } r = where_view_verify_condition( wv, cond->u.expr.left, valid ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) return r; break; case EXPR_IVAL: @@ -1202,7 +1202,7 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c break; } - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; } unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables, @@ -1216,7 +1216,7 @@ unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables wv = alloc_msiobject( sizeof *wv, NULL ); if( !wv ) - return ERROR_FUNCTION_FAILED; + return LIBMSI_RESULT_FUNCTION_FAILED; /* fill the structure */ wv->view.ops = &where_ops; @@ -1234,22 +1234,22 @@ unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables table = msi_alloc(sizeof(JOINTABLE)); if (!table) { - r = ERROR_OUTOFMEMORY; + r = LIBMSI_RESULT_OUTOFMEMORY; goto end; } r = table_view_create(db, tables, &table->view); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { WARN("can't create table: %s\n", debugstr_w(tables)); msi_free(table); - r = ERROR_BAD_QUERY_SYNTAX; + r = LIBMSI_RESULT_BAD_QUERY_SYNTAX; goto end; } r = table->view->ops->get_dimensions(table->view, NULL, &table->col_count); - if (r != ERROR_SUCCESS) + if (r != LIBMSI_RESULT_SUCCESS) { ERR("can't get table dimensions\n"); goto end; @@ -1270,17 +1270,17 @@ unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables if( cond ) { r = where_view_verify_condition( wv, cond, &valid ); - if( r != ERROR_SUCCESS ) + if( r != LIBMSI_RESULT_SUCCESS ) goto end; if( !valid ) { - r = ERROR_FUNCTION_FAILED; + r = LIBMSI_RESULT_FUNCTION_FAILED; goto end; } } *view = (LibmsiView*) wv; - return ERROR_SUCCESS; + return LIBMSI_RESULT_SUCCESS; end: where_view_delete(&wv->view); -- cgit