solaris fixes.
authorkramm <kramm>
Wed, 9 Jan 2002 12:30:16 +0000 (12:30 +0000)
committerkramm <kramm>
Wed, 9 Jan 2002 12:30:16 +0000 (12:30 +0000)
src/bitio.c
src/bitio.h
src/combine.c
src/flash.h
src/reloc.c
src/swfcombine.c
src/swfextract.c

index fbdbe88..029c4b9 100644 (file)
@@ -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)
index ac5f7d4..ee30eff 100644 (file)
@@ -11,6 +11,7 @@
 #define __bitio_h__
 
 #include "types.h"
+#include "../lib/rfxswf.h"
 
 struct reader_t {
     u8* data;
index 1e391aa..fa3c894 100644 (file)
@@ -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("<verbose> sprite length is %d",SWAP32(*tagidpos));
+    PUT32(tagidpos, (u8*)writer_getpos(w) - startpos); // set length of sprite (in header)
+    logf("<verbose> 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("<fatal> 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
 }
index 96e48cd..27d31a8 100644 (file)
@@ -65,7 +65,7 @@ struct CLIPACTIONS;
 
 struct swf_tag
 {
-    u8 id;
+    u16 id;
     u32 length;
     u8*data;
     u32 fulllength; // includes id
index 294570e..956d637 100644 (file)
@@ -18,12 +18,13 @@ int slaveids[65536];
 void maponeid(void*idpos)
 {
     u16*idptr = (u16*)idpos;
-    if(slaveids[SWAP16(*idptr)]<0) {
-       logf("<error> Trying to map id never encountered before: id=%d", SWAP16(*idptr));
+    U16 id = GET16(idptr);
+    if(slaveids[id]<0) {
+       logf("<error> Trying to map id never encountered before: id=%d", id);
        return ;
     }
-    logf("<debug> mapping %d to %d", SWAP16(*idptr), slaveids[SWAP16(*idptr)]);
-    *idptr =  SWAP16(slaveids[*idptr]);
+    logf("<debug> 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
index 2b189b9..6f082f3 100644 (file)
@@ -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;t<numslaves;t++)
     {
@@ -339,31 +339,31 @@ void makestackmaster(u8**masterdata, int*masterlength)
        } 
        namelen = strlen(slave_name[t]);
 
-       *(u16*)&pos[0] = SWAP16((u16)(TAGID_DEFINESPRITE<<6) + 6);
-       *(u16*)&pos[2] = SWAP16(t+1); //ID
-       *(u16*)&pos[4] = 0; // Frames
-       *(u16*)&pos[6] = 0; // TAG1
-       *(u16*)&pos[8] = SWAP16((u16)(TAGID_PLACEOBJECT2<<6) + 6 + namelen);
-       *(u16*)&pos[10]= SWAP16(34); //flags: id+name
-       *(u16*)&pos[11]= SWAP16(1+t); // depth
-       *(u16*)&pos[13]= SWAP16(t+1); // id
+       PUT16(&pos[0] , ((u16)(TAGID_DEFINESPRITE<<6) + 6));
+       PUT16(&pos[2] , (t+1)); //ID
+       PUT16(&pos[4] , 0); // Frames
+       PUT16(&pos[6] , 0); // TAG1
+       PUT16(&pos[8] , ((u16)(TAGID_PLACEOBJECT2<<6) + 6 + namelen));
+       PUT16(&pos[10], (34)); //flags: id+name
+       PUT16(&pos[11], (1+t)); // depth
+       PUT16(&pos[13], (t+1)); // id
        sprintf(&pos[15],slave_name[t]);
        pos += 15 + namelen + 1;
        if(!config.stack1 || t == numslaves-1) {
-           *(u16*)&pos[0]= SWAP16((u16)(TAGID_SHOWFRAME<<6) + 0);
+           PUT16(&pos[0],((u16)(TAGID_SHOWFRAME<<6) + 0));
            pos += 2;
        }
        if(!config.stack)
        if(t!=numslaves-1)
        {
-           *(u16*)&pos[0]= SWAP16((u16)(TAGID_REMOVEOBJECT2<<6) + 2);
-           *(u16*)&pos[2]= SWAP16(1+t); // depth;
+           PUT16(&pos[0], ((u16)(TAGID_REMOVEOBJECT2<<6) + 2));
+           PUT16(&pos[2], (1+t)); // depth;
            pos += 4;
        }
     }
-    *(u16*)pos = SWAP16(TAGID_END<<6 + 0);
+    PUT16(pos, (TAGID_END<<6 + 0));
     *masterlength = pos - *masterdata;
-    *fixpos = SWAP32(*masterlength);
+    PUT32(fixpos, *masterlength);
 }
 
 struct config_t config;
@@ -505,11 +505,11 @@ int main(int argn, char *argv[])
                slavedata[1] = 'W';
                slavedata[2] = 'S';
                slavedata[3] = 4; //version
-               *(u32*)&slavedata[4] = SWAP32(14); // length
+               PUT32(&slavedata[4], 14); ; // length
                slavedata[8] = 0; // boundingbox
-               *(u16*)&slavedata[9] = SWAP16(0); // rate
-               *(u16*)&slavedata[11] = SWAP16(0); // count
-               *(u16*)&slavedata[13] = SWAP16(0); // end tag
+               PUT16(&slavedata[9] , (0)); // rate
+               PUT16(&slavedata[11] , (0)); // count
+               PUT16(&slavedata[13] , (0)); // end tag
                slavelength = 17;
            }
 
index 62b6168..99844eb 100644 (file)
@@ -152,9 +152,9 @@ char * tagused;
 
 void idcallback(void*data)
 {
-    if(!(used[SWAP16(*(U16*)data)]&1)) {
+    if(!(used[GET16(data)]&1)) {
        changed = 1;
-       used[SWAP16(*(U16*)data)] |= 1;
+       used[GET16(data)] |= 1;
     }
 }
 
@@ -165,7 +165,7 @@ void enumerateIDs(TAG*tag, void(*callback)(void*))
     if(tag->len>=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
        <ff d9 ff d8> 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;