- remove unused loop that always iterates once

- remove warning
- preparations to use multiple fdi_decomp_state structures in a linkedlist,
  which will be used to implement split cabinets, if all goes according
  to plan -- this is somewhat analogous to struct cabinet in cabextract.
This commit is contained in:
Gregory M. Turner 2003-06-23 18:10:47 +00:00 committed by Alexandre Julliard
parent 9f67cfef42
commit 50c6965c78

View file

@ -93,6 +93,9 @@ typedef struct fdi_cds_fwd {
struct QTMstate qtm;
struct LZXstate lzx;
} methods;
struct fdi_folder *firstfol;
struct fdi_file *firstfile;
struct fdi_cds_fwd *next;
} fdi_decomp_state;
/*
@ -1790,10 +1793,12 @@ BOOL __cdecl FDICopy(
char fullpath[MAX_PATH];
size_t pathlen, filenamelen;
char emptystring = '\0';
cab_UBYTE buf[64], buf2[256] /* for modification by call back fn */ ;
cab_UBYTE buf[64];
BOOL initialcab = TRUE;
struct fdi_folder *fol = NULL, *linkfol = NULL, *firstfol = NULL;
struct fdi_file *file = NULL, *linkfile = NULL, *firstfile = NULL;
struct fdi_folder *fol = NULL, *linkfol = NULL;
struct fdi_file *file = NULL, *linkfile = NULL;
fdi_decomp_state _decomp_state;
fdi_decomp_state *decomp_state = &_decomp_state;
TRACE("(hfdi == ^%p, pszCabinet == ^%p, pszCabPath == ^%p, flags == %0d, \
pfnfdin == ^%p, pfnfdid == ^%p, pvUser == ^%p)\n",
@ -1804,7 +1809,8 @@ BOOL __cdecl FDICopy(
return FALSE;
}
while (TRUE) { /* this loop executes one per. cabinet */
ZeroMemory(decomp_state, sizeof(fdi_decomp_state));
pathlen = (pszCabPath) ? strlen(pszCabPath) : 0;
filenamelen = (pszCabinet) ? strlen(pszCabinet) : 0;
@ -1884,7 +1890,7 @@ BOOL __cdecl FDICopy(
goto bail_and_fail;
}
ZeroMemory(fol, sizeof(struct fdi_folder));
if (!firstfol) firstfol = fol;
if (!CAB(firstfol)) CAB(firstfol) = fol;
fol->offset[0] = (cab_off_t) EndGetI32(buf+cffold_DataOffset);
fol->num_blocks = EndGetI16(buf+cffold_NumBlocks);
@ -1914,7 +1920,7 @@ BOOL __cdecl FDICopy(
goto bail_and_fail;
}
ZeroMemory(file, sizeof(struct fdi_file));
if (!firstfile) firstfile = file;
if (!CAB(firstfile)) CAB(firstfile) = file;
file->length = EndGetI32(buf+cffile_UncompressedSize);
file->offset = EndGetI32(buf+cffile_FolderOffset);
@ -1936,7 +1942,7 @@ BOOL __cdecl FDICopy(
linkfile = file;
}
for (file = firstfile; (file); file = file->next) {
for (file = CAB(firstfile); (file); file = file->next) {
/* partial file notification (do it just once for the first cabinet) */
if (initialcab && ((file->index & cffileCONTINUED_FROM_PREV) == cffileCONTINUED_FROM_PREV)) {
/* OK, more MS bugs to simulate here, I think. I don't have a huge spanning
@ -1994,14 +2000,13 @@ BOOL __cdecl FDICopy(
if (filehf) {
cab_UWORD comptype = fol->comp_type;
int ct1 = comptype & cffoldCOMPTYPE_MASK;
fdi_decomp_state _decomp_state;
fdi_decomp_state *decomp_state = &_decomp_state;
int err = 0;
TRACE("Extracting file %s as requested by callee.\n", debugstr_a(file->filename));
/* set up decomp_state */
ZeroMemory(decomp_state, sizeof(fdi_decomp_state));
/* set up decomp_state (unneccesary?); at least
ignore trailing three pointers in the struct */
ZeroMemory(decomp_state, sizeof(fdi_decomp_state) - sizeof(void*) * 3);
CAB(hfdi) = hfdi;
CAB(filehf) = filehf;
CAB(cabhf) = cabhf;
@ -2089,7 +2094,6 @@ BOOL __cdecl FDICopy(
goto bail_and_fail;
}
/* FIXME: don't do it if we are continuing the file in another cab */
/* fdintCLOSE_FILE_INFO notification */
ZeroMemory(&fdin, sizeof(FDINOTIFICATION));
fdin.pv = pvUser;
@ -2114,16 +2118,23 @@ BOOL __cdecl FDICopy(
}
}
while (firstfol) {
fol = firstfol;
firstfol = firstfol->next;
while (decomp_state) {
fdi_decomp_state *prev_fds;
while (CAB(firstfol)) {
fol = CAB(firstfol);
CAB(firstfol) = CAB(firstfol)->next;
PFDI_FREE(hfdi, fol);
}
while (firstfile) {
file = firstfile;
firstfile = firstfile->next;
while (CAB(firstfile)) {
file = CAB(firstfile);
CAB(firstfile) = CAB(firstfile)->next;
PFDI_FREE(hfdi, file);
}
prev_fds = decomp_state;
decomp_state = CAB(next);
if (prev_fds != &_decomp_state)
PFDI_FREE(hfdi, prev_fds);
}
/* free the storage remembered by mii */
if (mii.nextname) PFDI_FREE(hfdi, mii.nextname);
@ -2132,20 +2143,27 @@ BOOL __cdecl FDICopy(
if (mii.previnfo) PFDI_FREE(hfdi, mii.previnfo);
PFDI_CLOSE(hfdi, cabhf);
/* TODO: if (:?) */ return TRUE; /* else { ...; initialcab=FALSE; continue; } */
return TRUE;
bail_and_fail: /* here we free ram before error returns */
while (firstfol) {
fol = firstfol;
firstfol = firstfol->next;
while (decomp_state) {
fdi_decomp_state *prev_fds;
while (CAB(firstfol)) {
fol = CAB(firstfol);
CAB(firstfol) = CAB(firstfol)->next;
PFDI_FREE(hfdi, fol);
}
while (firstfile) {
file = firstfile;
firstfile = firstfile->next;
while (CAB(firstfile)) {
file = CAB(firstfile);
CAB(firstfile) = CAB(firstfile)->next;
PFDI_FREE(hfdi, file);
}
prev_fds = decomp_state;
decomp_state = CAB(next);
if (prev_fds != &_decomp_state)
PFDI_FREE(hfdi, prev_fds);
}
/* free the storage remembered by mii */
if (mii.nextname) PFDI_FREE(hfdi, mii.nextname);
@ -2155,7 +2173,6 @@ BOOL __cdecl FDICopy(
PFDI_CLOSE(hfdi, cabhf);
return FALSE;
}
}
/***********************************************************************