MSI: use the new helper function MSI_QueryGetRecord
Mike McCormack
mike at codeweavers.com
Thu Jun 2 01:48:46 CDT 2005
ChangeLog:
* use the new helper function MSI_QueryGetRecord
-------------- next part --------------
Index: dlls/msi/action.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/action.c,v
retrieving revision 1.126
diff -u -p -r1.126 action.c
--- dlls/msi/action.c 31 May 2005 13:20:09 -0000 1.126
+++ dlls/msi/action.c 2 Jun 2005 06:49:29 -0000
@@ -730,8 +730,6 @@ static void ui_actiondata(MSIPACKAGE *pa
'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
' ','\'','%','s','\'',0};
WCHAR message[1024];
- UINT rc;
- MSIQUERY * view;
MSIRECORD * row = 0;
DWORD size;
static const WCHAR szActionData[] =
@@ -739,30 +737,13 @@ static void ui_actiondata(MSIPACKAGE *pa
if (!package->LastAction || strcmpW(package->LastAction,action))
{
- rc = MSI_OpenQuery(package->db, &view, Query_t, action);
- if (rc != ERROR_SUCCESS)
- return;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return;
- }
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, Query_t, action);
+ if (!row)
return;
- }
if (MSI_RecordIsNull(row,3))
{
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return;
}
@@ -774,8 +755,6 @@ static void ui_actiondata(MSIPACKAGE *pa
package->LastAction = strdupW(action);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
}
MSI_RecordSetStringW(record,0,package->ActionFormat);
@@ -807,35 +786,17 @@ static void ui_actionstart(MSIPACKAGE *p
' ','\'','%','s','\'',0};
WCHAR message[1024];
WCHAR timet[0x100];
- UINT rc;
- MSIQUERY * view;
MSIRECORD * row = 0;
WCHAR *ActionText=NULL;
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
- rc = MSI_OpenQuery(package->db, &view, Query_t, action);
- if (rc != ERROR_SUCCESS)
- return;
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return;
- }
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord( package->db, Query_t, action );
+ if (!row)
return;
- }
ActionText = load_dynamic_stringW(row,2);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
sprintfW(message,template_s,timet,action,ActionText);
@@ -1100,8 +1061,7 @@ UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE
static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
{
- MSIQUERY * view;
- UINT rc;
+ UINT rc = ERROR_SUCCESS;
WCHAR buffer[0x100];
DWORD sz = 0x100;
MSIRECORD * row = 0;
@@ -1118,30 +1078,14 @@ static UINT ACTION_PerformActionSequence
' ', '=',' ','%','i',0};
if (UI)
- rc = MSI_OpenQuery(package->db, &view, UISeqQuery, seq);
+ row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
else
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
- if (rc == ERROR_SUCCESS)
+ if (row)
{
- rc = MSI_ViewExecute(view, 0);
-
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- goto end;
- }
-
TRACE("Running the actions\n");
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- rc = ERROR_SUCCESS;
- goto end;
- }
-
/* check conditions */
if (!MSI_RecordIsNull(row,2))
{
@@ -1154,7 +1098,6 @@ static UINT ACTION_PerformActionSequence
if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
{
HeapFree(GetProcessHeap(),0,cond);
- msiobj_release(&row->hdr);
goto end;
}
else
@@ -1175,10 +1118,8 @@ static UINT ACTION_PerformActionSequence
rc = ACTION_PerformUIAction(package,buffer);
else
rc = ACTION_PerformAction(package,buffer, FALSE);
- msiobj_release(&row->hdr);
end:
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ msiobj_release(&row->hdr);
}
else
rc = ERROR_SUCCESS;
@@ -1219,27 +1160,11 @@ static UINT ACTION_ProcessExecSequence(M
/* get the sequence number */
if (UIran)
{
- rc = MSI_DatabaseOpenViewW(package->db, IVQuery, &view);
- if (rc != ERROR_SUCCESS)
- return rc;
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
+ row = MSI_QueryGetRecord(package->db, IVQuery);
+ if( !row )
+ return ERROR_FUNCTION_FAILED;
seq = MSI_RecordGetInteger(row,1);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
@@ -2105,8 +2030,6 @@ static INT load_folder(MSIPACKAGE *packa
'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
' ','=',' ','\'','%','s','\'',
0};
- UINT rc;
- MSIQUERY * view;
LPWSTR ptargetdir, targetdir, parent, srcdir;
LPWSTR shortname = NULL;
MSIRECORD * row = 0;
@@ -2139,25 +2062,9 @@ static INT load_folder(MSIPACKAGE *packa
package->folders[index].Directory = strdupW(dir);
- rc = MSI_OpenQuery(package->db, &view, Query, dir);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, Query, dir);
+ if (!row)
return -1;
- }
ptargetdir = targetdir = load_dynamic_stringW(row,3);
@@ -2226,8 +2133,6 @@ static INT load_folder(MSIPACKAGE *packa
package->folders[index].Property = load_dynamic_property(package, dir,NULL);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
TRACE(" %s retuning on index %i\n",debugstr_w(dir),index);
return index;
}
@@ -3154,8 +3059,7 @@ static BOOL extract_a_cabinet_file(MSIPA
static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path,
MSIFILE* file)
{
- UINT rc;
- MSIQUERY * view;
+ UINT rc = ERROR_SUCCESS;
MSIRECORD * row = 0;
static WCHAR source[MAX_PATH];
static const WCHAR ExecSeqQuery[] =
@@ -3164,7 +3068,6 @@ static UINT ready_media_for_file(MSIPACK
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',
' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ',
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',0};
- WCHAR Query[1024];
WCHAR cab[0x100];
DWORD sz=0x100;
INT seq;
@@ -3183,27 +3086,10 @@ static UINT ready_media_for_file(MSIPACK
return ERROR_SUCCESS;
}
- sprintfW(Query,ExecSeqQuery,file->Sequence);
-
- rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
- if (rc != ERROR_SUCCESS)
- return rc;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, file->Sequence);
+ if (!row)
+ return ERROR_FUNCTION_FAILED;
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
seq = MSI_RecordGetInteger(row,2);
last_sequence = seq;
@@ -3247,8 +3133,6 @@ static UINT ready_media_for_file(MSIPACK
strcpyW(path,source);
}
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -4043,9 +3927,8 @@ static LPWSTR resolve_keypath( MSIPACKAG
}
if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
{
- MSIQUERY * view;
MSIRECORD * row = 0;
- UINT rc,root,len;
+ UINT root,len;
LPWSTR key,deformated,buffer,name,deformated_name;
static const WCHAR ExecSeqQuery[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@@ -4056,26 +3939,9 @@ static LPWSTR resolve_keypath( MSIPACKAG
static const WCHAR fmt2[]=
{'%','0','2','i',':','\\','%','s','\\','%','s',0};
- rc = MSI_OpenQuery(package->db,&view,ExecSeqQuery,cmp->KeyPath);
-
- if (rc!=ERROR_SUCCESS)
- return NULL;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return NULL;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
+ if (!row)
return NULL;
- }
root = MSI_RecordGetInteger(row,2);
key = load_dynamic_stringW(row, 3);
@@ -4099,8 +3965,6 @@ static LPWSTR resolve_keypath( MSIPACKAG
HeapFree(GetProcessHeap(),0,name);
HeapFree(GetProcessHeap(),0,deformated_name);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return buffer;
}
@@ -4596,7 +4460,6 @@ static INT load_appid(MSIPACKAGE* packag
static INT load_given_appid(MSIPACKAGE *package, LPCWSTR appid)
{
INT rc;
- MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@@ -4615,30 +4478,12 @@ static INT load_given_appid(MSIPACKAGE *
return i;
}
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, appid);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, appid);
+ if (!row)
return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
rc = load_appid(package, row);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -4725,7 +4570,6 @@ static INT load_progid(MSIPACKAGE* packa
static INT load_given_progid(MSIPACKAGE *package, LPCWSTR progid)
{
INT rc;
- MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@@ -4744,30 +4588,12 @@ static INT load_given_progid(MSIPACKAGE
return i;
}
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, progid);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, progid);
+ if(!row)
return -1;
- }
rc = load_progid(package, row);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -4893,7 +4719,6 @@ static INT load_class(MSIPACKAGE* packag
static INT load_given_class(MSIPACKAGE *package, LPCWSTR classid)
{
INT rc;
- MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@@ -4913,30 +4738,12 @@ static INT load_given_class(MSIPACKAGE *
return i;
}
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, classid);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, classid);
+ if (!row)
return -1;
- }
rc = load_class(package, row);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -4980,7 +4787,6 @@ static INT load_mime(MSIPACKAGE* package
static INT load_given_mime(MSIPACKAGE *package, LPCWSTR mime)
{
INT rc;
- MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@@ -5000,30 +4806,12 @@ static INT load_given_mime(MSIPACKAGE *p
return i;
}
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, mime);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, mime);
+ if (!row)
return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
rc = load_mime(package, row);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -5079,7 +4867,6 @@ static INT load_extension(MSIPACKAGE* pa
static INT load_given_extension(MSIPACKAGE *package, LPCWSTR extension)
{
INT rc;
- MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@@ -5101,30 +4888,12 @@ static INT load_given_extension(MSIPACKA
return i;
}
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, extension);
- if (rc != ERROR_SUCCESS)
- return -1;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord(package->db, ExecSeqQuery, extension);
+ if (!row)
return -1;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return -1;
- }
rc = load_extension(package, row);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
Index: dlls/msi/custom.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/custom.c,v
retrieving revision 1.14
diff -u -p -r1.14 custom.c
--- dlls/msi/custom.c 27 May 2005 19:24:22 -0000 1.14
+++ dlls/msi/custom.c 2 Jun 2005 06:49:29 -0000
@@ -77,7 +77,6 @@ static UINT HANDLE_CustomType34(MSIPACKA
UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
{
UINT rc = ERROR_SUCCESS;
- MSIQUERY * view;
MSIRECORD * row = 0;
static const WCHAR ExecSeqQuery[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@@ -89,25 +88,9 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
LPWSTR target;
WCHAR *deformated=NULL;
- rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, action);
- if (rc != ERROR_SUCCESS)
- return rc;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
+ row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
+ if (!row)
return ERROR_CALL_NOT_IMPLEMENTED;
- }
type = MSI_RecordGetInteger(row,2);
@@ -127,8 +110,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return ERROR_SUCCESS;
}
if (!execute)
@@ -147,8 +128,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return ERROR_SUCCESS;
}
else
@@ -202,8 +181,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
return rc;
}
@@ -228,7 +205,6 @@ static UINT store_binary_to_temp(MSIPACK
{
/* write out the file */
UINT rc;
- MSIQUERY * view;
MSIRECORD * row = 0;
static const WCHAR fmt[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@@ -246,25 +222,9 @@ static UINT store_binary_to_temp(MSIPACK
if (the_file == INVALID_HANDLE_VALUE)
return ERROR_FUNCTION_FAILED;
- rc = MSI_OpenQuery(package->db, &view, fmt, source);
- if (rc != ERROR_SUCCESS)
- return rc;
-
- rc = MSI_ViewExecute(view, 0);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
-
- rc = MSI_ViewFetch(view,&row);
- if (rc != ERROR_SUCCESS)
- {
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
- return rc;
- }
+ row = MSI_QueryGetRecord(package->db, fmt, source);
+ if (!row)
+ return ERROR_FUNCTION_FAILED;
do
{
@@ -284,8 +244,6 @@ static UINT store_binary_to_temp(MSIPACK
CloseHandle(the_file);
msiobj_release(&row->hdr);
- MSI_ViewClose(view);
- msiobj_release(&view->hdr);
}
return ERROR_SUCCESS;
@@ -615,37 +573,23 @@ static UINT HANDLE_CustomType19(MSIPACKA
'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
'\'','%','s','\'',0
};
- MSIQUERY *view = NULL;
MSIRECORD *row = 0;
- UINT r;
LPWSTR deformated = NULL;
deformat_string( package, target, &deformated );
/* first try treat the error as a number */
- r = MSI_OpenQuery( package->db, &view, query, deformated );
- if( r == ERROR_SUCCESS )
+ row = MSI_QueryGetRecord( package->db, query, deformated );
+ if( row )
{
- r = MSI_ViewExecute( view, 0 );
- if( r == ERROR_SUCCESS )
- {
- r = MSI_ViewFetch( view, &row );
- if( r == ERROR_SUCCESS )
- {
- LPCWSTR error = MSI_RecordGetString( row, 1 );
- MessageBoxW( NULL, error, NULL, MB_OK );
- msiobj_release( &row->hdr );
- }
- }
- MSI_ViewClose( view );
- msiobj_release( &view->hdr );
+ LPCWSTR error = MSI_RecordGetString( row, 1 );
+ MessageBoxW( NULL, error, NULL, MB_OK );
+ msiobj_release( &row->hdr );
}
-
- if (r != ERROR_SUCCESS )
- {
+ else
MessageBoxW( NULL, deformated, NULL, MB_OK );
- HeapFree( GetProcessHeap(), 0, deformated );
- }
+
+ HeapFree( GetProcessHeap(), 0, deformated );
return ERROR_FUNCTION_FAILED;
}
More information about the wine-patches
mailing list