Blob Blame History Raw
diff -Nurb capi20.orig/capiutils.h capi20/capiutils.h
--- capi20.orig/capiutils.h	2005-05-13 21:23:48.000000000 +0200
+++ capi20/capiutils.h	2005-08-04 09:49:53.695166821 +0200
@@ -227,7 +227,8 @@
 	unsigned char *Data;
 
 	/* intern */
-	unsigned l, p;
+	_cword l;
+	unsigned p;
 	unsigned char *par;
 	_cbyte *m;
 
diff -Nurb capi20.orig/convert.c capi20/convert.c
--- capi20.orig/convert.c	2005-05-13 21:23:49.000000000 +0200
+++ capi20/convert.c	2005-08-04 09:49:53.729158485 +0200
@@ -83,6 +86,7 @@
 #include <stddef.h>
 #include <time.h>
 #include <ctype.h>
+#include <byteswap.h>
 
 #include "capi20.h"
 
@@ -481,20 +485,34 @@
 
 /*-------------------------------------------------------*/
 
+#ifdef _BIG_ENDIAN
+#define byteTLcpy(x,y)        *(_cbyte *)(x)=*(_cbyte *)(y);
+#define wordTLcpy(x,y)        *(_cword *)(x)=bswap_16(*(_cword *)(y));
+#define dwordTLcpy(x,y)       *(_cdword *)(x)=bswap_32(*(_cdword *)(y));
+ 
+#define byteTRcpy(x,y)        *(_cbyte *)(y)=*(_cbyte *)(x);
+#define wordTRcpy(x,y)        *(_cword *)(y)=bswap_16(*(_cword *)(x));
+#define dwordTRcpy(x,y)       *(_cdword *)(y)=bswap_32(*(_cdword *)(x));
+  
+#define qwordTLcpy(x,y)       *(_cqword *)(x)=bswap_64(*(_cqword *)(y));
+#define qwordTRcpy(x,y)       *(_cqword *)(y)=bswap_64(*(_cqword *)(x));
+#else
 #define byteTLcpy(x,y)        *(_cbyte *)(x)=*(_cbyte *)(y);
 #define wordTLcpy(x,y)        *(_cword *)(x)=*(_cword *)(y);
 #define dwordTLcpy(x,y)       memcpy(x,y,4);
-#define structTLcpy(x,y,l)    memcpy (x,y,l)
-#define structTLcpyovl(x,y,l) memmove (x,y,l)
 
 #define byteTRcpy(x,y)        *(_cbyte *)(y)=*(_cbyte *)(x);
 #define wordTRcpy(x,y)        *(_cword *)(y)=*(_cword *)(x);
 #define dwordTRcpy(x,y)       memcpy(y,x,4);
-#define structTRcpy(x,y,l)    memcpy (y,x,l)
-#define structTRcpyovl(x,y,l) memmove (y,x,l)
 
 #define qwordTLcpy(x,y)       memcpy(x,y,8);
 #define qwordTRcpy(x,y)       memcpy(y,x,8);
+#endif
+
+#define structTLcpy(x,y,l)    memcpy (x,y,l)
+#define structTLcpyovl(x,y,l) memmove (x,y,l)
+#define structTRcpy(x,y,l)    memcpy (y,x,l)
+#define structTRcpyovl(x,y,l) memmove (y,x,l)
 
 /*-------------------------------------------------------*/
 static unsigned command_2_index(unsigned c, unsigned sc)
@@ -559,9 +577,11 @@
 				structTLcpy(cmsg->m + cmsg->l, *(_cstruct *) OFF, 1 + **(_cstruct *) OFF);
 				cmsg->l += 1 + **(_cstruct *) OFF;
 			} else {
+				_cword iw;
 				_cstruct s = *(_cstruct *) OFF;
 				structTLcpy(cmsg->m + cmsg->l, s, 3 + *(_cword *) (s + 1));
-				cmsg->l += 3 + *(_cword *) (s + 1);
+				wordTLcpy(&iw, (s + 1));
+				cmsg->l += 3 + iw;
 			}
 			break;
 		case _CMSTRUCT:
@@ -647,10 +667,13 @@
 		case _CSTRUCT:
 			*(_cbyte **) OFF = cmsg->m + cmsg->l;
 
-			if (cmsg->m[cmsg->l] != 0xff)
+			if (cmsg->m[cmsg->l] != 0xff) {
 				cmsg->l += 1 + cmsg->m[cmsg->l];
-			else
-				cmsg->l += 3 + *(_cword *) (cmsg->m + cmsg->l + 1);
+			} else {
+				_cword iw;
+				wordTLcpy(&iw, (cmsg->m + cmsg->l + 1));
+				cmsg->l += 3 + iw;
+			}
 			break;
 		case _CMSTRUCT:
 /*----- Metastruktur 0 -----*/