mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
msi: Factor out the table insertion code.
This commit is contained in:
parent
88f39d95f2
commit
2abb8bba13
1 changed files with 27 additions and 74 deletions
|
@ -241,85 +241,38 @@ static UINT create_binary_table( MSIHANDLE hdb )
|
|||
"PRIMARY KEY `Name` )" );
|
||||
}
|
||||
|
||||
static UINT add_component_entry( MSIHANDLE hdb, const char *values )
|
||||
{
|
||||
char insert[] = "INSERT INTO `Component` "
|
||||
"(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
|
||||
"VALUES( %s )";
|
||||
char *query;
|
||||
UINT sz, r;
|
||||
#define make_add_entry(type, qtext) \
|
||||
static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
|
||||
{ \
|
||||
char insert[] = qtext; \
|
||||
char *query; \
|
||||
UINT sz, r; \
|
||||
sz = strlen(values) + sizeof insert; \
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz); \
|
||||
sprintf(query,insert,values); \
|
||||
r = run_query( hdb, 0, query ); \
|
||||
HeapFree(GetProcessHeap(), 0, query); \
|
||||
return r; \
|
||||
}
|
||||
|
||||
sz = strlen(values) + sizeof insert;
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
||||
sprintf(query,insert,values);
|
||||
r = run_query( hdb, 0, query );
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
return r;
|
||||
}
|
||||
make_add_entry(component,
|
||||
"INSERT INTO `Component` "
|
||||
"(`Component`, `ComponentId`, `Directory_`, "
|
||||
"`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
|
||||
|
||||
static UINT add_custom_action_entry( MSIHANDLE hdb, const char *values )
|
||||
{
|
||||
char insert[] = "INSERT INTO `CustomAction` "
|
||||
"(`Action`, `Type`, `Source`, `Target`) "
|
||||
"VALUES( %s )";
|
||||
char *query;
|
||||
UINT sz, r;
|
||||
make_add_entry(custom_action,
|
||||
"INSERT INTO `CustomAction` "
|
||||
"(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
|
||||
|
||||
sz = strlen(values) + sizeof insert;
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
||||
sprintf(query,insert,values);
|
||||
r = run_query( hdb, 0, query );
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
return r;
|
||||
}
|
||||
make_add_entry(feature_components,
|
||||
"INSERT INTO `FeatureComponents` "
|
||||
"(`Feature_`, `Component_`) VALUES( %s )")
|
||||
|
||||
static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
|
||||
{
|
||||
char insert[] = "INSERT INTO `FeatureComponents` "
|
||||
"(`Feature_`, `Component_`) "
|
||||
"VALUES( %s )";
|
||||
char *query;
|
||||
UINT sz, r;
|
||||
make_add_entry(std_dlls,
|
||||
"INSERT INTO `StdDlls` (`File`, `Binary_`) VALUES( %s )")
|
||||
|
||||
sz = strlen(values) + sizeof insert;
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
||||
sprintf(query,insert,values);
|
||||
r = run_query( hdb, 0, query );
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
return r;
|
||||
}
|
||||
|
||||
static UINT add_std_dlls_entry( MSIHANDLE hdb, const char *values )
|
||||
{
|
||||
char insert[] = "INSERT INTO `StdDlls` "
|
||||
"(`File`, `Binary_`) "
|
||||
"VALUES( %s )";
|
||||
char *query;
|
||||
UINT sz, r;
|
||||
|
||||
sz = strlen(values) + sizeof insert;
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
||||
sprintf(query,insert,values);
|
||||
r = run_query( hdb, 0, query );
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
return r;
|
||||
}
|
||||
|
||||
static UINT add_binary_entry( MSIHANDLE hdb, const char *values )
|
||||
{
|
||||
char insert[] = "INSERT INTO `Binary` "
|
||||
"(`Name`, `Data`) "
|
||||
"VALUES( %s )";
|
||||
char *query;
|
||||
UINT sz, r;
|
||||
|
||||
sz = strlen(values) + sizeof insert;
|
||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
||||
sprintf(query,insert,values);
|
||||
r = run_query( hdb, 0, query );
|
||||
HeapFree(GetProcessHeap(), 0, query);
|
||||
return r;
|
||||
}
|
||||
make_add_entry(binary,
|
||||
"INSERT INTO `Binary` (`Name`, `Data`) VALUES( %s )")
|
||||
|
||||
static void test_msiinsert(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue