Commit 38d67a45 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

- build a standard Wine list of components instead of using an array

- use component pointers instead of array indexes
parent 94feee32
......@@ -44,6 +44,8 @@ typedef struct tagMSIFEATURE
typedef struct tagMSICOMPONENT
{
struct list entry;
DWORD magic;
WCHAR Component[IDENTIFIER_SIZE];
WCHAR ComponentId[IDENTIFIER_SIZE];
WCHAR Directory[IDENTIFIER_SIZE];
......@@ -66,7 +68,7 @@ typedef struct tagMSICOMPONENT
typedef struct tagComponentList
{
struct list entry;
int component;
MSICOMPONENT *component;
} ComponentList;
typedef struct tagMSIFOLDER
......@@ -91,7 +93,7 @@ typedef struct tagMSIFOLDER
typedef struct tagMSIFILE
{
LPWSTR File;
INT ComponentIndex;
MSICOMPONENT *Component;
LPWSTR FileName;
LPWSTR ShortName;
INT FileSize;
......@@ -115,7 +117,7 @@ typedef struct tagMSICLASS
{
WCHAR CLSID[IDENTIFIER_SIZE]; /* Primary Key */
WCHAR Context[IDENTIFIER_SIZE]; /* Primary Key */
INT ComponentIndex; /* Primary Key */
MSICOMPONENT *Component;
INT ProgIDIndex;
LPWSTR ProgIDText;
LPWSTR Description;
......@@ -134,7 +136,7 @@ typedef struct tagMSICLASS
typedef struct tagMSIEXTENSION
{
WCHAR Extension[256]; /* Primary Key */
INT ComponentIndex; /* Primary Key */
MSICOMPONENT *Component;
INT ProgIDIndex;
LPWSTR ProgIDText;
INT MIMEIndex;
......@@ -233,7 +235,7 @@ WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index);
LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc);
LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
BOOL set_prop, MSIFOLDER **folder);
int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component );
MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature );
int get_loaded_file(MSIPACKAGE* package, LPCWSTR file);
int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
......@@ -242,7 +244,7 @@ UINT build_icon_path(MSIPACKAGE *, LPCWSTR, LPWSTR *);
DWORD build_version_dword(LPCWSTR);
LPWSTR build_directory_name(DWORD , ...);
BOOL create_full_pathW(const WCHAR *path);
BOOL ACTION_VerifyComponentForAction(MSIPACKAGE*, INT, INSTALLSTATE);
BOOL ACTION_VerifyComponentForAction(MSIPACKAGE*, MSICOMPONENT*, INSTALLSTATE);
BOOL ACTION_VerifyFeatureForAction(MSIPACKAGE*, INT, INSTALLSTATE);
void reduce_to_longfilename(WCHAR*);
void reduce_to_shortfilename(WCHAR*);
......
......@@ -253,8 +253,7 @@ static INT load_class(MSIPACKAGE* package, MSIRECORD *row)
sz = IDENTIFIER_SIZE;
MSI_RecordGetStringW(row, 2, package->classes[index].Context, &sz);
buffer = MSI_RecordGetString(row,3);
package->classes[index].ComponentIndex = get_loaded_component(package,
buffer);
package->classes[index].Component = get_loaded_component(package, buffer);
package->classes[index].ProgIDText = load_dynamic_stringW(row,4);
package->classes[index].ProgIDIndex =
......@@ -466,8 +465,7 @@ static INT load_extension(MSIPACKAGE* package, MSIRECORD *row)
debugstr_w(package->extensions[index].Extension));
buffer = MSI_RecordGetString(row,2);
package->extensions[index].ComponentIndex =
get_loaded_component(package,buffer);
package->extensions[index].Component = get_loaded_component(package,buffer);
package->extensions[index].ProgIDText = load_dynamic_stringW(row,3);
package->extensions[index].ProgIDIndex = load_given_progid(package,
......@@ -574,10 +572,10 @@ static UINT iterate_load_verb(MSIRECORD *row, LPVOID param)
static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
{
MSICOMPONENT *comp;
LPCWSTR clsid;
LPCWSTR context;
LPCWSTR buffer;
INT component_index;
MSIPACKAGE* package =(MSIPACKAGE*)param;
INT i;
BOOL match = FALSE;
......@@ -585,7 +583,7 @@ static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
clsid = MSI_RecordGetString(rec,1);
context = MSI_RecordGetString(rec,2);
buffer = MSI_RecordGetString(rec,3);
component_index = get_loaded_component(package,buffer);
comp = get_loaded_component(package,buffer);
for (i = 0; i < package->loaded_classes; i++)
{
......@@ -593,7 +591,7 @@ static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
continue;
if (strcmpW(context,package->classes[i].Context))
continue;
if (component_index == package->classes[i].ComponentIndex)
if (comp == package->classes[i].Component)
{
match = TRUE;
break;
......@@ -625,22 +623,22 @@ static VOID load_all_classes(MSIPACKAGE *package)
static UINT iterate_all_extensions(MSIRECORD *rec, LPVOID param)
{
MSICOMPONENT *comp;
LPCWSTR buffer;
LPCWSTR extension;
INT component_index;
MSIPACKAGE* package =(MSIPACKAGE*)param;
BOOL match = FALSE;
INT i;
extension = MSI_RecordGetString(rec,1);
buffer = MSI_RecordGetString(rec,2);
component_index = get_loaded_component(package,buffer);
comp = get_loaded_component(package,buffer);
for (i = 0; i < package->loaded_extensions; i++)
{
if (strcmpiW(extension,package->extensions[i].Extension))
continue;
if (component_index == package->extensions[i].ComponentIndex)
if (comp == package->extensions[i].Component)
{
match = TRUE;
break;
......@@ -920,16 +918,15 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
for (i = 0; i < package->loaded_classes; i++)
{
INT index,f_index;
MSICOMPONENT *comp;
INT index, f_index;
DWORD size, sz;
LPWSTR argument;
if (package->classes[i].ComponentIndex < 0)
{
comp = package->classes[i].Component;
if ( !comp )
continue;
}
index = package->classes[i].ComponentIndex;
f_index = package->classes[i].FeatureIndex;
/*
......@@ -963,7 +960,7 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
Description)+1)*sizeof(WCHAR));
RegCreateKeyW(hkey2,package->classes[i].Context,&hkey3);
index = get_loaded_file(package,package->components[index].KeyPath);
index = get_loaded_file( package, comp->KeyPath );
/* the context server is a short path name
......@@ -1425,14 +1422,13 @@ UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
for (i = 0; i < package->loaded_extensions; i++)
{
WCHAR extension[257];
INT index,f_index;
INT f_index;
index = package->extensions[i].ComponentIndex;
f_index = package->extensions[i].FeatureIndex;
if (index < 0)
if (!package->extensions[i].Component)
continue;
f_index = package->extensions[i].FeatureIndex;
/*
* yes. MSDN says that these are based on _Feature_ not on
* Component. So verify the feature is to be installed
......@@ -1512,7 +1508,7 @@ UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
/* do all the verbs */
for (v = 0; v < package->extensions[i].VerbCount; v++)
register_verb(package, progid,
&package->components[index],
package->extensions[i].Component,
&package->extensions[i],
&package->verbs[package->extensions[i].Verbs[v]],
&Sequence);
......
......@@ -56,14 +56,13 @@ extern const WCHAR szRemoveFiles[];
static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
inline static UINT create_component_directory ( MSIPACKAGE* package, INT component)
static UINT create_component_directory( MSIPACKAGE* package, MSICOMPONENT *comp )
{
UINT rc = ERROR_SUCCESS;
MSIFOLDER *folder;
LPWSTR install_path;
install_path = resolve_folder(package, package->components[component].Directory,
FALSE, FALSE, &folder);
install_path = resolve_folder(package, comp->Directory, FALSE, FALSE, &folder);
if (!install_path)
return ERROR_FUNCTION_FAILED;
......@@ -683,7 +682,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
if (file->Temporary)
continue;
if (!ACTION_VerifyComponentForAction(package, file->ComponentIndex,
if (!ACTION_VerifyComponentForAction(package, file->Component,
INSTALLSTATE_LOCAL))
{
ui_progress(package,2,file->FileSize,0,0);
......@@ -700,13 +699,12 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
TRACE("Pass 1: %s\n",debugstr_w(file->File));
create_component_directory( package, file->ComponentIndex);
create_component_directory( package, file->Component );
/* recalculate file paths because things may have changed */
if (file->ComponentIndex >= 0)
comp = &package->components[file->ComponentIndex];
else
comp = file->Component;
if (!comp)
{
ERR("No Component for file\n");
continue;
......@@ -724,7 +722,6 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
for (index = 0; index < package->loaded_files; index++)
{
MSIFILE *file;
MSICOMPONENT* comp = NULL;
file = &package->files[index];
......@@ -735,10 +732,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
{
TRACE("Pass 2: %s\n",debugstr_w(file->File));
if (file->ComponentIndex >= 0)
comp = &package->components[file->ComponentIndex];
rc = ready_media_for_file(package, index, comp);
rc = ready_media_for_file( package, index, file->Component );
if (rc != ERROR_SUCCESS)
{
ERR("Unable to ready media\n");
......@@ -808,27 +802,25 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param)
WCHAR dest_name[0x100];
LPWSTR dest_path, dest;
LPCWSTR file_key, component;
INT component_index;
DWORD sz;
DWORD rc;
MSICOMPONENT *comp;
component = MSI_RecordGetString(row,2);
component_index = get_loaded_component(package,component);
comp = get_loaded_component(package,component);
if (!ACTION_VerifyComponentForAction(package, component_index,
INSTALLSTATE_LOCAL))
if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL))
{
TRACE("Skipping copy due to disabled component %s\n",
debugstr_w(component));
/* the action taken was the same as the current install state */
package->components[component_index].Action =
package->components[component_index].Installed;
comp->Action = comp->Installed;
return ERROR_SUCCESS;
}
package->components[component_index].Action = INSTALLSTATE_LOCAL;
comp->Action = INSTALLSTATE_LOCAL;
file_key = MSI_RecordGetString(row,3);
if (!file_key)
......
......@@ -79,18 +79,17 @@ static const WCHAR* scanW(LPCWSTR buf, WCHAR token, DWORD len)
static LPWSTR deformat_component(MSIPACKAGE* package, LPCWSTR key, DWORD* sz)
{
LPWSTR value = NULL;
INT index;
MSICOMPONENT *comp;
*sz = 0;
if (!package)
return NULL;
ERR("POORLY HANDLED DEFORMAT.. [$componentkey] \n");
index = get_loaded_component(package,key);
if (index >= 0)
comp = get_loaded_component(package,key);
if (comp)
{
value = resolve_folder(package, package->components[index].Directory,
FALSE, FALSE, NULL);
value = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
*sz = (strlenW(value)) * sizeof(WCHAR);
}
......
......@@ -167,20 +167,16 @@ LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc)
return str;
}
int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component )
MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component )
{
int rc = -1;
DWORD i;
MSICOMPONENT *comp = NULL;
for (i = 0; i < package->loaded_components; i++)
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
{
if (strcmpW(Component,package->components[i].Component)==0)
{
rc = i;
break;
}
if (lstrcmpW(Component,comp->Component)==0)
return comp;
}
return rc;
return NULL;
}
int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
......@@ -487,11 +483,14 @@ void ACTION_free_package_structures( MSIPACKAGE* package)
if (package->folders && package->loaded_folders > 0)
HeapFree(GetProcessHeap(),0,package->folders);
for (i = 0; i < package->loaded_components; i++)
HeapFree(GetProcessHeap(),0,package->components[i].FullKeypath);
if (package->components && package->loaded_components > 0)
HeapFree(GetProcessHeap(),0,package->components);
LIST_FOR_EACH_SAFE( item, cursor, &package->components )
{
MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
list_remove( &comp->entry );
HeapFree( GetProcessHeap(), 0, comp->FullKeypath );
HeapFree( GetProcessHeap(), 0, comp );
}
for (i = 0; i < package->loaded_files; i++)
{
......@@ -762,13 +761,13 @@ void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
msiobj_release(&row->hdr);
}
BOOL ACTION_VerifyComponentForAction(MSIPACKAGE* package, INT index,
BOOL ACTION_VerifyComponentForAction(MSIPACKAGE* package, MSICOMPONENT* comp,
INSTALLSTATE check )
{
if (package->components[index].Installed == check)
if (comp->Installed == check)
return FALSE;
if (package->components[index].ActionRequest == check)
if (comp->ActionRequest == check)
return TRUE;
else
return FALSE;
......@@ -867,8 +866,8 @@ void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
LIST_FOR_EACH_ENTRY( cl, feature->Components, ComponentList, entry )
{
MSICOMPONENT* component = &package->components[cl->component];
MSICOMPONENT* component = cl->component;
TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
newstate, debugstr_w(component->Component), component->Installed,
component->Action, component->ActionRequest);
......
......@@ -545,20 +545,20 @@ UINT WINAPI MsiGetComponentStateA(MSIHANDLE hInstall, LPSTR szComponent,
UINT MSI_GetComponentStateW(MSIPACKAGE *package, LPWSTR szComponent,
INSTALLSTATE *piInstalled, INSTALLSTATE *piAction)
{
INT index;
MSICOMPONENT *comp;
TRACE("%p %s %p %p\n", package, debugstr_w(szComponent), piInstalled,
piAction);
index = get_loaded_component(package,szComponent);
if (index < 0)
comp = get_loaded_component(package,szComponent);
if (!comp)
return ERROR_UNKNOWN_COMPONENT;
if (piInstalled)
*piInstalled = package->components[index].Installed;
*piInstalled = comp->Installed;
if (piAction)
*piAction = package->components[index].Action;
*piAction = comp->Action;
TRACE("states (%i, %i)\n",
(piInstalled)?*piInstalled:-1,(piAction)?*piAction:-1);
......
......@@ -190,8 +190,7 @@ typedef struct tagMSIPACKAGE
UINT loaded_features;
struct tagMSIFOLDER *folders;
UINT loaded_folders;
struct tagMSICOMPONENT *components;
UINT loaded_components;
struct list components;
struct tagMSIFILE *files;
UINT loaded_files;
LPWSTR ActionFormat;
......
......@@ -379,11 +379,10 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
package->db = db;
package->features = NULL;
package->folders = NULL;
package->components = NULL;
list_init( &package->components );
package->files = NULL;
package->loaded_features = 0;
package->loaded_folders = 0;
package->loaded_components= 0;
package->loaded_files = 0;
package->ActionFormat = NULL;
package->LastAction = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment