[PATCH 1/3] msi: Remove a superfluous substructure and convert its arrays to lists.
Zebediah Figura
z.figura12 at gmail.com
Tue Sep 19 00:23:37 CDT 2017
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/msi/action.c | 45 +++++++++++++--------------------------------
dlls/msi/custom.c | 48 ++++++++++++++++--------------------------------
dlls/msi/msipriv.h | 40 +++++++++++++++++++---------------------
dlls/msi/package.c | 44 +++++++++++++++++++++++++++-----------------
4 files changed, 75 insertions(+), 102 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index ad42b36bf0..e92e5570dd 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -557,13 +557,13 @@ static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package)
MSIQUERY *view;
UINT rc;
- if (package->script->ExecuteSequenceRun)
+ if (package->ExecuteSequenceRun)
{
TRACE("Execute Sequence already Run\n");
return ERROR_SUCCESS;
}
- package->script->ExecuteSequenceRun = TRUE;
+ package->ExecuteSequenceRun = TRUE;
rc = MSI_OpenQuery(package->db, &view, query);
if (rc == ERROR_SUCCESS)
@@ -1536,41 +1536,24 @@ static UINT ACTION_CostInitialize(MSIPACKAGE *package)
return ERROR_SUCCESS;
}
-static UINT execute_script_action( MSIPACKAGE *package, UINT script, UINT index )
-{
- const WCHAR *action = package->script->Actions[script][index];
- ui_actionstart( package, action, NULL, NULL );
- TRACE("executing %s\n", debugstr_w(action));
- return ACTION_PerformAction( package, action, script );
-}
-
static UINT execute_script( MSIPACKAGE *package, UINT script )
{
- UINT i, rc = ERROR_SUCCESS;
+ struct action *action;
+ UINT rc = ERROR_SUCCESS;
TRACE("executing script %u\n", script);
- if (!package->script)
+ LIST_FOR_EACH_ENTRY( action, &package->script_actions[script], struct action, entry )
{
- ERR("no script!\n");
- return ERROR_FUNCTION_FAILED;
- }
- if (script == SCRIPT_ROLLBACK)
- {
- for (i = package->script->ActionCount[script]; i > 0; i--)
- {
- rc = execute_script_action( package, script, i - 1 );
- if (rc != ERROR_SUCCESS) break;
- }
- }
- else
- {
- for (i = 0; i < package->script->ActionCount[script]; i++)
+ rc = ACTION_PerformAction( package, action->action, script );
+ if (rc != ERROR_SUCCESS)
{
- rc = execute_script_action( package, script, i );
- if (rc != ERROR_SUCCESS) break;
+ ERR("Execution of script %i halted; action %s returned %u\n",
+ script, debugstr_w(action->action), rc);
+ break;
}
}
+
msi_free_action_script(package, script);
return rc;
}
@@ -5634,7 +5617,7 @@ static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
msiobj_release(&uirow->hdr);
/* Perform the installation. Always use the ExecuteSequence. */
- package->script->InWhatSequence |= SEQUENCE_EXEC;
+ package->InWhatSequence |= SEQUENCE_EXEC;
rc = ACTION_ProcessExecSequence(package);
/* Send return value and INSTALLEND. */
@@ -5688,7 +5671,7 @@ static UINT ACTION_INSTALL(MSIPACKAGE *package)
msi_set_property(package->db, szEXECUTEACTION, szINSTALL, -1);
if (needs_ui_sequence(package) && ui_sequence_exists(package))
{
- package->script->InWhatSequence |= SEQUENCE_UI;
+ package->InWhatSequence |= SEQUENCE_UI;
return ACTION_ProcessUISequence(package);
}
else
@@ -7976,8 +7959,6 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
UINT rc;
DWORD len = 0;
- package->script->InWhatSequence = SEQUENCE_INSTALL;
-
if (szPackagePath)
{
LPWSTR p, dir;
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 636f77fbdc..a3e32d9a24 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -66,8 +66,7 @@ static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_ac
UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action )
{
- UINT count;
- WCHAR **newbuf = NULL;
+ struct action *script_action = msi_alloc(sizeof(*script_action));
if (script >= SCRIPT_MAX)
{
@@ -76,60 +75,45 @@ UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action
}
TRACE("Scheduling action %s in script %u\n", debugstr_w(action), script);
- count = package->script->ActionCount[script];
- package->script->ActionCount[script]++;
- if (count != 0) newbuf = msi_realloc( package->script->Actions[script],
- package->script->ActionCount[script] * sizeof(WCHAR *) );
- else newbuf = msi_alloc( sizeof(WCHAR *) );
+ script_action->action = strdupW(action);
+ if (script == SCRIPT_ROLLBACK)
+ list_add_head(&package->script_actions[script], &script_action->entry);
+ else
+ list_add_tail(&package->script_actions[script], &script_action->entry);
- newbuf[count] = strdupW( action );
- package->script->Actions[script] = newbuf;
return ERROR_SUCCESS;
}
UINT msi_register_unique_action( MSIPACKAGE *package, const WCHAR *action )
{
- UINT count;
- WCHAR **newbuf = NULL;
-
- if (!package->script) return FALSE;
+ struct action *unique_action = msi_alloc(sizeof(*unique_action));
TRACE("Registering %s as unique action\n", debugstr_w(action));
- count = package->script->UniqueActionsCount;
- package->script->UniqueActionsCount++;
- if (count != 0) newbuf = msi_realloc( package->script->UniqueActions,
- package->script->UniqueActionsCount * sizeof(WCHAR *) );
- else newbuf = msi_alloc( sizeof(WCHAR *) );
+ unique_action->action = strdupW(action);
+ list_add_tail(&package->unique_actions, &unique_action->entry);
- newbuf[count] = strdupW( action );
- package->script->UniqueActions = newbuf;
return ERROR_SUCCESS;
}
BOOL msi_action_is_unique( const MSIPACKAGE *package, const WCHAR *action )
{
- UINT i;
+ struct action *unique_action;
- if (!package->script) return FALSE;
-
- for (i = 0; i < package->script->UniqueActionsCount; i++)
+ LIST_FOR_EACH_ENTRY( unique_action, &package->unique_actions, struct action, entry )
{
- if (!strcmpW( package->script->UniqueActions[i], action )) return TRUE;
+ if (!strcmpW( unique_action->action, action )) return TRUE;
}
return FALSE;
}
static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR action, UINT options)
{
- if (!package->script)
- return TRUE;
-
if ((options & msidbCustomActionTypeClientRepeat) ==
msidbCustomActionTypeClientRepeat)
{
- if (!(package->script->InWhatSequence & SEQUENCE_UI &&
- package->script->InWhatSequence & SEQUENCE_EXEC))
+ if (!(package->InWhatSequence & SEQUENCE_UI &&
+ package->InWhatSequence & SEQUENCE_EXEC))
{
TRACE("Skipping action due to dbCustomActionTypeClientRepeat option.\n");
return FALSE;
@@ -137,8 +121,8 @@ static BOOL check_execution_scheduling_options(MSIPACKAGE *package, LPCWSTR acti
}
else if (options & msidbCustomActionTypeFirstSequence)
{
- if (package->script->InWhatSequence & SEQUENCE_UI &&
- package->script->InWhatSequence & SEQUENCE_EXEC )
+ if (package->InWhatSequence & SEQUENCE_UI &&
+ package->InWhatSequence & SEQUENCE_EXEC )
{
TRACE("Skipping action due to msidbCustomActionTypeFirstSequence option.\n");
return FALSE;
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index a25ea31e94..efe75c8be7 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -371,6 +371,21 @@ enum clr_version
CLR_VERSION_MAX
};
+enum script
+{
+ SCRIPT_NONE = -1,
+ SCRIPT_INSTALL = 0,
+ SCRIPT_COMMIT = 1,
+ SCRIPT_ROLLBACK = 2,
+ SCRIPT_MAX = 3
+};
+
+struct action
+{
+ struct list entry;
+ WCHAR *action;
+};
+
typedef struct tagMSIPACKAGE
{
MSIOBJECTHDR hdr;
@@ -403,7 +418,10 @@ typedef struct tagMSIPACKAGE
struct list mimes;
struct list appids;
- struct tagMSISCRIPT *script;
+ struct list script_actions[SCRIPT_MAX];
+ struct list unique_actions;
+ BOOL ExecuteSequenceRun;
+ UINT InWhatSequence;
struct list RunningActions;
@@ -679,28 +697,8 @@ struct tagMSIMIME
MSICLASS *Class;
};
-enum SCRIPTS
-{
- SCRIPT_NONE = -1,
- SCRIPT_INSTALL = 0,
- SCRIPT_COMMIT = 1,
- SCRIPT_ROLLBACK = 2,
- SCRIPT_MAX = 3
-};
-
#define SEQUENCE_UI 0x1
#define SEQUENCE_EXEC 0x2
-#define SEQUENCE_INSTALL 0x10
-
-typedef struct tagMSISCRIPT
-{
- LPWSTR *Actions[SCRIPT_MAX];
- UINT ActionCount[SCRIPT_MAX];
- BOOL ExecuteSequenceRun;
- UINT InWhatSequence;
- LPWSTR *UniqueActions;
- UINT UniqueActionsCount;
-} MSISCRIPT;
#define MSIHANDLETYPE_ANY 0
#define MSIHANDLETYPE_DATABASE 1
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 7c6ca84665..476c92dcc0 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -128,18 +128,19 @@ static void free_assembly( MSIASSEMBLY *assembly )
void msi_free_action_script( MSIPACKAGE *package, UINT script )
{
- UINT i;
- for (i = 0; i < package->script->ActionCount[script]; i++)
- msi_free( package->script->Actions[script][i] );
-
- msi_free( package->script->Actions[script] );
- package->script->Actions[script] = NULL;
- package->script->ActionCount[script] = 0;
+ struct action *action, *cursor;
+ LIST_FOR_EACH_ENTRY_SAFE( action, cursor, &package->script_actions[script], struct action, entry )
+ {
+ list_remove( &action->entry );
+ msi_free( action->action );
+ msi_free( action );
+ }
}
static void free_package_structures( MSIPACKAGE *package )
{
struct list *item, *cursor;
+ int i;
LIST_FOR_EACH_SAFE( item, cursor, &package->features )
{
@@ -275,19 +276,25 @@ static void free_package_structures( MSIPACKAGE *package )
msi_free( info );
}
- if (package->script)
+ for (i = 0; i < SCRIPT_MAX; i++)
{
- INT i;
- UINT j;
+ LIST_FOR_EACH_SAFE( item, cursor, &package->script_actions[i] )
+ {
+ struct action *action = LIST_ENTRY( item, struct action, entry );
- for (i = 0; i < SCRIPT_MAX; i++)
- msi_free_action_script( package, i );
+ list_remove( &action->entry );
+ msi_free( action->action );
+ msi_free( action );
+ }
+ }
- for (j = 0; j < package->script->UniqueActionsCount; j++)
- msi_free( package->script->UniqueActions[j] );
+ LIST_FOR_EACH_SAFE( item, cursor, &package->unique_actions )
+ {
+ struct action *action = LIST_ENTRY( item, struct action, entry );
- msi_free( package->script->UniqueActions );
- msi_free( package->script );
+ list_remove( &action->entry );
+ msi_free( action->action );
+ msi_free( action );
}
LIST_FOR_EACH_SAFE( item, cursor, &package->binaries )
@@ -1003,6 +1010,7 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static MSIPACKAGE *msi_alloc_package( void )
{
MSIPACKAGE *package;
+ int i;
package = alloc_msiobject( MSIHANDLETYPE_PACKAGE, sizeof (MSIPACKAGE),
MSI_FreePackage );
@@ -1020,12 +1028,15 @@ static MSIPACKAGE *msi_alloc_package( void )
list_init( &package->mimes );
list_init( &package->extensions );
list_init( &package->progids );
+ list_init( &package->unique_actions );
list_init( &package->RunningActions );
list_init( &package->sourcelist_info );
list_init( &package->sourcelist_media );
list_init( &package->patches );
list_init( &package->binaries );
list_init( &package->cabinet_streams );
+ for (i = 0; i < SCRIPT_MAX; i++)
+ list_init( &package->script_actions[i] );
}
return package;
@@ -1087,7 +1098,6 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
msi_adjust_privilege_properties( package );
package->ProductCode = msi_dup_property( package->db, szProductCode );
- package->script = msi_alloc_zero( sizeof(MSISCRIPT) );
set_installer_properties( package );
--
2.14.1
More information about the wine-patches
mailing list