/********************************************************************************/
/* Author: Jorge Luis Zapata */
/* Author: Brian Mattern (rephorm) */
+/* Author: Sebastian Dransfeld */
/* Version: 0.3.0 */
/********************************************************************************/
/* Todo */
static Ecore_List2 *servers = NULL;
static Ecore_Event_Handler *handler[3];
+int words_bigendian = -1;
+
/* public functions */
EAPI int
ecore_dbus_init(void)
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();
ECORE_DBUS_EVENT_SERVER_ADD = ecore_event_type_new();
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 */
#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;
{
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];
_ecore_dbus_message_length_append(msg, 4);
i = *(unsigned int *)(msg->buffer + msg->length);
+ CONV32(msg->byte_order, i)
msg->length += 4;
return i;
}