summaryrefslogtreecommitdiff
path: root/legacy/eet/src/lib/eet_connection.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
commitf7019f134dd8e8ae830eb1d39fb8570c74b730e9 (patch)
tree6fc137cbc4e6505629d2210cf11ace757d162490 /legacy/eet/src/lib/eet_connection.c
parent55d01901859bb2fcca1befeb1011e204d271d59f (diff)
formatting. <- uncrustify
SVN revision: 50698
Diffstat (limited to 'legacy/eet/src/lib/eet_connection.c')
-rw-r--r--legacy/eet/src/lib/eet_connection.c92
1 files changed, 49 insertions, 43 deletions
diff --git a/legacy/eet/src/lib/eet_connection.c b/legacy/eet/src/lib/eet_connection.c
index fb41ff0d91..66b4911636 100644
--- a/legacy/eet/src/lib/eet_connection.c
+++ b/legacy/eet/src/lib/eet_connection.c
@@ -4,7 +4,7 @@
4 4
5#ifdef HAVE_CONFIG_H 5#ifdef HAVE_CONFIG_H
6# include <config.h> 6# include <config.h>
7#endif 7#endif /* ifdef HAVE_CONFIG_H */
8 8
9#ifdef HAVE_ALLOCA_H 9#ifdef HAVE_ALLOCA_H
10# include <alloca.h> 10# include <alloca.h>
@@ -15,24 +15,24 @@
15#elif defined _MSC_VER 15#elif defined _MSC_VER
16# include <malloc.h> 16# include <malloc.h>
17# define alloca _alloca 17# define alloca _alloca
18#else 18#else /* ifdef HAVE_ALLOCA_H */
19# include <stddef.h> 19# include <stddef.h>
20# ifdef __cplusplus 20# ifdef __cplusplus
21extern "C" 21extern "C"
22# endif 22# endif /* ifdef __cplusplus */
23void *alloca (size_t); 23void * alloca (size_t);
24#endif 24#endif /* ifdef HAVE_ALLOCA_H */
25 25
26#include <string.h> 26#include <string.h>
27#include <stdlib.h> 27#include <stdlib.h>
28 28
29#ifdef HAVE_NETINET_IN_H 29#ifdef HAVE_NETINET_IN_H
30# include <netinet/in.h> 30# include <netinet/in.h>
31#endif 31#endif /* ifdef HAVE_NETINET_IN_H */
32 32
33#ifdef _WIN32 33#ifdef _WIN32
34# include <winsock2.h> 34# include <winsock2.h>
35#endif 35#endif /* ifdef _WIN32 */
36 36
37#include <Eina.h> 37#include <Eina.h>
38 38
@@ -41,7 +41,7 @@ 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; 44typedef struct _Eet_Message Eet_Message;
45struct _Eet_Message 45struct _Eet_Message
46{ 46{
47 int magic; 47 int magic;
@@ -50,23 +50,23 @@ struct _Eet_Message
50 50
51struct _Eet_Connection 51struct _Eet_Connection
52{ 52{
53 Eet_Read_Cb *eet_read_cb; 53 Eet_Read_Cb * eet_read_cb;
54 Eet_Write_Cb *eet_write_cb; 54 Eet_Write_Cb * eet_write_cb;
55 void *user_data; 55 void * user_data;
56 56
57 size_t allocated; 57 size_t allocated;
58 size_t size; 58 size_t size;
59 size_t received; 59 size_t received;
60 60
61 void *buffer; 61 void * buffer;
62}; 62};
63 63
64EAPI Eet_Connection * 64EAPI Eet_Connection *
65eet_connection_new(Eet_Read_Cb *eet_read_cb, 65eet_connection_new(Eet_Read_Cb * eet_read_cb,
66 Eet_Write_Cb *eet_write_cb, 66 Eet_Write_Cb * eet_write_cb,
67 const void *user_data) 67 const void * user_data)
68{ 68{
69 Eet_Connection *conn; 69 Eet_Connection * conn;
70 70
71 if (!eet_read_cb || !eet_write_cb) 71 if (!eet_read_cb || !eet_write_cb)
72 return NULL; 72 return NULL;
@@ -80,12 +80,14 @@ eet_connection_new(Eet_Read_Cb *eet_read_cb,
80 conn->user_data = (void *)user_data; 80 conn->user_data = (void *)user_data;
81 81
82 return conn; 82 return conn;
83} 83} /* eet_connection_new */
84 84
85EAPI int 85EAPI int
86eet_connection_received(Eet_Connection *conn, const void *data, size_t size) 86eet_connection_received(Eet_Connection * conn,
87 const void * data,
88 size_t size)
87{ 89{
88 if (!conn || !data || !size) 90 if ((!conn) || (!data) || (!size))
89 return size; 91 return size;
90 92
91 do { 93 do {
@@ -93,7 +95,7 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
93 95
94 if (conn->size == 0) 96 if (conn->size == 0)
95 { 97 {
96 const Eet_Message *msg; 98 const Eet_Message * msg;
97 size_t packet_size; 99 size_t packet_size;
98 100
99 if (size < sizeof (Eet_Message)) 101 if (size < sizeof (Eet_Message))
@@ -127,7 +129,7 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
127 conn->size = packet_size; 129 conn->size = packet_size;
128 if (conn->allocated < conn->size) 130 if (conn->allocated < conn->size)
129 { 131 {
130 void *tmp; 132 void * tmp;
131 133
132 tmp = realloc(conn->buffer, conn->size); 134 tmp = realloc(conn->buffer, conn->size);
133 if (!tmp) 135 if (!tmp)
@@ -167,12 +169,14 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
167 } while (size > 0); 169 } while (size > 0);
168 170
169 return size; 171 return size;
170} 172} /* eet_connection_received */
171 173
172static Eina_Bool 174static Eina_Bool
173_eet_connection_raw_send(Eet_Connection *conn, void *data, int data_size) 175_eet_connection_raw_send(Eet_Connection * conn,
176 void * data,
177 int data_size)
174{ 178{
175 Eet_Message *message; 179 Eet_Message * message;
176 180
177 /* Message should never be above 64K */ 181 /* Message should never be above 64K */
178 if (data_size > 64 * 1024) 182 if (data_size > 64 * 1024)
@@ -182,21 +186,21 @@ _eet_connection_raw_send(Eet_Connection *conn, void *data, int data_size)
182 message->magic = htonl(MAGIC_EET_DATA_PACKET); 186 message->magic = htonl(MAGIC_EET_DATA_PACKET);
183 message->size = htonl(data_size); 187 message->size = htonl(data_size);
184 188
185 memcpy(message + 1, data, data_size); 189 memcpy(message + 1, data, data_size);
186 190
187 conn->eet_write_cb(message, 191 conn->eet_write_cb(message,
188 data_size + sizeof (Eet_Message), 192 data_size + sizeof (Eet_Message),
189 conn->user_data); 193 conn->user_data);
190 return EINA_TRUE; 194 return EINA_TRUE;
191} 195} /* _eet_connection_raw_send */
192 196
193EAPI Eina_Bool 197EAPI Eina_Bool
194eet_connection_send(Eet_Connection *conn, 198eet_connection_send(Eet_Connection * conn,
195 Eet_Data_Descriptor *edd, 199 Eet_Data_Descriptor * edd,
196 const void *data_in, 200 const void * data_in,
197 const char *cipher_key) 201 const char * cipher_key)
198{ 202{
199 void *flat_data; 203 void * flat_data;
200 int data_size; 204 int data_size;
201 Eina_Bool ret = EINA_FALSE; 205 Eina_Bool ret = EINA_FALSE;
202 206
@@ -212,14 +216,14 @@ eet_connection_send(Eet_Connection *conn,
212 216
213 free(flat_data); 217 free(flat_data);
214 return ret; 218 return ret;
215} 219} /* eet_connection_send */
216 220
217EAPI Eina_Bool 221EAPI Eina_Bool
218eet_connection_node_send(Eet_Connection *conn, 222eet_connection_node_send(Eet_Connection * conn,
219 Eet_Node *node, 223 Eet_Node * node,
220 const char *cipher_key) 224 const char * cipher_key)
221{ 225{
222 void *data; 226 void * data;
223 int data_size; 227 int data_size;
224 Eina_Bool ret = EINA_FALSE; 228 Eina_Bool ret = EINA_FALSE;
225 229
@@ -232,12 +236,13 @@ eet_connection_node_send(Eet_Connection *conn,
232 236
233 free(data); 237 free(data);
234 return ret; 238 return ret;
235} 239} /* eet_connection_node_send */
236 240
237EAPI void * 241EAPI void *
238eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going) 242eet_connection_close(Eet_Connection * conn,
243 Eina_Bool * on_going)
239{ 244{
240 void *user_data; 245 void * user_data;
241 246
242 if (!conn) 247 if (!conn)
243 return NULL; 248 return NULL;
@@ -251,4 +256,5 @@ eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going)
251 free(conn); 256 free(conn);
252 257
253 return user_data; 258 return user_data;
254} 259} /* eet_connection_close */
260