\hypertarget{eina_str_01_8c-example}{}\doxysection{eina\+\_\+str\+\_\+01.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{//gcc -\/Wall -\/o eina\_str\_01 eina\_str\_01.c `pkg-\/config -\/-\/cflags -\/-\/libs eina`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\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{   \textcolor{keywordtype}{char} *names = \textcolor{stringliteral}{"Calvin;Leoben;D'anna;Simon;Doral;Six;Daniel;Sharon"};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *str;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *tmp;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *prologue;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *part1 = \textcolor{stringliteral}{"The Cylons were created by man. They evolved. They rebelled."};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *part2 = \textcolor{stringliteral}{"There are many copies. And they have a plan."};}
\DoxyCodeLine{   \textcolor{keywordtype}{char} **arr;}
\DoxyCodeLine{   \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *time\_arr;}
\DoxyCodeLine{   time\_t curr\_time;}
\DoxyCodeLine{   \textcolor{keyword}{struct }tm *info;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   arr = \mbox{\hyperlink{group__Eina__String__Group_ga9001881b16684398e4e05bc537a8c1b6}{eina\_str\_split}}(names, \textcolor{stringliteral}{";"}, 0);}
\DoxyCodeLine{   \textcolor{keywordflow}{for} (i = 0; arr[i]; i++)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, arr[i]);}
\DoxyCodeLine{}
\DoxyCodeLine{   free(arr[0]);}
\DoxyCodeLine{   free(arr);}
\DoxyCodeLine{   }
\DoxyCodeLine{   str = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 4);}
\DoxyCodeLine{   strcpy(str, \textcolor{stringliteral}{"bsd"});}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__String__Group_ga93d69385f153eba439faf9d5292af85f}{eina\_str\_toupper}}((\textcolor{keywordtype}{char} **)\&str);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, str);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__String__Group_ga1a0b1b2c6f082e19c9918fb2c428c849}{eina\_str\_tolower}}(\&str);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, str);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Eina__String__Group_ga785b13b56a1f7c11086954ce676487b5}{eina\_str\_has\_prefix}}(names, \textcolor{stringliteral}{"Calvin"}))}
\DoxyCodeLine{      printf(\textcolor{stringliteral}{"Starts with 'Calvin'\(\backslash\)n"});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Eina__String__Group_gafe3b6abced87d088ea993456e3d2db82}{eina\_str\_has\_suffix}}(names, \textcolor{stringliteral}{"sharon"}))}
\DoxyCodeLine{      printf(\textcolor{stringliteral}{"Ends with 'sharon'\(\backslash\)n"});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Eina__String__Group_ga567e0b37fa2f30f95450ab5aa355445a}{eina\_str\_has\_extension}}(names, \textcolor{stringliteral}{"sharon"}))}
\DoxyCodeLine{      printf(\textcolor{stringliteral}{"Has extension 'sharon'\(\backslash\)n"});}
\DoxyCodeLine{}
\DoxyCodeLine{   tmp = \mbox{\hyperlink{group__Eina__String__Group_ga96760f2bf2d845b4abec0e95f08271bd}{eina\_str\_escape}}(\textcolor{stringliteral}{"They'll start going ripe on us pretty soon."});}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, tmp);}
\DoxyCodeLine{   free(tmp);}
\DoxyCodeLine{}
\DoxyCodeLine{   prologue = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 106);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__String__Group_ga24948e6a270ad2e574dda5b97012cb41}{eina\_str\_join\_len}}(prologue, 106, \textcolor{charliteral}{' '}, part1, strlen(part1), part2, strlen(part2));}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, prologue);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__String__Group_ga6bda31d2e1b6d2737b7fe1784780cd2f}{eina\_strlcpy}}(str, prologue, 4);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, str);}
\DoxyCodeLine{}
\DoxyCodeLine{   free(prologue);}
\DoxyCodeLine{   free(str);}
\DoxyCodeLine{}
\DoxyCodeLine{   str = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 14);}
\DoxyCodeLine{   sprintf(str, \textcolor{stringliteral}{"\%s"}, \textcolor{stringliteral}{"cylons+"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__String__Group_ga6c9583940f9f6b3c886a19f22f398ff2}{eina\_strlcat}}(str, \textcolor{stringliteral}{"humans"}, 14);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, str);}
\DoxyCodeLine{   free(str);}
\DoxyCodeLine{}
\DoxyCodeLine{   curr\_time = time(NULL);}
\DoxyCodeLine{   info = localtime(\&curr\_time);}
\DoxyCodeLine{   time\_arr = \mbox{\hyperlink{group__Eina__String__Group_gab8945e64c3f6aa59dab85d1437e4b398}{eina\_strftime}}(\textcolor{stringliteral}{"\%d/\%m/\%Y"}, info);}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Today's Date: \%s\(\backslash\)n"}, time\_arr);}
\DoxyCodeLine{   free(time\_arr);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}
 