Enlightenment CVS committal
Author : englebass
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_dbus
Modified Files:
ecore_dbus.c ecore_dbus_message.c ecore_dbus_private.h
ecore_dbus_utils.c
Log Message:
Make dbus endian aware.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_dbus/ecore_dbus.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- ecore_dbus.c 5 Nov 2006 17:45:03 -0000 1.28
+++ ecore_dbus.c 7 Feb 2007 00:23:54 -0000 1.29
@@ -13,6 +13,7 @@
/********************************************************************************/
/* Author: Jorge Luis Zapata
*/
/* Author: Brian Mattern (rephorm)
*/
+/* Author: Sebastian Dransfeld
*/
/* Version: 0.3.0
*/
/********************************************************************************/
/* Todo
*/
@@ -83,6 +84,8 @@
static Ecore_List2 *servers = NULL;
static Ecore_Event_Handler *handler[3];
+int words_bigendian = -1;
+
/* public functions */
EAPI int
ecore_dbus_init(void)
@@ -90,6 +93,15 @@
int i = 0;
if (++init_count != 1) return init_count;
+
+ if (words_bigendian == -1)
+ {
+ unsigned long int v;
+
+ v = htonl(0x12345678);
+ if (v == 0x12345678) words_bigendian = 1;
+ else words_bigendian = 0;
+ }
ecore_con_init();
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_dbus/ecore_dbus_message.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ecore_dbus_message.c 5 Nov 2006 17:45:03 -0000 1.13
+++ ecore_dbus_message.c 7 Feb 2007 00:23:54 -0000 1.14
@@ -462,8 +462,10 @@
if (!msg) return;
/* endianness (1) */
- /* XXX we need to detect for endianess and send 'B' for Bigendian machines
*/
- msg->buffer[0] = msg->byte_order = 'l';
+ if (words_bigendian)
+ msg->buffer[0] = msg->byte_order = 'B';
+ else
+ msg->buffer[0] = msg->byte_order = 'l';
/* type (1) */
msg->buffer[1] = msg->type = (char)type;
/* flags (1) 0x1 = no reply expected, 0x2 auto activation */
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_dbus/ecore_dbus_private.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- ecore_dbus_private.h 5 Nov 2006 17:45:03 -0000 1.17
+++ ecore_dbus_private.h 7 Feb 2007 00:23:54 -0000 1.18
@@ -7,6 +7,30 @@
#include "Ecore_Con.h"
#include "Ecore_Data.h"
+extern int words_bigendian;
+
+#define SWAP64(x) (x) = \
+ ((((unsigned long long)(x) & 0x00000000000000ffULL ) << 56) |\
+ (((unsigned long long)(x) & 0x000000000000ff00ULL ) << 40) |\
+ (((unsigned long long)(x) & 0x0000000000ff0000ULL ) << 24) |\
+ (((unsigned long long)(x) & 0x00000000ff000000ULL ) << 8) |\
+ (((unsigned long long)(x) & 0x000000ff00000000ULL ) >> 8) |\
+ (((unsigned long long)(x) & 0x0000ff0000000000ULL ) >> 24) |\
+ (((unsigned long long)(x) & 0x00ff000000000000ULL ) >> 40) |\
+ (((unsigned long long)(x) & 0xff00000000000000ULL ) >> 56))
+#define SWAP32(x) (x) = \
+ ((((unsigned int)(x) & 0x000000ff ) << 24) |\
+ (((unsigned int)(x) & 0x0000ff00 ) << 8) |\
+ (((unsigned int)(x) & 0x00ff0000 ) >> 8) |\
+ (((unsigned int)(x) & 0xff000000 ) >> 24))
+#define SWAP16(x) (x) = \
+ ((((unsigned short)(x) & 0x00ff ) << 8) |\
+ (((unsigned short)(x) & 0xff00 ) >> 8))
+
+#define CONV16(order, x) { if (words_bigendian && (order) != 'B') SWAP16(x); }
+#define CONV32(order, x) { if (words_bigendian && (order) != 'B') SWAP32(x); }
+#define CONV64(order, x) { if (words_bigendian && (order) != 'B') SWAP64(x); }
+
typedef unsigned char *(*Ecore_DBus_Auth_Transaction)(void *);
typedef struct _Ecore_DBus_Auth Ecore_DBus_Auth;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_dbus/ecore_dbus_utils.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ecore_dbus_utils.c 29 Sep 2006 03:05:21 -0000 1.7
+++ ecore_dbus_utils.c 7 Feb 2007 00:23:54 -0000 1.8
@@ -83,6 +83,7 @@
{
unsigned char *c;
+ CONV32(msg->byte_order, i)
c = (unsigned char *)&i;
_ecore_dbus_message_length_append(msg, 4);
msg->buffer[msg->length++] = c[0];
@@ -109,6 +110,7 @@
_ecore_dbus_message_length_append(msg, 4);
i = *(unsigned int *)(msg->buffer + msg->length);
+ CONV32(msg->byte_order, i)
msg->length += 4;
return i;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs