summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-27 16:08:39 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-29 12:44:19 -0300
commit17444557deab4f1ecb62e0fd03a7090a3a4bcbfd (patch)
tree60b356361ff3a9930403776fd77318210b88e517
parent8f6e3265b6c2d66309fec5fe27f1e91ad9568302 (diff)
ecore_con_*_example: compile on win32.
- win32 doesn't provide getline(). - _write() exists, use _write_() instead
-rw-r--r--src/examples/ecore/ecore_con_client_example.c18
-rw-r--r--src/examples/ecore/ecore_con_server_example.c4
2 files changed, 17 insertions, 5 deletions
diff --git a/src/examples/ecore/ecore_con_client_example.c b/src/examples/ecore/ecore_con_client_example.c
index 879e2200b6..35371ca42e 100644
--- a/src/examples/ecore/ecore_con_client_example.c
+++ b/src/examples/ecore/ecore_con_client_example.c
@@ -58,8 +58,20 @@ static Eina_Bool
58_on_stdin(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh EINA_UNUSED) 58_on_stdin(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh EINA_UNUSED)
59{ 59{
60 char *line = NULL; 60 char *line = NULL;
61#ifdef _WIN32
62 char lbuf[4096] = "";
63 ssize_t r;
64 if (fgets(lbuf, sizeof(lbuf), stdin) == NULL)
65 r = -1;
66 else
67 {
68 line = strdup(lbuf);
69 r = strlen(line);
70 }
71#else
61 size_t len = 0; 72 size_t len = 0;
62 ssize_t r = getline(&line, &len, stdin); 73 ssize_t r = getline(&line, &len, stdin);
74#endif
63 75
64 if (r < 0) 76 if (r < 0)
65 { 77 {
@@ -151,13 +163,13 @@ _data(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Data
151 "%.*s\n" 163 "%.*s\n"
152 ">>>>>\n", 164 ">>>>>\n",
153 ev->size, 165 ev->size,
154 ev->size, ev->data); 166 ev->size, (const char *)ev->data);
155 167
156 return ECORE_CALLBACK_RENEW; 168 return ECORE_CALLBACK_RENEW;
157} 169}
158 170
159Eina_Bool 171Eina_Bool
160_write(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Write *ev) 172_write_(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Write *ev)
161{ 173{
162 printf("Sent %d bytes to server\n", ev->size); 174 printf("Sent %d bytes to server\n", ev->size);
163 return ECORE_CALLBACK_RENEW; 175 return ECORE_CALLBACK_RENEW;
@@ -323,7 +335,7 @@ main(int argc, char *argv[])
323/* set event handler for receiving server data */ 335/* set event handler for receiving server data */
324 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_data, NULL); 336 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_data, NULL);
325/* set event handler that notifies of sent data */ 337/* set event handler that notifies of sent data */
326 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_WRITE, (Ecore_Event_Handler_Cb)_write, NULL); 338 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_WRITE, (Ecore_Event_Handler_Cb)_write_, NULL);
327/* set event handler that notifies of errors */ 339/* set event handler that notifies of errors */
328 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, (Ecore_Event_Handler_Cb)_error, NULL); 340 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, (Ecore_Event_Handler_Cb)_error, NULL);
329/* set event handler that notifies of upgrades */ 341/* set event handler that notifies of upgrades */
diff --git a/src/examples/ecore/ecore_con_server_example.c b/src/examples/ecore/ecore_con_server_example.c
index 08aee96720..4ccb1a495a 100644
--- a/src/examples/ecore/ecore_con_server_example.c
+++ b/src/examples/ecore/ecore_con_server_example.c
@@ -94,7 +94,7 @@ _data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
94 94
95 95
96Eina_Bool 96Eina_Bool
97_write(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 97_write_(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
98{ 98{
99 Ecore_Con_Event_Client_Write *ev = event; 99 Ecore_Con_Event_Client_Write *ev = event;
100 printf("Sent %d bytes to client %s\n", ev->size, ecore_con_client_ip_get(ev->client)); 100 printf("Sent %d bytes to client %s\n", ev->size, ecore_con_client_ip_get(ev->client));
@@ -290,7 +290,7 @@ main(int argc, char **argv)
290/* set event handler for receiving client data */ 290/* set event handler for receiving client data */
291 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL); 291 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL);
292/* set event handler that notifies of sent data */ 292/* set event handler that notifies of sent data */
293 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_WRITE, (Ecore_Event_Handler_Cb)_write, NULL); 293 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_WRITE, (Ecore_Event_Handler_Cb)_write_, NULL);
294/* set event handler that notifies of errors */ 294/* set event handler that notifies of errors */
295 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ERROR, (Ecore_Event_Handler_Cb)_error, NULL); 295 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ERROR, (Ecore_Event_Handler_Cb)_error, NULL);
296/* set event handler that notifies of upgrades */ 296/* set event handler that notifies of upgrades */