\hypertarget{util_8c}{
\section{util.c File Reference}
\label{util_8c}\index{util.c@{util.c}}
}
General character/conversion utilities. 

{\tt \#include \char`\"{}XLX/util.h\char`\"{}}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$ctype.h$>$}\par


Include dependency graph for util.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=92pt]{util_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned \hyperlink{util_8c_a0}{XLX\_\-pow} (unsigned exp)
\begin{CompactList}\small\item\em calculates 16 to the power x \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a1}{XLX\_\-is\-Enabled} (const char $\ast$$\ast$attribute, int $\ast$enabled)
\begin{CompactList}\small\item\em Reads the attribute list and sets {\em enabled\/} accordingly. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a2}{XLX\_\-get\-Attribute} (const char $\ast$$\ast$attribute, const char $\ast$name, int $\ast$value)
\begin{CompactList}\small\item\em Find {\em name\/} in the attribute list and sets {\em value\/} accordingly. \item\end{CompactList}\item 
unsigned int \hyperlink{util_8c_a3}{xtoi} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Convert a hexedecimal string into an unsigned integer. \item\end{CompactList}\item 
unsigned long long \hyperlink{util_8c_a4}{xtoll} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Convert a hexedecimal string into an unsigned long long. \item\end{CompactList}\item 
unsigned int \hyperlink{util_8c_a5}{ishex} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Test a string to see if it is a hexadecimal number. \item\end{CompactList}\item 
unsigned int \hyperlink{util_8c_a6}{dtoi} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Convert a decimal string into an unsigned integer. \item\end{CompactList}\item 
unsigned long long \hyperlink{util_8c_a7}{dtoll} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Convert a decimal string into an unsigned long long. \item\end{CompactList}\item 
unsigned int \hyperlink{util_8c_a8}{isdec} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Test a string to see if it is a hexadecimal number. \item\end{CompactList}\item 
unsigned int \hyperlink{util_8c_a9}{ischar} (const char $\ast$string, unsigned len)
\begin{CompactList}\small\item\em Test a string to see if it is a valid register wide character element. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
General character/conversion utilities. 

\begin{Desc}
\item[Author:]James Swain -- \href{mailto:jswain@slac.stanford.edu}{\tt jswain@slac.stanford.edu}\end{Desc}


\subsection{Function Documentation}
\hypertarget{util_8c_a6}{
\index{util.c@{util.c}!dtoi@{dtoi}}
\index{dtoi@{dtoi}!util.c@{util.c}}
\subsubsection[dtoi]{\setlength{\rightskip}{0pt plus 5cm}unsigned int dtoi (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a6}


Convert a decimal string into an unsigned integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Decimal string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]integer value of the string\end{Desc}
\hypertarget{util_8c_a7}{
\index{util.c@{util.c}!dtoll@{dtoll}}
\index{dtoll@{dtoll}!util.c@{util.c}}
\subsubsection[dtoll]{\setlength{\rightskip}{0pt plus 5cm}unsigned long long dtoll (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a7}


Convert a decimal string into an unsigned long long. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Decimal string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]long long value of the string\end{Desc}
\hypertarget{util_8c_a9}{
\index{util.c@{util.c}!ischar@{ischar}}
\index{ischar@{ischar}!util.c@{util.c}}
\subsubsection[ischar]{\setlength{\rightskip}{0pt plus 5cm}unsigned int ischar (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a9}


Test a string to see if it is a valid register wide character element. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Layer address string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 1}]if the string has valid characters before the start of the next tag \item[{\em 0}]if the string does not have valid characters before the start of the next tag\end{description}
\end{Desc}
Checks that the string has valid characters after any leading whitespace and before the start of the next tag.\hypertarget{util_8c_a8}{
\index{util.c@{util.c}!isdec@{isdec}}
\index{isdec@{isdec}!util.c@{util.c}}
\subsubsection[isdec]{\setlength{\rightskip}{0pt plus 5cm}unsigned int isdec (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a8}


Test a string to see if it is a hexadecimal number. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Hex string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 1}]if the string is a valid dec string \item[{\em 0}]if the string is not a valid dec string\end{description}
\end{Desc}
Test is quite weak, checks that the string starts with zero or more whitespace characters followed by \char`\"{}one or more numerical characters ('0' to '9').\hypertarget{util_8c_a5}{
\index{util.c@{util.c}!ishex@{ishex}}
\index{ishex@{ishex}!util.c@{util.c}}
\subsubsection[ishex]{\setlength{\rightskip}{0pt plus 5cm}unsigned int ishex (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a5}


Test a string to see if it is a hexadecimal number. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Hex string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 1}]if the string is a valid hex string \item[{\em 0}]if the string is not a valid hex string\end{description}
\end{Desc}
Test is quite weak, checks that the string starts with zero or more whitespace characters followed by \char`\"{}0x\char`\"{} followed by one or more hex characters ('0' to '9', 'a' to 'f' and 'A' to 'f').\hypertarget{util_8c_a2}{
\index{util.c@{util.c}!XLX_getAttribute@{XLX\_\-getAttribute}}
\index{XLX_getAttribute@{XLX\_\-getAttribute}!util.c@{util.c}}
\subsubsection[XLX\_\-getAttribute]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-get\-Attribute (const char $\ast$$\ast$ {\em attribute}, const char $\ast$ {\em name}, int $\ast$ {\em value})}}
\label{util_8c_a2}


