\chapter{Nested data example}
\hypertarget{Example_Eet_Data_Nested}{}\label{Example_Eet_Data_Nested}\index{Nested data example@{Nested data example}}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{00002\ \textcolor{comment}{//\ gcc\ -\/o\ eet-\/data-\/nested\ eet-\/data-\/nested.c\ \`{}pkg-\/config\ -\/-\/cflags\ -\/-\/libs\ eet\ eina`}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eet_8h}{Eet.h}}>}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ <limits.h>}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ <sys/types.h>}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <sys/stat.h>}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#include\ <unistd.h>}}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{comment}{//\ The\ struct\ that\ will\ be\ loaded\ and\ saved.}}
\DoxyCodeLine{00013\ \textcolor{comment}{//\ note\ that\ only\ the\ members\ described\ in\ the\ eet\_data\_descriptor}}
\DoxyCodeLine{00014\ \textcolor{comment}{//\ will\ be\ automatically\ handled.\ The\ other\ members\ will\ have\ their}}
\DoxyCodeLine{00015\ \textcolor{comment}{//\ space\ reserved\ and\ zeroed\ (as\ it\ uses\ calloc()),\ but\ not}}
\DoxyCodeLine{00016\ \textcolor{comment}{//\ saved\ or\ loaded\ from\ eet\ files.}}
\DoxyCodeLine{00017\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00018\ \{}
\DoxyCodeLine{00019\ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ version;\ \textcolor{comment}{//\ it\ is\ recommended\ to\ use\ versioned\ configuration!}}
\DoxyCodeLine{00020\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ *name;}
\DoxyCodeLine{00021\ \ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ id;}
\DoxyCodeLine{00022\ \ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ not\_saved\_value;\ \textcolor{comment}{//\ example\ of\ not\ saved\ data\ inside!}}
\DoxyCodeLine{00023\ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ enabled;}
\DoxyCodeLine{00024\ \ \ \ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ \ \ *subs;}
\DoxyCodeLine{00025\ \}\ My\_Conf\_Type;}
\DoxyCodeLine{00026\ }
\DoxyCodeLine{00027\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00028\ \{}
\DoxyCodeLine{00029\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *server;}
\DoxyCodeLine{00030\ \ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ port;}
\DoxyCodeLine{00031\ \}\ My\_Conf\_Subtype;}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \textcolor{comment}{//\ string\ that\ represents\ the\ entry\ in\ eet\ file,\ you\ might\ like\ to\ have}}
\DoxyCodeLine{00034\ \textcolor{comment}{//\ different\ profiles\ or\ so\ in\ the\ same\ file,\ this\ is\ possible\ with}}
\DoxyCodeLine{00035\ \textcolor{comment}{//\ different\ strings}}
\DoxyCodeLine{00036\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ MY\_CONF\_FILE\_ENTRY[]\ =\ \textcolor{stringliteral}{"{}config"{}};}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{comment}{//\ keep\ the\ descriptor\ static\ global,\ so\ it\ can\ be}}
\DoxyCodeLine{00039\ \textcolor{comment}{//\ shared\ by\ different\ functions\ (load/save)\ of\ this\ and\ only\ this}}
\DoxyCodeLine{00040\ \textcolor{comment}{//\ file.}}
\DoxyCodeLine{00041\ \textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_descriptor;}
\DoxyCodeLine{00042\ \textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_sub\_descriptor;}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00045\ \_my\_conf\_descriptor\_init(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00046\ \{}
\DoxyCodeLine{00047\ \ \ \ \mbox{\hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class}}\ eddc;}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \ \ \ \textcolor{comment}{//\ The\ class\ describe\ the\ functions\ to\ use\ to\ create\ the\ type\ and\ its}}
\DoxyCodeLine{00050\ \ \ \ \textcolor{comment}{//\ full\ allocated\ size.}}
\DoxyCodeLine{00051\ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00052\ \ \ \ \textcolor{comment}{//\ Eina\ types\ are\ very\ convenient,\ so\ use\ them\ to\ create\ the\ descriptor,}}
\DoxyCodeLine{00053\ \ \ \ \textcolor{comment}{//\ so\ we\ get\ eina\_list,\ \ eina\_hash\ and\ eina\_stringshare\ automatically!}}
\DoxyCodeLine{00054\ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00055\ \ \ \ \textcolor{comment}{//\ The\ STREAM\ variant\ is\ better\ for\ configuration\ files\ as\ the\ values}}
\DoxyCodeLine{00056\ \ \ \ \textcolor{comment}{//\ will\ likely\ change\ a\ lot.}}
\DoxyCodeLine{00057\ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00058\ \ \ \ \textcolor{comment}{//\ The\ other\ variant,\ FILE,\ is\ good\ for\ caches\ and\ things\ that\ are\ just}}
\DoxyCodeLine{00059\ \ \ \ \textcolor{comment}{//\ appended,\ but\ needs\ to\ take\ care\ when\ changing\ strings\ and\ files\ must}}
\DoxyCodeLine{00060\ \ \ \ \textcolor{comment}{//\ be\ kept\ open\ so\ mmap()ed\ strings\ will\ be\ kept\ alive.}}
\DoxyCodeLine{00061\ \ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Type);}
\DoxyCodeLine{00062\ \ \ \ \_my\_conf\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Subtype);}
\DoxyCodeLine{00065\ \ \ \ \_my\_conf\_sub\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00067\ \ \ \ \textcolor{comment}{//\ Describe\ the\ members\ to\ be\ saved:}}
\DoxyCodeLine{00068\ \ \ \ \textcolor{comment}{//\ Use\ a\ temporary\ macro\ so\ we\ don't\ type\ a\ lot,\ also\ avoid\ errors:}}
\DoxyCodeLine{00069\ \textcolor{preprocessor}{\#define\ MY\_CONF\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{00070\ \textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00071\ \textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\#define\ MY\_CONF\_SUB\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_sub\_descriptor,\ My\_Conf\_Subtype,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{00075\ }
\DoxyCodeLine{00076\ \ \ \ MY\_CONF\_SUB\_ADD\_BASIC(server,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{00077\ \ \ \ MY\_CONF\_SUB\_ADD\_BASIC(port,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ \ \ \ MY\_CONF\_ADD\_BASIC(version,\ \mbox{\hyperlink{group__Eet__Data__Group_gacf6a3c9f06e10e20be5b02cd8c6a220b}{EET\_T\_UINT}});}
\DoxyCodeLine{00080\ \ \ \ MY\_CONF\_ADD\_BASIC(name,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{00081\ \ \ \ MY\_CONF\_ADD\_BASIC(\textcolor{keywordtype}{id},\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{00082\ \ \ \ MY\_CONF\_ADD\_BASIC(enabled,\ \mbox{\hyperlink{group__Eet__Data__Group_ga09a1341cc158fda0ba60ad2386ecd795}{EET\_T\_UCHAR}});}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \ \ \ \textcolor{comment}{//\ And\ add\ the\ sub\ descriptor\ as\ a\ linked\ list\ at\ 'subs'\ in\ the\ main\ struct}}
\DoxyCodeLine{00085\ \ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}}}
\DoxyCodeLine{00086\ \ \ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \textcolor{stringliteral}{"{}subs"{}},\ subs,\ \_my\_conf\_sub\_descriptor);}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00088\ \textcolor{preprocessor}{\#undef\ MY\_CONF\_ADD\_BASIC}}
\DoxyCodeLine{00089\ \textcolor{preprocessor}{\#undef\ MY\_CONF\_SUB\_ADD\_BASIC}}
\DoxyCodeLine{00090\ \}\ \textcolor{comment}{/*\ \_my\_conf\_descriptor\_init\ */}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00093\ \_my\_conf\_descriptor\_shutdown(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}}(\_my\_conf\_sub\_descriptor);}
\DoxyCodeLine{00096\ \ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}}(\_my\_conf\_descriptor);}
\DoxyCodeLine{00097\ \}\ \textcolor{comment}{/*\ \_my\_conf\_descriptor\_shutdown\ */}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \textcolor{keyword}{static}\ My\_Conf\_Type\ *}
\DoxyCodeLine{00100\ \_my\_conf\_new(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00101\ \{}
\DoxyCodeLine{00102\ \ \ \ My\_Conf\_Type\ *my\_conf\ =\ calloc(1,\ \textcolor{keyword}{sizeof}(My\_Conf\_Type));}
\DoxyCodeLine{00103\ \ \ \ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{00104\ \ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{00105\ \ \ \ \ \ \{}
\DoxyCodeLine{00106\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ calloc\ My\_Conf\_Type\(\backslash\)n"{}});}
\DoxyCodeLine{00107\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00108\ \ \ \ \ \ \}}
\DoxyCodeLine{00109\ }
\DoxyCodeLine{00110\ \ \ \ my\_conf-\/>version\ =\ 0x112233;}
\DoxyCodeLine{00111\ \ \ \ my\_conf-\/>enabled\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{00112\ }
\DoxyCodeLine{00113\ \ \ \ sub\ =\ calloc(1,\ \textcolor{keyword}{sizeof}(My\_Conf\_Subtype));}
\DoxyCodeLine{00114\ \ \ \ \textcolor{keywordflow}{if}\ (sub)}
\DoxyCodeLine{00115\ \ \ \ \ \ \{}
\DoxyCodeLine{00116\ \ \ \ \ \ \ \ \ sub-\/>server\ =\ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga4e3ce40744291c1fb8574e26883c0bf2}{eina\_stringshare\_add}}(\textcolor{stringliteral}{"{}my-\/server.com"{}});}
\DoxyCodeLine{00117\ \ \ \ \ \ \ \ \ sub-\/>port\ =\ 1234;}
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ my\_conf-\/>subs\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\_list\_append}}(my\_conf-\/>subs,\ sub);}
\DoxyCodeLine{00119\ \ \ \ \ \ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00121\ \ \ \ \textcolor{keywordflow}{return}\ my\_conf;}
\DoxyCodeLine{00122\ \}\ \textcolor{comment}{/*\ \_my\_conf\_new\ */}}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00125\ \_my\_conf\_free(My\_Conf\_Type\ *my\_conf)}
\DoxyCodeLine{00126\ \{}
\DoxyCodeLine{00127\ \ \ \ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{00128\ \ \ \ \mbox{\hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}}(my\_conf-\/>subs,\ sub)}
\DoxyCodeLine{00129\ \ \ \ \ \ \{}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga5538b4a134987b8a01744fad1a845ba4}{eina\_stringshare\_del}}(sub-\/>server);}
\DoxyCodeLine{00131\ \ \ \ \ \ \ \ \ free(sub);}
\DoxyCodeLine{00132\ \ \ \ \ \ \}}
\DoxyCodeLine{00133\ }
\DoxyCodeLine{00134\ \ \ \ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga5538b4a134987b8a01744fad1a845ba4}{eina\_stringshare\_del}}(my\_conf-\/>name);}
\DoxyCodeLine{00135\ \ \ \ free(my\_conf);}
\DoxyCodeLine{00136\ \}\ \textcolor{comment}{/*\ \_my\_conf\_free\ */}}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00138\ \textcolor{keyword}{static}\ My\_Conf\_Type\ *}
\DoxyCodeLine{00139\ \_my\_conf\_load(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename)}
\DoxyCodeLine{00140\ \{}
\DoxyCodeLine{00141\ \ \ \ My\_Conf\_Type\ *my\_conf;}
\DoxyCodeLine{00142\ \ \ \ \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{00143\ \ \ \ \textcolor{keywordflow}{if}\ (!ef)}
\DoxyCodeLine{00144\ \ \ \ \ \ \{}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ open\ '\%s'\ for\ read\(\backslash\)n"{}},\ filename);}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ NULL;}
\DoxyCodeLine{00147\ \ \ \ \ \ \}}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00149\ \ \ \ my\_conf\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga4c09f4dfb051baabc0c0551ea98b6830}{eet\_data\_read}}(ef,\ \_my\_conf\_descriptor,\ MY\_CONF\_FILE\_ENTRY);}
\DoxyCodeLine{00150\ \ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{00151\ \ \ \ \ \ \textcolor{keywordflow}{goto}\ end;}
\DoxyCodeLine{00152\ }
\DoxyCodeLine{00153\ \ \ \ \textcolor{keywordflow}{if}\ (my\_conf-\/>version\ <\ 0x112233)}
\DoxyCodeLine{00154\ \ \ \ \ \ \{}
\DoxyCodeLine{00155\ \ \ \ \ \ \ \ \ fprintf(stderr,}
\DoxyCodeLine{00156\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}WARNING:\ version\ \%\#x\ was\ too\ old,\ upgrading\ it\ to\ \%\#x\(\backslash\)n"{}},}
\DoxyCodeLine{00157\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>version,\ 0x112233);}
\DoxyCodeLine{00158\ }
\DoxyCodeLine{00159\ \ \ \ \ \ \ \ \ my\_conf-\/>version\ =\ 0x112233;}
\DoxyCodeLine{00160\ \ \ \ \ \ \ \ \ my\_conf-\/>enabled\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{00161\ \ \ \ \ \ \}}
\DoxyCodeLine{00162\ }
\DoxyCodeLine{00163\ end:}
\DoxyCodeLine{00164\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{00165\ \ \ \ \textcolor{keywordflow}{return}\ my\_conf;}
\DoxyCodeLine{00166\ \}\ \textcolor{comment}{/*\ \_my\_conf\_load\ */}}
\DoxyCodeLine{00167\ }
\DoxyCodeLine{00168\ \textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{00169\ \_my\_conf\_save(\textcolor{keyword}{const}\ My\_Conf\_Type\ *my\_conf,}
\DoxyCodeLine{00170\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ \ \ \ \ \ \ \ *filename)}
\DoxyCodeLine{00171\ \{}
\DoxyCodeLine{00172\ \ \ \ \textcolor{keywordtype}{char}\ tmp[PATH\_MAX];}
\DoxyCodeLine{00173\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{00174\ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ ret;}
\DoxyCodeLine{00175\ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ i,\ len;}
\DoxyCodeLine{00176\ \ \ \ \textcolor{keyword}{struct\ }stat\ st;}
\DoxyCodeLine{00177\ }
\DoxyCodeLine{00178\ \ \ \ len\ =\ \mbox{\hyperlink{group__Eina__String__Group_gae28caa0c42c4e76ae584f22bd3615723}{eina\_strlcpy}}(tmp,\ filename,\ \textcolor{keyword}{sizeof}(tmp));}
\DoxyCodeLine{00179\ \ \ \ \textcolor{keywordflow}{if}\ (len\ +\ 12\ >=\ (\textcolor{keywordtype}{int})\textcolor{keyword}{sizeof}(tmp))}
\DoxyCodeLine{00180\ \ \ \ \ \ \{}
\DoxyCodeLine{00181\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ file\ name\ is\ too\ big:\ \%s\(\backslash\)n"{}},\ filename);}
\DoxyCodeLine{00182\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{00183\ \ \ \ \ \ \}}
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00185\ \ \ \ i\ =\ 0;}
\DoxyCodeLine{00186\ \ \ \ \textcolor{keywordflow}{do}}
\DoxyCodeLine{00187\ \ \ \ \ \ \{}
\DoxyCodeLine{00188\ \ \ \ \ \ \ \ \ snprintf(tmp\ +\ len,\ 12,\ \textcolor{stringliteral}{"{}.\%u"{}},\ i);}
\DoxyCodeLine{00189\ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00190\ \ \ \ \ \ \}}
\DoxyCodeLine{00191\ \ \ \ \textcolor{keywordflow}{while}\ (stat(tmp,\ \&st)\ ==\ 0);}
\DoxyCodeLine{00192\ }
\DoxyCodeLine{00193\ \ \ \ ef\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga675160a758832ee812edf7f64ed30ee6}{eet\_open}}(tmp,\ \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a8f395f56fba48be007c65be51d799ee9}{EET\_FILE\_MODE\_WRITE}});}
\DoxyCodeLine{00194\ \ \ \ \textcolor{keywordflow}{if}\ (!ef)}
\DoxyCodeLine{00195\ \ \ \ \ \ \{}
\DoxyCodeLine{00196\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ERROR:\ could\ not\ open\ '\%s'\ for\ write\(\backslash\)n"{}},\ tmp);}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{00198\ \ \ \ \ \ \}}
\DoxyCodeLine{00199\ }
\DoxyCodeLine{00200\ \ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__Data__Group_gac66d1c49e3490bc5d803982d833ff8aa}{eet\_data\_write}}}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ (ef,\ \_my\_conf\_descriptor,\ MY\_CONF\_FILE\_ENTRY,\ my\_conf,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{00202\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{00203\ }
\DoxyCodeLine{00204\ \ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{00205\ \ \ \ \ \ \{}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ unlink(filename);}
\DoxyCodeLine{00207\ \ \ \ \ \ \ \ \ rename(tmp,\ filename);}
\DoxyCodeLine{00208\ \ \ \ \ \ \}}
\DoxyCodeLine{00209\ }
\DoxyCodeLine{00210\ \ \ \ \textcolor{keywordflow}{return}\ ret;}
\DoxyCodeLine{00211\ \}\ \textcolor{comment}{/*\ \_my\_conf\_save\ */}}
\DoxyCodeLine{00212\ }
\DoxyCodeLine{00213\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00214\ main(\textcolor{keywordtype}{int}\ \ \ argc,}
\DoxyCodeLine{00215\ \ \ \ \ \ \textcolor{keywordtype}{char}\ *argv[])}
\DoxyCodeLine{00216\ \{}
\DoxyCodeLine{00217\ \ \ \ My\_Conf\_Type\ *my\_conf;}
\DoxyCodeLine{00218\ \ \ \ \textcolor{keyword}{const}\ My\_Conf\_Subtype\ *sub;}
\DoxyCodeLine{00219\ \ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ *l;}
\DoxyCodeLine{00220\ \ \ \ \textcolor{keywordtype}{int}\ ret\ =\ 0;}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \ \ \ \textcolor{keywordflow}{if}\ (argc\ !=\ 3)}
\DoxyCodeLine{00223\ \ \ \ \ \ \{}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Usage:\(\backslash\)n\(\backslash\)t\%s\ <input>\ <output>\(\backslash\)n\(\backslash\)n"{}},\ argv[0]);}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00226\ \ \ \ \ \ \}}
\DoxyCodeLine{00227\ }
\DoxyCodeLine{00228\ \ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga81b8137665b8a4d2cb38ca50017d4c74}{eina\_init}}();}
\DoxyCodeLine{00229\ \ \ \ \mbox{\hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}}();}
\DoxyCodeLine{00230\ \ \ \ \_my\_conf\_descriptor\_init();}
\DoxyCodeLine{00231\ }
\DoxyCodeLine{00232\ \ \ \ my\_conf\ =\ \_my\_conf\_load(argv[1]);}
\DoxyCodeLine{00233\ \ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{00234\ \ \ \ \ \ \{}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}creating\ new\ configuration.\(\backslash\)n"{}});}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ my\_conf\ =\ \_my\_conf\_new();}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!my\_conf)}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00239\ \ \ \ \ \ \ \ \ \ \ \ \ \ ret\ =\ -\/2;}
\DoxyCodeLine{00240\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{goto}\ end;}
\DoxyCodeLine{00241\ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00242\ \ \ \ \ \ \}}
\DoxyCodeLine{00243\ }
\DoxyCodeLine{00244\ \ \ \ printf(\textcolor{stringliteral}{"{}My\_Conf\_Type:\(\backslash\)n"{}}}
\DoxyCodeLine{00245\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tversion:\ \%\#x\(\backslash\)n"{}}}
\DoxyCodeLine{00246\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tname...:\ '\%s'\(\backslash\)n"{}}}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tid.....:\ \%d\(\backslash\)n"{}}}
\DoxyCodeLine{00248\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tenabled:\ \%hhu\(\backslash\)n"{}}}
\DoxyCodeLine{00249\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tsubs...:\(\backslash\)n"{}},}
\DoxyCodeLine{00250\ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>version,}
\DoxyCodeLine{00251\ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>name\ ?\ my\_conf-\/>name\ :\ \textcolor{stringliteral}{"{}"{}},}
\DoxyCodeLine{00252\ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>id,}
\DoxyCodeLine{00253\ \ \ \ \ \ \ \ \ \ \ my\_conf-\/>enabled);}
\DoxyCodeLine{00254\ }
\DoxyCodeLine{00255\ \ \ \ \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(my\_conf-\/>subs,\ l,\ sub)}
\DoxyCodeLine{00256\ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)t\(\backslash\)tserver:\ '\%s',\ port:\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00257\ \ \ \ \ \ \ \ \ \ \ \ \ sub-\/>server\ ?\ sub-\/>server\ :\ \textcolor{stringliteral}{"{}"{}},}
\DoxyCodeLine{00258\ \ \ \ \ \ \ \ \ \ \ \ \ sub-\/>port);}
\DoxyCodeLine{00259\ }
\DoxyCodeLine{00260\ \ \ \ \textcolor{keywordflow}{if}\ (!\_my\_conf\_save(my\_conf,\ argv[2]))}
\DoxyCodeLine{00261\ \ \ \ \ \ ret\ =\ -\/3;}
\DoxyCodeLine{00262\ }
\DoxyCodeLine{00263\ \ \ \ \_my\_conf\_free(my\_conf);}
\DoxyCodeLine{00264\ }
\DoxyCodeLine{00265\ end:}
\DoxyCodeLine{00266\ \ \ \ \_my\_conf\_descriptor\_shutdown();}
\DoxyCodeLine{00267\ \ \ \ \mbox{\hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}}();}
\DoxyCodeLine{00268\ \ \ \ \mbox{\hyperlink{group__Eina__Main__Group_ga5bf35513199d5220341437c05696285d}{eina\_shutdown}}();}
\DoxyCodeLine{00269\ }
\DoxyCodeLine{00270\ \ \ \ \textcolor{keywordflow}{return}\ ret;}
\DoxyCodeLine{00271\ \}\ \textcolor{comment}{/*\ main\ */}}
\DoxyCodeLine{00272\ }

\end{DoxyCodeInclude}
 