UINT MSI_RecordCopyField( MSIRECORD *in_rec, UINT in_n, MSIRECORD *out_rec, UINT out_n ) { UINT r = ERROR_SUCCESS; msiobj_lock( &in_rec->hdr ); if ( in_n > in_rec->count || out_n > out_rec->count ) r = ERROR_FUNCTION_FAILED; else if ( in_rec != out_rec || in_n != out_n ) { LPWSTR str; MSIFIELD *in, *out; in = &in_rec->fields[in_n]; out = &out_rec->fields[out_n]; switch ( in->type ) { case MSIFIELD_NULL: break; case MSIFIELD_INT: out->u.iVal = in->u.iVal; break; case MSIFIELD_INTPTR: out->u.pVal = in->u.pVal; break; case MSIFIELD_WSTR: if ((str = msi_strdupW( in->u.szwVal, in->len ))) { out->u.szwVal = str; out->len = in->len; } else r = ERROR_OUTOFMEMORY; break; case MSIFIELD_STREAM: IStream_AddRef( in->u.stream ); out->u.stream = in->u.stream; break; default: ERR("invalid field type %d\n", in->type); } if (r == ERROR_SUCCESS) out->type = in->type; } msiobj_unlock( &in_rec->hdr ); return r; }
UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, UINT iField, char *buf, LPDWORD sz) { MSIRECORD *rec; UINT ret; TRACE("%d %d %p %p\n", handle, iField, buf, sz); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; msiobj_lock( &rec->hdr ); ret = MSI_RecordReadStream( rec, iField, buf, sz ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT WINAPI MsiRecordDataSize(MSIHANDLE handle, UINT iField) { MSIRECORD *rec; UINT ret; TRACE("%d %d\n", handle, iField); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return 0; msiobj_lock( &rec->hdr ); ret = MSI_RecordDataSize( rec, iField); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, UINT iField, LPCSTR szValue ) { MSIRECORD *rec; UINT ret; TRACE("%d %d %s\n", handle, iField, debugstr_a(szValue)); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; msiobj_lock( &rec->hdr ); ret = MSI_RecordSetStringA( rec, iField, szValue ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT WINAPI MsiRecordSetInteger( MSIHANDLE handle, UINT iField, int iVal ) { MSIRECORD *rec; UINT ret; TRACE("%d %u %d\n", handle, iField, iVal); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; msiobj_lock( &rec->hdr ); ret = MSI_RecordSetInteger( rec, iField, iVal ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT WINAPI MsiRecordGetFieldCount( MSIHANDLE handle ) { MSIRECORD *rec; UINT ret; TRACE("%d\n", handle ); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return -1; msiobj_lock( &rec->hdr ); ret = MSI_RecordGetFieldCount( rec ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, UINT iField, LPWSTR szValue, LPDWORD pcchValue) { MSIRECORD *rec; UINT ret; TRACE("%d %d %p %p\n", handle, iField, szValue, pcchValue); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; msiobj_lock( &rec->hdr ); ret = MSI_RecordGetStringW( rec, iField, szValue, pcchValue ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
int WINAPI MsiRecordGetInteger( MSIHANDLE handle, UINT iField) { MSIRECORD *rec; UINT ret; TRACE("%d %d\n", handle, iField ); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return MSI_NULL_INTEGER; msiobj_lock( &rec->hdr ); ret = MSI_RecordGetInteger( rec, iField ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ret; }
UINT MSI_RecordStreamToFile( MSIRECORD *rec, UINT iField, LPCWSTR name ) { IStream *stm = NULL; UINT r; TRACE("%p %u %s\n", rec, iField, debugstr_w(name)); msiobj_lock( &rec->hdr ); r = MSI_RecordGetIStream( rec, iField, &stm ); if( r == ERROR_SUCCESS ) { r = msi_dump_stream_to_file( stm, name ); IStream_Release( stm ); } msiobj_unlock( &rec->hdr ); return r; }
UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, UINT iField, LPCSTR szValue ) { WCHAR *valueW = NULL; MSIRECORD *rec; UINT ret; TRACE("%d %d %s\n", handle, iField, debugstr_a(szValue)); if (szValue && !(valueW = strdupAtoW( szValue ))) return ERROR_OUTOFMEMORY; rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) { msi_free( valueW ); return ERROR_INVALID_HANDLE; } msiobj_lock( &rec->hdr ); ret = MSI_RecordSetStringW( rec, iField, valueW ); msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); msi_free( valueW ); return ret; }
UINT WINAPI MsiRecordClearData( MSIHANDLE handle ) { MSIRECORD *rec; UINT i; TRACE("%d\n", handle ); rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD ); if( !rec ) return ERROR_INVALID_HANDLE; msiobj_lock( &rec->hdr ); for( i=0; i<=rec->count; i++) { MSI_FreeField( &rec->fields[i] ); rec->fields[i].type = MSIFIELD_NULL; rec->fields[i].u.iVal = 0; } msiobj_unlock( &rec->hdr ); msiobj_release( &rec->hdr ); return ERROR_SUCCESS; }