advpack: Formalize the SESSION struct.

This commit is contained in:
James Hawkins 2007-08-22 17:41:04 -07:00 committed by Alexandre Julliard
parent 832e30694d
commit 5b62c8461c

View File

@ -29,6 +29,7 @@
#include "winternl.h" #include "winternl.h"
#include "setupapi.h" #include "setupapi.h"
#include "advpub.h" #include "advpub.h"
#include "fdi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "advpack_private.h" #include "advpack_private.h"
@ -515,28 +516,29 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT
/* The following defintions were copied from dlls/cabinet/cabinet.h */ /* The following defintions were copied from dlls/cabinet/cabinet.h */
/* EXTRACTdest flags */ /* SESSION Operation */
#define EXTRACT_FILLFILELIST 0x00000001 #define EXTRACT_FILLFILELIST 0x00000001
#define EXTRACT_EXTRACTFILES 0x00000002 #define EXTRACT_EXTRACTFILES 0x00000002
struct ExtractFileList { struct FILELIST{
LPSTR filename; LPSTR FileName;
struct ExtractFileList *next; struct FILELIST *next;
BOOL unknown; /* always 1L */ BOOL Extracted;
} ; };
/* the first parameter of the function Extract */
typedef struct { typedef struct {
long result1; /* 0x000 */ INT FileSize;
long unknown1[3]; /* 0x004 */ ERF Error;
struct ExtractFileList *filelist; /* 0x010 */ struct FILELIST *FileList;
long filecount; /* 0x014 */ INT FileCount;
DWORD flags; /* 0x018 */ INT Operation;
char directory[0x104]; /* 0x01c */ CHAR Destination[MAX_PATH];
char lastfile[0x20c]; /* 0x120 */ CHAR CurrentFile[MAX_PATH];
} EXTRACTdest; CHAR Reserved[MAX_PATH];
struct FILELIST *FilterList;
} SESSION;
static HRESULT (WINAPI *pExtract)(EXTRACTdest*, LPCSTR); static HRESULT (WINAPI *pExtract)(SESSION*, LPCSTR);
/* removes legal characters before and after file list, and /* removes legal characters before and after file list, and
* converts the file list to a NULL-separated list * converts the file list to a NULL-separated list
@ -591,9 +593,9 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
return szConvertedList; return szConvertedList;
} }
static void free_file_node(struct ExtractFileList *pNode) static void free_file_node(struct FILELIST *pNode)
{ {
HeapFree(GetProcessHeap(), 0, pNode->filename); HeapFree(GetProcessHeap(), 0, pNode->FileName);
HeapFree(GetProcessHeap(), 0, pNode); HeapFree(GetProcessHeap(), 0, pNode);
} }
@ -622,23 +624,23 @@ static BOOL file_in_list(LPCSTR szFile, LPCSTR szFileList)
/* removes nodes from the linked list that aren't specified in szFileList /* removes nodes from the linked list that aren't specified in szFileList
* returns the number of files that are in both the linked list and szFileList * returns the number of files that are in both the linked list and szFileList
*/ */
static DWORD fill_file_list(EXTRACTdest *extractDest, LPCSTR szCabName, LPCSTR szFileList) static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileList)
{ {
DWORD dwNumFound = 0; DWORD dwNumFound = 0;
struct ExtractFileList *pNode; struct FILELIST *pNode;
struct ExtractFileList *prev = NULL; struct FILELIST *prev = NULL;
extractDest->flags |= EXTRACT_FILLFILELIST; session->Operation |= EXTRACT_FILLFILELIST;
if (pExtract(extractDest, szCabName)) if (pExtract(session, szCabName))
{ {
extractDest->flags &= ~EXTRACT_FILLFILELIST; session->Operation &= ~EXTRACT_FILLFILELIST;
return -1; return -1;
} }
pNode = extractDest->filelist; pNode = session->FileList;
while (pNode) while (pNode)
{ {
if (file_in_list(pNode->filename, szFileList)) if (file_in_list(pNode->FileName, szFileList))
{ {
prev = pNode; prev = pNode;
pNode = pNode->next; pNode = pNode->next;
@ -652,13 +654,13 @@ static DWORD fill_file_list(EXTRACTdest *extractDest, LPCSTR szCabName, LPCSTR s
} }
else else
{ {
extractDest->filelist = pNode->next; session->FileList = pNode->next;
free_file_node(pNode); free_file_node(pNode);
pNode = extractDest->filelist; pNode = session->FileList;
} }
} }
extractDest->flags &= ~EXTRACT_FILLFILELIST; session->Operation &= ~EXTRACT_FILLFILELIST;
return dwNumFound; return dwNumFound;
} }
@ -690,7 +692,7 @@ static DWORD fill_file_list(EXTRACTdest *extractDest, LPCSTR szCabName, LPCSTR s
HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags,
LPCSTR FileList, LPVOID LReserved, DWORD Reserved) LPCSTR FileList, LPVOID LReserved, DWORD Reserved)
{ {
EXTRACTdest extractDest; SESSION session;
HMODULE hCabinet; HMODULE hCabinet;
HRESULT res = S_OK; HRESULT res = S_OK;
DWORD dwFileCount = 0; DWORD dwFileCount = 0;
@ -717,8 +719,8 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags,
goto done; goto done;
} }
ZeroMemory(&extractDest, sizeof(EXTRACTdest)); ZeroMemory(&session, sizeof(SESSION));
lstrcpyA(extractDest.directory, ExpandDir); lstrcpyA(session.Destination, ExpandDir);
if (FileList) if (FileList)
{ {
@ -729,7 +731,7 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags,
goto done; goto done;
} }
dwFilesFound = fill_file_list(&extractDest, CabName, szConvertedList); dwFilesFound = fill_file_list(&session, CabName, szConvertedList);
if (dwFilesFound != dwFileCount) if (dwFilesFound != dwFileCount)
{ {
res = E_FAIL; res = E_FAIL;
@ -737,15 +739,15 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags,
} }
} }
else else
extractDest.flags |= EXTRACT_FILLFILELIST; session.Operation |= EXTRACT_FILLFILELIST;
extractDest.flags |= EXTRACT_EXTRACTFILES; session.Operation |= EXTRACT_EXTRACTFILES;
res = pExtract(&extractDest, CabName); res = pExtract(&session, CabName);
if (extractDest.filelist) if (session.FileList)
{ {
struct ExtractFileList* curr = extractDest.filelist; struct FILELIST *curr = session.FileList;
struct ExtractFileList* next; struct FILELIST *next;
while (curr) while (curr)
{ {