\hypertarget{ecore_exe_example_child_8c-example}{}\doxysection{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}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <unistd.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define BUFFER\_SIZE 1024}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef \_WIN32}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define HANDLER\_TYPE Ecore\_Win32\_Handler}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define HANDLER\_TYPE Ecore\_Fd\_Handler}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_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}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{static} \textcolor{keywordtype}{int} numberOfMessages = 0;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} message[BUFFER\_SIZE];}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!fgets(message, BUFFER\_SIZE, stdin))}
\DoxyCodeLine{     \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{}
\DoxyCodeLine{   numberOfMessages++;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (numberOfMessages < 3)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"My father sent this message to me:\%s\(\backslash\)n"}, message);}
\DoxyCodeLine{        fflush(stdout);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"quit\(\backslash\)n"});}
\DoxyCodeLine{        fflush(stdout);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{        \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga780091d7d49a4bb6cb753f12e1a3b19d}{ECORE\_CALLBACK\_DONE}};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}())}
\DoxyCodeLine{     \textcolor{keywordflow}{goto} error;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef \_WIN32}}
\DoxyCodeLine{   \textcolor{comment}{/* note that stdin fd's on windows don't work the same}}
\DoxyCodeLine{\textcolor{comment}{    * as on unixes. this uses stdin just as a quick}}
\DoxyCodeLine{\textcolor{comment}{    * example that's simple instead of a more complex}}
\DoxyCodeLine{\textcolor{comment}{    * one, so this won't actually work on windows unless}}
\DoxyCodeLine{\textcolor{comment}{    * you use a fd that comes from somewhere that is}}
\DoxyCodeLine{\textcolor{comment}{    * select()able. */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_gaf1975a3e95a585aa98a367a39dc29074}{ecore\_main\_win32\_handler\_add}}(GetStdHandle(STD\_INPUT\_HANDLE),}
\DoxyCodeLine{                                \_fd\_handler\_cb,}
\DoxyCodeLine{                                NULL);}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga832e68eb7f15912abeadef816bb5d2f5}{ecore\_main\_fd\_handler\_add}}(STDIN\_FILENO,}
\DoxyCodeLine{                             \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ggab5644f471dfa3bd182619601d9b60608a1699f804eccf88e7e169a4a20f1d44e7}{ECORE\_FD\_READ}},}
\DoxyCodeLine{                             \_fd\_handler\_cb,}
\DoxyCodeLine{                             NULL, NULL, NULL);}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_SUCCESS;}
\DoxyCodeLine{}
\DoxyCodeLine{error:}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\end{DoxyCodeInclude}
 