

For this example we\textquotesingle{}ll be creating our own custom type of eina value. Eina value can already store struct timeval(man gettimeofday for more information) but it has no type to store struct timezone, so that\textquotesingle{}s what this example will do. \begin{DoxyNote}{Note}
Struct timezone is actually obsolete, so using it in real world programs is probably not a good idea, but this is an example so, bear with us.
\end{DoxyNote}
To create our own custom eina value type we need to define functions to do the following operations on it\+: \begin{DoxyItemize}
\item Setup \item Flush \item Copy \item Compare \item Set \item Get \item Conversion\end{DoxyItemize}
Most of this functions are very simple, so let\textquotesingle{}s look at them, starting with setup which only clear the memory so that we can be certain we won\textquotesingle{}t be using stale data\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{\textcolor{comment}{//gcc\ eina\_value\_03.c\ -\/o\ eina\_value\_03\ `pkg-\/config\ -\/-\/cflags\ -\/-\/libs\ eina`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <sys/time.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_setup(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type,\ \textcolor{keywordtype}{void}\ *mem)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ memset(mem,\ 0,\ type-\/>value\_size);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Now the flush function, which is even simpler, it does nothing, that\textquotesingle{}s because there is nothing we need to do, all the necessary steps are taken by eina value itself\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_flush(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *mem\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Our next function, copy, is a bit more interesting, but not much, it just casts our void pointers to struct timezone pointers and does the copy\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_copy(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *src,\ \textcolor{keywordtype}{void}\ *\ dst)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ *tzsrc\ =\ (\textcolor{keyword}{struct\ }timezone\ *)src;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ *tzdst\ =\ dst;}
\DoxyCodeLine{\ \ \ *tzdst\ =\ *tzsrc;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
\begin{DoxyNote}{Note}
By now you might be wondering why our functions receive void pointers instead of pointers to struct timezone, and this is a good point. The reason for this is that eina value doesn\textquotesingle{}t know anything about our type so it must use a generic void pointer, casting that pointer into a proper value is the job of the implementer of the new type.
\end{DoxyNote}
Next we have the comparison function, which compares the {\ttfamily tz\+\_\+minuteswest} field of struct timezone, we don\textquotesingle{}t compare {\ttfamily tz\+\_\+dsttime} because that field is not used in linux\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{\_tz\_compare(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *a,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *b)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ tza\ =\ *(\textcolor{keyword}{struct\ }timezone*)a;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ tzb\ =\ *(\textcolor{keyword}{struct\ }timezone*)b;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (tza.tz\_minuteswest\ <\ tzb.tz\_minuteswest)}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (tza.tz\_minuteswest\ >\ tzb.tz\_minuteswest)}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Next we have setting, this however requires not one but rather two functions, the reason for this is because to be able to receive arguments of any type eina value uses \href{https://wikipedia.org/wiki/Variadic_functions}{\texttt{ variadic functions}}, so we need a function to get the argument from a va\+\_\+list and another to actually to the setting.

Lets first look at the pset function which sets the received value to a pointer\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_pset(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *mem,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *ptr)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ *(\textcolor{keyword}{struct\ }timezone*)mem\ =\ *(\textcolor{keyword}{struct}\ timezone*)ptr;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Next we have the vset function which get the argument from the va\+\_\+list and passes it to the pset function\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_vset(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type,\ \textcolor{keywordtype}{void}\ *mem,\ va\_list\ args)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{struct\ }timezone\ tz\ =\ va\_arg(args,\ \textcolor{keyword}{struct}\ timezone);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \_tz\_pset(type,\ mem,\ \&tz);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 And now the function to get the value, a very simple copying of the value to the given pointer\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_pget(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *mem,\ \textcolor{keywordtype}{void}\ *ptr)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ memcpy(ptr,\ mem,\ type-\/>value\_size);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 And finally our conversion function, this is our longest and most interesting one. For numeric type we simply assign the value of {\ttfamily tz\+\_\+minuteswest} to the new type and call a set function using it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_tz\_convert\_to(\textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *type\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ *convert,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *type\_mem,\ \textcolor{keywordtype}{void}\ *convert\_mem)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ v\ =\ *(\textcolor{keyword}{struct\ }timezone*)type\_mem;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga798f7b7886e75d016d782c13332c9f7d}{EINA\_VALUE\_TYPE\_UCHAR}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{char}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga50bc262dd61c71bac1024b07c7cb1143}{EINA\_VALUE\_TYPE\_USHORT}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{short}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga2067ec9d7a8b415f78aaa9a0f5f53348}{EINA\_VALUE\_TYPE\_UINT}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_gaba83e2d960a53456d059f1aca2f3d7d1}{EINA\_VALUE\_TYPE\_ULONG}})\ ||\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga4406e1fba3da9b1dcb52e4b175370b78}{EINA\_VALUE\_TYPE\_TIMESTAMP}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{long}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_gac700d404e013551f960489cc49df7849}{EINA\_VALUE\_TYPE\_UINT64}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ uint64\_t\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga0d54e0b952b44b7ac4f2fd573f7839c0}{EINA\_VALUE\_TYPE\_CHAR}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga85845b9a6328ff7bfc202f38fe7cbd4c}{EINA\_VALUE\_TYPE\_SHORT}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{short}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga17974fd9ab773a3efefd591ffde58f77}{EINA\_VALUE\_TYPE\_INT}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_gaf8b9c1de294c0287cf28f514c59204a1}{EINA\_VALUE\_TYPE\_LONG}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{long}\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga127af77aa29eca66320f21145304ba64}{EINA\_VALUE\_TYPE\_INT64}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ int64\_t\ other\_mem\ =\ v.tz\_minuteswest;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_gaa9881efc130366d176e617c8f0f98cf8}{EINA\_VALUE\_TYPE\_FLOAT}})}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&v.tz\_minuteswest);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga959961fb03cd94a84ab469245c543732}{EINA\_VALUE\_TYPE\_DOUBLE}})}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&v.tz\_minuteswest);}

\end{DoxyCodeInclude}
\begin{DoxyNote}{Note}
It would be a good idea to add checks for over and underflow for these types and return \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}} in those cases, we omit this here for brevity.
\end{DoxyNote}
For string types we use {\ttfamily snprintf()} to format our {\ttfamily tz\+\_\+minuteswest} field and put it in a string(again {\ttfamily tz\+\_\+dsttime} is ignored because it\textquotesingle{}s not used)\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga9edaffb2d45ab4d820223289def3e888}{EINA\_VALUE\_TYPE\_STRINGSHARE}}\ ||}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ convert\ ==\ \mbox{\hyperlink{group__Eina__Value__Group_ga916f76c8d5ffd4c3ee3c322a54efd0b7}{EINA\_VALUE\_TYPE\_STRING}})}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *other\_mem;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ buf[64];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}\%d"{}},\ v.tz\_minuteswest);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ other\_mem\ =\ buf;\ \textcolor{comment}{/*\ required\ due\ \&buf\ ==\ buf\ */}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ eina\_value\_type\_pset(convert,\ convert\_mem,\ \&other\_mem);}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 Finally we handle any other types by returning an error in that case\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Now that we have all the functions, we can populate an {\ttfamily Eina\+\_\+\+Value\+\_\+\+Type} to later use it with {\ttfamily \mbox{\hyperlink{group__Eina__Value__Value__Group_gab5c6558b1b8be2ad597d71a765cbf5f6}{eina\+\_\+value\+\_\+setup()}}}\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{struct__Eina__Value__Type}{Eina\_Value\_Type}}\ TZ\_TYPE\ =\ \{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Value__Type__Group_ga16a703617b8fc48e3ee95663db7becb2}{EINA\_VALUE\_TYPE\_VERSION}},}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct\ }timezone),}
\DoxyCodeLine{\ \ \ \textcolor{stringliteral}{"{}struct\ timezone"{}},}
\DoxyCodeLine{\ \ \ \_tz\_setup,}
\DoxyCodeLine{\ \ \ \_tz\_flush,}
\DoxyCodeLine{\ \ \ \_tz\_copy,}
\DoxyCodeLine{\ \ \ \_tz\_compare,}
\DoxyCodeLine{\ \ \ \_tz\_convert\_to,}
\DoxyCodeLine{\ \ \ NULL,\ \textcolor{comment}{//No\ convert\ from}}
\DoxyCodeLine{\ \ \ \_tz\_vset,}
\DoxyCodeLine{\ \ \ \_tz\_pset,}
\DoxyCodeLine{\ \ \ \_tz\_pget}
\DoxyCodeLine{\};}

\end{DoxyCodeInclude}
 We can now finally use our new TZ\+\_\+\+TYPE with eina value, so lets conclude our example by practicing that by setting its value and printing it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\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}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eina__Value}{Eina\_Value}}\ vtv,\ vtz;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timeval\ tv;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }timezone\ tz;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ *s;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga81b8137665b8a4d2cb38ca50017d4c74}{eina\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ eina\_value\_setup(\&vtv,\ \mbox{\hyperlink{group__Eina__Value__Group_ga0dc75915976bd83b0d15f72a5ba34412}{EINA\_VALUE\_TYPE\_TIMEVAL}});}
\DoxyCodeLine{\ \ \ eina\_value\_setup(\&vtz,\ \&TZ\_TYPE);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ gettimeofday(\&tv,\ \&tz);}
\DoxyCodeLine{\ \ \ eina\_value\_set(\&vtv,\ tv);}
\DoxyCodeLine{\ \ \ eina\_value\_set(\&vtz,\ tz);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ s\ =\ \mbox{\hyperlink{group__Eina__Value__Value__Group_ga6d5197504d68bd4a72ff212fdda2b6af}{eina\_value\_to\_string}}(\&vtv);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}time:\ \%s\(\backslash\)n"{}},\ s);}
\DoxyCodeLine{\ \ \ free(s);}
\DoxyCodeLine{\ \ \ s\ =\ \mbox{\hyperlink{group__Eina__Value__Value__Group_ga6d5197504d68bd4a72ff212fdda2b6af}{eina\_value\_to\_string}}(\&vtz);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}timezone:\ \%s\(\backslash\)n"{}},\ s);}
\DoxyCodeLine{\ \ \ free(s);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Value__Value__Group_ga27a121e20a7109d5eae7203fc0f54850}{eina\_value\_free}}(\&vtz);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Value__Value__Group_ga27a121e20a7109d5eae7203fc0f54850}{eina\_value\_free}}(\&vtv);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga5bf35513199d5220341437c05696285d}{eina\_shutdown}}();}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 For the full source code see \mbox{\hyperlink{eina_value_03_c}{eina\+\_\+value\+\_\+03.\+c}}. 