git.asbjorn.biz
/
swftools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
81bfd1b
)
added byte order handling
author
kramm
<kramm>
Thu, 13 Dec 2001 09:54:59 +0000
(09:54 +0000)
committer
kramm
<kramm>
Thu, 13 Dec 2001 09:54:59 +0000
(09:54 +0000)
lib/rfxswf.c
patch
|
blob
|
history
lib/rfxswf.h
patch
|
blob
|
history
diff --git
a/lib/rfxswf.c
b/lib/rfxswf.c
index
7754ba9
..
5f49939
100644
(file)
--- a/
lib/rfxswf.c
+++ b/
lib/rfxswf.c
@@
-545,12
+545,15
@@
TAG * RFXSWF_ReadTag(int handle,TAG * prev)
int id;
if (read(handle,&raw,2)!=2) return NULL;
int id;
if (read(handle,&raw,2)!=2) return NULL;
+ raw = SWAP16(raw);
len = raw&0x3f;
id = raw>>6;
if (len==0x3f)
len = raw&0x3f;
id = raw>>6;
if (len==0x3f)
- { if (read(handle,&len,4)!=4) return NULL;
+ {
+ if (read(handle,&len,4)!=4) return NULL;
+ len = SWAP32(len);
}
if (id==ST_DEFINESPRITE) len = 2*sizeof(U16);
}
if (id==ST_DEFINESPRITE) len = 2*sizeof(U16);
@@
-610,7
+613,7
@@
int RFXSWF_WriteTag(int handle,TAG * t)
if (handle>=0)
{ if (short_tag)
if (handle>=0)
{ if (short_tag)
- { raw[0] = len|((t->id&0x3ff)<<6);
+ { raw[0] = SWAP16(len|((t->id&0x3ff)<<6));
if (write(handle,raw,2)!=2)
{
#ifdef DEBUG_RFXSWF
if (write(handle,raw,2)!=2)
{
#ifdef DEBUG_RFXSWF
@@
-620,13
+623,21
@@
int RFXSWF_WriteTag(int handle,TAG * t)
}
}
else
}
}
else
- { raw[0] = (t->id<<6)|0x3f;
- raw[1] = (U16)(len&0xffff);
- raw[2] = (U16)(len>>16);
- if (write(handle,raw,6)!=6)
+ {
+ raw[0] = SWAP16((t->id<<6)|0x3f);
+ if (write(handle,raw,2)!=2)
+ {
+#ifdef DEBUG_RFXSWF
+ fprintf(stderr,"WriteTag() failed: Long Header (1).\n");
+#endif
+ return -1;
+ }
+
+ len = SWAP32(len);
+ if (write(handle,&len,4)!=4)
{
#ifdef DEBUG_RFXSWF
{
#ifdef DEBUG_RFXSWF
- fprintf(stderr,"WriteTag() failed: Long Header.\n");
+ fprintf(stderr,"WriteTag() failed: Long Header (2).\n");
#endif
return -1;
}
#endif
return -1;
}
diff --git
a/lib/rfxswf.h
b/lib/rfxswf.h
index
016f8e3
..
81ccf9f
100644
(file)
--- a/
lib/rfxswf.h
+++ b/
lib/rfxswf.h
@@
-29,6
+29,14
@@
#define FALSE (0)
#endif
#define FALSE (0)
#endif
+#ifdef WORDS_BIGENDIAN
+#define SWAP16(s) ((U16) ((U8*)&s)[0] | ((U16) ((U8*)&s)[1] << 8))
+#define SWAP32(s) ((U32) ((U8*)&s)[0] | ((U32) ((U8*)&s)[1] << 8) | ((U32) ((U8*)&s)[2] << 16) | ((U32) ((U8*)&s)[3] << 24))
+#else
+#define SWAP16(x) x
+#define SWAP32(x) x
+#endif
+
// SWF Types
typedef unsigned long U32;
// SWF Types
typedef unsigned long U32;