\hypertarget{eet-data-nested_8c-example}{}\doxysection{eet-\/data-\/nested.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{\textcolor{comment}{//\ gcc\ -\/o\ eet-\/data-\/nested\ eet-\/data-\/nested.c\ `pkg-\/config\ -\/-\/cflags\ -\/-\/libs\ eet\ eina`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eet_8h}{Eet.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <limits.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <sys/types.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <sys/stat.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <unistd.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ The\ struct\ that\ will\ be\ loaded\ and\ saved.}}
\DoxyCodeLine{\textcolor{comment}{//\ note\ that\ only\ the\ members\ described\ in\ the\ eet\_data\_descriptor}}
\DoxyCodeLine{\textcolor{comment}{//\ will\ be\ automatically\ handled.\ The\ other\ members\ will\ have\ their}}
\DoxyCodeLine{\textcolor{comment}{//\ space\ reserved\ and\ zeroed\ (as\ it\ uses\ calloc()),\ but\ not}}
\DoxyCodeLine{\textcolor{comment}{//\ saved\ or\ loaded\ from\ eet\ files.}}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ version;\ \textcolor{comment}{//\ it\ is\ recommended\ to\ use\ versioned\ configuration!}}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ *name;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ id;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ not\_saved\_value;\ \textcolor{comment}{//\ example\ of\ not\ saved\ data\ inside!}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ enabled;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ \ \ *subs;}
\DoxyCodeLine{\}\ My\_Conf\_Type;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *server;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ port;}
\DoxyCodeLine{\}\ My\_Conf\_Subtype;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ string\ that\ represents\ the\ entry\ in\ eet\ file,\ you\ might\ like\ to\ have}}
\DoxyCodeLine{\textcolor{comment}{//\ different\ profiles\ or\ so\ in\ the\ same\ file,\ this\ is\ possible\ with}}
\DoxyCodeLine{\textcolor{comment}{//\ different\ strings}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ MY\_CONF\_FILE\_ENTRY[]\ =\ \textcolor{stringliteral}{"{}config"{}};}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ keep\ the\ descriptor\ static\ global,\ so\ it\ can\ be}}
\DoxyCodeLine{\textcolor{comment}{//\ shared\ by\ different\ functions\ (load/save)\ of\ this\ and\ only\ this}}
\DoxyCodeLine{\textcolor{comment}{//\ file.}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_descriptor;}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_sub\_descriptor;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_my\_conf\_descriptor\_init(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class}}\ eddc;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ The\ class\ describe\ the\ functions\ to\ use\ to\ create\ the\ type\ and\ its}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ full\ allocated\ size.}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ Eina\ types\ are\ very\ convenient,\ so\ use\ them\ to\ create\ the\ descriptor,}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ so\ we\ get\ eina\_list,\ \ eina\_hash\ and\ eina\_stringshare\ automatically!}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ The\ STREAM\ variant\ is\ better\ for\ configuration\ files\ as\ the\ values}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ will\ likely\ change\ a\ lot.}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ The\ other\ variant,\ FILE,\ is\ good\ for\ caches\ and\ things\ that\ are\ just}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ appended,\ but\ needs\ to\ take\ care\ when\ changing\ strings\ and\ files\ must}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ be\ kept\ open\ so\ mmap()ed\ strings\ will\ be\ kept\ alive.}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Type);}
\DoxyCodeLine{\ \ \ \_my\_conf\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Subtype);}
\DoxyCodeLine{\ \ \ \_my\_conf\_sub\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ Describe\ the\ members\ to\ be\ saved:}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ Use\ a\ temporary\ macro\ so\ we\ don't\ type\ a\ lot,\ also\ avoid\ errors:}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ MY\_CONF\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ MY\_CONF\_SUB\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_sub\_descriptor,\ My\_Conf\_Subtype,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ MY\_CONF\_SUB\_ADD\_BASIC(server,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_SUB\_ADD\_BASIC(port,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(version,\ \mbox{\hyperlink{group__Eet__Data__Group_gacf6a3c9f06e10e20be5b02cd8c6a220b}{EET\_T\_UINT}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(name,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(\textcolor{keywordtype}{id},\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(enabled,\ \mbox{\hyperlink{group__Eet__Data__Group_ga09a1341cc158fda0ba60ad2386ecd795}{EET\_T\_UCHAR}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ And\ add\ the\ sub\ descriptor\ as\ a\ linked\ list\ at\ 'subs'\ in\ the\ main\ struct}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}}}
\DoxyCodeLine{\ \ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \textcolor{stringliteral}{"{}subs"{}},\ subs,\ \_my\_conf\_sub\_descriptor);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#undef\ MY\_CONF\_ADD\_BASIC}}
\DoxyCodeLine{\textcolor{preprocessor}{\#undef\ MY\_CONF\_SUB\_ADD\_BASIC}}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_descriptor\_init\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_my\_conf\_descriptor\_shutdown(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}}(\_my\_conf\_sub\_descriptor);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}}(\_my\_conf\_descriptor);}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_descriptor\_shutdown\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ My\_Conf\_Type\ *}
\DoxyCodeLine{\_my\_conf\_new(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ My\_Conf\_Type\ *my\_conf\ =\ calloc(1,\ \textcolor{keyword}{sizeof}(My\_Conf\_Type));}
\DoxyCodeLine{\ \ \ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ calloc\ My\_Conf\_Type\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ my\_conf-\/>version\ =\ 0x112233;}
\DoxyCodeLine{\ \ \ my\_conf-\/>enabled\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ sub\ =\ calloc(1,\ \textcolor{keyword}{sizeof}(My\_Conf\_Subtype));}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (sub)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ sub-\/>server\ =\ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga4e3ce40744291c1fb8574e26883c0bf2}{eina\_stringshare\_add}}(\textcolor{stringliteral}{"{}my-\/server.com"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ sub-\/>port\ =\ 1234;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ my\_conf-\/>subs\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\_list\_append}}(my\_conf-\/>subs,\ sub);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ my\_conf;}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_new\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_my\_conf\_free(My\_Conf\_Type\ *my\_conf)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}}(my\_conf-\/>subs,\ sub)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga5538b4a134987b8a01744fad1a845ba4}{eina\_stringshare\_del}}(sub-\/>server);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ free(sub);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga5538b4a134987b8a01744fad1a845ba4}{eina\_stringshare\_del}}(my\_conf-\/>name);}
\DoxyCodeLine{\ \ \ free(my\_conf);}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_free\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ My\_Conf\_Type\ *}
\DoxyCodeLine{\_my\_conf\_load(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ My\_Conf\_Type\ *my\_conf;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga675160a758832ee812edf7f64ed30ee6}{eet\_open}}(filename,\ \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a416f7e9a76b8131a44bbeedb13060c81}{EET\_FILE\_MODE\_READ}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!ef)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ open\ '\%s'\ for\ read\(\backslash\)n"{}},\ filename);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ my\_conf\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga4c09f4dfb051baabc0c0551ea98b6830}{eet\_data\_read}}(ef,\ \_my\_conf\_descriptor,\ MY\_CONF\_FILE\_ENTRY);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{goto}\ end;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (my\_conf-\/>version\ <\ 0x112233)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}WARNING:\ version\ \%\#x\ was\ too\ old,\ upgrading\ it\ to\ \%\#x\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>version,\ 0x112233);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ my\_conf-\/>version\ =\ 0x112233;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ my\_conf-\/>enabled\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{end:}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ my\_conf;}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_load\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_my\_conf\_save(\textcolor{keyword}{const}\ My\_Conf\_Type\ *my\_conf,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ \ \ \ \ \ \ \ *filename)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ tmp[PATH\_MAX];}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ ret;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ i,\ len;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }stat\ st;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ len\ =\ \mbox{\hyperlink{group__Eina__String__Group_gae28caa0c42c4e76ae584f22bd3615723}{eina\_strlcpy}}(tmp,\ filename,\ \textcolor{keyword}{sizeof}(tmp));}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (len\ +\ 12\ >=\ (\textcolor{keywordtype}{int})\textcolor{keyword}{sizeof}(tmp))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ file\ name\ is\ too\ big:\ \%s\(\backslash\)n"{}},\ filename);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ i\ =\ 0;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{do}}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ snprintf(tmp\ +\ len,\ 12,\ \textcolor{stringliteral}{"{}.\%u"{}},\ i);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{while}\ (stat(tmp,\ \&st)\ ==\ 0);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ef\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga675160a758832ee812edf7f64ed30ee6}{eet\_open}}(tmp,\ \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a8f395f56fba48be007c65be51d799ee9}{EET\_FILE\_MODE\_WRITE}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!ef)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ open\ '\%s'\ for\ write\(\backslash\)n"{}},\ tmp);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__Data__Group_gac66d1c49e3490bc5d803982d833ff8aa}{eet\_data\_write}}}
\DoxyCodeLine{\ \ \ \ \ \ \ (ef,\ \_my\_conf\_descriptor,\ MY\_CONF\_FILE\_ENTRY,\ my\_conf,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ unlink(filename);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rename(tmp,\ filename);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ ret;}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_save\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int}\ \ \ argc,}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ My\_Conf\_Type\ *my\_conf;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ *l;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ ret\ =\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (argc\ !=\ 3)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Usage:\(\backslash\)n\(\backslash\)t\%s\ <input>\ <output>\(\backslash\)n\(\backslash\)n"{}},\ argv[0]);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga81b8137665b8a4d2cb38ca50017d4c74}{eina\_init}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}}();}
\DoxyCodeLine{\ \ \ \_my\_conf\_descriptor\_init();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ my\_conf\ =\ \_my\_conf\_load(argv[1]);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}creating\ new\ configuration.\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ my\_conf\ =\ \_my\_conf\_new();}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ ret\ =\ -\/2;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ end;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}My\_Conf\_Type:\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tversion:\ \%\#x\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tname...:\ '\%s'\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tid.....:\ \%d\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tenabled:\ \%hhu\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tsubs...:\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ my\_conf-\/>version,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ my\_conf-\/>name\ ?\ my\_conf-\/>name\ :\ \textcolor{stringliteral}{"{}"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ my\_conf-\/>id,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ my\_conf-\/>enabled);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(my\_conf-\/>subs,\ l,\ sub)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)t\(\backslash\)tserver:\ '\%s',\ port:\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ sub-\/>server\ ?\ sub-\/>server\ :\ \textcolor{stringliteral}{"{}"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ sub-\/>port);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\_my\_conf\_save(my\_conf,\ argv[2]))}
\DoxyCodeLine{\ \ \ \ \ ret\ =\ -\/3;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \_my\_conf\_free(my\_conf);}
\DoxyCodeLine{}
\DoxyCodeLine{end:}
\DoxyCodeLine{\ \ \ \_my\_conf\_descriptor\_shutdown();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga5bf35513199d5220341437c05696285d}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ ret;}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ main\ */}}
\DoxyCodeLine{}

\end{DoxyCodeInclude}
 