more fiddling with edgestyles
[swftools.git] / lib / rfxswf.c
index c9006c1..6570847 100644 (file)
@@ -1179,15 +1179,14 @@ TAG * swf_ReadTag(reader_t*reader, TAG * prev)
   int id;
 
   if (reader->read(reader, &raw, 2) !=2 ) return NULL;
-  raw = SWAP16(raw);
+  raw = LE_16_TO_NATIVE(raw);
 
   len = raw&0x3f;
   id  = raw>>6;
 
   if (len==0x3f)
   {
-      if (reader->read(reader, &len, 4) != 4) return NULL;
-      len = SWAP32(len);
+      len = reader_readU32(reader);
   }
 
   if (id==ST_DEFINESPRITE) len = 2*sizeof(U16);
@@ -1244,7 +1243,7 @@ int swf_WriteTag2(writer_t*writer, TAG * t)
 #endif
     
     if (short_tag)
-    { raw[0] = SWAP16(len|((t->id&0x3ff)<<6));
+    { raw[0] = LE_16_TO_NATIVE(len|((t->id&0x3ff)<<6));
       if (writer->write(writer,raw,2)!=2)
       {
         #ifdef DEBUG_RFXSWF
@@ -1255,7 +1254,7 @@ int swf_WriteTag2(writer_t*writer, TAG * t)
     }
     else
     {
-      raw[0] = SWAP16((t->id<<6)|0x3f);
+      raw[0] = LE_16_TO_NATIVE((t->id<<6)|0x3f);
       if (writer->write(writer,raw,2)!=2)
       {
 #ifdef DEBUG_RFXSWF
@@ -1264,14 +1263,7 @@ int swf_WriteTag2(writer_t*writer, TAG * t)
          return -1;
       }
       
-      len = SWAP32(len);
-      if (writer->write(writer,&len,4)!=4)
-      {
-        #ifdef DEBUG_RFXSWF
-          fprintf(stderr,"WriteTag() failed: Long Header (2).\n");
-        #endif
-        return -1;
-      }
+      writer_writeU32(writer, len);
     }
     
     if (t->data)
@@ -1567,9 +1559,9 @@ int swf_ReadSWF2(reader_t*reader, SWF * swf)   // Reads SWF to memory (malloc'ed
 
     reader_GetRect(reader, &swf->movieSize);
     reader->read(reader, &swf->frameRate, 2);
-    swf->frameRate = SWAP16(swf->frameRate);
+    swf->frameRate = LE_16_TO_NATIVE(swf->frameRate);
     reader->read(reader, &swf->frameCount, 2);
-    swf->frameCount = SWAP16(swf->frameCount);
+    swf->frameCount = LE_16_TO_NATIVE(swf->frameCount);
 
     /* read tags and connect to list */
     t1.next = 0;
@@ -1881,7 +1873,7 @@ int swf_WriteCGI(SWF * swf)
 
   sprintf(s,"Content-type: application/x-shockwave-flash\n"
             "Accept-Ranges: bytes\n"
-            "Content-Length: %lu\n"
+            "Content-Length: %d\n"
             "Expires: Thu, 13 Apr 2000 23:59:59 GMT\n"
             "\n",len);