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

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -g eina\_error\_01.c -o eina\_error\_01 `pkg-config --cflags --libs eina`}

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

\textcolor{preprocessor}{#include <eina\_main.h>}
\textcolor{preprocessor}{#include <eina\_error.h>}

\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error} MY\_ERROR\_NEGATIVE;
\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error} MY\_ERROR\_NULL;

\textcolor{keywordtype}{void} *data\_new()
\{
   \hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}(0);

   \hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}(MY\_ERROR\_NULL);
   \textcolor{keywordflow}{return} NULL;
\}

\textcolor{keywordtype}{int} test(\textcolor{keywordtype}{int} n)
\{
   \hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}(0);

   \textcolor{keywordflow}{if} (n < 0)
     \{
        \hyperlink{group__Eina__Error__Group_ga80a8249f135460d4e07ebfe3f0a7bad1}{eina\_error\_set}(MY\_ERROR\_NEGATIVE);
        \textcolor{keywordflow}{return} 0;
     \}

   \textcolor{keywordflow}{return} 1;
\}

\textcolor{keywordtype}{int} main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordtype}{void} *data;

   \textcolor{keywordflow}{if} (!\hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\_init}())
     \{
        printf (\textcolor{stringliteral}{"Error during the initialization of eina\_error module\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   MY\_ERROR\_NEGATIVE = \hyperlink{group__Eina__Error__Group_ga004c7ceb7103cd5a698247ae3eb4578a}{eina\_error\_msg\_static\_register}(\textcolor{stringliteral}{"Negative number"});
   MY\_ERROR\_NULL = \hyperlink{group__Eina__Error__Group_ga004c7ceb7103cd5a698247ae3eb4578a}{eina\_error\_msg\_static\_register}(\textcolor{stringliteral}{"NULL pointer"});

   data = data\_new();
   \textcolor{keywordflow}{if} (!data)
     \{
        \hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error} err;

        err = \hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}();
        \textcolor{keywordflow}{if} (err)
           printf(\textcolor{stringliteral}{"Error during memory allocation: %s\(\backslash\)n"},
                  \hyperlink{group__Eina__Error__Group_ga3402bc58a9f854391eb35fa7650edda5}{eina\_error\_msg\_get}(err));
     \}

   \textcolor{keywordflow}{if} (!test(0))
     \{
        \hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error} err;

        err = \hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}();
        \textcolor{keywordflow}{if} (err)
           printf(\textcolor{stringliteral}{"Error during test function: %s\(\backslash\)n"},
                  \hyperlink{group__Eina__Error__Group_ga3402bc58a9f854391eb35fa7650edda5}{eina\_error\_msg\_get}(err));
     \}

   \textcolor{keywordflow}{if} (!test(-1))
     \{
        \hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\_Error} err;

        err = \hyperlink{group__Eina__Error__Group_gae0683831c4f8eebfdcb4f3cf1aef7052}{eina\_error\_get}();
        \textcolor{keywordflow}{if} (err)
           printf(\textcolor{stringliteral}{"Error during test function: %s\(\backslash\)n"},
                  \hyperlink{group__Eina__Error__Group_ga3402bc58a9f854391eb35fa7650edda5}{eina\_error\_msg\_get}(err));
     \}

   \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}();

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