\hypertarget{group__Eina__Magic__Group}{\section{Magic}
\label{group__Eina__Magic__Group}\index{Magic@{Magic}}
}


\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} provides run-\/time type-\/checking.  


\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{group__Eina__Magic__Group_ga087a0d5a1e482da550b33fe4fcb0435f}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E}~0x1234fedc
\begin{DoxyCompactList}\small\item\em Definition of a random value for specifying that a structure using the magic feature has already been freed. \end{DoxyCompactList}\item 
\#define \hyperlink{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C}~\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} \+\_\+\+\_\+magic;
\begin{DoxyCompactList}\small\item\em Definition of of a variable of type \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic}. \end{DoxyCompactList}\item 
\#define \hyperlink{group__Eina__Magic__Group_ga470f5ce28eaaf59ce80523be8471c5e0}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T}(d, m)~(d)-\/$>$\+\_\+\+\_\+magic = (m)
\begin{DoxyCompactList}\small\item\em Definition to set the magic number of {\ttfamily d} to {\ttfamily m}. \end{DoxyCompactList}\item 
\#define \hyperlink{group__Eina__Magic__Group_ga13317919a91b35412b6f40ca1166b373}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K}(d, m)~(\hyperlink{group__Eina__Types__Group_gaa9820797ec4c069e571f57e3c0c12216}{E\+I\+N\+A\+\_\+\+L\+I\+K\+E\+L\+Y}((d) \&\& ((d)-\/$>$\+\_\+\+\_\+magic == (m))))
\begin{DoxyCompactList}\small\item\em Definition to test if {\ttfamily d} is {\ttfamily N\+U\+L\+L} or not, and if not {\ttfamily N\+U\+L\+L}, if {\ttfamily d-\/$>$\+\_\+\+\_\+eina\+\_\+magic} is equal to {\ttfamily m}. \end{DoxyCompactList}\item 
\#define \hyperlink{group__Eina__Magic__Group_gad7411adf9ff7121ad2004046f1b08408}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L}(d, m)
\begin{DoxyCompactList}\small\item\em Definition to call \hyperlink{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{eina\+\_\+magic\+\_\+fail()} with the parameters {\ttfamily d}, {\ttfamily d-\/$>$\+\_\+\+\_\+magic}, {\ttfamily m}, {\bfseries F\+I\+L\+E}, {\bfseries F\+U\+N\+C\+T\+I\+O\+N}, and {\bfseries L\+I\+N\+E}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\hypertarget{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{typedef unsigned int \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic}}\label{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}

\begin{DoxyCompactList}\small\item\em An abstract type for a magic number. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \hyperlink{group__Eina__Magic__Group_gaec80eb137d23153cbdbec0d4c400e399}{eina\+\_\+magic\+\_\+string\+\_\+get} (\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} magic)
\begin{DoxyCompactList}\small\item\em Gets the string associated to the given magic identifier. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Eina__Magic__Group_ga0d77e61edf5b7b6c276a382d6bf191e7}{eina\+\_\+magic\+\_\+string\+\_\+set} (\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} magic, const char $\ast$magic\+\_\+name)
\begin{DoxyCompactList}\small\item\em Sets the string associated to the given magic identifier. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Eina__Magic__Group_ga5d202c69f78f9cb078efd3e798cb5a53}{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set} (\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} magic, const char $\ast$magic\+\_\+name)
\begin{DoxyCompactList}\small\item\em Sets the string associated to the given magic identifier. \end{DoxyCompactList}\item 
void \hyperlink{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{eina\+\_\+magic\+\_\+fail} (void $\ast$d, \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} m, \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} req\+\_\+m, const char $\ast$file, const char $\ast$fnc, int line)
\begin{DoxyCompactList}\small\item\em Displays a message or aborts if a magic check failed. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{group__Eina__Magic__Group_gaab26b6393901fd271b3aa665ef703a3b}{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\+\_\+\+Error} \hyperlink{group__Eina__Magic__Group_gaab26b6393901fd271b3aa665ef703a3b}{E\+I\+N\+A\+\_\+\+E\+R\+R\+O\+R\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L\+E\+D}}\label{group__Eina__Magic__Group_gaab26b6393901fd271b3aa665ef703a3b}

