summaryrefslogtreecommitdiffstats
path: root/src/libuemf
diff options
context:
space:
mode:
authormathog <>2015-05-21 23:06:06 +0000
committermathog <>2015-05-21 23:06:06 +0000
commit252d594b8f4e0f8b340a62a242795f0583c57a25 (patch)
tree327a5da4bb917e53c406ffe92637472e9d79341d /src/libuemf
parentpatch for bug 1457612 (diff)
downloadinkscape-252d594b8f4e0f8b340a62a242795f0583c57a25.tar.gz
inkscape-252d594b8f4e0f8b340a62a242795f0583c57a25.zip
minor tweaks to libUEMF and related code
(bzr r14169)
Diffstat (limited to 'src/libuemf')
-rw-r--r--src/libuemf/uemf.h11
-rw-r--r--src/libuemf/uemf_print.c48
-rw-r--r--src/libuemf/uemf_print.h7
-rw-r--r--src/libuemf/upmf.c12
-rw-r--r--src/libuemf/upmf_print.c21
-rw-r--r--src/libuemf/upmf_print.h6
-rw-r--r--src/libuemf/uwmf.c42
-rw-r--r--src/libuemf/uwmf.h10
-rw-r--r--src/libuemf/uwmf_endian.c20
-rw-r--r--src/libuemf/uwmf_endian.h8
-rw-r--r--src/libuemf/uwmf_print.c25
11 files changed, 141 insertions, 69 deletions
diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h
index 53426cb55..f6ed7da03 100644
--- a/src/libuemf/uemf.h
+++ b/src/libuemf/uemf.h
@@ -95,8 +95,8 @@ these WMF enumerations is by referencing the following table:
/*
File: uemf.h
-Version: 0.0.31
-Date: 23-APR-2015
+Version: 0.0.32
+Date: 28-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -168,7 +168,12 @@ extern "C" {
#define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) )
#define MAKE_MIN_PTR(A,B) ( A < B ? A : B)
-#define IS_MEM_UNSAFE(A,B,C) ( (int8_t *)(A) > (int8_t *)(C) ? 1 : ((int8_t *)(C) - (int8_t *)(A) >= (int)(B) ? 0 : 1 )) //!< Return 1 when a region of memory starting at A of B bytes extends beyond pointer C
+/* This is tricky. The next one can be called with a size which is either an int or an unsigned int.
+ The former can be negative, which is obviously wrong, but testing for that means that the size cannot
+ be more than INT_MAX/2. Accept that limitation since no reasonable EMF record or file should ever be that large.
+ B must be an INT or size_t.
+ If a uint16_t is used gcc complains about the first test. Force B to be at least as big as int (at run time) */
+#define IS_MEM_UNSAFE(A,B,C) ( (sizeof(B) < sizeof(int) || (int)(B)) < 0 ? 1 : ((int8_t *)(A) > (int8_t *)(C) ? 1 : ((int8_t *)(C) - (int8_t *)(A) >= (int)(B) ? 0 : 1 ))) //!< Return 1 when a region of memory starting at A of B bytes extends beyond pointer C
/** @} */
diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c
index adcf54c0f..4bc9f0206 100644
--- a/src/libuemf/uemf_print.c
+++ b/src/libuemf/uemf_print.c
@@ -6,8 +6,8 @@
/*
File: uemf_print.c
-Version: 0.0.18
-Date: 25-MAR-2015
+Version: 0.0.20
+Date: 21-MAY-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -35,6 +35,31 @@ void U_swap4(void *ul, unsigned int count);
//! \endcond
/**
+ \brief calculate a CRC32 value for record
+ \returns CRC32 value calculated for record
+ \param record pointer to the first byte
+ \param Size number of bytes in the record
+
+Code based on example crc32b here:
+ http://www.hackersdelight.org/hdcodetxt/crc.c.txt
+*/
+uint32_t lu_crc32(const char *record, uint32_t Size){
+ const unsigned char *message = record;
+ uint32_t i, j;
+ uint32_t crc, mask;
+
+ crc = 0xFFFFFFFF;
+ for(i=0;i<Size;i++){ // over all bytes
+ crc = crc ^ *message++;
+ for (j = 0; j < 8; j++) { // over all bits
+ mask = -(crc & 1);
+ crc = (crc >> 1) ^ (0xEDB88320 & mask);
+ }
+ }
+ return ~crc;
+}
+
+/**
\brief Print some number of hex bytes
\param buf pointer to the first byte
\param num number of bytes
@@ -45,6 +70,7 @@ void hexbytes_print(uint8_t *buf,unsigned int num){
}
}
+
/* **********************************************************************************************
These functions print standard objects used in the EMR records.
The low level ones do not append EOL.
@@ -2505,7 +2531,7 @@ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, siz
uint32_t nSize;
uint32_t iType;
const char *record = contents + off;
-
+
if(record < contents)return(-1); // offset wrapped
/* Check that COMMON data in record can be touched without an access violation. If it cannot be
@@ -2514,7 +2540,21 @@ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, siz
*/
if(!U_emf_record_sizeok(record, blimit, &nSize, &iType, 1))return(-1);
- printf("%-30srecord:%5d type:%-4d offset:%8d rsize:%8d\n",U_emr_names(iType),recnum,iType,(int) off,nSize);
+ uint32_t crc;
+#if U_BYTE_SWAP
+ //This is a Big Endian machine, EMF crc values must be calculated on Little Endian form
+ char *swapbuf=malloc(nSize);
+ if(!swapbuf)return(-1);
+ memcpy(swapbuf,record,nSize);
+ U_emf_endian(swapbuf,nSize,1); // BE to LE
+ crc=lu_crc32(swapbuf,nSize);
+ free(swapbuf);
+#else
+ crc=lu_crc32(record,nSize);
+#endif
+ printf("%-30srecord:%5d type:%-4d offset:%8d rsize:%8d crc32:%8.8X\n",
+ U_emr_names(iType),recnum,iType,(int) off,nSize,crc);
+
fflush(stdout);
/* print the record header before checking further.
diff --git a/src/libuemf/uemf_print.h b/src/libuemf/uemf_print.h
index 6568b4cfa..088a8a302 100644
--- a/src/libuemf/uemf_print.h
+++ b/src/libuemf/uemf_print.h
@@ -6,8 +6,8 @@
/*
File: uemf_print.h
-Version: 0.0.7
-Date: 24-MAR-2015
+Version: 0.0.9
+Date: 21-MAY-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -21,6 +21,9 @@ extern "C" {
#endif
//! \cond
+/* prototypes for miscellaneous */
+uint32_t lu_crc32(const char *record, uint32_t Size);
+
/* prototypes for objects used in EMR records */
void hexbytes_print(uint8_t *buf,unsigned int num);
void colorref_print(U_COLORREF color);
diff --git a/src/libuemf/upmf.c b/src/libuemf/upmf.c
index 7d6349185..2ba818fa4 100644
--- a/src/libuemf/upmf.c
+++ b/src/libuemf/upmf.c
@@ -21,8 +21,8 @@
/*
File: upmf.c
-Version: 0.0.9
-Date: 25-MAR-2015
+Version: 0.0.10
+Date: 27-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -6575,15 +6575,17 @@ int U_PMF_VARPOINTS_get(const char *contents, uint16_t Flags, int Elements, U_PM
}
}
else if(Flags & U_PPF_C){
- for(XFS = YFS = 0.0; Elements; Elements--, pts++){
+ for(XF = YF = 0.0; Elements; Elements--, pts++){
if(!U_PMF_POINT_get(&contents, &XF, &XF, blimit))break; /* this should never happen */
pts->X = XF;
pts->Y = YF;
}
}
else {
- for(XFS = YFS = 0.0; Elements; Elements--, pts++){
- (void) U_PMF_POINTF_get(&contents, &(pts->X), &(pts->Y), blimit);
+ for(XF = YF = 0.0; Elements; Elements--, pts++){
+ (void) U_PMF_POINTF_get(&contents, &XF, &YF, blimit);
+ pts->X = XF;
+ pts->Y = YF;
}
}
if(Elements){ /* some error in the preceding */
diff --git a/src/libuemf/upmf_print.c b/src/libuemf/upmf_print.c
index 7d9598b0d..58ff4edd0 100644
--- a/src/libuemf/upmf_print.c
+++ b/src/libuemf/upmf_print.c
@@ -6,8 +6,8 @@
/*
File: upmf_print.c
-Version: 0.0.5
-Date: 24-MAR-2015
+Version: 0.0.7
+Date: 21-MAY-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -142,7 +142,7 @@ int U_pmf_onerec_print(const char *contents, const char *blimit, int recnum, int
int type = Header.Type & U_PMR_TYPE_MASK; /* strip the U_PMR_RECFLAG bit, leaving the indexable part */
if(type < U_PMR_MIN || type > U_PMR_MAX)return(-1); /* unknown EMF+ record type */
- status = U_PMF_CMN_HDR_print(Header, recnum, off); /* EMF+ part */
+ status = U_PMF_CMN_HDR_print(contents, Header, recnum, off); /* EMF+ part */
/* Buggy EMF+ can set the continue bit and then do something else. In that case, force out the pending
Object. Side effect - clears the pending object. */
@@ -222,14 +222,16 @@ int U_pmf_onerec_print(const char *contents, const char *blimit, int recnum, int
/**
\brief Print data from a U_PMF_CMN_HDR object
\return number of bytes in record, 0 on error
+ \param contents pointer to a buffer holding this EMF+ record
\param Header Header of the record
\param precnum EMF+ record number in file.
\param off Offset in file to the start of this EMF+ record.
common structure present at the beginning of all(*) EMF+ records
*/
-int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off){
- printf(" %-29srec+:%5d type:%X offset:%8d rsize:%8u dsize:%8u flags:%4.4X\n",
- U_pmr_names(Header.Type &U_PMR_TYPE_MASK),precnum, Header.Type,off,Header.Size,Header.DataSize,Header.Flags);
+int U_PMF_CMN_HDR_print(const char *contents, U_PMF_CMN_HDR Header, int precnum, int off){
+ printf(" %-29srec+:%5d type:%X offset:%8d rsize:%8u dsize:%8u flags:%4.4X crc32:%8.8X\n",
+ U_pmr_names(Header.Type &U_PMR_TYPE_MASK),precnum, Header.Type,off,Header.Size,Header.DataSize,Header.Flags,
+ lu_crc32(contents,Header.Size));
return((int) Header.Size);
}
@@ -1852,7 +1854,12 @@ int U_PMF_TRANSFORMMATRIX_print(const char *contents, const char *blimit){
EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object
*/
int U_PMF_TRANSFORMMATRIX2_print(U_PMF_TRANSFORMMATRIX *Tm){
- printf(" Matrix:{%f,%f,%f,%f,%f,%f}", Tm->m11, Tm->m12, Tm->m21, Tm->m22, Tm->dX, Tm->dY);
+ if(Tm){
+ printf(" Matrix:{%f,%f,%f,%f,%f,%f}", Tm->m11, Tm->m12, Tm->m21, Tm->m22, Tm->dX, Tm->dY);
+ }
+ else {
+ printf(" Matrix:(None)");
+ }
return(1);
}
diff --git a/src/libuemf/upmf_print.h b/src/libuemf/upmf_print.h
index fe1c57d60..a25374487 100644
--- a/src/libuemf/upmf_print.h
+++ b/src/libuemf/upmf_print.h
@@ -6,8 +6,8 @@
/*
File: upmf_print.h
-Version: 0.0.4
-Date: 24-MAR-2015
+Version: 0.0.5
+Date: 28-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
@@ -23,7 +23,7 @@ extern "C" {
#include "upmf.h" /* includes uemf.h */
/* prototypes for simple types and enums used in PMR records */
-int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off);
+int U_PMF_CMN_HDR_print(const char *contents, U_PMF_CMN_HDR Header, int precnum, int off);
int U_PMF_UINT8_ARRAY_print(const char *Start, const uint8_t *Array, int Elements, char *End);
int U_PMF_BRUSHTYPEENUMERATION_print(int otype);
int U_PMF_HATCHSTYLEENUMERATION_print(int hstype);
diff --git a/src/libuemf/uwmf.c b/src/libuemf/uwmf.c
index 35d38f69a..62e3d3c06 100644
--- a/src/libuemf/uwmf.c
+++ b/src/libuemf/uwmf.c
@@ -19,8 +19,8 @@
/*
File: uwmf.c
-Version: 0.0.16
-Date: 25-MAR-2015
+Version: 0.0.17
+Date: 28-MAR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2014 David Mathog and California Institute of Technology (Caltech)
@@ -696,7 +696,8 @@ int packed_DIB_safe(
int usedbytes;
if(!bitmapinfo_safe(record, blimit))return(0); // this DIB has issues with colors fitting into the record
- uint32_t width, height, colortype, numCt, invert; // these values will be set in get_DIB_params
+ uint32_t numCt; // these values will be set in get_DIB_params
+ int32_t width, height, colortype, invert; // these values will be set in get_DIB_params
// next call returns pointers and values, but allocates no memory
dibparams = wget_DIB_params(record, &px, (const U_RGBQUAD **) &ct, &numCt, &width, &height, &colortype, &invert);
// sanity checking
@@ -1564,7 +1565,7 @@ int wmf_finish(
#if U_BYTE_SWAP
//This is a Big Endian machine, WMF data must be Little Endian
- U_wmf_endian(wt->buf,wt->used,1);
+ U_wmf_endian(wt->buf,wt->used,1,0); // BE to LE, entire file
#endif
(void) U_wmr_properties(U_WMR_INVALID); /* force the release of the lookup table memory, returned value is irrelevant */
@@ -1610,7 +1611,7 @@ int wmf_readdata(
else {
#if U_BYTE_SWAP
//This is a Big Endian machine, WMF data is Little Endian
- U_wmf_endian(*contents,*length,0); // LE to BE
+ U_wmf_endian(*contents,*length,0,0); // LE to BE, entire file
#endif
}
}
@@ -4720,10 +4721,10 @@ int U_WMRCORE_PALETTE_get(
*/
void U_BITMAPCOREHEADER_get(
const char *BmiCh,
- int32_t *Size,
- int32_t *Width,
- int32_t *Height,
- int32_t *BitCount
+ uint32_t *Size,
+ int32_t *Width,
+ int32_t *Height,
+ int32_t *BitCount
){
uint32_t utmp4;
uint16_t utmp2;
@@ -4800,14 +4801,14 @@ int wget_DIB_params(
const char *dib,
const char **px,
const U_RGBQUAD **ct,
- int32_t *numCt,
- int32_t *width,
- int32_t *height,
- int32_t *colortype,
- int32_t *invert
+ uint32_t *numCt,
+ int32_t *width,
+ int32_t *height,
+ int32_t *colortype,
+ int32_t *invert
){
uint32_t bic;
- int32_t Size;
+ uint32_t Size;
bic = U_BI_RGB; // this information is not in the coreheader;
U_BITMAPCOREHEADER_get(dib, &Size, width, height, colortype);
if(Size != 0xC ){ //BitmapCoreHeader
@@ -4816,7 +4817,7 @@ int wget_DIB_params(
*/
uint32_t uig4;
int32_t ig4;
- U_BITMAPINFOHEADER_get(dib, &uig4, width, height,&uig4, (uint32_t *) colortype, &bic, &uig4, &ig4, &ig4,&uig4, &uig4);
+ U_BITMAPINFOHEADER_get(dib, &uig4, width, height,&uig4, (uint32_t *) colortype, &bic, &uig4, &ig4, &ig4, &uig4, &uig4);
}
if(*height < 0){
*height = -*height;
@@ -5559,7 +5560,8 @@ int U_WMRPOLYGON_get(
){
int size = U_WMRCORE_2U16_N16_get(contents, (U_SIZE_WMRPOLYGON), NULL, Length, Data);
if(size){
- if(IS_MEM_UNSAFE(*Data, (*Length)*sizeof(U_POINT16), contents+size))return(0);
+ int iLength = (*Length)*sizeof(U_POINT16);
+ if(IS_MEM_UNSAFE(*Data, iLength, contents+size))return(0);
}
return size;
}
@@ -5578,7 +5580,8 @@ int U_WMRPOLYLINE_get(
){
int size = U_WMRCORE_2U16_N16_get(contents, (U_SIZE_WMRPOLYGON), NULL, Length, Data);
if(size){
- if(IS_MEM_UNSAFE(*Data, (*Length)*sizeof(U_POINT16), contents+size))return(0);
+ int iLength = (*Length)*sizeof(U_POINT16);
+ if(IS_MEM_UNSAFE(*Data, iLength, contents+size))return(0);
}
return size;
}
@@ -5605,7 +5608,8 @@ int U_WMRESCAPE_get(
){
int size = U_WMRCORE_2U16_N16_get(contents, (U_SIZE_WMRESCAPE), Escape, Length, Data);
if(size){
- if(IS_MEM_UNSAFE(*Data, *Length, contents+size))return(0);
+ int iLength=*Length;
+ if(IS_MEM_UNSAFE(*Data, iLength, contents+size))return(0);
}
return size;
}
diff --git a/src/libuemf/uwmf.h b/src/libuemf/uwmf.h
index 2237d2221..027de8e06 100644
--- a/src/libuemf/uwmf.h
+++ b/src/libuemf/uwmf.h
@@ -36,11 +36,11 @@
/*
File: uwmf.h
-Version: 0.0.11
-Date: 23-APR-2014
+Version: 0.0.12
+Date: 28-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2014 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
*/
#ifndef _UWMF_
@@ -2407,8 +2407,8 @@ int wmr_arc_points(U_RECT16 rclBox, U_POINT16 ArcStart, U_POINT16 ArcEn
void U_BITMAPINFOHEADER_get(const char *Bmih, uint32_t *Size, int32_t *Width, int32_t *Height,
uint32_t *Planes, uint32_t *BitCount, uint32_t *Compression, uint32_t *SizeImage,
int32_t *XPelsPerMeter, int32_t *YPelsPerMeter, uint32_t *ClrUsed, uint32_t *ClrImportant);
-void U_BITMAPCOREHEADER_get(const char *BmiCh, int32_t *Size, int32_t *Width, int32_t *Height, int32_t *BitCount);
-int wget_DIB_params(const char *dib, const char **px, const U_RGBQUAD **ct, int32_t *numCt,
+void U_BITMAPCOREHEADER_get(const char *BmiCh, uint32_t *Size, int32_t *Width, int32_t *Height, int32_t *BitCount);
+int wget_DIB_params(const char *dib, const char **px, const U_RGBQUAD **ct, uint32_t *numCt,
int32_t *width, int32_t *height, int32_t *colortype, int32_t *invert);
int U_WMREOF_get(const char *contents);
int U_WMRSETBKCOLOR_get(const char *contents, U_COLORREF *Color);
diff --git a/src/libuemf/uwmf_endian.c b/src/libuemf/uwmf_endian.c
index 38a321ad0..de0b3ef87 100644
--- a/src/libuemf/uwmf_endian.c
+++ b/src/libuemf/uwmf_endian.c
@@ -6,11 +6,11 @@
/*
File: uwmf_endian.c
-Version: 0.1.3
-Date: 27-MAR-2014
+Version: 0.1.4
+Date: 28-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2014 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
*/
#ifdef __cplusplus
@@ -1470,21 +1470,24 @@ void U_WMRCREATEREGION_swap(char *record, int torev){
\param contents pointer to the buffer holding the entire EMF in memory
\param length number of bytes in the buffer
\param torev 1 for native to reversed, 0 for reversed to native
+ \param onerec 1 if this is operating on a single record instead of an entire file
Normally this would be called immediately before writing the data to a file
or immediately after reading the data from a file.
*/
-int U_wmf_endian(char *contents, size_t length, int torev){
- size_t off;
+int U_wmf_endian(char *contents, size_t length, int torev, int onerec){
+ size_t off=0;
uint32_t OK, Size16;
uint8_t iType;
char *record;
int recnum, offset;
record = contents;
- off = wmfheader_swap(record,torev); fflush(stdout); /* WMF header is not a normal record, handle it separately */
- record += off;
- offset = off;
+ if(!onerec){
+ off = wmfheader_swap(record,torev); fflush(stdout); /* WMF header is not a normal record, handle it separately */
+ record += off;
+ offset = off;
+ }
OK = 1;
recnum = 1; /* used when debugging */
@@ -1759,6 +1762,7 @@ int U_wmf_endian(char *contents, size_t length, int torev){
record += 2*Size16;
offset += 2*Size16;
recnum++;
+ if(onerec)break;
} //end of while
return(1);
}
diff --git a/src/libuemf/uwmf_endian.h b/src/libuemf/uwmf_endian.h
index 57fd4ae44..6ce7f1984 100644
--- a/src/libuemf/uwmf_endian.h
+++ b/src/libuemf/uwmf_endian.h
@@ -6,11 +6,11 @@
/*
File: uwmf_endian.h
-Version: 0.0.2
-Date: 26-NOV-2013
+Version: 0.0.3
+Date: 28-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2013 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
*/
#ifndef _UWMF_ENDIAN_
@@ -24,7 +24,7 @@ extern "C" {
//! \cond
// prototypes
-int U_wmf_endian(char *contents, size_t length, int torev);
+int U_wmf_endian(char *contents, size_t length, int torev, int onerec);
//! \endcond
#ifdef __cplusplus
diff --git a/src/libuemf/uwmf_print.c b/src/libuemf/uwmf_print.c
index dd460b2b0..d6d1b584e 100644
--- a/src/libuemf/uwmf_print.c
+++ b/src/libuemf/uwmf_print.c
@@ -6,11 +6,11 @@
/*
File: uwmf_print.c
-Version: 0.0.4
-Date: 05-FEB-2014
+Version: 0.0.6
+Date: 21-MAY-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
-Copyright: 2014 David Mathog and California Institute of Technology (Caltech)
+Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
*/
#ifdef __cplusplus
@@ -1351,13 +1351,20 @@ int U_wmf_onerec_print(const char *contents, const char *blimit, int recnum, siz
iType = *(uint8_t *)(contents + offsetof(U_METARECORD, iType ) );
-#if 1
- printf("%-30srecord:%5d type:%-4u offset:%8d rsize:%8u\n",
- U_wmr_names(iType), recnum, iType, (int) off, (int) size);
-#else /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */
- printf("%-30srecord:%5d type:%-4u offset:%8d size:%8u recchecksum:%u\n",
- U_wmr_names(iType), recnum, iType, (int) off, (int) size, U_16_checksum((int16_t *)contents, size));
+ uint32_t crc;
+#if U_BYTE_SWAP
+ //This is a Big Endian machine, WMF crc values must be calculated on Little Endian form
+ char *swapbuf=malloc(size);
+ if(!swapbuf)return(-1);
+ memcpy(swapbuf,contents,size);
+ U_wmf_endian(swapbuf,size,1,1); // BE to LE
+ crc=lu_crc32(swapbuf,size);
+ free(swapbuf);
+#else
+ crc=lu_crc32(contents,size);
#endif
+ printf("%-30srecord:%5d type:%-4u offset:%8d rsize:%8u crc32:%8.8X\n",
+ U_wmr_names(iType), recnum, iType, (int) off, (int) size, crc);
switch (iType)
{