From 1e33565b4a202a89b2aee42a5bdc19e5ad4b47cd Mon Sep 17 00:00:00 2001 From: kramm Date: Wed, 9 Jan 2002 12:30:16 +0000 Subject: [PATCH] solaris fixes. --- src/bitio.c | 4 ++-- src/bitio.h | 1 + src/combine.c | 32 ++++++++++++++------------------ src/flash.h | 2 +- src/reloc.c | 11 ++++++----- src/swfcombine.c | 40 ++++++++++++++++++++-------------------- src/swfextract.c | 12 ++++++------ 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/bitio.c b/src/bitio.c index fbdbe88..029c4b9 100644 --- a/src/bitio.c +++ b/src/bitio.c @@ -33,12 +33,12 @@ void reader_input1(struct reader_t*r, void*target) } void reader_input2(struct reader_t*r, void*target) { - *(u16*)target = SWAP16(*(u16*)&r->data[r->datapos]); + *(u16*)target = GET16(&r->data[r->datapos]); r->datapos += 2; } void reader_input4(struct reader_t*r, void*target) { - *(u32*)target = SWAP32(*(u32*)&r->data[r->datapos]); + *(u32*)target = GET32(&r->data[r->datapos]); r->datapos += 4; } uchar*reader_getinputpos(struct reader_t*r) diff --git a/src/bitio.h b/src/bitio.h index ac5f7d4..ee30eff 100644 --- a/src/bitio.h +++ b/src/bitio.h @@ -11,6 +11,7 @@ #define __bitio_h__ #include "types.h" +#include "../lib/rfxswf.h" struct reader_t { u8* data; diff --git a/src/combine.c b/src/combine.c index 1e391aa..fa3c894 100644 --- a/src/combine.c +++ b/src/combine.c @@ -58,17 +58,13 @@ void changedepth(struct swf_tag*tag, int add) { /* fucking big endian byte order */ if(tag->id == TAGID_PLACEOBJECT) - (*(u16*)&tag->data[2]) = - SWAP16(SWAP16(*(u16*)&tag->data[2]) + add); + PUT16(&tag->data[2],GET16(&tag->data[2])+add); if(tag->id == TAGID_PLACEOBJECT2) - (*(u16*)&tag->data[1]) = - SWAP16(SWAP16(*(u16*)&tag->data[1]) + add); + PUT16(&tag->data[1],GET16(&tag->data[1])+add); if(tag->id == TAGID_REMOVEOBJECT) - (*(u16*)&tag->data[2]) = - SWAP16(SWAP16(*(u16*)&tag->data[2]) + add); + PUT16(&tag->data[2],GET16(&tag->data[2])+add); if(tag->id == TAGID_REMOVEOBJECT2) - (*(u16*)&tag->data[0]) = - SWAP16(SWAP16(*(u16*)&tag->data[0]) + add); + PUT16(&tag->data[0],GET16(&tag->data[0])+add); } void jpeg_assert() @@ -305,8 +301,8 @@ void write_sprite(struct writer_t*w, int spriteid, int replaceddefine) } while(slave.tags[pos++].id != TAGID_END); - *tagidpos = SWAP32((u8*)writer_getpos(w) - startpos); // set length of sprite (in header) - logf(" sprite length is %d",SWAP32(*tagidpos)); + PUT32(tagidpos, (u8*)writer_getpos(w) - startpos); // set length of sprite (in header) + logf(" sprite length is %d",GET32(tagidpos)); } static char tag_ok_for_slave(int id) @@ -353,7 +349,7 @@ void write_master(struct writer_t*w, int spriteid, int replaceddefine, int flags { if(config.overlay) { - *(u16*)master.tags[pos].data = SWAP16(replaceddefine); + PUT16(master.tags[pos].data, replaceddefine); writer_write(w, master.tags[pos].fulldata, master.tags[pos].fulllength); } else { /* don't write this tag */ @@ -388,10 +384,10 @@ void write_master(struct writer_t*w, int spriteid, int replaceddefine, int flags if(config.clip) { logf(" Can't combine --clip and --frame"); } - *(u16*)&data[0] = SWAP16((u16)(TAGID_PLACEOBJECT2<<6) + 5); + PUT16(&data[0], (u16)(TAGID_PLACEOBJECT2<<6) + 5); *(u8*)&data[2]= 2; //flags: id - *(u16*)&data[3]= SWAP16(depth); // depth - *(u16*)&data[5]= SWAP16(id); + PUT16(&data[3], depth); + PUT16(&data[5], id); write_sprite_defines(w); write_sprite(w, id, -1); writer_write(w,data,7); @@ -554,8 +550,8 @@ uchar * catcombine(uchar*masterdata, int masterlength, char*_slavename, uchar*sl { char data[16]; int len; - *(u16*)(&data[0]) = SWAP16((TAGID_REMOVEOBJECT2<<6) + 2); - *(u16*)(&data[2]) = SWAP16(t); + PUT16(&data[0], (TAGID_REMOVEOBJECT2<<6) + 2); + PUT16(&data[2], t); writer_write(&w, data, 4); } free(depths); @@ -570,7 +566,7 @@ uchar * catcombine(uchar*masterdata, int masterlength, char*_slavename, uchar*sl tmp32 = (u8*)writer_getpos(&w) - (u8*)newdata; //length *newlength = tmp32; - *headlength = SWAP32(tmp32); // set the header to the correct length + PUT32(headlength, tmp32); // set the header to the correct length return newdata; //length } @@ -678,7 +674,7 @@ uchar * normalcombine(uchar*masterdata, int masterlength, char*_slavename, uchar tmp32 = (u8*)writer_getpos(&w) - (u8*)newdata; //length *newlength = tmp32; - *headlength = SWAP32(tmp32); // set the header to the correct length + PUT32(headlength, tmp32); return newdata; //length } diff --git a/src/flash.h b/src/flash.h index 96e48cd..27d31a8 100644 --- a/src/flash.h +++ b/src/flash.h @@ -65,7 +65,7 @@ struct CLIPACTIONS; struct swf_tag { - u8 id; + u16 id; u32 length; u8*data; u32 fulllength; // includes id diff --git a/src/reloc.c b/src/reloc.c index 294570e..956d637 100644 --- a/src/reloc.c +++ b/src/reloc.c @@ -18,12 +18,13 @@ int slaveids[65536]; void maponeid(void*idpos) { u16*idptr = (u16*)idpos; - if(slaveids[SWAP16(*idptr)]<0) { - logf(" Trying to map id never encountered before: id=%d", SWAP16(*idptr)); + U16 id = GET16(idptr); + if(slaveids[id]<0) { + logf(" Trying to map id never encountered before: id=%d", id); return ; } - logf(" mapping %d to %d", SWAP16(*idptr), slaveids[SWAP16(*idptr)]); - *idptr = SWAP16(slaveids[*idptr]); + logf(" mapping %d to %d", id, slaveids[id]); + PUT16(idptr, slaveids[id]); } @@ -194,7 +195,7 @@ void map_ids_mem(u8*mem, int length, void(*callback)(void*)) u16 charid; if(!reader_readu8(&reader)) //flags break; - charid = SWAP16(*(u16*)reader_getinputpos(&reader)); + charid = GET16(reader_getinputpos(&reader)); callback(reader_getinputpos(&reader)); reader_readu16(&reader); //char reader_readu16(&reader); //layer diff --git a/src/swfcombine.c b/src/swfcombine.c index 2b189b9..6f082f3 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -321,12 +321,12 @@ void makestackmaster(u8**masterdata, int*masterlength) pos += sizeof(head); *pos++ = fileversion; fixpos = (u32*)pos; - *(u32*)pos = SWAP32(0x12345678); // to be overwritten + PUT32(pos, 0x12345678); // to be overwritten pos += 4; writeRECT(&pos, &box); - *(u16*)pos = SWAP16(0x2000); // framerate + PUT16(pos, 0x2000) // framerate pos += 2; - *(u16*)pos = SWAP16(numslaves); + PUT16(pos, numslaves) // framerate pos += 2; for(t=0;tlen>=64) { len += 6; data = (U8*)malloc(len); - *(U16*)data = SWAP16((tag->id<<6)+63); + PUT16(data, (tag->id<<6)+63); *(U8*)&data[2] = tag->len; *(U8*)&data[3] = tag->len>>8; *(U8*)&data[4] = tag->len>>16; @@ -174,7 +174,7 @@ void enumerateIDs(TAG*tag, void(*callback)(void*)) } else { len += 2; data = (U8*)malloc(len); - *(U16*)data = SWAP16((tag->id<<6)+tag->len); + PUT16(data, (tag->id<<6)+tag->len); memcpy(&data[2], tag->data, tag->len); } map_ids_mem(data, len, callback); @@ -395,7 +395,7 @@ void handlejpeg(TAG*tag) { char name[80]; FILE*fi; - sprintf(name, "pic%d.jpeg", SWAP16(*(U16*)tag->data)); + sprintf(name, "pic%d.jpeg", GET16(tag->data)); /* swf jpeg images have two streams, which both start with ff d8 and end with ff d9. The following code handles sorting the middle bytes out, so that one stream remains */ @@ -417,7 +417,7 @@ void handlejpeg(TAG*tag) fclose(fi); } if(tag->id == ST_DEFINEBITSJPEG3 && tag->len>6) { - U32 end = SWAP32(*(U32*)&tag->data[2])+6; + U32 end = GET32(&tag->data[2])+6; int pos = findjpegboundary(&tag->data[6], tag->len-6); if(pos<0) return; -- 1.7.10.4