\begin{DoxyCompactList}\small\item\em The error identifier corresponding to the magic check failure. \end{DoxyCompactList}\item 
\hypertarget{group__Eina__Magic__Group_ga995900a133c4fb0a91e3d63afd171f62}{\hyperlink{group__Eina__Error__Group_ga95b3cbb33e987e7d92a81ea785001686}{Eina\+\_\+\+Error} \hyperlink{group__Eina__Magic__Group_ga995900a133c4fb0a91e3d63afd171f62}{E\+I\+N\+A\+\_\+\+E\+R\+R\+O\+R\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L\+E\+D} = 0}\label{group__Eina__Magic__Group_ga995900a133c4fb0a91e3d63afd171f62}

\begin{DoxyCompactList}\small\item\em The error identifier corresponding to the magic check failure. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} provides run-\/time type-\/checking. 

C is a weak statically typed language, in other words, it just checks for types during compile time and any cast that makes the compiler believe the type is correct.

In the real world code, we often need to deal with casts, either explicit or implicit, by means of {\ttfamily void$\ast$}. We also need to resort to casts when doing inheritance in C.

Eina\+\_\+\+Magic gives us a way to do casts and still be certain of the type we are operating on.

\begin{DoxyNote}{Note}
It should be noted that it is considered a good practice to {\bfseries disable} \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} for production code. The reasoning is that any \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic} errors should have been caught during testing and therefore there is no reason to incur the performance downside of \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic}.
\end{DoxyNote}
An \hyperlink{eina_magic_example_01_page}{example} should elucidate matters. 

\subsection{Macro Definition Documentation}
\hypertarget{group__Eina__Magic__Group_ga087a0d5a1e482da550b33fe4fcb0435f}{\index{Magic@{Magic}!E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E}}
\index{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E}!Magic@{Magic}}
\subsubsection[{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E~0x1234fedc}}\label{group__Eina__Magic__Group_ga087a0d5a1e482da550b33fe4fcb0435f}


Definition of a random value for specifying that a structure using the magic feature has already been freed. 

It is used by \hyperlink{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{eina\+\_\+magic\+\_\+fail()}.

\begin{DoxyNote}{Note}
If the magic feature of Eina is disabled, \hyperlink{group__Eina__Magic__Group_ga087a0d5a1e482da550b33fe4fcb0435f}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E} is just {\ttfamily 0}. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{eina_magic_01_8c-example}{eina\+\_\+magic\+\_\+01.\+c}.\end{Desc}


Referenced by eina\+\_\+cow\+\_\+free(), eina\+\_\+magic\+\_\+fail(), eina\+\_\+matrixsparse\+\_\+free(), eina\+\_\+rectangle\+\_\+pool\+\_\+free(), eina\+\_\+rectangle\+\_\+pool\+\_\+release(), eina\+\_\+simple\+\_\+xml\+\_\+attribute\+\_\+free(), and eldbus\+\_\+message\+\_\+unref().

\hypertarget{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{\index{Magic@{Magic}!E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C}}
\index{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C}!Magic@{Magic}}
\subsubsection[{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C~{\bf Eina\+\_\+\+Magic} \+\_\+\+\_\+magic;}}\label{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}


Definition of of a variable of type \hyperlink{group__Eina__Magic__Group_ga979d40af6182a8ec32890ba85df88f1d}{Eina\+\_\+\+Magic}. 

To put in a structure when one wants to use the magic feature of Eina with the functions of that structure, like this\+:


\begin{DoxyCode}
1 struct Foo
2 \{
3    int i;
4 
5    EINA\_MAGIC
6 \};
\end{DoxyCode}


\begin{DoxyNote}{Note}
If the magic feature of Eina is disabled, \hyperlink{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C} does nothing. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{eina_magic_01_8c-example}{eina\+\_\+magic\+\_\+01.\+c}.\end{Desc}
\hypertarget{group__Eina__Magic__Group_ga470f5ce28eaaf59ce80523be8471c5e0}{\index{Magic@{Magic}!E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T}}
\index{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T}!Magic@{Magic}}
\subsubsection[{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+S\+E\+T(
\begin{DoxyParamCaption}
\item[{}]{d, }
\item[{}]{m}
\end{DoxyParamCaption}
)~(d)-\/$>$\+\_\+\+\_\+magic = (m)}}\label{group__Eina__Magic__Group_ga470f5ce28eaaf59ce80523be8471c5e0}


Definition to set the magic number of {\ttfamily d} to {\ttfamily m}. 

{\ttfamily d} must be a valid pointer to a structure holding an Eina magic number declaration. Use \hyperlink{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C} to add such a declaration.

\begin{DoxyNote}{Note}
If the magic feature of Eina is disabled, \hyperlink{group__Eina__Magic__Group_ga13317919a91b35412b6f40ca1166b373}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K} is just the value {\ttfamily 0}. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{eina_magic_01_8c-example}{eina\+\_\+magic\+\_\+01.\+c}.\end{Desc}


Referenced by eet\+\_\+list\+\_\+entries(), eina\+\_\+array\+\_\+accessor\+\_\+new(), eina\+\_\+array\+\_\+iterator\+\_\+new(), eina\+\_\+array\+\_\+new(), eina\+\_\+array\+\_\+step\+\_\+set(), eina\+\_\+cow\+\_\+add(), eina\+\_\+cow\+\_\+free(), eina\+\_\+cow\+\_\+write(), eina\+\_\+file\+\_\+clean\+\_\+close(), eina\+\_\+file\+\_\+direct\+\_\+ls(), eina\+\_\+file\+\_\+ls(), eina\+\_\+file\+\_\+map\+\_\+lines(), eina\+\_\+file\+\_\+open(), eina\+\_\+file\+\_\+stat\+\_\+ls(), eina\+\_\+hash\+\_\+iterator\+\_\+data\+\_\+new(), eina\+\_\+hash\+\_\+iterator\+\_\+key\+\_\+new(), eina\+\_\+hash\+\_\+iterator\+\_\+tuple\+\_\+new(), eina\+\_\+hash\+\_\+new(), eina\+\_\+inarray\+\_\+accessor\+\_\+new(), eina\+\_\+inarray\+\_\+iterator\+\_\+new(), eina\+\_\+inarray\+\_\+iterator\+\_\+reversed\+\_\+new(), eina\+\_\+inlist\+\_\+accessor\+\_\+new(), eina\+\_\+inlist\+\_\+iterator\+\_\+new(), eina\+\_\+list\+\_\+accessor\+\_\+new(), eina\+\_\+list\+\_\+iterator\+\_\+new(), eina\+\_\+list\+\_\+iterator\+\_\+reversed\+\_\+new(), eina\+\_\+matrixsparse\+\_\+free(), eina\+\_\+matrixsparse\+\_\+iterator\+\_\+complete\+\_\+new(), eina\+\_\+matrixsparse\+\_\+iterator\+\_\+new(), eina\+\_\+matrixsparse\+\_\+new(), eina\+\_\+rectangle\+\_\+pool\+\_\+free(), eina\+\_\+rectangle\+\_\+pool\+\_\+new(), eina\+\_\+rectangle\+\_\+pool\+\_\+release(), eina\+\_\+rectangle\+\_\+pool\+\_\+request(), eina\+\_\+simple\+\_\+xml\+\_\+attribute\+\_\+free(), eina\+\_\+simple\+\_\+xml\+\_\+attribute\+\_\+new(), eina\+\_\+simple\+\_\+xml\+\_\+node\+\_\+load(), eina\+\_\+simple\+\_\+xml\+\_\+node\+\_\+tag\+\_\+new(), eina\+\_\+tile\+\_\+grid\+\_\+slicer\+\_\+iterator\+\_\+new(), eina\+\_\+tiler\+\_\+iterator\+\_\+new(), eina\+\_\+tiler\+\_\+new(), eina\+\_\+xattr\+\_\+fd\+\_\+ls(), eina\+\_\+xattr\+\_\+ls(), eina\+\_\+xattr\+\_\+value\+\_\+fd\+\_\+ls(), eina\+\_\+xattr\+\_\+value\+\_\+ls(), eldbus\+\_\+message\+\_\+unref(), eldbus\+\_\+object\+\_\+get(), and eldbus\+\_\+proxy\+\_\+get().

\hypertarget{group__Eina__Magic__Group_ga13317919a91b35412b6f40ca1166b373}{\index{Magic@{Magic}!E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K}}
\index{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K}!Magic@{Magic}}
\subsubsection[{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K(
\begin{DoxyParamCaption}
\item[{}]{d, }
\item[{}]{m}
\end{DoxyParamCaption}
)~({\bf E\+I\+N\+A\+\_\+\+L\+I\+K\+E\+L\+Y}((d) \&\& ((d)-\/$>$\+\_\+\+\_\+magic == (m))))}}\label{group__Eina__Magic__Group_ga13317919a91b35412b6f40ca1166b373}


Definition to test if {\ttfamily d} is {\ttfamily N\+U\+L\+L} or not, and if not {\ttfamily N\+U\+L\+L}, if {\ttfamily d-\/$>$\+\_\+\+\_\+eina\+\_\+magic} is equal to {\ttfamily m}. 

{\ttfamily d} must be a structure that holds an Eina magic number declaration. Use \hyperlink{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C} to add such a declaration.

\begin{DoxyNote}{Note}
If the magic feature of Eina is disabled, \hyperlink{group__Eina__Magic__Group_ga13317919a91b35412b6f40ca1166b373}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+C\+H\+E\+C\+K} is just the value {\ttfamily 1}. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{eina_magic_01_8c-example}{eina\+\_\+magic\+\_\+01.\+c}.\end{Desc}
\hypertarget{group__Eina__Magic__Group_gad7411adf9ff7121ad2004046f1b08408}{\index{Magic@{Magic}!E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L}}
\index{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L@{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L}!Magic@{Magic}}
\subsubsection[{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L(
\begin{DoxyParamCaption}
\item[{}]{d, }
\item[{}]{m}
\end{DoxyParamCaption}
)}}\label{group__Eina__Magic__Group_gad7411adf9ff7121ad2004046f1b08408}
{\bfseries Value\+:}
\begin{DoxyCode}
\hyperlink{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{eina\_magic\_fail}((\textcolor{keywordtype}{void} *)(d),            \(\backslash\)
                  (d) ? (d)->\_\_magic : 0, \(\backslash\)
                  (m),                    \(\backslash\)
                  \_\_FILE\_\_,               \(\backslash\)
                  \_\_FUNCTION\_\_,           \(\backslash\)
                  \_\_LINE\_\_);
\end{DoxyCode}


Definition to call \hyperlink{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{eina\+\_\+magic\+\_\+fail()} with the parameters {\ttfamily d}, {\ttfamily d-\/$>$\+\_\+\+\_\+magic}, {\ttfamily m}, {\bfseries F\+I\+L\+E}, {\bfseries F\+U\+N\+C\+T\+I\+O\+N}, and {\bfseries L\+I\+N\+E}. 

{\ttfamily d} must be a structure that holds an Eina magic number declaration. Use \hyperlink{group__Eina__Magic__Group_ga4085afe8dc73c98ae626cc952c69c668}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C} to add such a declaration.

\begin{DoxyNote}{Note}
If the magic feature of Eina is disabled, \hyperlink{group__Eina__Magic__Group_gad7411adf9ff7121ad2004046f1b08408}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L} does nothing. 
\end{DoxyNote}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{eina_magic_01_8c-example}{eina\+\_\+magic\+\_\+01.\+c}.\end{Desc}


