\hypertarget{eina_error_01_8c-example}{}\doxysection{eina\+\_\+error\+\_\+01.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{//gcc -\/g eina\_error\_01.c -\/o eina\_error\_01 `pkg-\/config -\/-\/cflags -\/-\/libs eina`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <eina\_main.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <eina\_error.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error}} MY\_ERROR\_NEGATIVE;}
\DoxyCodeLine{\mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error}} MY\_ERROR\_NULL;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void} *data\_new()}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}}(0);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}}(MY\_ERROR\_NULL);}
\DoxyCodeLine{   \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int} test(\textcolor{keywordtype}{int} n)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}}(0);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (n < 0)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}}(MY\_ERROR\_NEGATIVE);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 1;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int} main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{void} *data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Main__Group_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\_init}}())}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        printf (\textcolor{stringliteral}{"Error during the initialization of eina\_error module\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   MY\_ERROR\_NEGATIVE = \mbox{\hyperlink{group__Eina__Error__Group_ga004c7ceb7103cd5a698247ae3eb4578a}{eina\_error\_msg\_static\_register}}(\textcolor{stringliteral}{"Negative number"});}
\DoxyCodeLine{   MY\_ERROR\_NULL = \mbox{\hyperlink{group__Eina__Error__Group_ga004c7ceb7103cd5a698247ae3eb4578a}{eina\_error\_msg\_static\_register}}(\textcolor{stringliteral}{"NULL pointer"});}
\DoxyCodeLine{}
\DoxyCodeLine{   data = data\_new();}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!data)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error}} err;}
\DoxyCodeLine{}
\DoxyCodeLine{        err = \mbox{\hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}}();}
\DoxyCodeLine{        \textcolor{keywordflow}{if} (err)}
\DoxyCodeLine{           printf(\textcolor{stringliteral}{"Error during memory allocation: \%s\(\backslash\)n"},}
\DoxyCodeLine{                  \mbox{\hyperlink{group__Eina__Error__Group_ga627fd3d4e0e928c6c0c79e3b9faa48e8}{eina\_error\_msg\_get}}(err));}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!test(0))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error}} err;}
\DoxyCodeLine{}
\DoxyCodeLine{        err = \mbox{\hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}}();}
\DoxyCodeLine{        \textcolor{keywordflow}{if} (err)}
\DoxyCodeLine{           printf(\textcolor{stringliteral}{"Error during test function: \%s\(\backslash\)n"},}
\DoxyCodeLine{                  \mbox{\hyperlink{group__Eina__Error__Group_ga627fd3d4e0e928c6c0c79e3b9faa48e8}{eina\_error\_msg\_get}}(err));}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!test(-\/1))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error}} err;}
\DoxyCodeLine{}
\DoxyCodeLine{        err = \mbox{\hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}}();}
\DoxyCodeLine{        \textcolor{keywordflow}{if} (err)}
\DoxyCodeLine{           printf(\textcolor{stringliteral}{"Error during test function: \%s\(\backslash\)n"},}
\DoxyCodeLine{                  \mbox{\hyperlink{group__Eina__Error__Group_ga627fd3d4e0e928c6c0c79e3b9faa48e8}{eina\_error\_msg\_get}}(err));}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_SUCCESS;}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}
 