\hypertarget{ecore_exe_example_child_8c-example}{}\section{ecore\+\_\+exe\+\_\+example\+\_\+child.\+c}
This is a child process used to receive messages and send it back to its father.\+Check the \mbox{\hyperlink{Ecore_exe_simple_example_c}{Full tutorial}}


\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <unistd.h>}
\textcolor{preprocessor}{#include <Ecore.h>}

\textcolor{preprocessor}{#define BUFFER\_SIZE 1024}

\textcolor{preprocessor}{#ifdef \_WIN32}
\textcolor{preprocessor}{#define HANDLER\_TYPE Ecore\_Win32\_Handler}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{#define HANDLER\_TYPE Ecore\_Fd\_Handler}
\textcolor{preprocessor}{#endif}

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
\_fd\_handler\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, HANDLER\_TYPE *fd\_handler 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \textcolor{keyword}{static} \textcolor{keywordtype}{int} numberOfMessages = 0;
   \textcolor{keywordtype}{char} message[BUFFER\_SIZE];

   \textcolor{keywordflow}{if} (!fgets(message, BUFFER\_SIZE, stdin))
     \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};

   numberOfMessages++;

   \textcolor{keywordflow}{if} (numberOfMessages < 3)
     \{
        printf(\textcolor{stringliteral}{"My father sent this message to me:%s\(\backslash\)n"}, message);
        fflush(stdout);
        \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};
     \}
   \textcolor{keywordflow}{else}
     \{
        printf(\textcolor{stringliteral}{"quit\(\backslash\)n"});
        fflush(stdout);
        \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();
        \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga780091d7d49a4bb6cb753f12e1a3b19d}{ECORE\_CALLBACK\_DONE}};
     \}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}())
     \textcolor{keywordflow}{goto} \mbox{\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}};

\textcolor{preprocessor}{#ifdef \_WIN32}
   \textcolor{comment}{/* note that stdin fd's on windows don't work the same}
\textcolor{comment}{    * as on unixes. this uses stdin just as a quick}
\textcolor{comment}{    * example that's simple instead of a more complex}
\textcolor{comment}{    * one, so this won't actually work on windows unless}
\textcolor{comment}{    * you use a fd that comes from somewhere that is}
\textcolor{comment}{    * select()able. */}
   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_gaf1975a3e95a585aa98a367a39dc29074}{ecore\_main\_win32\_handler\_add}}(GetStdHandle(STD\_INPUT\_HANDLE),
                                \_fd\_handler\_cb,
                                NULL);
\textcolor{preprocessor}{#else}
   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga832e68eb7f15912abeadef816bb5d2f5}{ecore\_main\_fd\_handler\_add}}(STDIN\_FILENO,
                             \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ggab5644f471dfa3bd182619601d9b60608a1699f804eccf88e7e169a4a20f1d44e7}{ECORE\_FD\_READ}},
                             \_fd\_handler\_cb,
                             NULL, NULL, NULL);
\textcolor{preprocessor}{#endif}
   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();

   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();

   \textcolor{keywordflow}{return} EXIT\_SUCCESS;

\mbox{\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}}:
   \textcolor{keywordflow}{return} EXIT\_FAILURE;
\}

\end{DoxyCodeInclude}
 