\hypertarget{eet-file_8c-example}{}\doxysection{eet-\/file.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile\ with:}}
\DoxyCodeLine{\textcolor{comment}{//\ gcc\ -\/o\ eet-\/file\ eet-\/file.c\ `pkg-\/config\ -\/-\/cflags\ -\/-\/libs\ eet`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eet_8h}{Eet.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{create\_eet\_file(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ buf[1024],\ *ptr;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ size,\ len,\ i;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *some\_strings[]\ =\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \textcolor{stringliteral}{"{}And\ some\ more\ strings"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \textcolor{stringliteral}{"{}spread\ across\ several"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \textcolor{stringliteral}{"{}elements\ of\ an\ array!"{}}}
\DoxyCodeLine{\ \ \ \};}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ some\_data[]\ =}
\DoxyCodeLine{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \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{\ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)x72\(\backslash\)x79\(\backslash\)x2e\(\backslash\)x0a\(\backslash\)x00"{}};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ 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{\ \ \ \textcolor{keywordflow}{if}\ (!ef)\ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ strcpy(buf,\ \textcolor{stringliteral}{"{}Here\ is\ a\ string\ of\ data\ to\ save!"{}});}
\DoxyCodeLine{\ \ \ size\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga682d04715f0e11380c460814c4a9bd21}{eet\_write}}(ef,\ \textcolor{stringliteral}{"{}/key/to\_store/at"{}},\ buf,\ \textcolor{keyword}{sizeof}(buf),\ 1);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!size)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}Error\ writing\ data!\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ len\ =\ strlen(buf);}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}strlen()\ =\ \%d,\ eet\_write()\ =\ \%d\(\backslash\)n"{}},\ len,\ size);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ptr\ =\ buf;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ 3;\ i++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ len\ =\ strlen(some\_strings[i])\ +\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ memcpy(ptr,\ some\_strings[i],\ len);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ ptr\ +=\ len;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga682d04715f0e11380c460814c4a9bd21}{eet\_write}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}},\ buf,\ \textcolor{keyword}{sizeof}(buf),\ 1);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_gaf343f344180955ed898aa86b90ebefda}{eet\_sync}}(ef);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \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{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_gaa8a980d684123dfbaf12e7efefdb57f5}{eet\_delete}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef)\ ==\ \mbox{\hyperlink{group__Eet__Group_ggaa9142d865094701672375485d4a6284da2e3af24c66d0decf7c97fe4e5a7f75d4}{EET\_ERROR\_NONE}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ *ret,\ **list;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ size,\ num,\ i;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!create\_eet\_file())}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ 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{\ \ \ \textcolor{keywordflow}{if}\ (!ef)\ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ list\ =\ \mbox{\hyperlink{group__Eet__File__Group_gaab7f9d6d7460b8ec90039b6d82323aa1}{eet\_list}}(ef,\ \textcolor{stringliteral}{"{}*"{}},\ \&num);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (list)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ num;\ i++)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Key\ stored:\ \%s\(\backslash\)n"{}},\ list[i]);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ free(list);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/key/to\_store/at"{}},\ \&size);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Data\ read\ (\%i\ bytes):\(\backslash\)n\%s\(\backslash\)n"{}},\ size,\ ret);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/several/strings"{}},\ \&size);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}More\ data\ read\ (\%i\ bytes):\(\backslash\)n\%s\(\backslash\)n"{}},\ size,\ ret);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ret\ =\ \mbox{\hyperlink{group__Eet__File__Group_gab525b8d547c3542f6e430eeb6d919558}{eet\_read}}(ef,\ \textcolor{stringliteral}{"{}/some/mysterious/data"{}},\ \&size);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ret)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File}}\ *ef2;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ ef2\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga19dfe0a39087f16b07a82e0fafa09ca2}{eet\_memopen\_read}}(ret,\ size);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ num\ =\ \mbox{\hyperlink{group__Eet__File__Group_ga53bf1cf96267787aa93a99a0fe7ba8f7}{eet\_num\_entries}}(ef2);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Mysterious\ data\ has\ \%d\ entries\(\backslash\)n"{}},\ num);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Mysterious\ data:\(\backslash\)n\%s\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{char}\ *)\mbox{\hyperlink{group__Eet__File__Group_ga250ac882b4530dc8112b0c9517a5b44d}{eet\_read\_direct}}(ef2,\ \textcolor{stringliteral}{"{}/mysterious/data"{}},\ NULL));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef2);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ free(ret);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}}(ef);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}

\end{DoxyCodeInclude}
 