msi: Factor out the table insertion code.
This commit is contained in:
parent
2abb8bba13
commit
f12b9cea99
|
@ -108,97 +108,46 @@ static UINT create_custom_action_table( MSIHANDLE hdb )
|
||||||
"PRIMARY KEY `Action`)" );
|
"PRIMARY KEY `Action`)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
|
#define make_add_entry(type, qtext) \
|
||||||
{
|
static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
|
||||||
char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
|
{ \
|
||||||
"`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
|
char insert[] = qtext; \
|
||||||
char *query;
|
char *query; \
|
||||||
UINT sz, r;
|
UINT sz, r; \
|
||||||
|
sz = strlen(values) + sizeof insert; \
|
||||||
|
query = HeapAlloc(GetProcessHeap(),0,sz); \
|
||||||
|
sprintf(query,insert,values); \
|
||||||
|
r = run_query( hdb, query ); \
|
||||||
|
HeapFree(GetProcessHeap(), 0, query); \
|
||||||
|
return r; \
|
||||||
|
}
|
||||||
|
|
||||||
sz = strlen(values) + sizeof insert;
|
make_add_entry(feature,
|
||||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
"INSERT INTO `Feature` "
|
||||||
sprintf(query,insert,values);
|
"(`Feature`, `Feature_Parent`, `Title`, `Description`, "
|
||||||
r = run_query( hdb, query );
|
"`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UINT add_component_entry( MSIHANDLE hdb, const char *values )
|
make_add_entry(component,
|
||||||
{
|
"INSERT INTO `Component` "
|
||||||
char insert[] = "INSERT INTO `Component` "
|
"(`Component`, `ComponentId`, `Directory_`, "
|
||||||
"(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
|
"`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
|
||||||
"VALUES( %s )";
|
|
||||||
char *query;
|
|
||||||
UINT sz, r;
|
|
||||||
|
|
||||||
sz = strlen(values) + sizeof insert;
|
make_add_entry(feature_components,
|
||||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
"INSERT INTO `FeatureComponents` "
|
||||||
sprintf(query,insert,values);
|
"(`Feature_`, `Component_`) VALUES( %s )")
|
||||||
r = run_query( hdb, query );
|
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
|
make_add_entry(file,
|
||||||
{
|
"INSERT INTO `File` "
|
||||||
char insert[] = "INSERT INTO `FeatureComponents` "
|
"(`File`, `Component_`, `FileName`, `FileSize`, "
|
||||||
"(`Feature_`, `Component_`) "
|
"`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
|
||||||
"VALUES( %s )";
|
|
||||||
char *query;
|
|
||||||
UINT sz, r;
|
|
||||||
|
|
||||||
sz = strlen(values) + sizeof insert;
|
make_add_entry(directory,
|
||||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
"INSERT INTO `Directory` "
|
||||||
sprintf(query,insert,values);
|
"(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
|
||||||
r = run_query( hdb, query );
|
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UINT add_file_entry( MSIHANDLE hdb, const char *values )
|
make_add_entry(custom_action,
|
||||||
{
|
"INSERT INTO `CustomAction` "
|
||||||
char insert[] = "INSERT INTO `File` "
|
"(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
|
||||||
"(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
|
|
||||||
"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, query );
|
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
|
|
||||||
{
|
|
||||||
char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) 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, query );
|
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
sz = strlen(values) + sizeof insert;
|
|
||||||
query = HeapAlloc(GetProcessHeap(),0,sz);
|
|
||||||
sprintf(query,insert,values);
|
|
||||||
r = run_query( hdb, query );
|
|
||||||
HeapFree(GetProcessHeap(), 0, query);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static UINT set_summary_info(MSIHANDLE hdb)
|
static UINT set_summary_info(MSIHANDLE hdb)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue