Commit 0cd9009d authored by Gerold Jens Wucherpfennig's avatar Gerold Jens Wucherpfennig Committed by Alexandre Julliard

The fci_get_little_endian... and fci_set_little_endian... functions

don't really set and unset little endianes, they do the same thing: merely swapping bytes from one endianes to the other.
parent 30e248ff
...@@ -49,6 +49,16 @@ There is still some work to be done: ...@@ -49,6 +49,16 @@ There is still some work to be done:
#include "wine/debug.h" #include "wine/debug.h"
#ifdef WORDS_BIGENDIAN
#define fci_endian_ulong(x) RtlUlongByteSwap(x)
#define fci_endian_uword(x) RtlUshortByteSwap(x)
#else
#define fci_endian_ulong(x) (x)
#define fci_endian_uword(x) (x)
#endif
WINE_DEFAULT_DEBUG_CHANNEL(cabinet); WINE_DEFAULT_DEBUG_CHANNEL(cabinet);
typedef struct { typedef struct {
...@@ -442,41 +452,7 @@ static cab_ULONG fci_get_checksum(void *pv, UINT cb, CHECKSUM seed) ...@@ -442,41 +452,7 @@ static cab_ULONG fci_get_checksum(void *pv, UINT cb, CHECKSUM seed)
} /* end of fci_get_checksum */ } /* end of fci_get_checksum */
static inline cab_ULONG fci_set_little_endian_ulong( cab_ULONG i )
{
#ifdef WORDS_BIGENDIAN
return RtlUlongByteSwap( i );
#else
return i;
#endif
}
static inline cab_ULONG fci_get_little_endian_ulong( cab_ULONG i )
{
#ifdef WORDS_BIGENDIAN
return RtlUlongByteSwap( i );
#else
return i;
#endif
}
static inline cab_UWORD fci_set_little_endian_uword( cab_UWORD i )
{
#ifdef WORDS_BIGENDIAN
return RtlUshortByteSwap( i );
#else
return i;
#endif
}
static inline cab_UWORD fci_get_little_endian_uword( cab_UWORD i )
{
#ifdef WORDS_BIGENDIAN
return RtlUshortByteSwap( i );
#else
return i;
#endif
}
static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveCFData, static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveCFData,
...@@ -634,8 +610,8 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC ...@@ -634,8 +610,8 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
} }
/* set little endian */ /* set little endian */
pcfdata->cbData=fci_set_little_endian_uword(pcfdata->cbData); pcfdata->cbData=fci_endian_uword(pcfdata->cbData);
pcfdata->cbUncomp=fci_set_little_endian_uword(pcfdata->cbUncomp); pcfdata->cbUncomp=fci_endian_uword(pcfdata->cbUncomp);
/* get checksum and write to cfdata.csum */ /* get checksum and write to cfdata.csum */
pcfdata->csum = fci_get_checksum( &(pcfdata->cbData), pcfdata->csum = fci_get_checksum( &(pcfdata->cbData),
...@@ -644,7 +620,7 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC ...@@ -644,7 +620,7 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
pcfdata->cbData, 0 ) ); pcfdata->cbData, 0 ) );
/* set little endian */ /* set little endian */
pcfdata->csum=fci_set_little_endian_ulong(pcfdata->csum); pcfdata->csum=fci_endian_ulong(pcfdata->csum);
/* write cfdata with checksum to p_fci_internal->handleCFDATA2 */ /* write cfdata with checksum to p_fci_internal->handleCFDATA2 */
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
...@@ -659,9 +635,9 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC ...@@ -659,9 +635,9 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData; p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData;
/* reset little endian */ /* reset little endian */
pcfdata->cbData=fci_get_little_endian_uword(pcfdata->cbData); pcfdata->cbData=fci_endian_uword(pcfdata->cbData);
pcfdata->cbUncomp=fci_get_little_endian_uword(pcfdata->cbUncomp); pcfdata->cbUncomp=fci_endian_uword(pcfdata->cbUncomp);
pcfdata->csum=fci_get_little_endian_ulong(pcfdata->csum); pcfdata->csum=fci_endian_ulong(pcfdata->csum);
/* write compressed data into p_fci_internal->handleCFDATA2 */ /* write compressed data into p_fci_internal->handleCFDATA2 */
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
...@@ -1013,12 +989,12 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne ...@@ -1013,12 +989,12 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne
} }
/* set little endian */ /* set little endian */
cffile.cbFile=fci_set_little_endian_ulong(cffile.cbFile); cffile.cbFile=fci_endian_ulong(cffile.cbFile);
cffile.uoffFolderStart=fci_set_little_endian_ulong(cffile.uoffFolderStart); cffile.uoffFolderStart=fci_endian_ulong(cffile.uoffFolderStart);
cffile.iFolder=fci_set_little_endian_uword(cffile.iFolder); cffile.iFolder=fci_endian_uword(cffile.iFolder);
cffile.date=fci_set_little_endian_uword(cffile.date); cffile.date=fci_endian_uword(cffile.date);
cffile.time=fci_set_little_endian_uword(cffile.time); cffile.time=fci_endian_uword(cffile.time);
cffile.attribs=fci_set_little_endian_uword(cffile.attribs); cffile.attribs=fci_endian_uword(cffile.attribs);
/* write cffile to p_fci_internal->handleCFFILE2 */ /* write cffile to p_fci_internal->handleCFFILE2 */
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
...@@ -1033,12 +1009,12 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne ...@@ -1033,12 +1009,12 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne
p_fci_internal->sizeFileCFFILE2 += sizeof(cffile); p_fci_internal->sizeFileCFFILE2 += sizeof(cffile);
/* reset little endian */ /* reset little endian */
cffile.cbFile=fci_get_little_endian_ulong(cffile.cbFile); cffile.cbFile=fci_endian_ulong(cffile.cbFile);
cffile.uoffFolderStart=fci_get_little_endian_ulong(cffile.uoffFolderStart); cffile.uoffFolderStart=fci_endian_ulong(cffile.uoffFolderStart);
cffile.iFolder=fci_get_little_endian_uword(cffile.iFolder); cffile.iFolder=fci_endian_uword(cffile.iFolder);
cffile.date=fci_get_little_endian_uword(cffile.date); cffile.date=fci_endian_uword(cffile.date);
cffile.time=fci_get_little_endian_uword(cffile.time); cffile.time=fci_endian_uword(cffile.time);
cffile.attribs=fci_get_little_endian_uword(cffile.attribs); cffile.attribs=fci_endian_uword(cffile.attribs);
/* write file name to p_fci_internal->handleCFFILE2 */ /* write file name to p_fci_internal->handleCFFILE2 */
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
...@@ -1644,16 +1620,16 @@ static BOOL fci_flush_cabinet( ...@@ -1644,16 +1620,16 @@ static BOOL fci_flush_cabinet(
} }
/* set little endian */ /* set little endian */
cfheader.reserved1=fci_set_little_endian_ulong(cfheader.reserved1); cfheader.reserved1=fci_endian_ulong(cfheader.reserved1);
cfheader.cbCabinet=fci_set_little_endian_ulong(cfheader.cbCabinet); cfheader.cbCabinet=fci_endian_ulong(cfheader.cbCabinet);
cfheader.reserved2=fci_set_little_endian_ulong(cfheader.reserved2); cfheader.reserved2=fci_endian_ulong(cfheader.reserved2);
cfheader.coffFiles=fci_set_little_endian_ulong(cfheader.coffFiles); cfheader.coffFiles=fci_endian_ulong(cfheader.coffFiles);
cfheader.reserved3=fci_set_little_endian_ulong(cfheader.reserved3); cfheader.reserved3=fci_endian_ulong(cfheader.reserved3);
cfheader.cFolders=fci_set_little_endian_uword(cfheader.cFolders); cfheader.cFolders=fci_endian_uword(cfheader.cFolders);
cfheader.cFiles=fci_set_little_endian_uword(cfheader.cFiles); cfheader.cFiles=fci_endian_uword(cfheader.cFiles);
cfheader.flags=fci_set_little_endian_uword(cfheader.flags); cfheader.flags=fci_endian_uword(cfheader.flags);
cfheader.setID=fci_set_little_endian_uword(cfheader.setID); cfheader.setID=fci_endian_uword(cfheader.setID);
cfheader.iCabinet=fci_set_little_endian_uword(cfheader.iCabinet); cfheader.iCabinet=fci_endian_uword(cfheader.iCabinet);
/* write CFHEADER into cabinet file */ /* write CFHEADER into cabinet file */
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
...@@ -1666,16 +1642,16 @@ static BOOL fci_flush_cabinet( ...@@ -1666,16 +1642,16 @@ static BOOL fci_flush_cabinet(
/* TODO error handling of err */ /* TODO error handling of err */
/* reset little endian */ /* reset little endian */
cfheader.reserved1=fci_get_little_endian_ulong(cfheader.reserved1); cfheader.reserved1=fci_endian_ulong(cfheader.reserved1);
cfheader.cbCabinet=fci_get_little_endian_ulong(cfheader.cbCabinet); cfheader.cbCabinet=fci_endian_ulong(cfheader.cbCabinet);
cfheader.reserved2=fci_get_little_endian_ulong(cfheader.reserved2); cfheader.reserved2=fci_endian_ulong(cfheader.reserved2);
cfheader.coffFiles=fci_get_little_endian_ulong(cfheader.coffFiles); cfheader.coffFiles=fci_endian_ulong(cfheader.coffFiles);
cfheader.reserved3=fci_get_little_endian_ulong(cfheader.reserved3); cfheader.reserved3=fci_endian_ulong(cfheader.reserved3);
cfheader.cFolders=fci_get_little_endian_uword(cfheader.cFolders); cfheader.cFolders=fci_endian_uword(cfheader.cFolders);
cfheader.cFiles=fci_get_little_endian_uword(cfheader.cFiles); cfheader.cFiles=fci_endian_uword(cfheader.cFiles);
cfheader.flags=fci_get_little_endian_uword(cfheader.flags); cfheader.flags=fci_endian_uword(cfheader.flags);
cfheader.setID=fci_get_little_endian_uword(cfheader.setID); cfheader.setID=fci_endian_uword(cfheader.setID);
cfheader.iCabinet=fci_get_little_endian_uword(cfheader.iCabinet); cfheader.iCabinet=fci_endian_uword(cfheader.iCabinet);
if( cfheader.flags & cfheadRESERVE_PRESENT ) { if( cfheader.flags & cfheadRESERVE_PRESENT ) {
/* NOTE: No checks for maximum value overflows as designed by MS!!! */ /* NOTE: No checks for maximum value overflows as designed by MS!!! */
...@@ -1689,7 +1665,7 @@ static BOOL fci_flush_cabinet( ...@@ -1689,7 +1665,7 @@ static BOOL fci_flush_cabinet(
} }
/* set little endian */ /* set little endian */
cfreserved.cbCFHeader=fci_set_little_endian_uword(cfreserved.cbCFHeader); cfreserved.cbCFHeader=fci_endian_uword(cfreserved.cbCFHeader);
/* write reserved info into cabinet file */ /* write reserved info into cabinet file */
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
...@@ -1702,7 +1678,7 @@ static BOOL fci_flush_cabinet( ...@@ -1702,7 +1678,7 @@ static BOOL fci_flush_cabinet(
/* TODO error handling of err */ /* TODO error handling of err */
/* reset little endian */ /* reset little endian */
cfreserved.cbCFHeader=fci_get_little_endian_uword(cfreserved.cbCFHeader); cfreserved.cbCFHeader=fci_endian_uword(cfreserved.cbCFHeader);
} }
/* add optional reserved area */ /* add optional reserved area */
...@@ -1830,9 +1806,9 @@ static BOOL fci_flush_cabinet( ...@@ -1830,9 +1806,9 @@ static BOOL fci_flush_cabinet(
} }
/* set little endian */ /* set little endian */
cffolder.coffCabStart=fci_set_little_endian_ulong(cffolder.coffCabStart); cffolder.coffCabStart=fci_endian_ulong(cffolder.coffCabStart);
cffolder.cCFData=fci_set_little_endian_uword(cffolder.cCFData); cffolder.cCFData=fci_endian_uword(cffolder.cCFData);
cffolder.typeCompress=fci_set_little_endian_uword(cffolder.typeCompress); cffolder.typeCompress=fci_endian_uword(cffolder.typeCompress);
/* write cffolder to cabinet file */ /* write cffolder to cabinet file */
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
...@@ -1845,9 +1821,9 @@ static BOOL fci_flush_cabinet( ...@@ -1845,9 +1821,9 @@ static BOOL fci_flush_cabinet(
/* TODO error handling of err */ /* TODO error handling of err */
/* reset little endian */ /* reset little endian */
cffolder.coffCabStart=fci_get_little_endian_ulong(cffolder.coffCabStart); cffolder.coffCabStart=fci_endian_ulong(cffolder.coffCabStart);
cffolder.cCFData=fci_get_little_endian_uword(cffolder.cCFData); cffolder.cCFData=fci_endian_uword(cffolder.cCFData);
cffolder.typeCompress=fci_get_little_endian_uword(cffolder.typeCompress); cffolder.typeCompress=fci_endian_uword(cffolder.typeCompress);
/* add optional reserved area */ /* add optional reserved area */
......
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