summaryrefslogtreecommitdiff
path: root/legacy/eet/src/lib/eet_connection.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2010-08-02 14:30:46 +0000
committerCedric BAIL <cedric.bail@free.fr>2010-08-02 14:30:46 +0000
commit1edd7e4ffad487c8968f4d6940c14ded50c5c320 (patch)
treeefb8f15d1cacbc32b9909703bfae31fa3828d32e /legacy/eet/src/lib/eet_connection.c
parent1ba6b5004298fc5e588e0f0a6c1820c8aa101a3e (diff)
* eet: fix bug on 32bits computer.
SVN revision: 50743
Diffstat (limited to 'legacy/eet/src/lib/eet_connection.c')
-rw-r--r--legacy/eet/src/lib/eet_connection.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/legacy/eet/src/lib/eet_connection.c b/legacy/eet/src/lib/eet_connection.c
index 4f141c16f3..fa4b868a87 100644
--- a/legacy/eet/src/lib/eet_connection.c
+++ b/legacy/eet/src/lib/eet_connection.c
@@ -41,13 +41,6 @@ void * alloca (size_t);
41 41
42#define MAGIC_EET_DATA_PACKET 0x4270ACE1 42#define MAGIC_EET_DATA_PACKET 0x4270ACE1
43 43
44typedef struct _Eet_Message Eet_Message;
45struct _Eet_Message
46{
47 int magic;
48 int size;
49};
50
51struct _Eet_Connection 44struct _Eet_Connection
52{ 45{
53 Eet_Read_Cb *eet_read_cb; 46 Eet_Read_Cb *eet_read_cb;
@@ -95,24 +88,24 @@ eet_connection_received(Eet_Connection *conn,
95 88
96 if (conn->size == 0) 89 if (conn->size == 0)
97 { 90 {
98 const Eet_Message *msg; 91 const int *msg;
99 size_t packet_size; 92 size_t packet_size;
100 93
101 if (size < sizeof (Eet_Message)) 94 if (size < sizeof (int) * 2)
102 break; 95 break;
103 96
104 msg = data; 97 msg = data;
105 /* Check the magic */ 98 /* Check the magic */
106 if (ntohl(msg->magic) != MAGIC_EET_DATA_PACKET) 99 if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET)
107 break; 100 break;
108 101
109 packet_size = ntohl(msg->size); 102 packet_size = ntohl(msg[1]);
110 /* Message should always be under 64K */ 103 /* Message should always be under 64K */
111 if (packet_size > 64 * 1024) 104 if (packet_size > 64 * 1024)
112 break; 105 break;
113 106
114 data = (void *)(msg + 1); 107 data = (void *)(msg + 2);
115 size -= sizeof (msg); 108 size -= sizeof (int) * 2;
116 if ((size_t)packet_size <= size) 109 if ((size_t)packet_size <= size)
117 { 110 {
118 /* Not a partial receive, go the quick way. */ 111 /* Not a partial receive, go the quick way. */
@@ -176,20 +169,20 @@ _eet_connection_raw_send(Eet_Connection *conn,
176 void *data, 169 void *data,
177 int data_size) 170 int data_size)
178{ 171{
179 Eet_Message *message; 172 int *message;
180 173
181 /* Message should never be above 64K */ 174 /* Message should never be above 64K */
182 if (data_size > 64 * 1024) 175 if (data_size > 64 * 1024)
183 return EINA_FALSE; 176 return EINA_FALSE;
184 177
185 message = alloca(data_size + sizeof (Eet_Message)); 178 message = alloca(data_size + sizeof (int) * 2);
186 message->magic = htonl(MAGIC_EET_DATA_PACKET); 179 message[0] = htonl(MAGIC_EET_DATA_PACKET);
187 message->size = htonl(data_size); 180 message[1] = htonl(data_size);
188 181
189 memcpy(message + 1, data, data_size); 182 memcpy(message + 2, data, data_size);
190 183
191 conn->eet_write_cb(message, 184 conn->eet_write_cb(message,
192 data_size + sizeof (Eet_Message), 185 data_size + sizeof (int) * 2,
193 conn->user_data); 186 conn->user_data);
194 return EINA_TRUE; 187 return EINA_TRUE;
195} /* _eet_connection_raw_send */ 188} /* _eet_connection_raw_send */