summaryrefslogtreecommitdiffstats
path: root/libmsi
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-11-30 11:06:53 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-06 20:30:31 +0100
commit95586f6733d3fcbc756265818ef7e52b207542fe (patch)
tree6bc3b0de47e1001dab546f31cae765bf20b8998b /libmsi
parentc8b9a23e3d89efbc3f15f0c675a4bad421bfbe15 (diff)
downloadmsitools-95586f6733d3fcbc756265818ef7e52b207542fe.tar.gz
msitools-95586f6733d3fcbc756265818ef7e52b207542fe.tar.xz
msitools-95586f6733d3fcbc756265818ef7e52b207542fe.zip
use actual types in the API
Diffstat (limited to 'libmsi')
-rw-r--r--libmsi/database.c123
-rw-r--r--libmsi/handle.c16
-rw-r--r--libmsi/insert.c10
-rw-r--r--libmsi/msipriv.h36
-rw-r--r--libmsi/msiquery.c164
-rw-r--r--libmsi/record.c222
-rw-r--r--libmsi/select.c10
-rw-r--r--libmsi/storages.c4
-rw-r--r--libmsi/streams.c4
-rw-r--r--libmsi/suminfo.c51
-rw-r--r--libmsi/table.c62
-rw-r--r--libmsi/update.c4
-rw-r--r--libmsi/where.c12
13 files changed, 249 insertions, 469 deletions
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);