Commit f03889ae authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Add initial implementation of MsiDatabaseMerge, with tests.

parent c9ec69db
......@@ -703,6 +703,8 @@ extern UINT MSI_RecordSetStream( MSIRECORD *, UINT, IStream * );
extern UINT MSI_RecordDataSize( MSIRECORD *, UINT );
extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
extern MSIRECORD *MSI_CloneRecord( MSIRECORD * );
extern BOOL MSI_RecordsAreEqual( MSIRECORD *, MSIRECORD * );
/* stream internals */
extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
......
......@@ -903,3 +903,74 @@ UINT MSI_RecordStreamToFile( MSIRECORD *rec, UINT iField, LPCWSTR name )
return r;
}
MSIRECORD *MSI_CloneRecord(MSIRECORD *rec)
{
MSIRECORD *clone;
UINT r, i, count;
count = MSI_RecordGetFieldCount(rec);
clone = MSI_CreateRecord(count);
if (!clone)
return NULL;
for (i = 0; i <= count; i++)
{
if (rec->fields[i].type == MSIFIELD_STREAM)
{
if (FAILED(IStream_Clone(rec->fields[i].u.stream,
&clone->fields[i].u.stream)))
{
msiobj_release(&clone->hdr);
return NULL;
}
}
else
{
r = MSI_RecordCopyField(rec, i, clone, i);
if (r != ERROR_SUCCESS)
{
msiobj_release(&clone->hdr);
return NULL;
}
}
}
return clone;
}
BOOL MSI_RecordsAreEqual(MSIRECORD *a, MSIRECORD *b)
{
UINT i;
if (a->count != b->count)
return FALSE;
for (i = 0; i <= a->count; i++)
{
if (a->fields[i].type != b->fields[i].type)
return FALSE;
switch (a->fields[i].type)
{
case MSIFIELD_NULL:
break;
case MSIFIELD_INT:
if (a->fields[i].u.iVal != b->fields[i].u.iVal)
return FALSE;
break;
case MSIFIELD_WSTR:
if (lstrcmpW(a->fields[i].u.szwVal, b->fields[i].u.szwVal))
return FALSE;
break;
case MSIFIELD_STREAM:
default:
return FALSE;
}
}
return TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment