diff options
-rw-r--r-- | include/libmsi.h | 72 | ||||
-rw-r--r-- | libmsi/database.c | 123 | ||||
-rw-r--r-- | libmsi/handle.c | 16 | ||||
-rw-r--r-- | libmsi/insert.c | 10 | ||||
-rw-r--r-- | libmsi/msipriv.h | 36 | ||||
-rw-r--r-- | libmsi/msiquery.c | 164 | ||||
-rw-r--r-- | libmsi/record.c | 222 | ||||
-rw-r--r-- | libmsi/select.c | 10 | ||||
-rw-r--r-- | libmsi/storages.c | 4 | ||||
-rw-r--r-- | libmsi/streams.c | 4 | ||||
-rw-r--r-- | libmsi/suminfo.c | 51 | ||||
-rw-r--r-- | libmsi/table.c | 62 | ||||
-rw-r--r-- | libmsi/update.c | 4 | ||||
-rw-r--r-- | libmsi/where.c | 12 | ||||
-rw-r--r-- | tests/testdatabase.c | 345 | ||||
-rw-r--r-- | tests/testrecord.c | 12 | ||||
-rw-r--r-- | tests/testsuminfo.c | 8 |
17 files changed, 469 insertions, 686 deletions
diff --git a/include/libmsi.h b/include/libmsi.h index 489b6f9..df65688 100644 --- a/include/libmsi.h +++ b/include/libmsi.h @@ -22,8 +22,10 @@ #include <stdint.h> #include <stdbool.h> -struct LibmsiObject; -typedef struct LibmsiObject LibmsiObject; +typedef struct LibmsiQuery LibmsiQuery; +typedef struct LibmsiDatabase LibmsiDatabase; +typedef struct LibmsiRecord LibmsiRecord; +typedef struct LibmsiSummaryInfo LibmsiSummaryInfo; typedef enum LibmsiCondition { @@ -143,58 +145,58 @@ extern "C" { /* view manipulation */ -unsigned MsiQueryFetch(LibmsiObject *,LibmsiObject **); -unsigned MsiQueryExecute(LibmsiObject *,LibmsiObject *); -unsigned MsiQueryClose(LibmsiObject *); -unsigned MsiDatabaseOpenQuery(LibmsiObject *,const char *,LibmsiObject **); -LibmsiDBError MsiQueryGetError(LibmsiObject *,char *,unsigned *); +unsigned MsiQueryFetch(LibmsiQuery *,LibmsiRecord **); +unsigned MsiQueryExecute(LibmsiQuery *,LibmsiRecord *); +unsigned MsiQueryClose(LibmsiQuery *); +unsigned MsiDatabaseOpenQuery(LibmsiDatabase *,const char *,LibmsiQuery **); +LibmsiDBError MsiQueryGetError(LibmsiQuery *,char *,unsigned *); -LibmsiDBState MsiGetDatabaseState(LibmsiObject *); +LibmsiDBState MsiGetDatabaseState(LibmsiDatabase *); /* record manipulation */ -LibmsiObject * MsiCreateRecord(unsigned); -unsigned MsiRecordClearData(LibmsiObject *); -unsigned MsiRecordSetInteger(LibmsiObject *,unsigned,int); -unsigned MsiRecordSetString(LibmsiObject *,unsigned,const char *); -unsigned MsiRecordGetString(LibmsiObject *,unsigned,char *,unsigned *); -unsigned MsiRecordGetFieldCount(LibmsiObject *); -int MsiRecordGetInteger(LibmsiObject *,unsigned); -unsigned MsiRecordDataSize(LibmsiObject *,unsigned); -bool MsiRecordIsNull(LibmsiObject *,unsigned); +LibmsiRecord * MsiCreateRecord(unsigned); +unsigned MsiRecordClearData(LibmsiRecord *); +unsigned MsiRecordSetInteger(LibmsiRecord *,unsigned,int); +unsigned MsiRecordSetString(LibmsiRecord *,unsigned,const char *); +unsigned MsiRecordGetString(const LibmsiRecord *,unsigned,char *,unsigned *); +unsigned MsiRecordGetFieldCount(const LibmsiRecord *); +int MsiRecordGetInteger(const LibmsiRecord *,unsigned); +unsigned MsiRecordDataSize(const LibmsiRecord *,unsigned); +bool MsiRecordIsNull(const LibmsiRecord *,unsigned); -unsigned MsiRecordSetStream(LibmsiObject *,unsigned,const char *); -unsigned MsiRecordReadStream(LibmsiObject *,unsigned,char*,unsigned *); +unsigned MsiRecordSetStream(LibmsiRecord *,unsigned,const char *); +unsigned MsiRecordReadStream(LibmsiRecord *,unsigned,char*,unsigned *); -unsigned MsiDatabaseGetPrimaryKeys(LibmsiObject *,const char *,LibmsiObject **); +unsigned MsiDatabaseGetPrimaryKeys(LibmsiDatabase *,const char *,LibmsiRecord **); /* database transforms */ -unsigned MsiDatabaseApplyTransform(LibmsiObject *,const char *,int); +unsigned MsiDatabaseApplyTransform(LibmsiDatabase *,const char *,int); -unsigned MsiQueryGetColumnInfo(LibmsiObject *, LibmsiColInfo, LibmsiObject **); +unsigned MsiQueryGetColumnInfo(LibmsiQuery *, LibmsiColInfo, LibmsiRecord **); -unsigned MsiSummaryInfoGetProperty(LibmsiObject *,unsigned,unsigned *,int *,uint64_t*,char *,unsigned *); +unsigned MsiSummaryInfoGetProperty(LibmsiSummaryInfo *,unsigned,unsigned *,int *,uint64_t*,char *,unsigned *); -unsigned MsiSummaryInfoSetProperty(LibmsiObject *, unsigned, unsigned, int, uint64_t*, const char *); +unsigned MsiSummaryInfoSetProperty(LibmsiSummaryInfo *, unsigned, unsigned, int, uint64_t*, const char *); -unsigned MsiDatabaseExport(LibmsiObject *, const char *, int fd); +unsigned MsiDatabaseExport(LibmsiDatabase *, const char *, int fd); -unsigned MsiDatabaseImport(LibmsiObject *, const char *, const char *); +unsigned MsiDatabaseImport(LibmsiDatabase *, const char *, const char *); -unsigned MsiOpenDatabase(const char *, const char *, LibmsiObject **); +unsigned MsiOpenDatabase(const char *, const char *, LibmsiDatabase **); -LibmsiCondition MsiDatabaseIsTablePersistent(LibmsiObject *, const char *); +LibmsiCondition MsiDatabaseIsTablePersistent(LibmsiDatabase *, const char *); -unsigned MsiSummaryInfoPersist(LibmsiObject *); -unsigned MsiSummaryInfoGetPropertyCount(LibmsiObject *,unsigned *); +unsigned MsiSummaryInfoPersist(LibmsiSummaryInfo *); +unsigned MsiSummaryInfoGetPropertyCount(LibmsiSummaryInfo *,unsigned *); -unsigned MsiQueryModify(LibmsiObject *, LibmsiModify, LibmsiObject *); +unsigned MsiQueryModify(LibmsiQuery *, LibmsiModify, LibmsiRecord *); -unsigned MsiDatabaseMerge(LibmsiObject *, LibmsiObject *, const char *); +unsigned MsiDatabaseMerge(LibmsiDatabase *, LibmsiDatabase *, const char *); /* Non Unicode */ -unsigned MsiGetSummaryInformation(LibmsiObject *, unsigned, LibmsiObject **); -unsigned MsiDatabaseCommit(LibmsiObject *); -unsigned MsiCloseHandle(LibmsiObject *); +unsigned MsiGetSummaryInformation(LibmsiDatabase *, unsigned, LibmsiSummaryInfo **); +unsigned MsiDatabaseCommit(LibmsiDatabase *); +unsigned MsiCloseHandle(void *); #ifdef __cplusplus } diff --git a/libmsi/database.c b/libmsi/database.c index acb7b60..eaeeb1f 100644 --- a/libmsi/database.c +++ b/libmsi/database.c @@ -296,7 +296,7 @@ static HRESULT db_initialize( IStorage *stg, const GUID *clsid ) return S_OK; } -unsigned MSI_OpenDatabase(const char *szDBPath, const char *szPersist, LibmsiDatabase **pdb) +unsigned MsiOpenDatabase(const char *szDBPath, const char *szPersist, LibmsiDatabase **pdb) { IStorage *stg = NULL; HRESULT r; @@ -308,7 +308,7 @@ unsigned MSI_OpenDatabase(const char *szDBPath, const char *szPersist, LibmsiDat bool created = false, patch = false; char path[MAX_PATH]; - TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) ); + TRACE("%s %p\n",debugstr_a(szDBPath),szPersist ); if( !pdb ) return ERROR_INVALID_PARAMETER; @@ -403,8 +403,7 @@ unsigned MSI_OpenDatabase(const char *szDBPath, const char *szPersist, LibmsiDat goto end; } - db = alloc_msiobject( LIBMSI_OBJECT_TYPE_DATABASE, sizeof (LibmsiDatabase), - MSI_CloseDatabase ); + db = alloc_msiobject( sizeof (LibmsiDatabase), MSI_CloseDatabase ); if( !db ) { FIXME("Failed to allocate a handle\n"); @@ -454,22 +453,6 @@ end: return ret; } -unsigned MsiOpenDatabase(const char *szDBPath, const char *szPersist, LibmsiObject **phDB) -{ - LibmsiDatabase *db; - unsigned ret; - - TRACE("%s %s %p\n",debugstr_a(szDBPath),debugstr_a(szPersist), phDB); - - ret = MSI_OpenDatabase( szDBPath, szPersist, &db ); - if( ret == ERROR_SUCCESS ) - { - *phDB = &db->hdr; - } - - return ret; -} - static WCHAR *msi_read_text_archive(const char *path, unsigned *len) { int fd; @@ -756,7 +739,7 @@ static unsigned msi_add_table_to_db(LibmsiDatabase *db, WCHAR **columns, WCHAR * goto done; r = MSI_QueryExecute(view, NULL); - MSI_QueryClose(view); + MsiQueryClose(view); msiobj_release(&view->hdr); done: @@ -799,7 +782,7 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types, { unsigned i; - *rec = MSI_CreateRecord(num_columns); + *rec = MsiCreateRecord(num_columns); if (!*rec) return ERROR_OUTOFMEMORY; @@ -812,7 +795,7 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types, break; case 'I': case 'i': if (*data[i]) - MSI_RecordSetInteger(*rec, i + 1, atoiW(data[i])); + MsiRecordSetInteger(*rec, i + 1, atoiW(data[i])); break; case 'V': case 'v': if (*data[i]) @@ -906,7 +889,7 @@ static unsigned MSI_DatabaseImport(LibmsiDatabase *db, const char *folder, const static const WCHAR forcecodepage[] = {'_','F','o','r','c','e','C','o','d','e','p','a','g','e',0}; - TRACE("%p %s %s\n", db, debugstr_a(folder), debugstr_w(file) ); + TRACE("%p %s %s\n", db, debugstr_a(folder), debugstr_a(file) ); if( folder == NULL || file == NULL ) return ERROR_INVALID_PARAMETER; @@ -1003,16 +986,16 @@ done: return r; } -unsigned MsiDatabaseImport(LibmsiObject *handle, const char *szFolder, const char *szFilename) +unsigned MsiDatabaseImport(LibmsiDatabase *db, const char *szFolder, const char *szFilename) { - LibmsiDatabase *db; unsigned r; - TRACE("%x %s %s\n",handle,debugstr_w(szFolder), debugstr_w(szFilename)); + TRACE("%x %s %s\n",db,debugstr_a(szFolder), debugstr_a(szFilename)); - db = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; + + msiobj_addref( &db->hdr ); r = MSI_DatabaseImport( db, szFolder, szFilename ); msiobj_release( &db->hdr ); return r; @@ -1030,11 +1013,11 @@ static unsigned msi_export_record( int fd, LibmsiRecord *row, unsigned start ) if ( !buffer ) return ERROR_OUTOFMEMORY; - count = MSI_RecordGetFieldCount( row ); + count = MsiRecordGetFieldCount( row ); for ( i=start; i<=count; i++ ) { sz = len; - r = MSI_RecordGetStringA( row, i, buffer, &sz ); + r = MsiRecordGetString( row, i, buffer, &sz ); if (r == ERROR_MORE_DATA) { char *p = msi_realloc( buffer, sz + 1 ); @@ -1044,7 +1027,7 @@ static unsigned msi_export_record( int fd, LibmsiRecord *row, unsigned start ) buffer = p; } sz = len; - r = MSI_RecordGetStringA( row, i, buffer, &sz ); + r = MsiRecordGetString( row, i, buffer, &sz ); if (r != ERROR_SUCCESS) break; @@ -1097,8 +1080,7 @@ static unsigned MSI_DatabaseExport( LibmsiDatabase *db, const WCHAR *table, LibmsiQuery *view = NULL; unsigned r; - TRACE("%p %s %s %s\n", db, debugstr_w(table), - debugstr_w(folder), debugstr_w(file) ); + TRACE("%p %s %d\n", db, debugstr_w(table), fd ); if (!strcmpW( table, forcecodepage )) { @@ -1159,17 +1141,15 @@ done: * * row4 : data <tab> data <tab> data <tab> ... data <cr> <lf> */ -unsigned MsiDatabaseExport( LibmsiObject *handle, const char *szTable, +unsigned MsiDatabaseExport( LibmsiDatabase *db, const char *szTable, int fd ) { - LibmsiDatabase *db; WCHAR *path = NULL; WCHAR *file = NULL; WCHAR *table = NULL; unsigned r = ERROR_OUTOFMEMORY; - TRACE("%x %s %s %s\n", handle, debugstr_a(szTable), - debugstr_a(szFolder), debugstr_a(szFilename)); + TRACE("%x %s %d\n", db, debugstr_a(szTable), fd); if( szTable ) { @@ -1178,9 +1158,10 @@ unsigned MsiDatabaseExport( LibmsiObject *handle, const char *szTable, goto end; } - db = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; + + msiobj_addref ( &db->hdr ); r = MSI_DatabaseExport( db, table, fd ); msiobj_release( &db->hdr ); @@ -1247,13 +1228,13 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie if (r != ERROR_SUCCESS) return r; - count = MSI_RecordGetFieldCount(dbrec); + count = MsiRecordGetFieldCount(dbrec); for (i = 1; i <= count; i++) { - if (!MSI_RecordGetString(mergerec, i)) + if (!MSI_RecordGetStringRaw(mergerec, i)) break; - if (strcmpW( MSI_RecordGetString( dbrec, i ), MSI_RecordGetString( mergerec, i ) )) + if (strcmpW( MSI_RecordGetStringRaw( dbrec, i ), MSI_RecordGetStringRaw( mergerec, i ) )) { r = ERROR_DATATYPE_MISMATCH; goto done; @@ -1272,14 +1253,14 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie if (r != ERROR_SUCCESS) return r; - count = MSI_RecordGetFieldCount(dbrec); + count = MsiRecordGetFieldCount(dbrec); for (i = 1; i <= count; i++) { - if (!MSI_RecordGetString(mergerec, i)) + if (!MSI_RecordGetStringRaw(mergerec, i)) break; - if (!merge_type_match(MSI_RecordGetString(dbrec, i), - MSI_RecordGetString(mergerec, i))) + if (!merge_type_match(MSI_RecordGetStringRaw(dbrec, i), + MSI_RecordGetStringRaw(mergerec, i))) { r = ERROR_DATATYPE_MISMATCH; break; @@ -1307,8 +1288,8 @@ static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *me if (r != ERROR_SUCCESS) goto done; - count = MSI_RecordGetFieldCount(dbrec); - if (count != MSI_RecordGetFieldCount(mergerec)) + count = MsiRecordGetFieldCount(dbrec); + if (count != MsiRecordGetFieldCount(mergerec)) { r = ERROR_DATATYPE_MISMATCH; goto done; @@ -1316,7 +1297,7 @@ static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *me for (i = 1; i <= count; i++) { - if (strcmpW( MSI_RecordGetString( dbrec, i ), MSI_RecordGetString( mergerec, i ) )) + if (strcmpW( MSI_RecordGetStringRaw( dbrec, i ), MSI_RecordGetStringRaw( mergerec, i ) )) { r = ERROR_DATATYPE_MISMATCH; goto done; @@ -1356,7 +1337,7 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r return NULL; sz++; - if (MSI_RecordGetString(rec, i)) /* check record field is a string */ + if (MSI_RecordGetStringRaw(rec, i)) /* check record field is a string */ { /* quote string record fields */ const WCHAR szQuote[] = {'\'', 0}; @@ -1418,10 +1399,10 @@ static WCHAR *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view, goto done; size = 1; - count = MSI_RecordGetFieldCount(keys); + count = MsiRecordGetFieldCount(keys); for (i = 1; i <= count; i++) { - key = MSI_RecordGetString(keys, i); + key = MSI_RecordGetStringRaw(keys, i); val = get_key_value(view, key, rec); if (i == count) @@ -1524,7 +1505,7 @@ static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCH if (r != ERROR_SUCCESS) return r; - count = MSI_RecordGetFieldCount(prec); + count = MsiRecordGetFieldCount(prec); *numlabels = count + 1; *labels = msi_alloc((*numlabels)*sizeof(WCHAR *)); if (!*labels) @@ -1536,7 +1517,7 @@ static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCH (*labels)[0] = strdupW(table); for (i=1; i<=count; i++ ) { - (*labels)[i] = strdupW(MSI_RecordGetString(prec, i)); + (*labels)[i] = strdupW(MSI_RecordGetStringRaw(prec, i)); } end: @@ -1553,7 +1534,7 @@ static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsi if (r != ERROR_SUCCESS) return r; - count = MSI_RecordGetFieldCount(prec); + count = MsiRecordGetFieldCount(prec); *columns = msi_alloc(count*sizeof(WCHAR *)); if (!*columns) { @@ -1563,7 +1544,7 @@ static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsi for (i=1; i<=count; i++ ) { - (*columns)[i-1] = strdupW(MSI_RecordGetString(prec, i)); + (*columns)[i-1] = strdupW(MSI_RecordGetStringRaw(prec, i)); } *numcolumns = count; @@ -1582,7 +1563,7 @@ static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned if (r != ERROR_SUCCESS) return r; - count = MSI_RecordGetFieldCount(prec); + count = MsiRecordGetFieldCount(prec); *types = msi_alloc(count*sizeof(WCHAR *)); if (!*types) { @@ -1593,7 +1574,7 @@ static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned *numtypes = count; for (i=1; i<=count; i++ ) { - (*types)[i-1] = strdupW(MSI_RecordGetString(prec, i)); + (*types)[i-1] = strdupW(MSI_RecordGetStringRaw(prec, i)); } end: @@ -1709,7 +1690,7 @@ static unsigned merge_diff_tables(LibmsiRecord *rec, void *param) static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ','`','%','s','`',0}; - name = MSI_RecordGetString(rec, 1); + name = MSI_RecordGetStringRaw(rec, 1); r = MSI_OpenQuery(data->merge, &mergeview, query, name); if (r != ERROR_SUCCESS) @@ -1845,32 +1826,28 @@ static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error, return r; } -unsigned MsiDatabaseMerge(LibmsiObject *hDatabase, LibmsiObject *hDatabaseMerge, +unsigned MsiDatabaseMerge(LibmsiDatabase *db, LibmsiDatabase *merge, const char *szTableName) { struct list tabledata = LIST_INIT(tabledata); struct list *item, *cursor; - LibmsiDatabase *db, *merge; WCHAR *szwTableName; MERGETABLE *table; bool conflicts; unsigned r; - TRACE("(%d, %d, %s)\n", hDatabase, hDatabaseMerge, - debugstr_w(szTableName)); + TRACE("(%d, %d, %s)\n", db, merge, + debugstr_a(szTableName)); if (szTableName && !*szTableName) return ERROR_INVALID_TABLE; - szwTableName = strdupAtoW(szTableName); - db = msihandle2msiinfo(hDatabase, LIBMSI_OBJECT_TYPE_DATABASE); - merge = msihandle2msiinfo(hDatabaseMerge, LIBMSI_OBJECT_TYPE_DATABASE); if (!db || !merge) - { - r = ERROR_INVALID_HANDLE; - goto done; - } + return ERROR_INVALID_HANDLE; + szwTableName = strdupAtoW(szTableName); + msiobj_addref( &db->hdr ); + msiobj_addref( &merge->hdr ); r = gather_merge_data(db, merge, &tabledata); if (r != ERROR_SUCCESS) goto done; @@ -1911,16 +1888,16 @@ done: return r; } -LibmsiDBState MsiGetDatabaseState( LibmsiObject *handle ) +LibmsiDBState MsiGetDatabaseState( LibmsiDatabase *db ) { LibmsiDBState ret = LIBMSI_DB_STATE_READ; - LibmsiDatabase *db; - TRACE("%d\n", handle); + TRACE("%d\n", db); - db = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; + + msiobj_addref( &db->hdr ); if (db->mode != LIBMSI_DB_OPEN_READONLY ) ret = LIBMSI_DB_STATE_WRITE; msiobj_release( &db->hdr ); diff --git a/libmsi/handle.c b/libmsi/handle.c index 50f6553..251a4c8 100644 --- a/libmsi/handle.c +++ b/libmsi/handle.c @@ -31,25 +31,13 @@ #include "msipriv.h" -void *msihandle2msiinfo(LibmsiObject *obj, unsigned type) -{ - if( !obj ) - return NULL; - if( type && obj->type != type ) - return NULL; - - msiobj_addref( obj ); - return obj; -} - -void *alloc_msiobject(unsigned type, unsigned size, msihandledestructor destroy ) +void *alloc_msiobject(unsigned size, msihandledestructor destroy ) { LibmsiObject *info; info = msi_alloc_zero( size ); if( info ) { - info->type = type; info->refcount = 1; info->destructor = destroy; } @@ -87,7 +75,7 @@ int msiobj_release( LibmsiObject *obj ) /*********************************************************** * MsiCloseHandle [MSI.@] */ -unsigned MsiCloseHandle(LibmsiObject *obj) +unsigned MsiCloseHandle(void *obj) { TRACE("%x\n",obj); diff --git a/libmsi/insert.c b/libmsi/insert.c index 67c4b16..b6def40 100644 --- a/libmsi/insert.c +++ b/libmsi/insert.c @@ -67,7 +67,7 @@ LibmsiRecord *msi_query_merge_record( unsigned fields, const column_info *vl, Li LibmsiRecord *merged; unsigned wildcard_count = 1, i; - merged = MSI_CreateRecord( fields ); + merged = MsiCreateRecord( fields ); for( i=1; i <= fields; i++ ) { if( !vl ) @@ -82,7 +82,7 @@ LibmsiRecord *msi_query_merge_record( unsigned fields, const column_info *vl, Li MSI_RecordSetStringW( merged, i, vl->val->u.sval ); break; case EXPR_IVAL: - MSI_RecordSetInteger( merged, i, vl->val->u.ival ); + MsiRecordSetInteger( merged, i, vl->val->u.ival ); break; case EXPR_WILDCARD: if( !rec ) @@ -136,7 +136,7 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values) if (r != ERROR_SUCCESS) return r; - val_count = MSI_RecordGetFieldCount(*values); + val_count = MsiRecordGetFieldCount(*values); /* check to see if the columns are arranged already * to avoid unnecessary copying @@ -144,7 +144,7 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values) if (col_count == val_count && msi_columns_in_order(iv, col_count)) return ERROR_SUCCESS; - padded = MSI_CreateRecord(col_count); + padded = MsiCreateRecord(col_count); if (!padded) return ERROR_OUTOFMEMORY; @@ -195,7 +195,7 @@ static bool row_has_null_primary_keys(LibmsiInsertView *iv, LibmsiRecord *row) if (!(type & MSITYPE_KEY)) continue; - if (MSI_RecordIsNull(row, i)) + if (MsiRecordIsNull(row, i)) return true; } diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h index cec346d..84f78e9 100644 --- a/libmsi/msipriv.h +++ b/libmsi/msipriv.h @@ -63,7 +63,6 @@ typedef VOID (*msihandledestructor)( LibmsiObject * ); struct LibmsiObject { unsigned magic; - unsigned type; LONG refcount; msihandledestructor destructor; }; @@ -272,14 +271,6 @@ typedef struct LibmsiSummaryInfo PROPVARIANT property[MSI_MAX_PROPS]; } LibmsiSummaryInfo; -#define LIBMSI_OBJECT_TYPE_ANY 0 -#define LIBMSI_OBJECT_TYPE_DATABASE 1 -#define LIBMSI_OBJECT_TYPE_SUMMARYINFO 2 -#define LIBMSI_OBJECT_TYPE_QUERY 3 -#define LIBMSI_OBJECT_TYPE_RECORD 4 -#define LIBMSI_OBJECT_TYPE_PACKAGE 5 -#define LIBMSI_OBJECT_TYPE_PREVIEW 6 - /* handle unicode/ascii output in the Msi* API functions */ typedef struct { bool unicode; @@ -300,8 +291,7 @@ typedef struct { unsigned msi_strcpy_to_awstring( const WCHAR *str, awstring *awbuf, unsigned *sz ); /* handle functions */ -extern void *msihandle2msiinfo(LibmsiObject *handle, unsigned type); -extern void *alloc_msiobject(unsigned type, unsigned size, msihandledestructor destroy ); +extern void *alloc_msiobject(unsigned size, msihandledestructor destroy ); extern void msiobj_addref(LibmsiObject *); extern int msiobj_release(LibmsiObject *); @@ -343,26 +333,20 @@ extern void append_storage_to_db( LibmsiDatabase *db, IStorage *stg ); /* record internals */ extern void MSI_CloseRecord( LibmsiObject * ); extern unsigned MSI_RecordSetIStream( LibmsiRecord *, unsigned, IStream *); -extern unsigned MSI_RecordGetIStream( LibmsiRecord *, unsigned, IStream **); -extern const WCHAR *MSI_RecordGetString( const LibmsiRecord *, unsigned ); -extern LibmsiRecord *MSI_CreateRecord( unsigned ); -extern unsigned MSI_RecordSetInteger( LibmsiRecord *, unsigned, int ); +extern unsigned MSI_RecordGetIStream( const LibmsiRecord *, unsigned, IStream **); +extern const WCHAR *MSI_RecordGetStringRaw( const LibmsiRecord *, unsigned ); extern unsigned MSI_RecordSetIntPtr( LibmsiRecord *, unsigned, intptr_t ); extern unsigned MSI_RecordSetStringW( LibmsiRecord *, unsigned, const WCHAR *); -extern bool MSI_RecordIsNull( LibmsiRecord *, unsigned ); -extern unsigned MSI_RecordGetStringW( LibmsiRecord *, unsigned, WCHAR *, unsigned *); -extern unsigned MSI_RecordGetStringA( LibmsiRecord *, unsigned, char *, unsigned *); -extern int MSI_RecordGetInteger( LibmsiRecord *, unsigned ); -extern intptr_t MSI_RecordGetIntPtr( LibmsiRecord *, unsigned ); -extern unsigned MSI_RecordReadStream( LibmsiRecord *, unsigned, char *, unsigned *); +extern unsigned MSI_RecordGetStringW( const LibmsiRecord *, unsigned, WCHAR *, unsigned *); +extern intptr_t MSI_RecordGetIntPtr( const LibmsiRecord *, unsigned ); +extern unsigned MSI_RecordReadStream( const LibmsiRecord *, unsigned, char *, unsigned *); extern unsigned MSI_RecordSetStream(LibmsiRecord *, unsigned, IStream *); -extern unsigned MSI_RecordGetFieldCount( const LibmsiRecord *rec ); -extern unsigned MSI_RecordStreamToFile( LibmsiRecord *, unsigned, const WCHAR *); +extern unsigned MSI_RecordStreamToFile( const LibmsiRecord *, unsigned, const WCHAR *); extern unsigned MSI_RecordSetStreamFromFile( LibmsiRecord *, unsigned, const char *); extern unsigned MSI_RecordCopyField( LibmsiRecord *, unsigned, LibmsiRecord *, unsigned ); extern LibmsiRecord *MSI_CloneRecord( LibmsiRecord * ); -extern bool MSI_RecordsAreEqual( LibmsiRecord *, LibmsiRecord * ); -extern bool MSI_RecordsAreFieldsEqual(LibmsiRecord *a, LibmsiRecord *b, unsigned field); +extern bool MSI_RecordsAreEqual( const LibmsiRecord *, const LibmsiRecord * ); +extern bool MSI_RecordsAreFieldsEqual(const LibmsiRecord *a, const LibmsiRecord *b, unsigned field); /* stream internals */ extern void enum_stream_names( IStorage *stg ); @@ -373,7 +357,6 @@ extern void decode_streamname(const WCHAR *in, WCHAR *out); extern unsigned msi_get_raw_stream( LibmsiDatabase *, const WCHAR *, IStream **); extern unsigned msi_clone_open_stream( LibmsiDatabase *, IStorage *, const WCHAR *, IStream ** ); void msi_destroy_stream( LibmsiDatabase *, const WCHAR * ); -extern unsigned MSI_OpenDatabaseW( const WCHAR *, const WCHAR *, LibmsiDatabase **); extern unsigned MSI_DatabaseOpenQueryW(LibmsiDatabase *, const WCHAR *, LibmsiQuery **); extern unsigned MSI_OpenQuery( LibmsiDatabase *, LibmsiQuery **, const WCHAR *, ... ); typedef unsigned (*record_func)( LibmsiRecord *, void *); @@ -384,7 +367,6 @@ extern unsigned MSI_DatabaseGetPrimaryKeys( LibmsiDatabase *, const WCHAR *, Lib /* view internals */ extern unsigned MSI_QueryExecute( LibmsiQuery*, LibmsiRecord * ); extern unsigned MSI_QueryFetch( LibmsiQuery*, LibmsiRecord ** ); -extern unsigned MSI_QueryClose( LibmsiQuery* ); extern unsigned MSI_QueryGetColumnInfo(LibmsiQuery *, LibmsiColInfo, LibmsiRecord **); extern unsigned MSI_QueryModify( LibmsiQuery *, LibmsiModify, LibmsiRecord * ); extern unsigned VIEW_find_column( LibmsiView *, const WCHAR *, const WCHAR *, unsigned *); diff --git a/libmsi/msiquery.c b/libmsi/msiquery.c index 47635f3..3b23c0e 100644 --- a/libmsi/msiquery.c +++ b/libmsi/msiquery.c @@ -84,15 +84,13 @@ unsigned VIEW_find_column( LibmsiView *table, const WCHAR *name, const WCHAR *ta return ERROR_INVALID_PARAMETER; } -unsigned MsiDatabaseOpenQuery(LibmsiObject *hdb, - const char *szQuery, LibmsiObject **phView) +unsigned MsiDatabaseOpenQuery(LibmsiDatabase *db, + const char *szQuery, LibmsiQuery **pQuery) { unsigned r; WCHAR *szwQuery; - LibmsiDatabase *db; - LibmsiQuery *query = NULL; - TRACE("%d %s %p\n", hdb, debugstr_a(szQuery), phView); + TRACE("%d %s %p\n", db, debugstr_a(szQuery), pQuery); if( szQuery ) { @@ -103,15 +101,11 @@ unsigned MsiDatabaseOpenQuery(LibmsiObject *hdb, else szwQuery = NULL; - TRACE("%s %p\n", debugstr_w(szQuery), phView); - - db = msihandle2msiinfo( hdb, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; + msiobj_addref( &db->hdr); - r = MSI_DatabaseOpenQueryW( db, szwQuery, &query ); - if( r == ERROR_SUCCESS ) - *phView = &query->hdr; + r = MSI_DatabaseOpenQueryW( db, szwQuery, pQuery ); msiobj_release( &db->hdr ); msi_free( szwQuery ); @@ -130,8 +124,7 @@ unsigned MSI_DatabaseOpenQueryW(LibmsiDatabase *db, return ERROR_INVALID_PARAMETER; /* pre allocate a handle to hold a pointer to the view */ - query = alloc_msiobject( LIBMSI_OBJECT_TYPE_QUERY, sizeof (LibmsiQuery), - MSI_CloseQuery ); + query = alloc_msiobject( sizeof (LibmsiQuery), MSI_CloseQuery ); if( !query ) return ERROR_FUNCTION_FAILED; @@ -201,7 +194,7 @@ unsigned MSI_IterateRecords( LibmsiQuery *view, unsigned *count, break; } - MSI_QueryClose( view ); + MsiQueryClose( view ); if( count ) *count = n; @@ -242,7 +235,7 @@ LibmsiRecord *MSI_QueryGetRecord( LibmsiDatabase *db, const WCHAR *fmt, ... ) { MSI_QueryExecute( view, NULL ); MSI_QueryFetch( view, &rec ); - MSI_QueryClose( view ); + MsiQueryClose( view ); msiobj_release( &view->hdr ); } return rec; @@ -264,7 +257,7 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li if (row >= row_count) return ERROR_NO_MORE_ITEMS; - *rec = MSI_CreateRecord(col_count); + *rec = MsiCreateRecord(col_count); if (!*rec) return ERROR_FUNCTION_FAILED; @@ -317,9 +310,9 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li else { if ((type & MSI_DATASIZEMASK) == 2) - MSI_RecordSetInteger(*rec, i, ival - (1<<15)); + MsiRecordSetInteger(*rec, i, ival - (1<<15)); else - MSI_RecordSetInteger(*rec, i, ival - (1<<31)); + MsiRecordSetInteger(*rec, i, ival - (1<<31)); } } @@ -347,55 +340,42 @@ unsigned MSI_QueryFetch(LibmsiQuery *query, LibmsiRecord **prec) return r; } -unsigned MsiQueryFetch(LibmsiObject *hView, LibmsiObject **record) +unsigned MsiQueryFetch(LibmsiQuery *query, LibmsiRecord **record) { - LibmsiQuery *query; - LibmsiRecord *rec = NULL; unsigned ret; - TRACE("%d %p\n", hView, record); + TRACE("%d %p\n", query, record); if( !record ) return ERROR_INVALID_PARAMETER; *record = 0; - query = msihandle2msiinfo( hView, LIBMSI_OBJECT_TYPE_QUERY ); if( !query ) return ERROR_INVALID_HANDLE; - ret = MSI_QueryFetch( query, &rec ); - if( ret == ERROR_SUCCESS ) - *record = &rec->hdr; + msiobj_addref( &query->hdr); + ret = MSI_QueryFetch( query, record ); msiobj_release( &query->hdr ); return ret; } -unsigned MSI_QueryClose(LibmsiQuery *query) +unsigned MsiQueryClose(LibmsiQuery *query) { LibmsiView *view; + unsigned ret; TRACE("%p\n", query ); + if( !query ) + return ERROR_INVALID_HANDLE; + + msiobj_addref( &query->hdr ); view = query->view; if( !view ) return ERROR_FUNCTION_FAILED; if( !view->ops->close ) return ERROR_FUNCTION_FAILED; - return view->ops->close( view ); -} - -unsigned MsiQueryClose(LibmsiObject *hView) -{ - LibmsiQuery *query; - unsigned ret; - - TRACE("%d\n", hView ); - - query = msihandle2msiinfo( hView, LIBMSI_OBJECT_TYPE_QUERY ); - if( !query ) - return ERROR_INVALID_HANDLE; - - ret = MSI_QueryClose( query ); + ret = view->ops->close( view ); msiobj_release( &query->hdr ); return ret; } @@ -416,31 +396,21 @@ unsigned MSI_QueryExecute(LibmsiQuery *query, LibmsiRecord *rec ) return view->ops->execute( view, rec ); } -unsigned MsiQueryExecute(LibmsiObject *hView, LibmsiObject *hRec) +unsigned MsiQueryExecute(LibmsiQuery *query, LibmsiRecord *rec) { - LibmsiQuery *query; - LibmsiRecord *rec = NULL; unsigned ret; - TRACE("%d %d\n", hView, hRec); + TRACE("%d %d\n", query, rec); - query = msihandle2msiinfo( hView, LIBMSI_OBJECT_TYPE_QUERY ); if( !query ) return ERROR_INVALID_HANDLE; + msiobj_addref( &query->hdr ); - if( hRec ) - { - rec = msihandle2msiinfo( hRec, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - { - ret = ERROR_INVALID_HANDLE; - goto out; - } - } + if( rec ) + msiobj_addref( &rec->hdr ); ret = MSI_QueryExecute( query, rec ); -out: msiobj_release( &query->hdr ); if( rec ) msiobj_release( &rec->hdr ); @@ -505,7 +475,7 @@ unsigned MSI_QueryGetColumnInfo( LibmsiQuery *query, LibmsiColInfo info, LibmsiR if( !count ) return ERROR_INVALID_PARAMETER; - rec = MSI_CreateRecord( count ); + rec = MsiCreateRecord( count ); if( !rec ) return ERROR_FUNCTION_FAILED; @@ -524,28 +494,23 @@ unsigned MSI_QueryGetColumnInfo( LibmsiQuery *query, LibmsiColInfo info, LibmsiR return ERROR_SUCCESS; } -unsigned MsiQueryGetColumnInfo(LibmsiObject *hView, LibmsiColInfo info, LibmsiObject **hRec) +unsigned MsiQueryGetColumnInfo(LibmsiQuery *query, LibmsiColInfo info, LibmsiRecord **prec) { - LibmsiQuery *query = NULL; - LibmsiRecord *rec = NULL; unsigned r; - TRACE("%d %d %p\n", hView, info, hRec); + TRACE("%d %d %p\n", query, info, prec); - if( !hRec ) + if( !prec ) return ERROR_INVALID_PARAMETER; if( info != LIBMSI_COL_INFO_NAMES && info != LIBMSI_COL_INFO_TYPES ) return ERROR_INVALID_PARAMETER; - query = msihandle2msiinfo( hView, LIBMSI_OBJECT_TYPE_QUERY ); if( !query ) return ERROR_INVALID_HANDLE; - r = MSI_QueryGetColumnInfo( query, info, &rec ); - if ( r == ERROR_SUCCESS ) - *hRec = &rec->hdr; - + msiobj_addref ( &query->hdr ); + r = MSI_QueryGetColumnInfo( query, info, prec ); msiobj_release( &query->hdr ); return r; @@ -573,20 +538,21 @@ unsigned MSI_QueryModify( LibmsiQuery *query, LibmsiModify mode, LibmsiRecord *r return r; } -unsigned MsiQueryModify( LibmsiObject *hView, LibmsiModify eModifyMode, - LibmsiObject *hRecord) +unsigned MsiQueryModify( LibmsiQuery *query, LibmsiModify eModifyMode, + LibmsiRecord *rec) { - LibmsiQuery *query = NULL; - LibmsiRecord *rec = NULL; unsigned r = ERROR_FUNCTION_FAILED; - TRACE("%d %x %d\n", hView, eModifyMode, hRecord); + TRACE("%d %x %d\n", query, eModifyMode, rec); - query = msihandle2msiinfo( hView, LIBMSI_OBJECT_TYPE_QUERY ); if( !query ) return ERROR_INVALID_HANDLE; - rec = msihandle2msiinfo( hRecord, LIBMSI_OBJECT_TYPE_RECORD ); + msiobj_addref( &query->hdr); + + if (rec) + msiobj_addref( &rec->hdr); + r = MSI_QueryModify( query, eModifyMode, rec ); msiobj_release( &query->hdr ); @@ -596,22 +562,21 @@ unsigned MsiQueryModify( LibmsiObject *hView, LibmsiModify eModifyMode, return r; } -LibmsiDBError MsiQueryGetError( LibmsiObject *handle, char *buffer, unsigned *buflen ) +LibmsiDBError MsiQueryGetError( LibmsiQuery *query, char *buffer, unsigned *buflen ) { - LibmsiQuery *query; const WCHAR *column; LibmsiDBError r; unsigned len; - TRACE("%u %p %p\n", handle, buffer, buflen); + TRACE("%u %p %p\n", query, buffer, buflen); if (!buflen) return LIBMSI_DB_ERROR_INVALIDARG; - query = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_QUERY ); if (!query) return LIBMSI_DB_ERROR_INVALIDARG; + msiobj_addref( &query->hdr); if ((r = query->view->error)) column = query->view->error_column; else column = szEmpty; @@ -668,13 +633,12 @@ end: return ret; } -unsigned MsiDatabaseApplyTransform( LibmsiObject *hdb, +unsigned MsiDatabaseApplyTransform( LibmsiDatabase *db, const char *szTransformFile, int iErrorCond) { - LibmsiDatabase *db; unsigned r; - db = msihandle2msiinfo( hdb, LIBMSI_OBJECT_TYPE_DATABASE ); + msiobj_addref( &db->hdr ); if( !db ) return ERROR_INVALID_HANDLE; r = MSI_DatabaseApplyTransform( db, szTransformFile, iErrorCond ); @@ -682,14 +646,13 @@ unsigned MsiDatabaseApplyTransform( LibmsiObject *hdb, return r; } -unsigned MsiDatabaseCommit( LibmsiObject *hdb ) +unsigned MsiDatabaseCommit( LibmsiDatabase *db ) { - LibmsiDatabase *db; unsigned r; - TRACE("%d\n", hdb); + TRACE("%d\n", db); - db = msihandle2msiinfo( hdb, LIBMSI_OBJECT_TYPE_DATABASE ); + msiobj_addref( &db->hdr ); if( !db ) return ERROR_INVALID_HANDLE; @@ -730,7 +693,7 @@ static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param ) const WCHAR *table; unsigned type; - type = MSI_RecordGetInteger( rec, 4 ); + type = MsiRecordGetInteger( rec, 4 ); if( type & MSITYPE_KEY ) { info->n++; @@ -738,11 +701,11 @@ static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param ) { if ( info->n == 1 ) { - table = MSI_RecordGetString( rec, 1 ); + table = MSI_RecordGetStringRaw( rec, 1 ); MSI_RecordSetStringW( info->rec, 0, table); } - name = MSI_RecordGetString( rec, 3 ); + name = MSI_RecordGetStringRaw( rec, 3 ); MSI_RecordSetStringW( info->rec, info->n, name ); } } @@ -778,7 +741,7 @@ unsigned MSI_DatabaseGetPrimaryKeys( LibmsiDatabase *db, TRACE("Found %d primary keys\n", info.n ); /* allocate a record and fill in the names of the tables */ - info.rec = MSI_CreateRecord( info.n ); + info.rec = MsiCreateRecord( info.n ); info.n = 0; r = MSI_IterateRecords( query, 0, msi_primary_key_iterator, &info ); if( r == ERROR_SUCCESS ) @@ -791,15 +754,13 @@ unsigned MSI_DatabaseGetPrimaryKeys( LibmsiDatabase *db, return r; } -unsigned MsiDatabaseGetPrimaryKeys(LibmsiObject *hdb, - const char *table, LibmsiObject **phRec) +unsigned MsiDatabaseGetPrimaryKeys(LibmsiDatabase *db, + const char *table, LibmsiRecord **prec) { - LibmsiRecord *rec = NULL; - LibmsiDatabase *db; WCHAR *szwTable = NULL; unsigned r; - TRACE("%d %s %p\n", hdb, debugstr_a(table), phRec); + TRACE("%d %s %p\n", db, debugstr_a(table), prec); if( table ) { @@ -808,13 +769,11 @@ unsigned MsiDatabaseGetPrimaryKeys(LibmsiObject *hdb, return ERROR_OUTOFMEMORY; } - db = msihandle2msiinfo( hdb, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; - r = MSI_DatabaseGetPrimaryKeys( db, szwTable, &rec ); - if( r == ERROR_SUCCESS ) - *phRec = &rec->hdr; + msiobj_addref( &db->hdr ); + r = MSI_DatabaseGetPrimaryKeys( db, szwTable, prec ); msiobj_release( &db->hdr ); msi_free( szwTable ); @@ -822,13 +781,12 @@ unsigned MsiDatabaseGetPrimaryKeys(LibmsiObject *hdb, } LibmsiCondition MsiDatabaseIsTablePersistent( - LibmsiObject *hDatabase, const char *szTableName) + LibmsiDatabase *db, const char *szTableName) { WCHAR *szwTableName = NULL; - LibmsiDatabase *db; LibmsiCondition r; - TRACE("%x %s\n", hDatabase, debugstr_a(szTableName)); + TRACE("%x %s\n", db, debugstr_a(szTableName)); if( szTableName ) { @@ -837,7 +795,7 @@ LibmsiCondition MsiDatabaseIsTablePersistent( return LIBMSI_CONDITION_ERROR; } - db = msihandle2msiinfo( hDatabase, LIBMSI_OBJECT_TYPE_DATABASE ); + msiobj_addref( &db->hdr ); if( !db ) return LIBMSI_CONDITION_ERROR; diff --git a/libmsi/record.c b/libmsi/record.c index 23b6cc2..0d3405f 100644 --- a/libmsi/record.c +++ b/libmsi/record.c @@ -72,7 +72,7 @@ void MSI_CloseRecord( LibmsiObject *arg ) MSI_FreeField( &rec->fields[i] ); } -LibmsiRecord *MSI_CreateRecord( unsigned cParams ) +LibmsiRecord *MsiCreateRecord( unsigned cParams ) { LibmsiRecord *rec; unsigned len; @@ -83,42 +83,18 @@ LibmsiRecord *MSI_CreateRecord( unsigned cParams ) return NULL; len = sizeof (LibmsiRecord) + sizeof (LibmsiField)*cParams; - rec = alloc_msiobject( LIBMSI_OBJECT_TYPE_RECORD, len, MSI_CloseRecord ); + rec = alloc_msiobject( len, MSI_CloseRecord ); if( rec ) rec->count = cParams; return rec; } -LibmsiObject * MsiCreateRecord( unsigned cParams ) +unsigned MsiRecordGetFieldCount( const LibmsiRecord *rec ) { - LibmsiRecord *rec; - - TRACE("%d\n", cParams); - - rec = MSI_CreateRecord( cParams ); - return &rec->hdr; -} - -unsigned MSI_RecordGetFieldCount( const LibmsiRecord *rec ) -{ - return rec->count; -} - -unsigned MsiRecordGetFieldCount( LibmsiObject *handle ) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d\n", handle ); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); if( !rec ) return -1; - ret = MSI_RecordGetFieldCount( rec ); - msiobj_release( &rec->hdr ); - - return ret; + return rec->count; } static bool string2intW( const WCHAR *str, int *out ) @@ -190,7 +166,7 @@ unsigned MSI_RecordCopyField( LibmsiRecord *in_rec, unsigned in_n, return r; } -intptr_t MSI_RecordGetIntPtr( LibmsiRecord *rec, unsigned iField ) +intptr_t MSI_RecordGetIntPtr( const LibmsiRecord *rec, unsigned iField ) { int ret; @@ -216,12 +192,15 @@ intptr_t MSI_RecordGetIntPtr( LibmsiRecord *rec, unsigned iField ) return INTPTR_MIN; } -int MSI_RecordGetInteger( LibmsiRecord *rec, unsigned iField) +int MsiRecordGetInteger( const LibmsiRecord *rec, unsigned iField) { int ret = 0; TRACE("%p %d\n", rec, iField ); + if( !rec ) + return MSI_NULL_INTEGER; + if( iField > rec->count ) return MSI_NULL_INTEGER; @@ -242,34 +221,16 @@ int MSI_RecordGetInteger( LibmsiRecord *rec, unsigned iField) return MSI_NULL_INTEGER; } -int MsiRecordGetInteger( LibmsiObject *handle, unsigned iField) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %d\n", handle, iField ); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - return MSI_NULL_INTEGER; - - ret = MSI_RecordGetInteger( rec, iField ); - msiobj_release( &rec->hdr ); - - return ret; -} - -unsigned MsiRecordClearData( LibmsiObject *handle ) +unsigned MsiRecordClearData( LibmsiRecord *rec ) { - LibmsiRecord *rec; unsigned i; - TRACE("%d\n", handle ); + TRACE("%d\n", rec ); - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; + msiobj_addref( &rec->hdr ); for( i=0; i<=rec->count; i++) { MSI_FreeField( &rec->fields[i] ); @@ -295,10 +256,13 @@ unsigned MSI_RecordSetIntPtr( LibmsiRecord *rec, unsigned iField, intptr_t pVal return ERROR_SUCCESS; } -unsigned MSI_RecordSetInteger( LibmsiRecord *rec, unsigned iField, int iVal ) +unsigned MsiRecordSetInteger( LibmsiRecord *rec, unsigned iField, int iVal ) { TRACE("%p %u %d\n", rec, iField, iVal); + if( !rec ) + return ERROR_INVALID_HANDLE; + if( iField > rec->count ) return ERROR_INVALID_PARAMETER; @@ -309,51 +273,22 @@ unsigned MSI_RecordSetInteger( LibmsiRecord *rec, unsigned iField, int iVal ) return ERROR_SUCCESS; } -unsigned MsiRecordSetInteger( LibmsiObject *handle, unsigned iField, int iVal ) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %u %d\n", handle, iField, iVal); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - return ERROR_INVALID_HANDLE; - - ret = MSI_RecordSetInteger( rec, iField, iVal ); - msiobj_release( &rec->hdr ); - return ret; -} - -bool MSI_RecordIsNull( LibmsiRecord *rec, unsigned iField ) +bool MsiRecordIsNull( const LibmsiRecord *rec, unsigned iField ) { bool r = true; TRACE("%p %d\n", rec, iField ); + if( !rec ) + return 0; + r = ( iField > rec->count ) || ( rec->fields[iField].type == LIBMSI_FIELD_TYPE_NULL ); return r; } -bool MsiRecordIsNull( LibmsiObject *handle, unsigned iField ) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %d\n", handle, iField ); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - return 0; - ret = MSI_RecordIsNull( rec, iField ); - msiobj_release( &rec->hdr ); - return ret; - -} - -unsigned MSI_RecordGetStringA(LibmsiRecord *rec, unsigned iField, +unsigned MsiRecordGetString(const LibmsiRecord *rec, unsigned iField, char *szValue, unsigned *pcchValue) { unsigned len=0, ret; @@ -361,6 +296,9 @@ unsigned MSI_RecordGetStringA(LibmsiRecord *rec, unsigned iField, TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue); + if( !rec ) + return ERROR_INVALID_HANDLE; + if( iField > rec->count ) { if ( szValue && *pcchValue > 0 ) @@ -406,23 +344,7 @@ unsigned MSI_RecordGetStringA(LibmsiRecord *rec, unsigned iField, return ret; } -unsigned MsiRecordGetString(LibmsiObject *handle, unsigned iField, - char *szValue, unsigned *pcchValue) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %d %p %p\n", handle, iField, szValue, pcchValue); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - return ERROR_INVALID_HANDLE; - ret = MSI_RecordGetStringA( rec, iField, szValue, pcchValue); - msiobj_release( &rec->hdr ); - return ret; -} - -const WCHAR *MSI_RecordGetString( const LibmsiRecord *rec, unsigned iField ) +const WCHAR *MSI_RecordGetStringRaw( const LibmsiRecord *rec, unsigned iField ) { if( iField > rec->count ) return NULL; @@ -433,7 +355,7 @@ const WCHAR *MSI_RecordGetString( const LibmsiRecord *rec, unsigned iField ) return rec->fields[iField].u.szwVal; } -unsigned MSI_RecordGetStringW(LibmsiRecord *rec, unsigned iField, +unsigned MSI_RecordGetStringW(const LibmsiRecord *rec, unsigned iField, WCHAR *szValue, unsigned *pcchValue) { unsigned len=0, ret; @@ -491,10 +413,13 @@ static unsigned msi_get_stream_size( IStream *stm ) return stat.cbSize.QuadPart; } -static unsigned MSI_RecordDataSize(LibmsiRecord *rec, unsigned iField) +unsigned MsiRecordDataSize(const LibmsiRecord *rec, unsigned iField) { TRACE("%p %d\n", rec, iField); + if( !rec ) + return 0; + if( iField > rec->count ) return 0; @@ -512,59 +437,17 @@ static unsigned MSI_RecordDataSize(LibmsiRecord *rec, unsigned iField) return 0; } -unsigned MsiRecordDataSize(LibmsiObject *handle, unsigned iField) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %d\n", handle, iField); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); - if( !rec ) - return 0; - ret = MSI_RecordDataSize( rec, iField); - msiobj_release( &rec->hdr ); - return ret; -} - -static unsigned MSI_RecordSetStringA( LibmsiRecord *rec, unsigned iField, const char *szValue ) +unsigned MsiRecordSetString( LibmsiRecord *rec, unsigned iField, const char *szValue ) { WCHAR *str; - TRACE("%p %d %s\n", rec, iField, debugstr_a(szValue)); - - if( iField > rec->count ) - return ERROR_INVALID_FIELD; + TRACE("%d %d %s\n", rec, iField, debugstr_a(szValue)); - MSI_FreeField( &rec->fields[iField] ); - if( szValue && szValue[0] ) - { - str = strdupAtoW( szValue ); - rec->fields[iField].type = LIBMSI_FIELD_TYPE_WSTR; - rec->fields[iField].u.szwVal = str; - } - else - { - rec->fields[iField].type = LIBMSI_FIELD_TYPE_NULL; - rec->fields[iField].u.szwVal = NULL; - } - - return 0; -} - -unsigned MsiRecordSetString( LibmsiObject *handle, unsigned iField, const char *szValue ) -{ - LibmsiRecord *rec; - unsigned ret; - - TRACE("%d %d %s\n", handle, iField, debugstr_a(szValue)); - - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; - ret = MSI_RecordSetStringA( rec, iField, szValue ); - msiobj_release( &rec->hdr ); - return ret; + + str = strdupAtoW( szValue ); + return MSI_RecordSetStringW( rec, iField, str ); } unsigned MSI_RecordSetStringW( LibmsiRecord *rec, unsigned iField, const WCHAR *szValue ) @@ -602,7 +485,7 @@ static unsigned RECORD_StreamFromFile(const char *szFile, IStream **pstm) HRESULT hr; ULARGE_INTEGER ulSize; - TRACE("reading %s\n", debugstr_w(szFile)); + TRACE("reading %s\n", debugstr_a(szFile)); /* read the file into memory */ handle = CreateFileA(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -638,7 +521,7 @@ static unsigned RECORD_StreamFromFile(const char *szFile, IStream **pstm) ulSize.QuadPart = sz; IStream_SetSize(*pstm, ulSize); - TRACE("read %s, %d bytes into IStream %p\n", debugstr_w(szFile), sz, *pstm); + TRACE("read %s, %d bytes into IStream %p\n", debugstr_a(szFile), sz, *pstm); return ERROR_SUCCESS; } @@ -695,23 +578,22 @@ unsigned MSI_RecordSetStreamFromFile(LibmsiRecord *rec, unsigned iField, const c return ERROR_SUCCESS; } -unsigned MsiRecordSetStream(LibmsiObject *handle, unsigned iField, const char *szFilename) +unsigned MsiRecordSetStream(LibmsiRecord *rec, unsigned iField, const char *szFilename) { - LibmsiRecord *rec; unsigned ret; - TRACE("%d %d %s\n", handle, iField, debugstr_w(szFilename)); + TRACE("%d %d %s\n", rec, iField, debugstr_a(szFilename)); - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; + msiobj_addref( &rec->hdr ); ret = MSI_RecordSetStreamFromFile( rec, iField, szFilename ); msiobj_release( &rec->hdr ); return ret; } -unsigned MSI_RecordReadStream(LibmsiRecord *rec, unsigned iField, char *buf, unsigned *sz) +unsigned MSI_RecordReadStream(const LibmsiRecord *rec, unsigned iField, char *buf, unsigned *sz) { unsigned count; HRESULT r; @@ -769,16 +651,16 @@ unsigned MSI_RecordReadStream(LibmsiRecord *rec, unsigned iField, char *buf, uns return ERROR_SUCCESS; } -unsigned MsiRecordReadStream(LibmsiObject *handle, unsigned iField, char *buf, unsigned *sz) +unsigned MsiRecordReadStream(LibmsiRecord *rec, unsigned iField, char *buf, unsigned *sz) { - LibmsiRecord *rec; unsigned ret; - TRACE("%d %d %p %p\n", handle, iField, buf, sz); + TRACE("%d %d %p %p\n", rec, iField, buf, sz); - rec = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; + + msiobj_addref( &rec->hdr ); ret = MSI_RecordReadStream( rec, iField, buf, sz ); msiobj_release( &rec->hdr ); return ret; @@ -800,7 +682,7 @@ unsigned MSI_RecordSetIStream( LibmsiRecord *rec, unsigned iField, IStream *stm return ERROR_SUCCESS; } -unsigned MSI_RecordGetIStream( LibmsiRecord *rec, unsigned iField, IStream **pstm) +unsigned MSI_RecordGetIStream( const LibmsiRecord *rec, unsigned iField, IStream **pstm) { TRACE("%p %d %p\n", rec, iField, pstm); @@ -848,7 +730,7 @@ end: return ERROR_SUCCESS; } -unsigned MSI_RecordStreamToFile( LibmsiRecord *rec, unsigned iField, const WCHAR *name ) +unsigned MSI_RecordStreamToFile( const LibmsiRecord *rec, unsigned iField, const WCHAR *name ) { IStream *stm = NULL; unsigned r; @@ -870,8 +752,8 @@ LibmsiRecord *MSI_CloneRecord(LibmsiRecord *rec) LibmsiRecord *clone; unsigned r, i, count; - count = MSI_RecordGetFieldCount(rec); - clone = MSI_CreateRecord(count); + count = MsiRecordGetFieldCount(rec); + clone = MsiCreateRecord(count); if (!clone) return NULL; @@ -901,7 +783,7 @@ LibmsiRecord *MSI_CloneRecord(LibmsiRecord *rec) return clone; } -bool MSI_RecordsAreFieldsEqual(LibmsiRecord *a, LibmsiRecord *b, unsigned field) +bool MSI_RecordsAreFieldsEqual(const LibmsiRecord *a, const LibmsiRecord *b, unsigned field) { if (a->fields[field].type != b->fields[field].type) return false; @@ -929,7 +811,7 @@ bool MSI_RecordsAreFieldsEqual(LibmsiRecord *a, LibmsiRecord *b, unsigned field) } -bool MSI_RecordsAreEqual(LibmsiRecord *a, LibmsiRecord *b) +bool MSI_RecordsAreEqual(const LibmsiRecord *a, const LibmsiRecord *b) { unsigned i; @@ -951,7 +833,7 @@ WCHAR *msi_dup_record_field( LibmsiRecord *rec, int field ) WCHAR *str; unsigned r; - if (MSI_RecordIsNull( rec, field )) return NULL; + if (MsiRecordIsNull( rec, field )) return NULL; r = MSI_RecordGetStringW( rec, field, NULL, &sz ); if (r != ERROR_SUCCESS) diff --git a/libmsi/select.c b/libmsi/select.c index c23f239..636e4d4 100644 --- a/libmsi/select.c +++ b/libmsi/select.c @@ -121,7 +121,7 @@ static unsigned SELECT_set_row( LibmsiView *view, unsigned row, LibmsiRecord *re return r; /* expand the record to the right size for the underlying table */ - expanded = MSI_CreateRecord( col_count ); + expanded = MsiCreateRecord( col_count ); if ( !expanded ) return ERROR_FUNCTION_FAILED; @@ -158,7 +158,7 @@ static unsigned SELECT_insert_row( LibmsiView *view, LibmsiRecord *record, unsig if (r != ERROR_SUCCESS) return r; - outrec = MSI_CreateRecord( table_cols + 1 ); + outrec = MsiCreateRecord( table_cols + 1 ); for (i=0; i<sv->num_cols; i++) { @@ -274,13 +274,13 @@ static unsigned msi_select_update(LibmsiView *view, LibmsiRecord *rec, unsigned } else if (type & MSITYPE_STRING) { - str = MSI_RecordGetString(rec, i + 1); + str = MSI_RecordGetStringRaw(rec, i + 1); r = MSI_RecordSetStringW(mod, col, str); } else { - val = MSI_RecordGetInteger(rec, i + 1); - r = MSI_RecordSetInteger(mod, col, val); + val = MsiRecordGetInteger(rec, i + 1); + r = MsiRecordSetInteger(mod, col, val); } if (r != ERROR_SUCCESS) diff --git a/libmsi/storages.c b/libmsi/storages.c index 5a875a0..387b431 100644 --- a/libmsi/storages.c +++ b/libmsi/storages.c @@ -195,7 +195,7 @@ static unsigned STORAGES_set_row(LibmsiView *view, unsigned row, LibmsiRecord *r return r; } - name = strdupW(MSI_RecordGetString(rec, 1)); + name = strdupW(MSI_RecordGetStringRaw(rec, 1)); if (!name) { r = ERROR_OUTOFMEMORY; @@ -308,7 +308,7 @@ static unsigned storages_find_row(LibmsiStorageView *sv, LibmsiRecord *rec, unsi const WCHAR *str; unsigned r, i, id, data; - str = MSI_RecordGetString(rec, 1); + str = MSI_RecordGetStringRaw(rec, 1); r = msi_string2idW(sv->db->strings, str, &id); if (r != ERROR_SUCCESS) return r; diff --git a/libmsi/streams.c b/libmsi/streams.c index ee8ba25..9b86043 100644 --- a/libmsi/streams.c +++ b/libmsi/streams.c @@ -174,7 +174,7 @@ static unsigned STREAMS_set_row(LibmsiView *view, unsigned row, LibmsiRecord *re goto done; } - name = strdupW(MSI_RecordGetString(rec, 1)); + name = strdupW(MSI_RecordGetStringRaw(rec, 1)); if (!name) { WARN("failed to retrieve stream name\n"); @@ -298,7 +298,7 @@ static unsigned streams_find_row(LibmsiStreamSVIEW *sv, LibmsiRecord *rec, unsig const WCHAR *str; unsigned r, i, id, data; - str = MSI_RecordGetString(rec, 1); + str = MSI_RecordGetStringRaw(rec, 1); r = msi_string2idW(sv->db->strings, str, &id); if (r != ERROR_SUCCESS) return r; diff --git a/libmsi/suminfo.c b/libmsi/suminfo.c index d405eff..7d40b0f 100644 --- a/libmsi/suminfo.c +++ b/libmsi/suminfo.c @@ -441,8 +441,7 @@ LibmsiSummaryInfo *MSI_GetSummaryInformation( IStorage *stg, unsigned uiUpdateCo TRACE("%p %d\n", stg, uiUpdateCount ); - si = alloc_msiobject( LIBMSI_OBJECT_TYPE_SUMMARYINFO, - sizeof (LibmsiSummaryInfo), MSI_CloseSummaryInfo ); + si = alloc_msiobject( sizeof (LibmsiSummaryInfo), MSI_CloseSummaryInfo ); if( !si ) return si; @@ -462,26 +461,25 @@ LibmsiSummaryInfo *MSI_GetSummaryInformation( IStorage *stg, unsigned uiUpdateCo return si; } -unsigned MsiGetSummaryInformation( LibmsiObject *hDatabase, - unsigned uiUpdateCount, LibmsiObject **pHandle ) +unsigned MsiGetSummaryInformation( LibmsiDatabase *db, + unsigned uiUpdateCount, LibmsiSummaryInfo **psi ) { LibmsiSummaryInfo *si; - LibmsiDatabase *db; unsigned ret = ERROR_FUNCTION_FAILED; - TRACE("%d %d %p\n", hDatabase, uiUpdateCount, pHandle); + TRACE("%d %d %p\n", db, uiUpdateCount, psi); - if( !pHandle ) + if( !psi ) return ERROR_INVALID_PARAMETER; - db = msihandle2msiinfo( hDatabase, LIBMSI_OBJECT_TYPE_DATABASE ); if( !db ) return ERROR_INVALID_HANDLE; + msiobj_addref( &db->hdr); si = MSI_GetSummaryInformation( db->storage, uiUpdateCount ); if (si) { - *pHandle = &si->hdr; + *psi = si; ret = ERROR_SUCCESS; } @@ -489,16 +487,14 @@ unsigned MsiGetSummaryInformation( LibmsiObject *hDatabase, return ret; } -unsigned MsiSummaryInfoGetPropertyCount(LibmsiObject *hSummaryInfo, unsigned *pCount) +unsigned MsiSummaryInfoGetPropertyCount(LibmsiSummaryInfo *si, unsigned *pCount) { - LibmsiSummaryInfo *si; - - TRACE("%d %p\n", hSummaryInfo, pCount); + TRACE("%d %p\n", si, pCount); - si = msihandle2msiinfo( hSummaryInfo, LIBMSI_OBJECT_TYPE_SUMMARYINFO ); if( !si ) return ERROR_INVALID_HANDLE; + msiobj_addref( &si->hdr ); if( pCount ) *pCount = get_property_count( si->property ); msiobj_release( &si->hdr ); @@ -507,14 +503,13 @@ unsigned MsiSummaryInfoGetPropertyCount(LibmsiObject *hSummaryInfo, unsigned *pC } unsigned MsiSummaryInfoGetProperty( - LibmsiObject *handle, unsigned uiProperty, unsigned *puiDataType, int *piValue, + LibmsiSummaryInfo *si, unsigned uiProperty, unsigned *puiDataType, int *piValue, uint64_t *pftValue, char *szValueBuf, unsigned *pcchValueBuf) { - LibmsiSummaryInfo *si; PROPVARIANT *prop; unsigned ret = ERROR_SUCCESS; - TRACE("%d %d %p %p %p %p %p\n", handle, uiProperty, puiDataType, + TRACE("%d %d %p %p %p %p %p\n", si, uiProperty, puiDataType, piValue, pftValue, szValueBuf, pcchValueBuf); if ( uiProperty >= MSI_MAX_PROPS ) @@ -523,10 +518,10 @@ unsigned MsiSummaryInfoGetProperty( return ERROR_UNKNOWN_PROPERTY; } - si = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_SUMMARYINFO ); if( !si ) return ERROR_INVALID_HANDLE; + msiobj_addref( &si->hdr ); prop = &si->property[uiProperty]; if( puiDataType ) @@ -609,10 +604,9 @@ WCHAR *msi_get_suminfo_product( IStorage *stg ) return prod; } -unsigned MsiSummaryInfoSetProperty( LibmsiObject *handle, unsigned uiProperty, +unsigned MsiSummaryInfoSetProperty( LibmsiSummaryInfo *si, unsigned uiProperty, unsigned uiDataType, int iValue, uint64_t* pftValue, const char *szValue ) { - LibmsiSummaryInfo *si; PROPVARIANT *prop; unsigned len; unsigned ret; @@ -621,6 +615,9 @@ unsigned MsiSummaryInfoSetProperty( LibmsiObject *handle, unsigned uiProperty, TRACE("%p %u %u %i %p %p\n", si, uiProperty, type, iValue, pftValue, szValue ); + if( !si ) + return ERROR_INVALID_HANDLE; + type = get_type( uiProperty ); if( type == VT_EMPTY || type != uiDataType ) return ERROR_DATATYPE_MISMATCH; @@ -631,9 +628,7 @@ unsigned MsiSummaryInfoSetProperty( LibmsiObject *handle, unsigned uiProperty, if( uiDataType == VT_FILETIME && !pftValue ) return ERROR_INVALID_PARAMETER; - si = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_SUMMARYINFO ); - if( !si ) - return ERROR_INVALID_HANDLE; + msiobj_addref( &si->hdr); prop = &si->property[uiProperty]; @@ -805,7 +800,7 @@ unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, if (r != ERROR_SUCCESS) goto end; - r = MsiSummaryInfoSetProperty( &si->hdr, pid, get_type(pid), int_value, &ft_value, str_value ); + r = MsiSummaryInfoSetProperty( si, pid, get_type(pid), int_value, &ft_value, str_value ); if (r != ERROR_SUCCESS) goto end; @@ -821,19 +816,17 @@ end: return r; } -unsigned MsiSummaryInfoPersist( LibmsiObject *handle ) +unsigned MsiSummaryInfoPersist( LibmsiSummaryInfo *si ) { - LibmsiSummaryInfo *si; unsigned ret; - TRACE("%d\n", handle ); + TRACE("%d\n", si ); - si = msihandle2msiinfo( handle, LIBMSI_OBJECT_TYPE_SUMMARYINFO ); if( !si ) return ERROR_INVALID_HANDLE; + msiobj_addref( &si->hdr); ret = suminfo_persist( si ); - msiobj_release( &si->hdr ); return ret; } diff --git a/libmsi/table.c b/libmsi/table.c index 1d26278..211fc72 100644 --- a/libmsi/table.c +++ b/libmsi/table.c @@ -826,7 +826,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c if( r ) goto err; - rec = MSI_CreateRecord( 1 ); + rec = MsiCreateRecord( 1 ); if( !rec ) goto err; @@ -857,7 +857,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c if( r ) goto err; - rec = MSI_CreateRecord( 4 ); + rec = MsiCreateRecord( 4 ); if( !rec ) goto err; @@ -872,7 +872,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c nField = 1; for( col = col_info; col; col = col->next ) { - r = MSI_RecordSetInteger( rec, 2, nField ); + r = MsiRecordSetInteger( rec, 2, nField ); if( r ) goto err; @@ -880,7 +880,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c if( r ) goto err; - r = MSI_RecordSetInteger( rec, 4, col->type ); + r = MsiRecordSetInteger( rec, 4, col->type ); if( r ) goto err; @@ -1272,7 +1272,7 @@ static unsigned msi_addstreamW( LibmsiDatabase *db, const WCHAR *name, IStream * TRACE("%p %s %p\n", db, debugstr_w(name), data); - rec = MSI_CreateRecord( 2 ); + rec = MsiCreateRecord( 2 ); if ( !rec ) return ERROR_OUTOFMEMORY; @@ -1303,7 +1303,7 @@ static unsigned get_table_value_from_record( LibmsiTableVIEW *tv, LibmsiRecord * if ( (iField <= 0) || (iField > tv->num_cols) || - MSI_RecordIsNull( rec, iField ) ) + MsiRecordIsNull( rec, iField ) ) return ERROR_FUNCTION_FAILED; columninfo = tv->columns[ iField - 1 ]; @@ -1314,7 +1314,7 @@ static unsigned get_table_value_from_record( LibmsiTableVIEW *tv, LibmsiRecord * } else if ( columninfo.type & MSITYPE_STRING ) { - const WCHAR *sval = MSI_RecordGetString( rec, iField ); + const WCHAR *sval = MSI_RecordGetStringRaw( rec, iField ); if (sval) { r = msi_string2idW(tv->db->strings, sval, pvalue); @@ -1325,7 +1325,7 @@ static unsigned get_table_value_from_record( LibmsiTableVIEW *tv, LibmsiRecord * } else if ( bytes_per_column( tv->db, &columninfo, LONG_STR_BYTES ) == 2 ) { - *pvalue = 0x8000 + MSI_RecordGetInteger( rec, iField ); + *pvalue = 0x8000 + MsiRecordGetInteger( rec, iField ); if ( *pvalue & 0xffff0000 ) { ERR("field %u value %d out of range\n", iField, *pvalue - 0x8000); @@ -1334,7 +1334,7 @@ static unsigned get_table_value_from_record( LibmsiTableVIEW *tv, LibmsiRecord * } else { - int ival = MSI_RecordGetInteger( rec, iField ); + int ival = MsiRecordGetInteger( rec, iField ); *pvalue = ival ^ 0x80000000; } @@ -1366,7 +1366,7 @@ static unsigned TABLE_set_row( LibmsiView *view, unsigned row, LibmsiRecord *rec /* FIXME: should we allow updating keys? */ val = 0; - if ( !MSI_RecordIsNull( rec, i + 1 ) ) + if ( !MsiRecordIsNull( rec, i + 1 ) ) { r = get_table_value_from_record (tv, rec, i + 1, &val); if ( MSITYPE_IS_BINARY(tv->columns[ i ].type) ) @@ -1401,7 +1401,7 @@ static unsigned TABLE_set_row( LibmsiView *view, unsigned row, LibmsiRecord *rec if ( r != ERROR_SUCCESS ) { - const WCHAR *sval = MSI_RecordGetString( rec, i + 1 ); + const WCHAR *sval = MSI_RecordGetStringRaw( rec, i + 1 ); val = msi_addstringW( tv->db->strings, sval, -1, 1, persistent ? StringPersistent : StringNonPersistent ); } @@ -1573,7 +1573,7 @@ static unsigned table_validate_new( LibmsiTableVIEW *tv, LibmsiRecord *rec, unsi { const WCHAR *str; - str = MSI_RecordGetString( rec, i+1 ); + str = MSI_RecordGetStringRaw( rec, i+1 ); if (str == NULL || str[0] == 0) { if (column) *column = i; @@ -1584,7 +1584,7 @@ static unsigned table_validate_new( LibmsiTableVIEW *tv, LibmsiRecord *rec, unsi { unsigned n; - n = MSI_RecordGetInteger( rec, i+1 ); + n = MsiRecordGetInteger( rec, i+1 ); if (n == MSI_NULL_INTEGER) { if (column) *column = i; @@ -1795,7 +1795,7 @@ static unsigned msi_refresh_record( LibmsiView *view, LibmsiRecord *rec, unsigne /* Close the original record */ MSI_CloseRecord(&rec->hdr); - count = MSI_RecordGetFieldCount(rec); + count = MsiRecordGetFieldCount(rec); for (i = 0; i < count; i++) MSI_RecordCopyField(curr, i + 1, rec, i + 1); @@ -1994,12 +1994,12 @@ static unsigned TABLE_remove_column(LibmsiView *view, const WCHAR *table, unsign LibmsiView *columns = NULL; unsigned row, r; - rec = MSI_CreateRecord(2); + rec = MsiCreateRecord(2); if (!rec) return ERROR_OUTOFMEMORY; MSI_RecordSetStringW(rec, 1, table); - MSI_RecordSetInteger(rec, 2, number); + MsiRecordSetInteger(rec, 2, number); r = TABLE_CreateView(tv->db, szColumns, &columns); if (r != ERROR_SUCCESS) @@ -2066,14 +2066,14 @@ static unsigned TABLE_add_column(LibmsiView *view, const WCHAR *table, unsigned LibmsiRecord *rec; unsigned r, i; - rec = MSI_CreateRecord(4); + rec = MsiCreateRecord(4); if (!rec) return ERROR_OUTOFMEMORY; MSI_RecordSetStringW(rec, 1, table); - MSI_RecordSetInteger(rec, 2, number); + MsiRecordSetInteger(rec, 2, number); MSI_RecordSetStringW(rec, 3, column); - MSI_RecordSetInteger(rec, 4, type); + MsiRecordSetInteger(rec, 4, type); r = TABLE_insert_row(&tv->view, rec, -1, false); if (r != ERROR_SUCCESS) @@ -2117,7 +2117,7 @@ static unsigned TABLE_drop(LibmsiView *view) return r; } - rec = MSI_CreateRecord(1); + rec = MsiCreateRecord(1); if (!rec) return ERROR_OUTOFMEMORY; @@ -2344,7 +2344,7 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableVIEW *tv, const mask = rawdata[0] | (rawdata[1] << 8); rawdata += 2; - rec = MSI_CreateRecord( tv->num_cols ); + rec = MsiCreateRecord( tv->num_cols ); if( !rec ) return rec; @@ -2399,13 +2399,13 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableVIEW *tv, const case 2: val = read_raw_int(rawdata, ofs, n); if (val) - MSI_RecordSetInteger( rec, i+1, val-0x8000 ); + MsiRecordSetInteger( rec, i+1, val-0x8000 ); TRACE(" field %d [0x%04x]\n", i+1, val ); break; case 4: val = read_raw_int(rawdata, ofs, n); if (val) - MSI_RecordSetInteger( rec, i+1, val^0x80000000 ); + MsiRecordSetInteger( rec, i+1, val^0x80000000 ); TRACE(" field %d [0x%08x]\n", i+1, val ); break; default: @@ -2422,17 +2422,17 @@ static void dump_record( LibmsiRecord *rec ) { unsigned i, n; - n = MSI_RecordGetFieldCount( rec ); + n = MsiRecordGetFieldCount( rec ); for( i=1; i<=n; i++ ) { const WCHAR *sval; - if( MSI_RecordIsNull( rec, i ) ) + if( MsiRecordIsNull( rec, i ) ) TRACE("row -> []\n"); - else if( (sval = MSI_RecordGetString( rec, i )) ) + else if( (sval = MSI_RecordGetStringRaw( rec, i )) ) TRACE("row -> [%s]\n", debugstr_w(sval)); else - TRACE("row -> [0x%08x]\n", MSI_RecordGetInteger( rec, i ) ); + TRACE("row -> [0x%08x]\n", MsiRecordGetInteger( rec, i ) ); } } @@ -2465,7 +2465,7 @@ static unsigned* msi_record_to_row( const LibmsiTableVIEW *tv, LibmsiRecord *rec if ( ( tv->columns[i].type & MSITYPE_STRING ) && ! MSITYPE_IS_BINARY(tv->columns[i].type) ) { - str = MSI_RecordGetString( rec, i+1 ); + str = MSI_RecordGetStringRaw( rec, i+1 ); if (str) { r = msi_string2idW( tv->db->strings, str, &data[i] ); @@ -2482,7 +2482,7 @@ static unsigned* msi_record_to_row( const LibmsiTableVIEW *tv, LibmsiRecord *rec } else { - data[i] = MSI_RecordGetInteger( rec, i+1 ); + data[i] = MsiRecordGetInteger( rec, i+1 ); if (data[i] == MSI_NULL_INTEGER) data[i] = 0; @@ -2654,7 +2654,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, if (!strcmpW( name, szColumns )) { MSI_RecordGetStringW( rec, 1, table, &sz ); - number = MSI_RecordGetInteger( rec, 2 ); + number = MsiRecordGetInteger( rec, 2 ); /* * Native msi seems writes nul into the Number (2nd) column of @@ -2670,7 +2670,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, IStorage *stg, } /* fix nul column numbers */ - MSI_RecordSetInteger( rec, 2, ++colcol ); + MsiRecordSetInteger( rec, 2, ++colcol ); } } diff --git a/libmsi/update.c b/libmsi/update.c index b169644..7623a8c 100644 --- a/libmsi/update.c +++ b/libmsi/update.c @@ -68,7 +68,7 @@ static unsigned UPDATE_execute( LibmsiView *view, LibmsiRecord *record ) /* extract the where markers from the record */ if (record) { - r = MSI_RecordGetFieldCount(record); + r = MsiRecordGetFieldCount(record); for (i = 0; col; col = col->next) i++; @@ -78,7 +78,7 @@ static unsigned UPDATE_execute( LibmsiView *view, LibmsiRecord *record ) if (where_count > 0) { - where = MSI_CreateRecord(where_count); + where = MsiCreateRecord(where_count); if (where) for (i = 1; i <= where_count; i++) diff --git a/libmsi/where.c b/libmsi/where.c index 87f9b07..9cc74d7 100644 --- a/libmsi/where.c +++ b/libmsi/where.c @@ -323,7 +323,7 @@ static unsigned WHERE_set_row( LibmsiView *view, unsigned row, LibmsiRecord *rec continue; } - reduced = MSI_CreateRecord(col_count); + reduced = MsiCreateRecord(col_count); if (!reduced) return ERROR_FUNCTION_FAILED; @@ -503,7 +503,7 @@ static unsigned STRING_evaluate( LibmsiWhereView *wv, const unsigned rows[], break; case EXPR_WILDCARD: - *str = MSI_RecordGetString(record, ++wv->rec_index); + *str = MSI_RecordGetStringRaw(record, ++wv->rec_index); break; default: @@ -587,7 +587,7 @@ static unsigned WHERE_evaluate( LibmsiWhereView *wv, const unsigned rows[], return STRCMP_Evaluate( wv, rows, &cond->u.expr, val, record ); case EXPR_WILDCARD: - *val = MSI_RecordGetInteger( record, ++wv->rec_index ); + *val = MsiRecordGetInteger( record, ++wv->rec_index ); return ERROR_SUCCESS; default: @@ -881,7 +881,7 @@ static unsigned join_find_row( LibmsiWhereView *wv, LibmsiRecord *rec, unsigned const WCHAR *str; unsigned r, i, id, data; - str = MSI_RecordGetString( rec, 1 ); + str = MSI_RecordGetStringRaw( rec, 1 ); r = msi_string2idW( wv->db->strings, str, &id ); if (r != ERROR_SUCCESS) return r; @@ -915,9 +915,9 @@ static unsigned join_modify_update( LibmsiView *view, LibmsiRecord *rec ) if (r != ERROR_SUCCESS) return r; - assert(MSI_RecordGetFieldCount(rec) == MSI_RecordGetFieldCount(current)); + assert(MsiRecordGetFieldCount(rec) == MsiRecordGetFieldCount(current)); - for (i = MSI_RecordGetFieldCount(rec); i > 0; i--) + for (i = MsiRecordGetFieldCount(rec); i > 0; i--) { if (!MSI_RecordsAreFieldsEqual(rec, current, i)) mask |= 1 << (i - 1); diff --git a/tests/testdatabase.c b/tests/testdatabase.c index 0b63053..ca03659 100644 --- a/tests/testdatabase.c +++ b/tests/testdatabase.c @@ -38,8 +38,8 @@ static const WCHAR msifileW[] = {'w','i','n','e','t','e','s','t','-','d','b','.' static void test_msidatabase(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hdb2 = 0; + LibmsiDatabase *hdb = 0; + LibmsiDatabase *hdb2 = 0; unsigned res; DeleteFile(msifile); @@ -145,9 +145,9 @@ static void test_msidatabase(void) ok( res == true, "Failed to delete database\n" ); } -static unsigned do_query(LibmsiObject *hdb, const char *sql, LibmsiObject **phrec) +static unsigned do_query(LibmsiDatabase *hdb, const char *sql, LibmsiRecord **phrec) { - LibmsiObject *hquery = 0; + LibmsiQuery *hquery = 0; unsigned r, ret; if (phrec) @@ -170,9 +170,9 @@ static unsigned do_query(LibmsiObject *hdb, const char *sql, LibmsiObject **phre return ret; } -static unsigned run_query( LibmsiObject *hdb, LibmsiObject *hrec, const char *sql ) +static unsigned run_query( LibmsiDatabase *hdb, LibmsiRecord *hrec, const char *sql ) { - LibmsiObject *hquery = 0; + LibmsiQuery *hquery = 0; unsigned r; r = MsiDatabaseOpenQuery(hdb, sql, &hquery); @@ -186,7 +186,7 @@ static unsigned run_query( LibmsiObject *hdb, LibmsiObject *hrec, const char *sq return r; } -static unsigned create_component_table( LibmsiObject *hdb ) +static unsigned create_component_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `Component` ( " @@ -199,7 +199,7 @@ static unsigned create_component_table( LibmsiObject *hdb ) "PRIMARY KEY `Component`)" ); } -static unsigned create_custom_action_table( LibmsiObject *hdb ) +static unsigned create_custom_action_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `CustomAction` ( " @@ -210,7 +210,7 @@ static unsigned create_custom_action_table( LibmsiObject *hdb ) "PRIMARY KEY `Action`)" ); } -static unsigned create_directory_table( LibmsiObject *hdb ) +static unsigned create_directory_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `Directory` ( " @@ -220,7 +220,7 @@ static unsigned create_directory_table( LibmsiObject *hdb ) "PRIMARY KEY `Directory`)" ); } -static unsigned create_feature_components_table( LibmsiObject *hdb ) +static unsigned create_feature_components_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `FeatureComponents` ( " @@ -229,7 +229,7 @@ static unsigned create_feature_components_table( LibmsiObject *hdb ) "PRIMARY KEY `Feature_`, `Component_` )" ); } -static unsigned create_std_dlls_table( LibmsiObject *hdb ) +static unsigned create_std_dlls_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `StdDlls` ( " @@ -238,7 +238,7 @@ static unsigned create_std_dlls_table( LibmsiObject *hdb ) "PRIMARY KEY `File` )" ); } -static unsigned create_binary_table( LibmsiObject *hdb ) +static unsigned create_binary_table( LibmsiDatabase *hdb ) { return run_query( hdb, 0, "CREATE TABLE `Binary` ( " @@ -248,7 +248,7 @@ static unsigned create_binary_table( LibmsiObject *hdb ) } #define make_add_entry(type, qtext) \ - static unsigned add##_##type##_##entry( LibmsiObject *hdb, const char *values ) \ + static unsigned add##_##type##_##entry( LibmsiDatabase *hdb, const char *values ) \ { \ char insert[] = qtext; \ char *sql; \ @@ -282,10 +282,10 @@ make_add_entry(binary, static void test_msiinsert(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hquery2 = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiQuery *hquery2 = 0; + LibmsiRecord *hrec = 0; unsigned r; const char *sql; char buf[80]; @@ -441,9 +441,9 @@ static void test_msiinsert(void) ok(r == true, "file didn't exist after commit\n"); } -static unsigned try_query_param( LibmsiObject *hdb, const char *szQuery, LibmsiObject *hrec ) +static unsigned try_query_param( LibmsiDatabase *hdb, const char *szQuery, LibmsiRecord *hrec ) { - LibmsiObject *htab = 0; + LibmsiQuery *htab = 0; unsigned res; res = MsiDatabaseOpenQuery( hdb, szQuery, &htab ); @@ -466,14 +466,14 @@ static unsigned try_query_param( LibmsiObject *hdb, const char *szQuery, LibmsiO return res; } -static unsigned try_query( LibmsiObject *hdb, const char *szQuery ) +static unsigned try_query( LibmsiDatabase *hdb, const char *szQuery ) { return try_query_param( hdb, szQuery, 0 ); } -static unsigned try_insert_query( LibmsiObject *hdb, const char *szQuery ) +static unsigned try_insert_query( LibmsiDatabase *hdb, const char *szQuery ) { - LibmsiObject *hrec = 0; + LibmsiRecord *hrec = 0; unsigned r; hrec = MsiCreateRecord( 1 ); @@ -487,7 +487,7 @@ static unsigned try_insert_query( LibmsiObject *hdb, const char *szQuery ) static void test_msibadqueries(void) { - LibmsiObject *hdb = 0; + LibmsiDatabase *hdb = 0; unsigned r; DeleteFile(msifile); @@ -706,9 +706,9 @@ static void test_msibadqueries(void) static void test_querymodify(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned r; LibmsiDBError err; const char *sql; @@ -1056,9 +1056,9 @@ static void test_querymodify(void) ok(r == ERROR_SUCCESS, "MsiOpenDatabase close failed\n"); } -static LibmsiObject *create_db(void) +static LibmsiDatabase *create_db(void) { - LibmsiObject *hdb = 0; + LibmsiDatabase *hdb = 0; unsigned res; DeleteFile(msifile); @@ -1077,9 +1077,9 @@ static LibmsiObject *create_db(void) static void test_getcolinfo(void) { - LibmsiObject *hdb; - LibmsiObject *hquery = 0; - LibmsiObject *rec = 0; + LibmsiDatabase *hdb; + LibmsiQuery *hquery = 0; + LibmsiRecord *rec = 0; unsigned r; unsigned sz; char buffer[0x20]; @@ -1137,10 +1137,10 @@ static void test_getcolinfo(void) ok( r == ERROR_SUCCESS, "failed to close database\n"); } -static LibmsiObject *get_column_info(LibmsiObject *hdb, const char *sql, LibmsiColInfo type) +static LibmsiRecord *get_column_info(LibmsiDatabase *hdb, const char *sql, LibmsiColInfo type) { - LibmsiObject *hquery = 0; - LibmsiObject *rec = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *rec = 0; unsigned r; r = MsiDatabaseOpenQuery(hdb, sql, &hquery); @@ -1157,10 +1157,10 @@ static LibmsiObject *get_column_info(LibmsiObject *hdb, const char *sql, LibmsiC return rec; } -static unsigned get_columns_table_type(LibmsiObject *hdb, const char *table, unsigned field) +static unsigned get_columns_table_type(LibmsiDatabase *hdb, const char *table, unsigned field) { - LibmsiObject *hquery = 0; - LibmsiObject *rec = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *rec = 0; unsigned r, type = 0; char sql[0x100]; @@ -1189,7 +1189,7 @@ static unsigned get_columns_table_type(LibmsiObject *hdb, const char *table, uns return type; } -static bool check_record( LibmsiObject *rec, unsigned field, const char *val ) +static bool check_record( LibmsiRecord *rec, unsigned field, const char *val ) { char buffer[0x20]; unsigned r; @@ -1202,8 +1202,8 @@ static bool check_record( LibmsiObject *rec, unsigned field, const char *val ) static void test_querygetcolumninfo(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; unsigned r; hdb = create_db(); @@ -1309,8 +1309,8 @@ static void test_querygetcolumninfo(void) static void test_msiexport(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; unsigned r; const char *sql; int fd; @@ -1388,9 +1388,9 @@ static void test_longstrings(void) const char insert_query[] = "INSERT INTO `strings` ( `id`, `val` ) VALUES('1', 'Z')"; char *str; - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned len; unsigned r; const unsigned STRING_LENGTH = 0x10005; @@ -1469,10 +1469,10 @@ static void create_file_data(const char *name, const char *data, unsigned size) static void test_streamtable(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; - LibmsiObject *query; - LibmsiObject *hsi; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; + LibmsiQuery *query; + LibmsiSummaryInfo *hsi; char file[MAX_PATH]; char buf[MAX_PATH]; unsigned size; @@ -1709,8 +1709,8 @@ static void test_streamtable(void) static void test_binary(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; char file[MAX_PATH]; char buf[MAX_PATH]; unsigned size; @@ -1793,9 +1793,9 @@ static void test_binary(void) static void test_where_not_in_selected(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; - LibmsiObject *query; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; + LibmsiQuery *query; const char *sql; unsigned r; @@ -1892,9 +1892,9 @@ static void test_where_not_in_selected(void) static void test_where(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; - LibmsiObject *query; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; + LibmsiQuery *query; const char *sql; unsigned r; unsigned size; @@ -2094,7 +2094,7 @@ static void write_file(const char *filename, const char *data, int data_size) CloseHandle(hf); } -static unsigned add_table_to_db(LibmsiObject *hdb, const char *table_data) +static unsigned add_table_to_db(LibmsiDatabase *hdb, const char *table_data) { unsigned r; @@ -2107,9 +2107,9 @@ static unsigned add_table_to_db(LibmsiObject *hdb, const char *table_data) static void test_suminfo_import(void) { - LibmsiObject *hdb; - LibmsiObject *hsi; - LibmsiObject *query = 0; + LibmsiDatabase *hdb; + LibmsiSummaryInfo *hsi; + LibmsiQuery *query = 0; const char *sql; unsigned r, count, size, type; char str_value[50]; @@ -2232,9 +2232,9 @@ static void test_suminfo_import(void) static void test_msiimport(void) { - LibmsiObject *hdb; - LibmsiObject *query; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiQuery *query; + LibmsiRecord *rec; const char *sql; unsigned r, count; signed int i; @@ -2453,8 +2453,8 @@ static const char bin_import_dat[] = "Name\tData\r\n" static void test_binary_import(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; char file[MAX_PATH]; char buf[MAX_PATH]; char path[MAX_PATH]; @@ -2506,8 +2506,8 @@ static void test_binary_import(void) static void test_markers(void) { - LibmsiObject *hdb; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiRecord *rec; const char *sql; unsigned r; @@ -2693,8 +2693,8 @@ static void test_markers(void) static void test_handle_limit(void) { int i; - LibmsiObject *hdb; - LibmsiObject *hqueries[MY_NQUERIES]; + LibmsiDatabase *hdb; + LibmsiQuery *hqueries[MY_NQUERIES]; unsigned r; /* create an empty db */ @@ -2855,10 +2855,10 @@ static void generate_transform_manual(void) IStorage_Release(stg); } -static unsigned set_summary_info(LibmsiObject *hdb) +static unsigned set_summary_info(LibmsiDatabase *hdb) { unsigned res; - LibmsiObject *suminfo; + LibmsiSummaryInfo *suminfo; /* build summary info */ res = MsiGetSummaryInformation(hdb, 7, &suminfo); @@ -2899,9 +2899,9 @@ static unsigned set_summary_info(LibmsiObject *hdb) return res; } -static LibmsiObject *create_package_db(const char *filename) +static LibmsiDatabase *create_package_db(const char *filename) { - LibmsiObject *hdb = 0; + LibmsiDatabase *hdb = 0; unsigned res; DeleteFile(msifile); @@ -2926,10 +2926,9 @@ static LibmsiObject *create_package_db(const char *filename) static void test_try_transform(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; - LibmsiObject *hpkg = 0; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; unsigned r; unsigned sz; @@ -3095,6 +3094,8 @@ static void test_try_transform(void) MsiCloseHandle(hquery); #if 0 + LibmsiObject *hpkg = 0; + /* check that the property was added */ r = package_from_db(hdb, &hpkg); if (r == ERROR_INSTALL_PACKAGE_REJECTED) @@ -3108,9 +3109,9 @@ static void test_try_transform(void) r = MsiGetProperty(hpkg, "prop", buffer, &sz); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(!strcmp(buffer, "val"), "Expected val, got %s\n", buffer); -#endif MsiCloseHandle(hpkg); +#endif error: MsiCloseHandle(hdb); @@ -3212,9 +3213,9 @@ static const struct join_res_uint join_res_ninth[] = static void test_join(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buf[MAX_PATH]; unsigned r, count; @@ -3852,9 +3853,9 @@ static void test_join(void) static void test_temporary_table(void) { LibmsiCondition cond; - LibmsiObject *hdb = 0; - LibmsiObject *query = 0; - LibmsiObject *rec; + LibmsiDatabase *hdb = 0; + LibmsiQuery *query = 0; + LibmsiRecord *rec; const char *sql; unsigned r; char buf[0x10]; @@ -3980,7 +3981,7 @@ static void test_temporary_table(void) static void test_alter(void) { LibmsiCondition cond; - LibmsiObject *hdb = 0; + LibmsiDatabase *hdb = 0; const char *sql; unsigned r; @@ -4156,9 +4157,9 @@ static void test_alter(void) static void test_integers(void) { - LibmsiObject *hdb = 0; - LibmsiObject *query = 0; - LibmsiObject *rec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *query = 0; + LibmsiRecord *rec = 0; unsigned count, i; const char *sql; unsigned r; @@ -4289,9 +4290,9 @@ static void test_integers(void) static void test_update(void) { - LibmsiObject *hdb = 0; - LibmsiObject *query = 0; - LibmsiObject *rec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *query = 0; + LibmsiRecord *rec = 0; char result[MAX_PATH]; const char *sql; unsigned size; @@ -4611,7 +4612,7 @@ static void test_update(void) static void test_special_tables(void) { const char *sql; - LibmsiObject *hdb = 0; + LibmsiDatabase *hdb = 0; unsigned r; r = MsiOpenDatabase(msifile, LIBMSI_DB_OPEN_CREATE, &hdb); @@ -4649,9 +4650,9 @@ static void test_special_tables(void) static void test_tables_order(void) { const char *sql; - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned r; char buffer[100]; unsigned sz; @@ -4805,9 +4806,9 @@ static void test_tables_order(void) static void test_rows_order(void) { const char *sql; - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned r; char buffer[100]; unsigned sz; @@ -4957,9 +4958,9 @@ static void test_collation(void) static const char letter_a_ring[] = "a\xcc\x8a"; static const char letter_a_with_ring[] = "\xc3\xa5"; const char *sql; - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned r; char buffer[100]; unsigned sz; @@ -5095,10 +5096,10 @@ static void test_collation(void) static void test_select_markers(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; - LibmsiObject *query; - LibmsiObject *res; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; + LibmsiQuery *query; + LibmsiRecord *res; const char *sql; unsigned r; unsigned size; @@ -5241,9 +5242,9 @@ static void test_select_markers(void) static void test_querymodify_update(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned i, test_max, offset, count; const char *sql; unsigned r; @@ -5501,9 +5502,9 @@ static void test_querymodify_update(void) static void test_querymodify_assign(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; const char *sql; unsigned r; @@ -5653,9 +5654,9 @@ static const WCHAR data13[] = { /* _StringPool */ static void test_stringtable(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; IStorage *stg = NULL; IStream *stm; WCHAR name[0x20]; @@ -5893,9 +5894,9 @@ static void test_stringtable(void) static void test_querymodify_delete(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hquery = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb = 0; + LibmsiQuery *hquery = 0; + LibmsiRecord *hrec = 0; unsigned r; const char *sql; char buffer[0x100]; @@ -6073,7 +6074,7 @@ static void test_defaultdatabase(void) { unsigned r; HRESULT hr; - LibmsiObject *hdb; + LibmsiDatabase *hdb; IStorage *stg = NULL; DeleteFile(msifile); @@ -6098,9 +6099,9 @@ static void test_defaultdatabase(void) static void test_order(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; char buffer[MAX_PATH]; const char *sql; unsigned r, sz; @@ -6358,9 +6359,9 @@ static void test_order(void) static void test_querymodify_delete_temporary(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; unsigned r; @@ -6476,9 +6477,9 @@ static void test_querymodify_delete_temporary(void) static void test_deleterow(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buf[MAX_PATH]; unsigned r; @@ -6545,9 +6546,9 @@ static const char import_dat[] = "A\n" static void test_quotes(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buf[MAX_PATH]; unsigned r; @@ -6653,9 +6654,9 @@ static void test_quotes(void) static void test_carriagereturn(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buf[MAX_PATH]; unsigned r; @@ -6841,9 +6842,9 @@ static void test_carriagereturn(void) static void test_noquotes(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buf[MAX_PATH]; unsigned r; @@ -7053,7 +7054,7 @@ static void read_file_data(const char *filename, char *buffer) static void test_forcecodepage(void) { - LibmsiObject *hdb; + LibmsiDatabase *hdb; const char *sql; char buffer[MAX_PATH]; unsigned r; @@ -7132,9 +7133,9 @@ static void test_forcecodepage(void) static void test_querymodify_refresh(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; char buffer[MAX_PATH]; unsigned r; @@ -7224,9 +7225,9 @@ static void test_querymodify_refresh(void) static void test_where_querymodify(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; const char *sql; unsigned r; @@ -7358,9 +7359,9 @@ done: static void test_storages_table(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; IStorage *stg, *inner; IStream *stm; char file[MAX_PATH]; @@ -7483,9 +7484,9 @@ static void test_storages_table(void) static void test_droptable(void) { - LibmsiObject *hdb; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiQuery *hquery; + LibmsiRecord *hrec; char buf[MAX_PATH]; const char *sql; unsigned size; @@ -7704,10 +7705,10 @@ static void test_droptable(void) static void test_dbmerge(void) { - LibmsiObject *hdb; - LibmsiObject *href; - LibmsiObject *hquery; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiDatabase *href; + LibmsiQuery *hquery; + LibmsiRecord *hrec; char buf[MAX_PATH]; const char *sql; unsigned size; @@ -8334,9 +8335,9 @@ static void test_dbmerge(void) static void test_select_with_tablenames(void) { - LibmsiObject *hdb; - LibmsiObject *query; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiQuery *query; + LibmsiRecord *rec; const char *sql; unsigned r; int i; @@ -8421,9 +8422,9 @@ static const unsigned ordervals[6][3] = static void test_insertorder(void) { - LibmsiObject *hdb; - LibmsiObject *query; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiQuery *query; + LibmsiRecord *rec; const char *sql; unsigned r; int i; @@ -8561,9 +8562,9 @@ static void test_insertorder(void) static void test_columnorder(void) { - LibmsiObject *hdb; - LibmsiObject *query; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiQuery *query; + LibmsiRecord *rec; char buf[MAX_PATH]; const char *sql; unsigned sz; @@ -9058,9 +9059,9 @@ static void test_columnorder(void) static void test_createtable(void) { - LibmsiObject *hdb; - LibmsiObject *htab = 0; - LibmsiObject *hrec = 0; + LibmsiDatabase *hdb; + LibmsiQuery *htab = 0; + LibmsiRecord *hrec = 0; const char *sql; unsigned res; unsigned size; @@ -9178,8 +9179,8 @@ static void test_embedded_nulls(void) "Control\tDialog\n" "LicenseAgreementDlg\ttext\x11\x19text\0text"; unsigned r, sz; - LibmsiObject *hdb; - LibmsiObject *hrec; + LibmsiDatabase *hdb; + LibmsiRecord *hrec; char buffer[32]; r = MsiOpenDatabase( msifile, LIBMSI_DB_OPEN_CREATE, &hdb ); @@ -9207,10 +9208,10 @@ static void test_embedded_nulls(void) static void test_select_column_names(void) { - LibmsiObject *hdb = 0; - LibmsiObject *rec; - LibmsiObject *rec2; - LibmsiObject *query; + LibmsiDatabase *hdb = 0; + LibmsiRecord *rec; + LibmsiRecord *rec2; + LibmsiQuery *query; char buffer[32]; unsigned r, size; diff --git a/tests/testrecord.c b/tests/testrecord.c index fbc3026..fcd9f35 100644 --- a/tests/testrecord.c +++ b/tests/testrecord.c @@ -50,7 +50,7 @@ static void test_msirecord(void) { unsigned r, sz; int i; - LibmsiObject *h; + LibmsiRecord *h; char buf[10]; const char str[] = "hello"; char filename[MAX_PATH]; @@ -355,7 +355,7 @@ static void test_msirecord(void) static void test_MsiRecordGetString(void) { - LibmsiObject *rec; + LibmsiRecord *rec; char buf[MAX_PATH]; unsigned sz; unsigned r; @@ -417,7 +417,7 @@ static void test_MsiRecordGetString(void) static void test_MsiRecordGetInteger(void) { - LibmsiObject *rec; + LibmsiRecord *rec; int val; unsigned r; @@ -447,9 +447,9 @@ static void test_MsiRecordGetInteger(void) static void test_fieldzero(void) { - LibmsiObject *hdb; - LibmsiObject *hview; - LibmsiObject *rec; + LibmsiDatabase *hdb; + LibmsiQuery *hview; + LibmsiRecord *rec; char buf[MAX_PATH]; const char *query; unsigned sz; diff --git a/tests/testsuminfo.c b/tests/testsuminfo.c index 2c2ef03..bda096c 100644 --- a/tests/testsuminfo.c +++ b/tests/testsuminfo.c @@ -33,8 +33,8 @@ static const WCHAR msifileW[] = { static void test_suminfo(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hsuminfo; + LibmsiDatabase *hdb = 0; + LibmsiSummaryInfo *hsuminfo; unsigned r, count, type; unsigned sz; int val; @@ -370,8 +370,8 @@ static void test_create_database_binary(void) static void test_summary_binary(void) { - LibmsiObject *hdb = 0; - LibmsiObject *hsuminfo = 0; + LibmsiDatabase *hdb = 0; + LibmsiSummaryInfo *hsuminfo = 0; unsigned r, type, count; int ival; unsigned sz; |