

As always when using eina we need to include it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}

\end{DoxyCodeInclude}


Here we a declare an unimpressive \mbox{\hyperlink{group__Eina__Types__Group_gab115f6c19b6641ab5ba22ed45d9b7aa4}{function}} that prints some data\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{print\_one(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *container \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *data, \textcolor{keywordtype}{void} *fdata \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, (\textcolor{keywordtype}{char}*)data);}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
Returning E\+I\+N\+A\+\_\+\+T\+R\+UE is important so we don\textquotesingle{}t stop iterating over the container.
\end{DoxyNote}
And here\textquotesingle{}s a more interesting function, it uses an iterator to print the contents of a container. What\textquotesingle{}s interesting about it is that it doesn\textquotesingle{}t care the type of container, it works for anything that can provide an iterator\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{print\_eina\_container(\mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Iterator__Group_gad9b7adc8db40a640d03e9bc4a5d52370}{eina\_iterator\_foreach}}(it, print\_one, NULL);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\(\backslash\)n"});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


And on to our main function were we declare some variables and initialize eina, nothing too special\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *strings[] = \{}
\DoxyCodeLine{      \textcolor{stringliteral}{"unintersting string"}, \textcolor{stringliteral}{"husker"}, \textcolor{stringliteral}{"starbuck"}, \textcolor{stringliteral}{"husker"}}
\DoxyCodeLine{   \};}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *more\_strings[] = \{}
\DoxyCodeLine{      \textcolor{stringliteral}{"very unintersting string"},}
\DoxyCodeLine{      \textcolor{stringliteral}{"what do your hear?"},}
\DoxyCodeLine{      \textcolor{stringliteral}{"nothing but the rain"},}
\DoxyCodeLine{      \textcolor{stringliteral}{"then grab your gun and bring the cat in"}}
\DoxyCodeLine{   \};}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__Array}{Eina\_Array}} *array;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *list = NULL;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it;}
\DoxyCodeLine{   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short} \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *uninteresting;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\_init}}();}

\end{DoxyCodeInclude}


Next we populate both an array and a list with our strings, for more details see \mbox{\hyperlink{eina_list_01_example_page}{Adding elements to Eina\+\_\+\+List}} and \mbox{\hyperlink{eina_array_01_example_page}{Basic array usage}} \+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   array = \mbox{\hyperlink{group__Eina__Array__Group_ga4a389204db37b44b31d29f581258ac7d}{eina\_array\_new}}(4);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)}
\DoxyCodeLine{      \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Array__Group_gaf2f4a5907f1826354977adbd63e3379a}{eina\_array\_push}}(array, strings[i]);}
\DoxyCodeLine{        list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, more\_strings[i]);}
\DoxyCodeLine{      \}}

\end{DoxyCodeInclude}


And now we create an array and because the first element of the container doesn\textquotesingle{}t interest us we skip it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   it = \mbox{\hyperlink{group__Eina__Array__Group_ga3cc5cffcf52a2e8c60a651f8df66fbdf}{eina\_array\_iterator\_new}}(array);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Iterator__Group_ga83346e93c32dbebc8fd66e4f278140c5}{eina\_iterator\_next}}(it, (\textcolor{keywordtype}{void} **)\&uninteresting))}

\end{DoxyCodeInclude}


Having our iterator now pointing to interesting data we go ahead and print\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{     \textcolor{keywordflow}{return} -\/1;}
\DoxyCodeLine{   print\_eina\_container(it);}

\end{DoxyCodeInclude}


As always once data with a structure we free it, but just because we can we do it by asking the iterator for it\textquotesingle{}s container, and then of course free the iterator itself\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Array__Group_gacd0118606f9e5b42839b91ed0da8b168}{eina\_array\_free}}(\mbox{\hyperlink{group__Eina__Iterator__Group_ga5583ab703b156f74f0c2a74875c95cc2}{eina\_iterator\_container\_get}}(it));}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);}

\end{DoxyCodeInclude}


But so far you\textquotesingle{}re not impressed in \mbox{\hyperlink{eina_array_01_example_page}{Basic array usage}} an array is also printed, so now we go to the cool stuff and use an iterator to do same stuff to a list\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   it = \mbox{\hyperlink{group__Eina__List__Group_gabcfb6a861aa7c0db0ee36252ac2a254d}{eina\_list\_iterator\_new}}(list);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Iterator__Group_ga83346e93c32dbebc8fd66e4f278140c5}{eina\_iterator\_next}}(it, (\textcolor{keywordtype}{void} **)\&uninteresting))}
\DoxyCodeLine{     \textcolor{keywordflow}{return} -\/1;}
\DoxyCodeLine{   print\_eina\_container(it);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
The only significant difference to the block above is in the function used to create the iterator.
\end{DoxyNote}
And now we free the list and shut eina down\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}}(list);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 