Make load_string_table return the string table.

This commit is contained in:
Mike McCormack 2005-09-16 19:01:40 +00:00 committed by Alexandre Julliard
parent 43fece976f
commit 6b5f290d75
3 changed files with 14 additions and 19 deletions

View File

@ -157,10 +157,12 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
db->mode = szMode; db->mode = szMode;
list_init( &db->tables ); list_init( &db->tables );
ret = load_string_table( db ); db->strings = load_string_table( stg );
if( ret != ERROR_SUCCESS ) if( !db->strings )
goto end; goto end;
ret = ERROR_SUCCESS;
msiobj_addref( &db->hdr ); msiobj_addref( &db->hdr );
IStorage_AddRef( stg ); IStorage_AddRef( stg );
*pdb = db; *pdb = db;

View File

@ -276,7 +276,7 @@ extern void free_table( MSIDATABASE *db, MSITABLE *table );
extern void free_cached_tables( MSIDATABASE *db ); extern void free_cached_tables( MSIDATABASE *db );
extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
extern UINT load_string_table( MSIDATABASE *db ); extern string_table *load_string_table( IStorage *stg );
extern UINT MSI_CommitTables( MSIDATABASE *db ); extern UINT MSI_CommitTables( MSIDATABASE *db );
extern HRESULT init_string_table( IStorage *stg ); extern HRESULT init_string_table( IStorage *stg );

View File

@ -684,27 +684,22 @@ HRESULT init_string_table( IStorage *stg )
return r; return r;
} }
UINT load_string_table( MSIDATABASE *db ) string_table *load_string_table( IStorage *stg )
{ {
string_table *st = NULL;
CHAR *data; CHAR *data;
USHORT *pool; USHORT *pool;
UINT r, ret = ERROR_FUNCTION_FAILED, datasize = 0, poolsize = 0, codepage; UINT r, datasize = 0, poolsize = 0, codepage;
DWORD i, count, offset, len, n; DWORD i, count, offset, len, n;
static const WCHAR szStringData[] = { static const WCHAR szStringData[] = {
'_','S','t','r','i','n','g','D','a','t','a',0 }; '_','S','t','r','i','n','g','D','a','t','a',0 };
static const WCHAR szStringPool[] = { static const WCHAR szStringPool[] = {
'_','S','t','r','i','n','g','P','o','o','l',0 }; '_','S','t','r','i','n','g','P','o','o','l',0 };
if( db->strings ) r = read_stream_data( stg, szStringPool, &pool, &poolsize );
{
msi_destroy_stringtable( db->strings );
db->strings = NULL;
}
r = read_stream_data( db->storage, szStringPool, &pool, &poolsize );
if( r != ERROR_SUCCESS) if( r != ERROR_SUCCESS)
goto end; goto end;
r = read_stream_data( db->storage, szStringData, (USHORT**)&data, &datasize ); r = read_stream_data( stg, szStringData, (USHORT**)&data, &datasize );
if( r != ERROR_SUCCESS) if( r != ERROR_SUCCESS)
goto end; goto end;
@ -713,7 +708,7 @@ UINT load_string_table( MSIDATABASE *db )
codepage = pool[0] | ( pool[1] << 16 ); codepage = pool[0] | ( pool[1] << 16 );
else else
codepage = CP_ACP; codepage = CP_ACP;
db->strings = msi_init_stringtable( count, codepage ); st = msi_init_stringtable( count, codepage );
offset = 0; offset = 0;
n = 1; n = 1;
@ -738,7 +733,7 @@ UINT load_string_table( MSIDATABASE *db )
/* don't add the high word of a string's length as a string */ /* don't add the high word of a string's length as a string */
if ( len || !pool[i*2+1] ) if ( len || !pool[i*2+1] )
{ {
r = msi_addstring( db->strings, n, data+offset, len, pool[i*2+1] ); r = msi_addstring( st, n, data+offset, len, pool[i*2+1] );
if( r != n ) if( r != n )
ERR("Failed to add string %ld\n", n ); ERR("Failed to add string %ld\n", n );
n++; n++;
@ -752,13 +747,11 @@ UINT load_string_table( MSIDATABASE *db )
TRACE("Loaded %ld strings\n", count); TRACE("Loaded %ld strings\n", count);
ret = ERROR_SUCCESS;
end: end:
HeapFree( GetProcessHeap(), 0, pool ); HeapFree( GetProcessHeap(), 0, pool );
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
return ret; return st;
} }
static UINT save_string_table( MSIDATABASE *db ) static UINT save_string_table( MSIDATABASE *db )
@ -806,7 +799,7 @@ static UINT save_string_table( MSIDATABASE *db )
} }
if( sz && (sz < (datasize - used ) ) ) if( sz && (sz < (datasize - used ) ) )
sz--; sz--;
TRACE("adding %u bytes %s\n", sz, data+used ); TRACE("adding %u bytes %s\n", sz, debugstr_a(data+used) );
pool[ i*2 ] = sz; pool[ i*2 ] = sz;
pool[ i*2 + 1 ] = msi_id_refcount( db->strings, i ); pool[ i*2 + 1 ] = msi_id_refcount( db->strings, i );
used += sz; used += sz;