\subsection{Function Documentation}
\hypertarget{group__Eina__Magic__Group_gaec80eb137d23153cbdbec0d4c400e399}{\index{Magic@{Magic}!eina\+\_\+magic\+\_\+string\+\_\+get@{eina\+\_\+magic\+\_\+string\+\_\+get}}
\index{eina\+\_\+magic\+\_\+string\+\_\+get@{eina\+\_\+magic\+\_\+string\+\_\+get}!Magic@{Magic}}
\subsubsection[{eina\+\_\+magic\+\_\+string\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}const char$\ast$ eina\+\_\+magic\+\_\+string\+\_\+get (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Magic}}]{magic}
\end{DoxyParamCaption}
)}}\label{group__Eina__Magic__Group_gaec80eb137d23153cbdbec0d4c400e399}


Gets the string associated to the given magic identifier. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em magic} & The magic identifier \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The string associated to the identifier
\end{DoxyReturn}
This function returns the string associated to {\ttfamily magic}. Even if none are found this function still returns non {\ttfamily N\+U\+L\+L}, in this case an identifier such as \char`\"{}(none)\char`\"{}, \char`\"{}(undefined)\char`\"{}, or \char`\"{}(unknown)\char`\"{}.

\begin{DoxyNote}{Note}
The following identifiers may be returned whenever magic is invalid, with their meanings\+:
\end{DoxyNote}

\begin{DoxyItemize}
\item (none)\+: No magic that had been registered exists at all.
\item (undefined)\+: Magic is registered and found, but no string is associated.
\item (unknown)\+: Magic is not found in the registry.
\end{DoxyItemize}

\begin{DoxyWarning}{Warning}
The returned value must not be freed. 
\end{DoxyWarning}


Referenced by eina\+\_\+magic\+\_\+fail().

\hypertarget{group__Eina__Magic__Group_ga0d77e61edf5b7b6c276a382d6bf191e7}{\index{Magic@{Magic}!eina\+\_\+magic\+\_\+string\+\_\+set@{eina\+\_\+magic\+\_\+string\+\_\+set}}
\index{eina\+\_\+magic\+\_\+string\+\_\+set@{eina\+\_\+magic\+\_\+string\+\_\+set}!Magic@{Magic}}
\subsubsection[{eina\+\_\+magic\+\_\+string\+\_\+set}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} eina\+\_\+magic\+\_\+string\+\_\+set (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Magic}}]{magic, }
\item[{const char $\ast$}]{magic\+\_\+name}
\end{DoxyParamCaption}
)}}\label{group__Eina__Magic__Group_ga0d77e61edf5b7b6c276a382d6bf191e7}


Sets the string associated to the given magic identifier. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em magic} & The magic identifier \\
\hline
\mbox{\tt in}  & {\em magic\+\_\+name} & The string associated to the identifier, must not be {\ttfamily N\+U\+L\+L} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} on success, otherwise \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E} on failure
\end{DoxyReturn}
This function sets the string {\ttfamily magic\+\_\+name} to {\ttfamily magic}. It is not checked if number or string are already set, in which case you end with duplicates. Internally, eina makes a copy of {\ttfamily magic\+\_\+name}.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__Eina__Magic__Group_ga5d202c69f78f9cb078efd3e798cb5a53}{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set()} 
\end{DoxySeeAlso}


References E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E, E\+I\+N\+A\+\_\+\+T\+R\+U\+E, and E\+R\+R.



Referenced by ecore\+\_\+con\+\_\+init(), and eldbus\+\_\+init().

\hypertarget{group__Eina__Magic__Group_ga5d202c69f78f9cb078efd3e798cb5a53}{\index{Magic@{Magic}!eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set@{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set}}
\index{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set@{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set}!Magic@{Magic}}
\subsubsection[{eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} eina\+\_\+magic\+\_\+string\+\_\+static\+\_\+set (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Magic}}]{magic, }
\item[{const char $\ast$}]{magic\+\_\+name}
\end{DoxyParamCaption}
)}}\label{group__Eina__Magic__Group_ga5d202c69f78f9cb078efd3e798cb5a53}


