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

{\tt \#include \char`\"{}XLX\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}EXPAT/expat.h\char`\"{}}\par
{\tt \#include \char`\"{}stdlib.h\char`\"{}}\par
{\tt \#include \char`\"{}stdio.h\char`\"{}}\par
{\tt \#include \char`\"{}string.h\char`\"{}}\par
{\tt \#include \char`\"{}ctype.h\char`\"{}}\par


Include dependency graph for util.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=160pt]{util_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static unsigned \hyperlink{util_8c_a0}{strtobin} (int optns, const char $\ast$string, unsigned int len, void $\ast$value)
\begin{CompactList}\small\item\em Convert a string to binary. \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 a named attribute in an attribute list. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a3}{XLX\_\-strtoi} (const char $\ast$string, unsigned int len, int $\ast$value)
\begin{CompactList}\small\item\em Convert a string to a signed 32-bit integer. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a4}{XLX\_\-strtou} (const char $\ast$string, unsigned int len, unsigned int $\ast$value)
\begin{CompactList}\small\item\em Convert a string to an unsigned 32-bit integer. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a5}{XLX\_\-strtoll} (const char $\ast$string, unsigned int len, long long $\ast$value)
\begin{CompactList}\small\item\em Convert a string to a signed 64-bit integer. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a6}{XLX\_\-strtoull} (const char $\ast$string, unsigned int len, unsigned long long $\ast$value)
\begin{CompactList}\small\item\em Convert a string to an unsigned 64-bit integer. \item\end{CompactList}\item 
void \hyperlink{util_8c_a7}{XLX\_\-val\-Error} (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$state, const char $\ast$func, const char $\ast$string, unsigned int len)
\begin{CompactList}\small\item\em Report value string to be in error. \item\end{CompactList}\item 
void \hyperlink{util_8c_a8}{XLX\_\-attr\-Error} (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$state, const char $\ast$func, const char $\ast$name)
\begin{CompactList}\small\item\em Report missing attribute error. \item\end{CompactList}\item 
void \hyperlink{util_8c_a9}{XLX\_\-attr\-Val\-Error} (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$state, const char $\ast$func, const char $\ast$name)
\begin{CompactList}\small\item\em Report invalid attribute value error. \item\end{CompactList}\item 
void \hyperlink{util_8c_a10}{XLX\_\-disp\-File\-Name} (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$state, const char $\ast$func)
\begin{CompactList}\small\item\em Display the name of the current file being parsed. \item\end{CompactList}\item 
unsigned \hyperlink{util_8c_a11}{XLX\_\-ischar} (const char $\ast$string, unsigned int 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 \& Owen Saxton\end{Desc}
\begin{Desc}
\item[Id]\hyperlink{util_8c}{util.c},v 1.13 2006/09/18 18:03:03 saxton Exp \end{Desc}


\subsection{Function Documentation}
\hypertarget{util_8c_a0}{
\index{util.c@{util.c}!strtobin@{strtobin}}
\index{strtobin@{strtobin}!util.c@{util.c}}
\subsubsection[strtobin]{\setlength{\rightskip}{0pt plus 5cm}unsigned strtobin (int {\em optns}, const char $\ast$ {\em string}, unsigned int {\em len}, void $\ast$ {\em value})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{util_8c_a0}


Convert a string to binary. 

This routine converts a decimal or hexadecimal string to an integer. By default the string must be unsigned and the integer is 32-bit. Options allow the string to be signed, and the integer to be 64-bit.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em optns}]Bit mask of conversion options: 1 = signed, 2 = 64-bit\item[{\em string}]String to convert\item[{\em len}]Maximum length of the string (including whitespace)\item[{\em value}]Address of the converted value\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the string represents a valid integer \item[{\em -1}]If the string contains invalid characters\end{description}
\end{Desc}
\hypertarget{util_8c_a8}{
\index{util.c@{util.c}!XLX_attrError@{XLX\_\-attrError}}
\index{XLX_attrError@{XLX\_\-attrError}!util.c@{util.c}}
\subsubsection[XLX\_\-attrError]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-attr\-Error (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$ {\em state}, const char $\ast$ {\em func}, const char $\ast$ {\em name})}}
\label{util_8c_a8}


Report missing attribute error. 

This routine displays the name of the missing attribute, along with the line number in and the name of the file being parsed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]Current parse state\item[{\em func}]Name of function reporting the error\item[{\em name}]Attribute name\end{description}
\end{Desc}
\hypertarget{util_8c_a9}{
\index{util.c@{util.c}!XLX_attrValError@{XLX\_\-attrValError}}
\index{XLX_attrValError@{XLX\_\-attrValError}!util.c@{util.c}}
\subsubsection[XLX\_\-attrValError]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-attr\-Val\-Error (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$ {\em state}, const char $\ast$ {\em func}, const char $\ast$ {\em name})}}
\label{util_8c_a9}


Report invalid attribute value error. 

