

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

\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}

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
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}})
\{
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keywordtype}{char}*)data);
   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};
\}

\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}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
print\_eina\_container(\mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it)
\{
   \mbox{\hyperlink{group__Eina__Iterator__Group_gad9b7adc8db40a640d03e9bc4a5d52370}{eina\_iterator\_foreach}}(it, print\_one, NULL);
   printf(\textcolor{stringliteral}{"\(\backslash\)n"});
\}

\end{DoxyCodeInclude}


And on to our main function were we declare some variables and initialize eina, nothing too special\+: 
\begin{DoxyCodeInclude}

\textcolor{keywordtype}{int}
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}})
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *strings[] = \{
      \textcolor{stringliteral}{"unintersting string"}, \textcolor{stringliteral}{"husker"}, \textcolor{stringliteral}{"starbuck"}, \textcolor{stringliteral}{"husker"}
   \};
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *more\_strings[] = \{
      \textcolor{stringliteral}{"very unintersting string"},
      \textcolor{stringliteral}{"what do your hear?"},
      \textcolor{stringliteral}{"nothing but the rain"},
      \textcolor{stringliteral}{"then grab your gun and bring the cat in"}
   \};
   \mbox{\hyperlink{struct__Eina__Array}{Eina\_Array}} *array;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *list = NULL;
   \mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short} \textcolor{keywordtype}{int} i;
   \textcolor{keywordtype}{char} *uninteresting;

   \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}

   array = \mbox{\hyperlink{group__Eina__Array__Group_ga4a389204db37b44b31d29f581258ac7d}{eina\_array\_new}}(4);

   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
      \{
        \mbox{\hyperlink{group__Eina__Array__Group_gaf2f4a5907f1826354977adbd63e3379a}{eina\_array\_push}}(array, strings[i]);
        list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, more\_strings[i]);
      \}

\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}

   it = \mbox{\hyperlink{group__Eina__Array__Group_ga3cc5cffcf52a2e8c60a651f8df66fbdf}{eina\_array\_iterator\_new}}(array);
   \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}
     \textcolor{keywordflow}{return} -1;
   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}
   \mbox{\hyperlink{group__Eina__Array__Group_gacd0118606f9e5b42839b91ed0da8b168}{eina\_array\_free}}(\mbox{\hyperlink{group__Eina__Iterator__Group_ga5583ab703b156f74f0c2a74875c95cc2}{eina\_iterator\_container\_get}}(it));
   \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}

   it = \mbox{\hyperlink{group__Eina__List__Group_gabcfb6a861aa7c0db0ee36252ac2a254d}{eina\_list\_iterator\_new}}(list);
   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Iterator__Group_ga83346e93c32dbebc8fd66e4f278140c5}{eina\_iterator\_next}}(it, (\textcolor{keywordtype}{void} **)&uninteresting))
     \textcolor{keywordflow}{return} -1;
   print\_eina\_container(it);
   \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}

   \mbox{\hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}}(list);

   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}
 