summaryrefslogtreecommitdiff
path: root/src/examples/ecore
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2018-01-10 10:53:19 -0800
committerCedric Bail <cedric@osg.samsung.com>2018-01-10 18:16:25 -0800
commit1b10ef1313310fff4115bb245637e1e87a08bd6e (patch)
treec87c4e8ad47cafec1f0054f36c643ea231d2e8e1 /src/examples/ecore
parentdacf3293a9a795b7adbfb251e91221d49a49bb12 (diff)
ecore: remove use of efl_main_loop_get from efl_net_server_example.
Diffstat (limited to 'src/examples/ecore')
-rw-r--r--src/examples/ecore/efl_net_server_example.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/src/examples/ecore/efl_net_server_example.c b/src/examples/ecore/efl_net_server_example.c
index 570123eb46..df6e210add 100644
--- a/src/examples/ecore/efl_net_server_example.c
+++ b/src/examples/ecore/efl_net_server_example.c
@@ -1,11 +1,7 @@
1#define EFL_BETA_API_SUPPORT 1 1#include <Efl_Net.h>
2#define EFL_EO_API_SUPPORT 1
3#include <Ecore.h>
4#include <Ecore_Con.h>
5#include <Ecore_Getopt.h> 2#include <Ecore_Getopt.h>
6#include <fcntl.h> 3#include <fcntl.h>
7 4
8static int retval = EXIT_SUCCESS;
9static Eina_Bool echo = EINA_FALSE; 5static Eina_Bool echo = EINA_FALSE;
10static double timeout = 10.0; 6static double timeout = 10.0;
11 7
@@ -77,7 +73,7 @@ _echo_copier_error(void *data EINA_UNUSED, const Efl_Event *event)
77 return; 73 return;
78 } 74 }
79 75
80 retval = EXIT_FAILURE; 76 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
81 77
82 fprintf(stderr, "ERROR: echo copier %p failed %d '%s', close and del.\n", 78 fprintf(stderr, "ERROR: echo copier %p failed %d '%s', close and del.\n",
83 copier, *perr, eina_error_msg_get(*perr)); 79 copier, *perr, eina_error_msg_get(*perr));
@@ -182,7 +178,7 @@ _send_copier_error(void *data, const Efl_Event *event)
182 return; 178 return;
183 } 179 }
184 180
185 retval = EXIT_FAILURE; 181 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
186 182
187 offset = efl_io_buffer_position_read_get(buffer); 183 offset = efl_io_buffer_position_read_get(buffer);
188 slice = efl_io_buffer_slice_get(buffer); 184 slice = efl_io_buffer_slice_get(buffer);
@@ -263,7 +259,7 @@ _recv_copier_error(void *data, const Efl_Event *event)
263 return; 259 return;
264 } 260 }
265 261
266 retval = EXIT_FAILURE; 262 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
267 263
268 slice = efl_io_buffer_slice_get(buffer); 264 slice = efl_io_buffer_slice_get(buffer);
269 fprintf(stderr, 265 fprintf(stderr,
@@ -410,8 +406,7 @@ _server_error(void *data EINA_UNUSED, const Efl_Event *event)
410{ 406{
411 const Eina_Error *perr = event->info; 407 const Eina_Error *perr = event->info;
412 fprintf(stderr, "ERROR: %d '%s'\n", *perr, eina_error_msg_get(*perr)); 408 fprintf(stderr, "ERROR: %d '%s'\n", *perr, eina_error_msg_get(*perr));
413 retval = EXIT_FAILURE; 409 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
414 ecore_main_loop_quit();
415} 410}
416 411
417static void 412static void
@@ -536,8 +531,39 @@ static const Ecore_Getopt options = {
536 } 531 }
537}; 532};
538 533
539int 534static Eo *server = NULL;
540main(int argc, char **argv) 535
536EAPI_MAIN void
537efl_pause(void *data EINA_UNUSED,
538 const Efl_Event *ev EINA_UNUSED)
539{
540}
541
542EAPI_MAIN void
543efl_resume(void *data EINA_UNUSED,
544 const Efl_Event *ev EINA_UNUSED)
545{
546}
547
548EAPI_MAIN void
549efl_terminate(void *data EINA_UNUSED,
550 const Efl_Event *ev EINA_UNUSED)
551{
552 /* FIXME: For the moment the main loop doesn't get
553 properly destroyed on shutdown which disallow
554 relying on parent destroying their children */
555 if (server)
556 {
557 efl_del(server);
558 server = NULL;
559 }
560
561 fprintf(stderr, "INFO: main loop finished.\n");
562}
563
564EAPI_MAIN void
565efl_main(void *data EINA_UNUSED,
566 const Efl_Event *ev)
541{ 567{
542 const Efl_Class *cls; 568 const Efl_Class *cls;
543 char *protocol = NULL; 569 char *protocol = NULL;
@@ -591,34 +617,27 @@ main(int argc, char **argv)
591 ECORE_GETOPT_VALUE_NONE /* sentinel */ 617 ECORE_GETOPT_VALUE_NONE /* sentinel */
592 }; 618 };
593 int args; 619 int args;
594 Eo *server;
595 Eina_Error err; 620 Eina_Error err;
596 621
597 ecore_init(); 622 args = ecore_getopt_parse(&options, values, 0, NULL);
598 ecore_con_init();
599
600 args = ecore_getopt_parse(&options, values, argc, argv);
601 if (args < 0) 623 if (args < 0)
602 { 624 {
603 fputs("ERROR: Could not parse command line options.\n", stderr); 625 fputs("ERROR: Could not parse command line options.\n", stderr);
604 retval = EXIT_FAILURE;
605 goto end; 626 goto end;
606 } 627 }
607 628
608 if (quit_option) goto end; 629 if (quit_option) goto end;
609 630
610 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 631 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
611 if (args < 0) 632 if (args < 0)
612 { 633 {
613 fputs("ERROR: Could not parse positional arguments.\n", stderr); 634 fputs("ERROR: Could not parse positional arguments.\n", stderr);
614 retval = EXIT_FAILURE;
615 goto end; 635 goto end;
616 } 636 }
617 637
618 if (!protocol) 638 if (!protocol)
619 { 639 {
620 fputs("ERROR: missing protocol.\n", stderr); 640 fputs("ERROR: missing protocol.\n", stderr);
621 retval = EXIT_FAILURE;
622 goto end; 641 goto end;
623 } 642 }
624 643
@@ -637,7 +656,7 @@ main(int argc, char **argv)
637 goto end; 656 goto end;
638 } 657 }
639 658
640 server = efl_add(cls, efl_main_loop_get(), /* it's mandatory to use a main loop provider as the server parent */ 659 server = efl_add(cls, ev->object, /* it's mandatory to use a main loop provider as the server parent */
641 efl_net_server_clients_limit_set(efl_added, 660 efl_net_server_clients_limit_set(efl_added,
642 clients_limit, 661 clients_limit,
643 clients_reject_excess), /* optional */ 662 clients_reject_excess), /* optional */
@@ -733,7 +752,7 @@ main(int argc, char **argv)
733 } 752 }
734 } 753 }
735 754
736 ecore_main_loop_begin(); 755 return ;
737 756
738 end_server: 757 end_server:
739 efl_del(server); 758 efl_del(server);
@@ -742,8 +761,8 @@ main(int argc, char **argv)
742 end: 761 end:
743 EINA_LIST_FREE(udp_mcast_groups, str) 762 EINA_LIST_FREE(udp_mcast_groups, str)
744 free(str); 763 free(str);
745 ecore_con_shutdown();
746 ecore_shutdown();
747 764
748 return retval; 765 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
749} 766}
767
768EFL_MAIN_EX();