\chapter{Example of the various ways to interface with an Eet File}
\hypertarget{Example_Eet_File}{}\label{Example_Eet_File}\index{Example of the various ways to interface with an Eet File@{Example of the various ways to interface with an Eet File}}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{00002\ \textcolor{comment}{//\ gcc\ -\/o\ eet-\/file\ eet-\/file.c\ \`{}pkg-\/config\ -\/-\/cflags\ -\/-\/libs\ eet`}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eet_8h}{Eet.h}}>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00009\ create\_eet\_file(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00010\ \{}
\DoxyCodeLine{00011\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{00012\ \ \ \ \textcolor{keywordtype}{char}\ buf[1024],\ *ptr;}
\DoxyCodeLine{00013\ \ \ \ \textcolor{keywordtype}{int}\ size,\ len,\ i;}
\DoxyCodeLine{00014\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *some\_strings[]\ =\ \{}
\DoxyCodeLine{00015\ \ \ \ \ \ \ \textcolor{stringliteral}{"{}And\ some\ more\ strings"{}},}
\DoxyCodeLine{00016\ \ \ \ \ \ \ \textcolor{stringliteral}{"{}spread\ across\ several"{}},}
\DoxyCodeLine{00017\ \ \ \ \ \ \ \textcolor{stringliteral}{"{}elements\ of\ an\ array!"{}}}
\DoxyCodeLine{00018\ \ \ \ \};}
\DoxyCodeLine{00019\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ some\_data[]\ =}
\DoxyCodeLine{00020\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x1e\(\backslash\)xe7\(\backslash\)x0f\(\backslash\)x42\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x01\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x35"{}}}
\DoxyCodeLine{00021\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)xa0\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)xa0\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x24\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x11"{}}}
\DoxyCodeLine{00022\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x00\(\backslash\)x2f\(\backslash\)x6d\(\backslash\)x69\(\backslash\)x73\(\backslash\)x74\(\backslash\)x65\(\backslash\)x72\(\backslash\)x69\(\backslash\)x6f\(\backslash\)x75\(\backslash\)x73\(\backslash\)x2f"{}}}
\DoxyCodeLine{00023\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x64\(\backslash\)x61\(\backslash\)x74\(\backslash\)x61\(\backslash\)x00\(\backslash\)x41\(\backslash\)x6e\(\backslash\)x20\(\backslash\)x45\(\backslash\)x45\(\backslash\)x54\(\backslash\)x20\(\backslash\)x69\(\backslash\)x6e\(\backslash\)x73\(\backslash\)x69"{}}}
\DoxyCodeLine{00024\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x64\(\backslash\)x65\(\backslash\)x20\(\backslash\)x6f\(\backslash\)x66\(\backslash\)x20\(\backslash\)x61\(\backslash\)x6e\(\backslash\)x20\(\backslash\)x45\(\backslash\)x45\(\backslash\)x54\(\backslash\)x21\(\backslash\)x0a\(\backslash\)x54\(\backslash\)x68"{}}}
\DoxyCodeLine{00025\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x69\(\backslash\)x73\(\backslash\)x20\(\backslash\)x77\(\backslash\)x61\(\backslash\)x73\(\backslash\)x6e\(\backslash\)x27\(\backslash\)x74\(\backslash\)x20\(\backslash\)x72\(\backslash\)x65\(\backslash\)x61\(\backslash\)x6c\(\backslash\)x6c\(\backslash\)x79"{}}}
\DoxyCodeLine{00026\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x20\(\backslash\)x75\(\backslash\)x73\(\backslash\)x65\(\backslash\)x66\(\backslash\)x75\(\backslash\)x6c\(\backslash\)x20\(\backslash\)x62\(\backslash\)x75\(\backslash\)x74\(\backslash\)x20\(\backslash\)x69\(\backslash\)x74\(\backslash\)x20\(\backslash\)x68"{}}}
\DoxyCodeLine{00027\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x65\(\backslash\)x6c\(\backslash\)x70\(\backslash\)x65\(\backslash\)x64\(\backslash\)x20\(\backslash\)x74\(\backslash\)x6f\(\backslash\)x20\(\backslash\)x73\(\backslash\)x68\(\backslash\)x6f\(\backslash\)x77\(\backslash\)x20\(\backslash\)x68\(\backslash\)x6f"{}}}
\DoxyCodeLine{00028\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x77\(\backslash\)x0a\(\backslash\)x74\(\backslash\)x6f\(\backslash\)x20\(\backslash\)x75\(\backslash\)x73\(\backslash\)x65\(\backslash\)x20\(\backslash\)x65\(\backslash\)x65\(\backslash\)x74\(\backslash\)x5f\(\backslash\)x6d\(\backslash\)x65\(\backslash\)x6d"{}}}
\DoxyCodeLine{00029\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x6f\(\backslash\)x70\(\backslash\)x65\(\backslash\)x6e\(\backslash\)x5f\(\backslash\)x72\(\backslash\)x65\(\backslash\)x61\(\backslash\)x64\(\backslash\)x28\(\backslash\)x29\(\backslash\)x20\(\backslash\)x74\(\backslash\)x6f\(\backslash\)x20\(\backslash\)x6f"{}}}
\DoxyCodeLine{00030\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x70\(\backslash\)x65\(\backslash\)x6e\(\backslash\)x20\(\backslash\)x61\(\backslash\)x6e\(\backslash\)x20\(\backslash\)x65\(\backslash\)x65\(\backslash\)x74\(\backslash\)x20\(\backslash\)x66\(\backslash\)x69\(\backslash\)x6c\(\backslash\)x65\(\backslash\)x20"{}}}
\DoxyCodeLine{00031\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x66\(\backslash\)x72\(\backslash\)x6f\(\backslash\)x6d\(\backslash\)x0a\(\backslash\)x64\(\backslash\)x61\(\backslash\)x74\(\backslash\)x61\(\backslash\)x20\(\backslash\)x61\(\backslash\)x6c\(\backslash\)x72\(\backslash\)x65\(\backslash\)x61\(\backslash\)x64"{}}}
\DoxyCodeLine{00032\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x79\(\backslash\)x20\(\backslash\)x6c\(\backslash\)x6f\(\backslash\)x61\(\backslash\)x64\(\backslash\)x65\(\backslash\)x64\(\backslash\)x20\(\backslash\)x69\(\backslash\)x6e\(\backslash\)x20\(\backslash\)x6d\(\backslash\)x65\(\backslash\)x6d\(\backslash\)x6f"{}}}
\DoxyCodeLine{00033\ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x72\(\backslash\)x79\(\backslash\)x2e\(\backslash\)x0a\(\backslash\)x00"{}};}
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00035\ \ \ \ ef\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga675160a758832ee812edf7f64ed30ee6}{eet\_open}}(\textcolor{stringliteral}{"{}/tmp/my\_file.eet"{}},\ \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a8f395f56fba48be007c65be51d799ee9}{EET\_FILE\_MODE\_WRITE}});}
\DoxyCodeLine{00036\ \ \ \ \textcolor{keywordflow}{if}\ (!ef)\ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \ \ \ strcpy(buf,\ \textcolor{stringliteral}{"{}Here\ is\ a\ string\ of\ data\ to\ save!"{}});}
\DoxyCodeLine{00039\ \ \ \ size\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga682d04715f0e11380c460814c4a9bd21}{eet\_write}}(ef,\ \textcolor{stringliteral}{"{}/key/to\_store/at"{}},\ buf,\ \textcolor{keyword}{sizeof}(buf),\ 1);}
\DoxyCodeLine{00040\ \ \ \ \textcolor{keywordflow}{if}\ (!size)}
\DoxyCodeLine{00041\ \ \ \ \ \ \{}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Error\ writing\ data!\(\backslash\)n"{}});}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00045\ \ \ \ \ \ \}}
\DoxyCodeLine{00046\ \ \ \ len\ =\ strlen(buf);}
\DoxyCodeLine{00047\ \ \ \ printf(\textcolor{stringliteral}{"{}strlen()\ =\ \%d,\ eet\_write()\ =\ \%d\(\backslash\)n"{}},\ len,\ size);}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \ \ \ ptr\ =\ buf;}
\DoxyCodeLine{00050\ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ 3;\ i++)}
\DoxyCodeLine{00051\ \ \ \ \ \ \{}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ len\ =\ strlen(some\_strings[i])\ +\ 1;}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ memcpy(ptr,\ some\_strings[i],\ len);}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ ptr\ +=\ len;}
\DoxyCodeLine{00055\ \ \ \ \ \ \}}
\DoxyCodeLine{00056\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga682d04715f0e11380c460814c4a9bd21}{eet\_write}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}},\ buf,\ \textcolor{keyword}{sizeof}(buf),\ 1);}
\DoxyCodeLine{00057\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_gaf343f344180955ed898aa86b90ebefda}{eet\_sync}}(ef);}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga682d04715f0e11380c460814c4a9bd21}{eet\_write}}(ef,\ \textcolor{stringliteral}{"{}/some/mysterious/data"{}},\ some\_data,\ \textcolor{keyword}{sizeof}(some\_data)\ -\/\ 1,\ 1);}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_gaa8a980d684123dfbaf12e7efefdb57f5}{eet\_delete}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}});}
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00063\ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef)\ ==\ \mbox{\hyperlink{group__Eet__Group_ggaa9142d865094701672375485d4a6284da2e3af24c66d0decf7c97fe4e5a7f75d4}{EET\_ERROR\_NONE}};}
\DoxyCodeLine{00064\ \}}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00067\ main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{00068\ \{}
\DoxyCodeLine{00069\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{00070\ \ \ \ \textcolor{keywordtype}{char}\ *ret,\ **list;}
\DoxyCodeLine{00071\ \ \ \ \textcolor{keywordtype}{int}\ size,\ num,\ i;}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \ \ \ \mbox{\hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}}();}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \ \ \ \textcolor{keywordflow}{if}\ (!create\_eet\_file())}
\DoxyCodeLine{00076\ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00078\ \ \ \ ef\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga675160a758832ee812edf7f64ed30ee6}{eet\_open}}(\textcolor{stringliteral}{"{}/tmp/my\_file.eet"{}},\ \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a416f7e9a76b8131a44bbeedb13060c81}{EET\_FILE\_MODE\_READ}});}
\DoxyCodeLine{00079\ \ \ \ \textcolor{keywordflow}{if}\ (!ef)\ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00081\ \ \ \ list\ =\ \mbox{\hyperlink{group__Eet__File__Group_gaab7f9d6d7460b8ec90039b6d82323aa1}{eet\_list}}(ef,\ \textcolor{stringliteral}{"{}*"{}},\ \&num);}
\DoxyCodeLine{00082\ \ \ \ \textcolor{keywordflow}{if}\ (list)}
\DoxyCodeLine{00083\ \ \ \ \ \ \{}
\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ num;\ i++)}
\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Key\ stored:\ \%s\(\backslash\)n"{}},\ list[i]);}
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ free(list);}
\DoxyCodeLine{00087\ \ \ \ \ \ \}}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/key/to\_store/at"{}},\ \&size);}
\DoxyCodeLine{00090\ \ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{00091\ \ \ \ \ \ \{}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Data\ read\ (\%i\ bytes):\(\backslash\)n\%s\(\backslash\)n"{}},\ size,\ ret);}
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{00094\ \ \ \ \ \ \}}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}},\ \&size);}
\DoxyCodeLine{00097\ \ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{00098\ \ \ \ \ \ \{}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}More\ data\ read\ (\%i\ bytes):\(\backslash\)n\%s\(\backslash\)n"{}},\ size,\ ret);}
\DoxyCodeLine{00100\ \ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{00101\ \ \ \ \ \ \}}
\DoxyCodeLine{00102\ }
\DoxyCodeLine{00103\ \ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/some/mysterious/data"{}},\ \&size);}
\DoxyCodeLine{00104\ \ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{00105\ \ \ \ \ \ \{}
\DoxyCodeLine{00106\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef2;}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ ef2\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga19dfe0a39087f16b07a82e0fafa09ca2}{eet\_memopen\_read}}(ret,\ size);}
\DoxyCodeLine{00109\ }
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ num\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga53bf1cf96267787aa93a99a0fe7ba8f7}{eet\_num\_entries}}(ef2);}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Mysterious\ data\ has\ \%d\ entries\(\backslash\)n"{}},\ num);}
\DoxyCodeLine{00112\ }
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Mysterious\ data:\(\backslash\)n\%s\(\backslash\)n"{}},}
\DoxyCodeLine{00114\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{char}\ *)\mbox{\hyperlink{group__Eet__File__Group_ga250ac882b4530dc8112b0c9517a5b44d}{eet\_read\_direct}}(ef2,\ \textcolor{stringliteral}{"{}/mysterious/data"{}},\ NULL));}
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef2);}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{00119\ \ \ \ \ \ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00121\ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{00122\ }
\DoxyCodeLine{00123\ \ \ \ \mbox{\hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}}();}
\DoxyCodeLine{00124\ }
\DoxyCodeLine{00125\ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00126\ \}}
\DoxyCodeLine{00127\ }

\end{DoxyCodeInclude}
 