aboutsummaryrefslogtreecommitdiffstats
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-27 16:14:52 -0300
commit3bab78beed4c769a8b3c198c88e52389da2806cb (patch)
treecf5e6c6dea1318773fb7a35f586fe763c0c462ac
parentecore_ipc_client_example: win32 doesn't provide getline(). (diff)
downloadefl-3bab78beed4c769a8b3c198c88e52389da2806cb.tar.gz
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 781dff62ba..121ddf7d3b 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
_on_stdin(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh EINA_UNUSED)
{
char *line = NULL;
+#ifdef _WIN32
+ char lbuf[4096] = "";
+ ssize_t r;
+ if (fgets(lbuf, sizeof(lbuf), stdin) == NULL)
+ r = -1;
+ else
+ {
+ line = strdup(lbuf);
+ r = strlen(line);
+ }
+#else
size_t len = 0;
ssize_t r = getline(&line, &len, stdin);
+#endif
if (r < 0)
{
@@ -151,13 +163,13 @@ _data(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Data
"%.*s\n"
">>>>>\n",
ev->size,
- ev->size, ev->data);
+ ev->size, (const char *)ev->data);
return ECORE_CALLBACK_RENEW;
}
Eina_Bool
-_write(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Write *ev)
+_write_(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Server_Write *ev)
{
printf("Sent %d bytes to server\n", ev->size);
return ECORE_CALLBACK_RENEW;
@@ -323,7 +335,7 @@ main(int argc, char *argv[])
/* set event handler for receiving server data */
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_data, NULL);
/* set event handler that notifies of sent data */
- ecore_event_handler_add(ECORE_CON_EVENT_SERVER_WRITE, (Ecore_Event_Handler_Cb)_write, NULL);
+ ecore_event_handler_add(ECORE_CON_EVENT_SERVER_WRITE, (Ecore_Event_Handler_Cb)_write_, NULL);
/* set event handler that notifies of errors */
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ERROR, (Ecore_Event_Handler_Cb)_error, NULL);
/* 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 fed7c9c29e..a9c650008f 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)
Eina_Bool
-_write(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+_write_(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Con_Event_Client_Write *ev = event;
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)
/* set event handler for receiving client data */
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL);
/* set event handler that notifies of sent data */
- ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_WRITE, (Ecore_Event_Handler_Cb)_write, NULL);
+ ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_WRITE, (Ecore_Event_Handler_Cb)_write_, NULL);
/* set event handler that notifies of errors */
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ERROR, (Ecore_Event_Handler_Cb)_error, NULL);
/* set event handler that notifies of upgrades */