James Hawkins : msi: Factor out the table insertion code.
Alexandre Julliard
julliard at winehq.org
Tue Nov 4 07:29:07 CST 2008
Module: wine
Branch: master
Commit: f12b9cea99475fae63ab87c3f60dba379a1f450f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f12b9cea99475fae63ab87c3f60dba379a1f450f
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Mon Nov 3 22:16:30 2008 -0600
msi: Factor out the table insertion code.
---
dlls/msi/tests/format.c | 131 ++++++++++++++--------------------------------
1 files changed, 40 insertions(+), 91 deletions(-)
diff --git a/dlls/msi/tests/format.c b/dlls/msi/tests/format.c
index 00d3856..c4be429 100644
--- a/dlls/msi/tests/format.c
+++ b/dlls/msi/tests/format.c
@@ -108,97 +108,46 @@ static UINT create_custom_action_table( MSIHANDLE hdb )
"PRIMARY KEY `Action`)" );
}
-static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
-{
- char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
- "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) 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;
-}
+#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, query ); \
+ HeapFree(GetProcessHeap(), 0, query); \
+ return r; \
+ }
-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;
-
- 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;
-}
+make_add_entry(feature,
+ "INSERT INTO `Feature` "
+ "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
+ "`Display`, `Level`, `Directory_`, `Attributes`) 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;
-
- 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;
-}
+make_add_entry(component,
+ "INSERT INTO `Component` "
+ "(`Component`, `ComponentId`, `Directory_`, "
+ "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
-static UINT add_file_entry( MSIHANDLE hdb, const char *values )
-{
- char insert[] = "INSERT INTO `File` "
- "(`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;
-}
+make_add_entry(feature_components,
+ "INSERT INTO `FeatureComponents` "
+ "(`Feature_`, `Component_`) VALUES( %s )")
-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;
-}
+make_add_entry(file,
+ "INSERT INTO `File` "
+ "(`File`, `Component_`, `FileName`, `FileSize`, "
+ "`Version`, `Language`, `Attributes`, `Sequence`) 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;
-
- 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;
-}
+make_add_entry(directory,
+ "INSERT INTO `Directory` "
+ "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
+
+make_add_entry(custom_action,
+ "INSERT INTO `CustomAction` "
+ "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
static UINT set_summary_info(MSIHANDLE hdb)
{
More information about the wine-cvs
mailing list