Sets the string associated to the given magic identifier. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em magic} & The magic identifier \\
\hline
\mbox{\tt in}  & {\em magic\+\_\+name} & The string associated to the identifier, must not be {\ttfamily N\+U\+L\+L} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} on success, otherwise \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E} on failure
\end{DoxyReturn}
This function sets the string {\ttfamily magic\+\_\+name} to {\ttfamily magic}. It is not checked if number or string are already set, in which case you might end with duplicates. Eina does {\bfseries not} make a copy of {\ttfamily magic\+\_\+name}, this means that {\ttfamily magic\+\_\+name} has to be a valid pointer for as long as {\ttfamily magic} is used.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__Eina__Magic__Group_ga0d77e61edf5b7b6c276a382d6bf191e7}{eina\+\_\+magic\+\_\+string\+\_\+set()} 
\end{DoxySeeAlso}


References E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E, and E\+I\+N\+A\+\_\+\+T\+R\+U\+E.

\hypertarget{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}{\index{Magic@{Magic}!eina\+\_\+magic\+\_\+fail@{eina\+\_\+magic\+\_\+fail}}
\index{eina\+\_\+magic\+\_\+fail@{eina\+\_\+magic\+\_\+fail}!Magic@{Magic}}
\subsubsection[{eina\+\_\+magic\+\_\+fail}]{\setlength{\rightskip}{0pt plus 5cm}void eina\+\_\+magic\+\_\+fail (
\begin{DoxyParamCaption}
\item[{void $\ast$}]{d, }
\item[{{\bf Eina\+\_\+\+Magic}}]{m, }
\item[{{\bf Eina\+\_\+\+Magic}}]{req\+\_\+m, }
\item[{const char $\ast$}]{file, }
\item[{const char $\ast$}]{fnc, }
\item[{int}]{line}
\end{DoxyParamCaption}
)}}\label{group__Eina__Magic__Group_ga1b837f53d9fbb370b29b0818d6c94a10}


Displays a message or aborts if a magic check failed. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em d} & The checked data pointer \\
\hline
\mbox{\tt in}  & {\em m} & The magic identifier to check \\
\hline
\mbox{\tt in}  & {\em req\+\_\+m} & The requested magic identifier to check \\
\hline
\mbox{\tt in}  & {\em file} & The file in which the magic check failed \\
\hline
\mbox{\tt in}  & {\em fnc} & The function in which the magic check failed \\
\hline
\mbox{\tt in}  & {\em line} & The line at which the magic check failed\\
\hline
\end{DoxyParams}
\begin{DoxyWarning}{Warning}
You should {\bfseries strongly} consider using \hyperlink{group__Eina__Magic__Group_gad7411adf9ff7121ad2004046f1b08408}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+F\+A\+I\+L(d, m)} instead.
\end{DoxyWarning}
This function displays an error message if a magic check has failed, using the following logic in the following order\+: \begin{DoxyItemize}
\item If {\ttfamily d} is {\ttfamily N\+U\+L\+L}, a message warns about a {\ttfamily N\+U\+L\+L} pointer. \item Otherwise, if {\ttfamily m} is equal to \hyperlink{group__Eina__Magic__Group_ga087a0d5a1e482da550b33fe4fcb0435f}{E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E}, a message warns about a handle that is already freed. \item Otherwise, if {\ttfamily m} is equal to {\ttfamily req\+\_\+m}, a message warns about a handle that is of the wrong type. \item Otherwise, a message warns you about abusing that function...\end{DoxyItemize}
\begin{DoxyNote}{Note}
If the environment variable E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+A\+B\+O\+R\+T is set, abort() is called and the program stops. It is useful for debugging programs with gdb. 
\end{DoxyNote}


References E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+D\+O\+M\+A\+I\+N\+\_\+\+G\+L\+O\+B\+A\+L, E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+C\+R\+I\+T\+I\+C\+A\+L, E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+L\+E\+V\+E\+L\+\_\+\+E\+R\+R, eina\+\_\+log\+\_\+print(), E\+I\+N\+A\+\_\+\+M\+A\+G\+I\+C\+\_\+\+N\+O\+N\+E, and eina\+\_\+magic\+\_\+string\+\_\+get().