Find {\em name\/} in the attribute list and sets {\em value\/} accordingly. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em attribute}]Attribute list from the start tag of the element \item[{\em name}]Attribute to find and return \item[{\em value}]Location to put value of attribute \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the name is found in the attribute list \item[{\em -1}]If the name is missing from the attribute list\end{description}
\end{Desc}
\hypertarget{util_8c_a1}{
\index{util.c@{util.c}!XLX_isEnabled@{XLX\_\-isEnabled}}
\index{XLX_isEnabled@{XLX\_\-isEnabled}!util.c@{util.c}}
\subsubsection[XLX\_\-isEnabled]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-is\-Enabled (const char $\ast$$\ast$ {\em attribute}, int $\ast$ {\em enabled})}}
\label{util_8c_a1}


Reads the attribute list and sets {\em enabled\/} accordingly. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em attribute}]Attribute list from the start tag of the element \item[{\em enabled}]Location to write 0 (FALSE) or 1 (TRUE) \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the attribute list was read correctly \item[{\em -1}]If there was a bad attribute\end{description}
\end{Desc}
\hypertarget{util_8c_a0}{
\index{util.c@{util.c}!XLX_pow@{XLX\_\-pow}}
\index{XLX_pow@{XLX\_\-pow}!util.c@{util.c}}
\subsubsection[XLX\_\-pow]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-pow (unsigned {\em exp})}}
\label{util_8c_a0}


calculates 16 to the power x 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exp}]Exponent \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]16 raised to the power exp\end{Desc}
\hypertarget{util_8c_a3}{
\index{util.c@{util.c}!xtoi@{xtoi}}
\index{xtoi@{xtoi}!util.c@{util.c}}
\subsubsection[xtoi]{\setlength{\rightskip}{0pt plus 5cm}unsigned int xtoi (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a3}


Convert a hexedecimal string into an unsigned integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Hex string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]integer value of the string\end{Desc}
\hypertarget{util_8c_a4}{
\index{util.c@{util.c}!xtoll@{xtoll}}
\index{xtoll@{xtoll}!util.c@{util.c}}
\subsubsection[xtoll]{\setlength{\rightskip}{0pt plus 5cm}unsigned long long xtoll (const char $\ast$ {\em string}, unsigned {\em len})}}
\label{util_8c_a4}


Convert a hexedecimal string into an unsigned long long. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]Max length of the string (including whitespace) \item[{\em string}]Hex string to convert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]long long value of the string\end{Desc}