This routine displays the name of the attribute, along with the line number in and the name of the file being parsed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]Current parse state\item[{\em func}]Name of function reporting the error\item[{\em name}]Attribute name\end{description}
\end{Desc}
\hypertarget{util_8c_a10}{
\index{util.c@{util.c}!XLX_dispFileName@{XLX\_\-dispFileName}}
\index{XLX_dispFileName@{XLX\_\-dispFileName}!util.c@{util.c}}
\subsubsection[XLX\_\-dispFileName]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-disp\-File\-Name (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$ {\em state}, const char $\ast$ {\em func})}}
\label{util_8c_a10}


Display the name of the current file being parsed. 

This routine is used when reporting errors during the parsing.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]Current parse state\item[{\em func}]Name of function reporting the error\end{description}
\end{Desc}
\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 a named attribute in an attribute list. 

This routine looks for the attribute in the attribute list and returns its associated value (signed decimal or hexadecimal string) converted to an integer.

\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 and its value is valid \item[{\em -1}]If the value is not a valid number \item[{\em -2}]If the name is missing from the attribute list\end{description}
\end{Desc}
\hypertarget{util_8c_a11}{
\index{util.c@{util.c}!XLX_ischar@{XLX\_\-ischar}}
\index{XLX_ischar@{XLX\_\-ischar}!util.c@{util.c}}
\subsubsection[XLX\_\-ischar]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-ischar (const char $\ast$ {\em string}, unsigned int {\em len})}}
\label{util_8c_a11}


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

Checks that the string has valid characters after any leading whitespace and before the start of the next tag.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em string}]Layer address string to convert\item[{\em len}]Max length of the string (including whitespace)\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}
\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 value for the 'enabled' attribute \item[{\em -2}]If there was no 'enabled' attribute\end{description}
\end{Desc}
\hypertarget{util_8c_a3}{
\index{util.c@{util.c}!XLX_strtoi@{XLX\_\-strtoi}}
\index{XLX_strtoi@{XLX\_\-strtoi}!util.c@{util.c}}
\subsubsection[XLX\_\-strtoi]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-strtoi (const char $\ast$ {\em string}, unsigned int {\em len}, int $\ast$ {\em value})}}
\label{util_8c_a3}


Convert a string to a signed 32-bit integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em string}]String to convert\item[{\em len}]Maximum length of the string (including whitespace)\item[{\em value}]Address of the converted value\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the string represents a valid integer \item[{\em -1}]If the string contains invalid characters\end{description}
\end{Desc}
\hypertarget{util_8c_a5}{
\index{util.c@{util.c}!XLX_strtoll@{XLX\_\-strtoll}}
\index{XLX_strtoll@{XLX\_\-strtoll}!util.c@{util.c}}
\subsubsection[XLX\_\-strtoll]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-strtoll (const char $\ast$ {\em string}, unsigned int {\em len}, long long $\ast$ {\em value})}}
\label{util_8c_a5}


Convert a string to a signed 64-bit integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em string}]String to convert\item[{\em len}]Maximum length of the string (including whitespace)\item[{\em value}]Address of the converted value\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the string represents a valid integer \item[{\em -1}]If the string contains invalid characters\end{description}
\end{Desc}
\hypertarget{util_8c_a4}{
\index{util.c@{util.c}!XLX_strtou@{XLX\_\-strtou}}
\index{XLX_strtou@{XLX\_\-strtou}!util.c@{util.c}}
\subsubsection[XLX\_\-strtou]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-strtou (const char $\ast$ {\em string}, unsigned int {\em len}, unsigned int $\ast$ {\em value})}}
\label{util_8c_a4}


Convert a string to an unsigned 32-bit integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em string}]String to convert\item[{\em len}]Maximum length of the string (including whitespace)\item[{\em value}]Address of the converted value\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the string represents a valid integer \item[{\em -1}]If the string contains invalid characters\end{description}
\end{Desc}
\hypertarget{util_8c_a6}{
\index{util.c@{util.c}!XLX_strtoull@{XLX\_\-strtoull}}
\index{XLX_strtoull@{XLX\_\-strtoull}!util.c@{util.c}}
\subsubsection[XLX\_\-strtoull]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-strtoull (const char $\ast$ {\em string}, unsigned int {\em len}, unsigned long long $\ast$ {\em value})}}
\label{util_8c_a6}


Convert a string to an unsigned 64-bit integer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em string}]String to convert\item[{\em len}]Maximum length of the string (including whitespace)\item[{\em value}]Address of the converted value\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the string represents a valid integer \item[{\em -1}]If the string contains invalid characters\end{description}
\end{Desc}
\hypertarget{util_8c_a7}{
\index{util.c@{util.c}!XLX_valError@{XLX\_\-valError}}
\index{XLX_valError@{XLX\_\-valError}!util.c@{util.c}}
\subsubsection[XLX\_\-valError]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-val\-Error (\hyperlink{struct__XLX__state}{XLX\_\-state} $\ast$ {\em state}, const char $\ast$ {\em func}, const char $\ast$ {\em string}, unsigned int {\em len})}}
\label{util_8c_a7}


Report value string to be in error. 

This routine displays the contents of the string, along with the line number in and the name of the file being parsed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]Current parse state\item[{\em func}]Name of function reporting the error\item[{\em string}]String to report\item[{\em len}]Max length of the string (including whitespace)\end{description}
\end{Desc}
