File libxls-dword.patch of Package libxls
diff -Naur libxls/formulas/xlsformula.h libxls-new/formulas/xlsformula.h
--- libxls/formulas/xlsformula.h 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/formulas/xlsformula.h 2016-09-20 12:52:21.467817291 +0200
@@ -52,14 +52,14 @@
typedef unsigned char BYTE;
typedef uint16_t WORD;
-typedef uint32_t DWORD;
+typedef uint32_t xDWORD;
#ifdef NO_ALIGN
typedef uint16_t WORD_UA;
-typedef uint32_t DWORD_UA;
+typedef uint32_t xDWORD_UA;
#else
typedef uint16_t WORD_UA __attribute__ ((aligned (1))); // 2 bytes
-typedef uint32_t DWORD_UA __attribute__ ((aligned (1))); // 4 bytes
+typedef uint32_t xDWORD_UA __attribute__ ((aligned (1))); // 4 bytes
#endif
typedef struct FORMULA // BIFF8
diff -Naur libxls/include/libxls/ole.h libxls-new/include/libxls/ole.h
--- libxls/include/libxls/ole.h 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/include/libxls/ole.h 2016-09-20 12:53:00.742895520 +0200
@@ -45,15 +45,15 @@
typedef struct TIME_T
{
- DWORD LowDate;
- DWORD HighDate;
+ xDWORD LowDate;
+ xDWORD HighDate;
}
TIME_T;
typedef struct OLE2Header
{
- DWORD id[2]; //D0CF11E0 A1B11AE1
- DWORD clid[4];
+ xDWORD id[2]; //D0CF11E0 A1B11AE1
+ xDWORD clid[4];
WORD verminor; //0x3e
WORD verdll; //0x03
WORD byteorder;
@@ -61,20 +61,20 @@
WORD lssectorB;
WORD reserved1;
- DWORD reserved2;
- DWORD reserved3;
+ xDWORD reserved2;
+ xDWORD reserved3;
- DWORD cfat; // count full sectors
- DWORD dirstart;
+ xDWORD cfat; // count full sectors
+ xDWORD dirstart;
- DWORD reserved4;
+ xDWORD reserved4;
- DWORD sectorcutoff; // min size of a standard stream ; if less than this then it uses short-streams
- DWORD sfatstart; // first short-sector or EOC
- DWORD csfat; // count short sectors
- DWORD difstart; // first sector master sector table or EOC
- DWORD cdif; // total count
- DWORD MSAT[109]; // First 109 MSAT
+ xDWORD sectorcutoff; // min size of a standard stream ; if less than this then it uses short-streams
+ xDWORD sfatstart; // first short-sector or EOC
+ xDWORD csfat; // count short sectors
+ xDWORD difstart; // first sector master sector table or EOC
+ xDWORD cdif; // total count
+ xDWORD MSAT[109]; // First 109 MSAT
}
OLE2Header;
@@ -87,8 +87,8 @@
struct st_olefiles_data
{
BYTE* name;
- DWORD start;
- DWORD size;
+ xDWORD start;
+ xDWORD size;
}
* file;
}
@@ -99,16 +99,16 @@
FILE* file;
WORD lsector;
WORD lssector;
- DWORD cfat;
- DWORD dirstart;
+ xDWORD cfat;
+ xDWORD dirstart;
- DWORD sectorcutoff;
- DWORD sfatstart;
- DWORD csfat;
- DWORD difstart;
- DWORD cdif;
- DWORD* SecID; // regular sector data
- DWORD* SSecID; // short sector data
+ xDWORD sectorcutoff;
+ xDWORD sfatstart;
+ xDWORD csfat;
+ xDWORD difstart;
+ xDWORD cdif;
+ xDWORD* SecID; // regular sector data
+ xDWORD* SSecID; // short sector data
BYTE* SSAT; // directory of short sectors
st_olefiles files;
}
@@ -117,13 +117,13 @@
typedef struct OLE2Stream
{
OLE2* ole;
- DWORD start;
+ xDWORD start;
size_t pos;
size_t cfat;
size_t size;
size_t fatpos;
BYTE* buf;
- DWORD bufsize;
+ xDWORD bufsize;
BYTE eof;
BYTE sfat; // short
}
@@ -146,23 +146,23 @@
#define PS_USER_ROOT 05
BYTE flag; //COLOR
#define BLACK 1
- DWORD left;
- DWORD right;
- DWORD child;
+ xDWORD left;
+ xDWORD right;
+ xDWORD child;
WORD guid[8];
- DWORD userflags;
+ xDWORD userflags;
TIME_T time[2];
- DWORD sstart;
- DWORD size;
- DWORD proptype;
+ xDWORD sstart;
+ xDWORD size;
+ xDWORD proptype;
}
PSS;
#pragma pack(pop)
extern size_t ole2_read(void* buf,size_t size,size_t count,OLE2Stream* olest);
-extern OLE2Stream* ole2_sopen(OLE2* ole,DWORD start, size_t size);
-extern void ole2_seek(OLE2Stream* olest,DWORD ofs);
+extern OLE2Stream* ole2_sopen(OLE2* ole,xDWORD start, size_t size);
+extern void ole2_seek(OLE2Stream* olest,xDWORD ofs);
extern OLE2Stream* ole2_fopen(OLE2* ole,BYTE* file);
extern void ole2_fclose(OLE2Stream* ole2st);
extern OLE2* ole2_open(const BYTE *file);
diff -Naur libxls/include/libxls/xlsstruct.h libxls-new/include/libxls/xlsstruct.h
--- libxls/include/libxls/xlsstruct.h 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/include/libxls/xlsstruct.h 2016-09-20 12:53:32.798143202 +0200
@@ -54,8 +54,8 @@
WORD type;
WORD id_make;
WORD year;
- DWORD flags;
- DWORD min_ver;
+ xDWORD flags;
+ xDWORD min_ver;
BYTE buf[100];
}
BIFF;
@@ -76,7 +76,7 @@
typedef struct BOUNDSHEET
{
- DWORD filepos;
+ xDWORD filepos;
BYTE type;
BYTE visible;
BYTE name[];
@@ -139,7 +139,7 @@
WORD row;
WORD col;
WORD xf;
- DWORD_UA value;
+ xDWORD_UA value;
}
RK;
@@ -149,7 +149,7 @@
WORD col;
struct {
WORD xf;
- DWORD_UA value;
+ xDWORD_UA value;
} rk[];
//WORD last_col;
}
@@ -184,8 +184,8 @@
typedef struct SST
{
- DWORD num;
- DWORD numofstr;
+ xDWORD num;
+ xDWORD numofstr;
BYTE strings;
}
SST;
@@ -212,8 +212,8 @@
BYTE rotation;
BYTE ident;
BYTE usedattr;
- DWORD linestyle;
- DWORD linecolor;
+ xDWORD linestyle;
+ xDWORD linecolor;
WORD groundcolor;
}
XF8;
@@ -275,10 +275,10 @@
typedef struct st_sheet
{
- DWORD count; // Count of sheets
+ xDWORD count; // Count of sheets
struct st_sheet_data
{
- DWORD filepos;
+ xDWORD filepos;
BYTE visibility;
BYTE type;
BYTE* name;
@@ -289,7 +289,7 @@
typedef struct st_font
{
- DWORD count; // Count of FONT's
+ xDWORD count; // Count of FONT's
struct st_font_data
{
WORD height;
@@ -308,7 +308,7 @@
typedef struct st_format
{
- DWORD count; // Count of FORMAT's
+ xDWORD count; // Count of FORMAT's
struct st_format_data
{
WORD index;
@@ -320,7 +320,7 @@
typedef struct st_xf
{
- DWORD count; // Count of XF
+ xDWORD count; // Count of XF
// XF** xf;
struct st_xf_data
{
@@ -331,8 +331,8 @@
BYTE rotation;
BYTE ident;
BYTE usedattr;
- DWORD linestyle;
- DWORD linecolor;
+ xDWORD linestyle;
+ xDWORD linecolor;
WORD groundcolor;
}
* xf;
@@ -342,12 +342,12 @@
typedef struct st_sst
{
- DWORD count;
- DWORD lastid;
- DWORD continued;
- DWORD lastln;
- DWORD lastrt;
- DWORD lastsz;
+ xDWORD count;
+ xDWORD lastid;
+ xDWORD continued;
+ xDWORD lastln;
+ xDWORD lastrt;
+ xDWORD lastsz;
struct str_sst_string
{
BYTE* str;
@@ -359,7 +359,7 @@
typedef struct st_cell
{
- DWORD count;
+ xDWORD count;
struct st_cell_data
{
WORD id;
@@ -381,7 +381,7 @@
typedef struct st_row
{
- // DWORD count;
+ // xDWORD count;
WORD lastcol; // numCols - 1
WORD lastrow; // numRows - 1
struct st_row_data
@@ -402,7 +402,7 @@
typedef struct st_colinfo
{
- DWORD count; //Count of COLINFO
+ xDWORD count; //Count of COLINFO
struct st_colinfo_data
{
WORD first;
@@ -442,7 +442,7 @@
typedef struct xlsWorkSheet
{
- DWORD filepos;
+ xDWORD filepos;
WORD defcolwidth;
st_row rows;
xlsWorkBook *workbook;
diff -Naur libxls/include/libxls/xlstool.h libxls-new/include/libxls/xlstool.h
--- libxls/include/libxls/xlstool.h 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/include/libxls/xlstool.h 2016-09-20 12:53:04.787800587 +0200
@@ -35,10 +35,10 @@
extern void dumpbuf(BYTE* fname,long size,BYTE* buf);
extern void verbose(char* str);
-extern BYTE *utf8_decode(BYTE *str, DWORD len, char *encoding);
+extern BYTE *utf8_decode(BYTE *str, xDWORD len, char *encoding);
extern BYTE* unicode_decode(const BYTE *s, int len, size_t *newlen, const char* encoding);
extern BYTE* get_string(BYTE *s,BYTE is2, BYTE isUnicode, char *charset);
-extern DWORD xls_getColor(const WORD color,WORD def);
+extern xDWORD xls_getColor(const WORD color,WORD def);
extern void xls_showBookInfo(xlsWorkBook* pWB);
extern void xls_showROW(struct st_row_data* row);
diff -Naur libxls/include/libxls/xlstypes.h libxls-new/include/libxls/xlstypes.h
--- libxls/include/libxls/xlstypes.h 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/include/libxls/xlstypes.h 2016-09-20 12:53:37.390035431 +0200
@@ -37,14 +37,14 @@
typedef unsigned char BYTE;
typedef uint16_t WORD;
-typedef uint32_t DWORD;
+typedef uint32_t xDWORD;
#ifdef NO_ALIGN
typedef uint16_t WORD_UA;
-typedef uint32_t DWORD_UA;
+typedef uint32_t xDWORD_UA;
#else
typedef uint16_t WORD_UA __attribute__ ((aligned (1))); // 2 bytes
-typedef uint32_t DWORD_UA __attribute__ ((aligned (1))); // 4 bytes
+typedef uint32_t xDWORD_UA __attribute__ ((aligned (1))); // 4 bytes
#endif
#endif
diff -Naur libxls/src/ole.c libxls-new/src/ole.c
--- libxls/src/ole.c 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/src/ole.c 2016-09-20 12:51:35.606893640 +0200
@@ -48,10 +48,10 @@
//#define OLE_DEBUG
-//static const DWORD MSATSECT = 0xFFFFFFFC; // -4
-//static const DWORD FATSECT = 0xFFFFFFFD; // -3
-static const DWORD ENDOFCHAIN = 0xFFFFFFFE; // -2
-static const DWORD FREESECT = 0xFFFFFFFF; // -1
+//static const xDWORD MSATSECT = 0xFFFFFFFC; // -4
+//static const xDWORD FATSECT = 0xFFFFFFFD; // -3
+static const xDWORD ENDOFCHAIN = 0xFFFFFFFE; // -2
+static const xDWORD FREESECT = 0xFFFFFFFF; // -1
static size_t sector_pos(OLE2* ole2, size_t sid);
static int sector_read(OLE2* ole2, BYTE *buffer, size_t sid);
@@ -65,7 +65,7 @@
assert(olest);
assert(olest->ole);
- if ((DWORD)olest->fatpos!=ENDOFCHAIN)
+ if ((xDWORD)olest->fatpos!=ENDOFCHAIN)
{
if(olest->sfat) {
assert(olest->ole->SSAT);
@@ -147,7 +147,7 @@
}
assert(didReadCount <= totalReadCount);
//printf(" if(fatpos=0x%X==EOC=0x%X) && (pos=%d >= bufsize=%d)\n", olest->fatpos, ENDOFCHAIN, olest->pos, olest->bufsize);
- if (((DWORD)olest->fatpos == ENDOFCHAIN) && (olest->pos >= olest->bufsize))
+ if (((xDWORD)olest->fatpos == ENDOFCHAIN) && (olest->pos >= olest->bufsize))
{
olest->eof=1;
}
@@ -173,7 +173,7 @@
}
// Open stream in logical ole file
-OLE2Stream* ole2_sopen(OLE2* ole,DWORD start, size_t size)
+OLE2Stream* ole2_sopen(OLE2* ole,xDWORD start, size_t size)
{
OLE2Stream* olest=NULL;
@@ -204,7 +204,7 @@
}
// Move in stream
-void ole2_seek(OLE2Stream* olest,DWORD ofs)
+void ole2_seek(OLE2Stream* olest,xDWORD ofs)
{
if(olest->sfat) {
ldiv_t div_rez=ldiv(ofs,olest->ole->lssector);
@@ -392,7 +392,7 @@
#endif
} else
if(pss->type == PS_USER_ROOT) {
- DWORD sector, k, blocks;
+ xDWORD sector, k, blocks;
BYTE *wptr;
blocks = (pss->size + (ole->lsector - 1)) / ole->lsector; // count partial
@@ -493,7 +493,7 @@
// Add additionnal sectors of the MSAT
{
- DWORD sid = ole2->difstart;
+ xDWORD sid = ole2->difstart;
BYTE *sector = malloc(ole2->lsector);
//printf("sid=%u (0x%x) sector=%u\n", sid, sid, ole2->lsector);
@@ -506,7 +506,7 @@
// read content
for (posInSector = 0; posInSector < (ole2->lsector-4)/4; posInSector++)
{
- DWORD s = *(DWORD_UA *)(sector + posInSector*4);
+ xDWORD s = *(xDWORD_UA *)(sector + posInSector*4);
//printf(" s[%d]=%d (0x%x)\n", posInSector, s, s);
if (s != FREESECT)
@@ -515,7 +515,7 @@
sectorNum++;
}
}
- sid = *(DWORD_UA *)(sector + posInSector*4);
+ sid = *(xDWORD_UA *)(sector + posInSector*4);
//printf(" s[%d]=%d (0x%x)\n", posInSector, sid, sid);
}
free(sector);
@@ -533,10 +533,10 @@
// read in short table
if(ole2->sfatstart != ENDOFCHAIN) {
- DWORD sector, k;
+ xDWORD sector, k;
BYTE *wptr;
- ole2->SSecID = (DWORD *)malloc(ole2->csfat*ole2->lsector);
+ ole2->SSecID = (xDWORD *)malloc(ole2->csfat*ole2->lsector);
sector = ole2->sfatstart;
wptr=(BYTE*)ole2->SSecID;
for(k=0; k<ole2->csfat; ++k) {
diff -Naur libxls/src/xls.c libxls-new/src/xls.c
--- libxls/src/xls.c 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/src/xls.c 2016-09-20 12:51:59.356336241 +0200
@@ -52,11 +52,11 @@
int xls_debug;
-static double NumFromRk(DWORD_UA drk);
+static double NumFromRk(xDWORD_UA drk);
static xls_formula_handler formula_handler;
-extern void xls_addSST(xlsWorkBook* pWB,SST* sst,DWORD size);
-extern void xls_appendSST(xlsWorkBook* pWB,BYTE* buf,DWORD size);
+extern void xls_addSST(xlsWorkBook* pWB,SST* sst,xDWORD size);
+extern void xls_appendSST(xlsWorkBook* pWB,BYTE* buf,xDWORD size);
extern void xls_addFormat(xlsWorkBook* pWB,FORMAT* format);
extern BYTE* xls_addSheet(xlsWorkBook* pWB,BOUNDSHEET* bs);
extern void xls_addRow(xlsWorkSheet* pWS,ROW* row);
@@ -117,7 +117,7 @@
return 1;
}
-void xls_addSST(xlsWorkBook* pWB,SST* sst,DWORD size)
+void xls_addSST(xlsWorkBook* pWB,SST* sst,xDWORD size)
{
verbose("xls_addSST");
@@ -132,12 +132,12 @@
xls_appendSST(pWB,&sst->strings,size-8);
}
-void xls_appendSST(xlsWorkBook* pWB,BYTE* buf,DWORD size)
+void xls_appendSST(xlsWorkBook* pWB,BYTE* buf,xDWORD size)
{
- DWORD ln; // String character count
- DWORD ofs; // Current offset in SST buffer
- DWORD rt; // Count of rich text formatting runs
- DWORD sz; // Size of asian phonetic settings block
+ xDWORD ln; // String character count
+ xDWORD ofs; // Current offset in SST buffer
+ xDWORD rt; // Count of rich text formatting runs
+ xDWORD sz; // Size of asian phonetic settings block
BYTE flag; // String flags
BYTE* ret;
@@ -189,7 +189,7 @@
// Size of asian phonetic settings block
if (flag & 0x4)
{
- sz=xlsIntVal(*(DWORD_UA *)(buf+ofs));
+ sz=xlsIntVal(*(xDWORD_UA *)(buf+ofs));
ofs+=4;
if (xls_debug) {
@@ -305,7 +305,7 @@
}
}
-static double NumFromRk(DWORD_UA drk)
+static double NumFromRk(xDWORD_UA drk)
{
double ret;
@@ -330,7 +330,7 @@
BYTE* xls_addSheet(xlsWorkBook* pWB, BOUNDSHEET *bs)
{
BYTE* name;
- DWORD filepos;
+ xDWORD filepos;
BYTE visible, type;
filepos = bs->filepos;
@@ -408,7 +408,7 @@
void xls_makeTable(xlsWorkSheet* pWS)
{
- DWORD i,t;
+ xDWORD i,t;
struct st_row_data* tmp;
verbose ("xls_makeTable");
@@ -1034,8 +1034,8 @@
void xls_formatColumn(xlsWorkSheet* pWS)
{
- DWORD i,t,ii;
- DWORD fcol,lcol;
+ xDWORD i,t,ii;
+ xDWORD fcol,lcol;
for (i=0;i<pWS->colinfo.count;i++)
{
@@ -1113,7 +1113,7 @@
break;
case 0x00D7:
if(xls_debug > 10) {
- DWORD *foo = (DWORD_UA *)buf;
+ xDWORD *foo = (xDWORD_UA *)buf;
WORD *goo;
int i;
printf("DBCELL: size %d\n", tmp.size);
@@ -1125,7 +1125,7 @@
break;
case 0x020B: //INDEX
if(xls_debug > 10) {
- DWORD *foo = (DWORD_UA *)buf;
+ xDWORD *foo = (xDWORD_UA *)buf;
int i;
printf("INDEX: size %d\n", tmp.size);
for(i=0; i<5; ++i) printf("FOO[%d]=%4.4x %u\n", i, foo[i], foo[i]);
@@ -1315,7 +1315,7 @@
// Sheets
{
- DWORD i;
+ xDWORD i;
for(i=0; i<pWB->sheets.count; ++i) {
free(pWB->sheets.sheet[i].name);
}
@@ -1324,7 +1324,7 @@
// SST
{
- DWORD i;
+ xDWORD i;
for(i=0; i<pWB->sst.count; ++i) {
free(pWB->sst.string[i].str);
}
@@ -1338,7 +1338,7 @@
// fonts
{
- DWORD i;
+ xDWORD i;
for(i=0; i<pWB->fonts.count; ++i) {
free(pWB->fonts.font[i].name);
}
@@ -1347,7 +1347,7 @@
// formats
{
- DWORD i;
+ xDWORD i;
for(i=0; i<pWB->formats.count; ++i) {
free(pWB->formats.format[i].value);
}
@@ -1368,7 +1368,7 @@
// ROWS
{
- DWORD i, j;
+ xDWORD i, j;
for(j=0; j<=pWS->rows.lastrow; ++j) {
struct st_row_data *row = &pWS->rows.row[j];
for(i=0; i<row->cells.count; ++i) {
diff -Naur libxls/src/xlstool.c libxls-new/src/xlstool.c
--- libxls/src/xlstool.c 2014-01-11 23:06:35.000000000 +0100
+++ libxls-new/src/xlstool.c 2016-09-20 12:52:14.565979277 +0200
@@ -59,7 +59,7 @@
static void xls_showBOUNDSHEET(void* bsheet);
-static const DWORD colors[] =
+static const xDWORD colors[] =
{
0x000000,
0xFFFFFF,
@@ -204,11 +204,11 @@
printf("libxls : %s\n",str);
}
-BYTE *utf8_decode(BYTE *str, DWORD len, char *encoding)
+BYTE *utf8_decode(BYTE *str, xDWORD len, char *encoding)
{
int utf8_chars = 0;
BYTE *ret;
- DWORD i;
+ xDWORD i;
for(i=0; i<len; ++i) {
if(str[i] & (BYTE)0x80) {
@@ -221,7 +221,7 @@
memcpy(ret, str, len);
ret[len] = 0;
} else {
- DWORD i;
+ xDWORD i;
BYTE *out;
// UTF-8 encoding inline
ret = (BYTE *)malloc(len+utf8_chars+1);
@@ -373,7 +373,7 @@
BYTE* get_string(BYTE *s, BYTE is2, BYTE is5ver, char *charset)
{
WORD ln;
- DWORD ofs;
+ xDWORD ofs;
BYTE flag;
BYTE* str;
BYTE* ret;
@@ -406,8 +406,8 @@
}
if (flag&0x4)
{
- // DWORD sz;
- // sz=*(DWORD*)(str+ofs); // unused
+ // xDWORD sz;
+ // sz=*(xDWORD*)(str+ofs); // unused
ofs+=4;
}
if(flag & 0x1)
@@ -437,7 +437,7 @@
return ret;
}
-DWORD xls_getColor(const WORD color,WORD def)
+xDWORD xls_getColor(const WORD color,WORD def)
{
int cor=8;
int size = 64 - cor;
@@ -712,8 +712,8 @@
WORD size;
char fontname[255];
struct st_xf_data* xf;
- DWORD background;
- DWORD i;
+ xDWORD background;
+ xDWORD i;
char *ret = malloc(65535);
char *buf = malloc(4096);