\hypertarget{parseargs_8c}{}\doxysection{src/parseargs.c File Reference}
\label{parseargs_8c}\index{src/parseargs.c@{src/parseargs.c}}
{\ttfamily \#include \char`\"{}parseargs.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}printing.\+h\char`\"{}}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$getopt.\+h$>$}\newline
{\ttfamily \#include $<$limits.\+h$>$}\newline
{\ttfamily \#include $<$math.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$ctype.\+h$>$}\newline
Include dependency graph for parseargs.\+c\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{parseargs_8c__incl}
\end{center}
\end{figure}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{parseargs_8c_ab4f632f3c0aeabccd476e083ad2e81c9}{check\+UInt\+Arg}} (int name, unsigned int $\ast$value, const char $\ast$opt\+Arg)
\begin{DoxyCompactList}\small\item\em Checks if the provided argument is a valid integer and parses it. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{parseargs_8c_aaf2d069af6cc2b87e8475f050aa2d221}{check\+File\+Arg}} (int name, FILE $\ast$$\ast$file\+Ptr, const char $\ast$opt\+Arg, const char $\ast$mode)
\begin{DoxyCompactList}\small\item\em Parses command line arguments and fills the \mbox{\hyperlink{structCapConfig}{Cap\+Config}} struct. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{parseargs_8c_affe148b16953fa74822c7b24207ca5c7}{parse\+Arguments}} (int argc, char $\ast$argv\mbox{[}$\,$\mbox{]}, \mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg)
\begin{DoxyCompactList}\small\item\em Parses command line arguments and fills the \mbox{\hyperlink{structCapConfig}{Cap\+Config}} struct. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{parseargs_8c_a109804a71dfeacda0de64e0b8fb182e2}{get\+Int}} (char $\ast$ptr)
\begin{DoxyCompactList}\small\item\em Parses an integer from a string. \end{DoxyCompactList}\item 
double \mbox{\hyperlink{parseargs_8c_aab971caa9b7eb0827483d98357cb1b13}{get\+Double}} (char $\ast$ptr)
\begin{DoxyCompactList}\small\item\em Parses a double from a string. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{parseargs_8c_ade4b241bef609b19381dc4baff3c380e}{get\+Doubles\+From\+Stdin}} (size\+\_\+t max\+Count, double $\ast$arr)
\begin{DoxyCompactList}\small\item\em Reads one line from stdin and parses up to max\+Count doubles into array. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{parseargs_8c_a22a89b0e4e695c3783e15f00652d5193}{get\+Ints\+From\+File}} (size\+\_\+t max\+Count, int $\ast$arr, FILE $\ast$file)
\begin{DoxyCompactList}\small\item\em Reads integers from file until EOF or max\+Count is reached. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{parseargs_8c_aaf2d069af6cc2b87e8475f050aa2d221}\label{parseargs_8c_aaf2d069af6cc2b87e8475f050aa2d221}} 
\index{parseargs.c@{parseargs.c}!checkFileArg@{checkFileArg}}
\index{checkFileArg@{checkFileArg}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{checkFileArg()}{checkFileArg()}}
{\footnotesize\ttfamily int check\+File\+Arg (\begin{DoxyParamCaption}\item[{int}]{name,  }\item[{FILE $\ast$$\ast$}]{file\+Ptr,  }\item[{const char $\ast$}]{opt\+Arg,  }\item[{const char $\ast$}]{mode }\end{DoxyParamCaption})}



Parses command line arguments and fills the \mbox{\hyperlink{structCapConfig}{Cap\+Config}} struct. 

Also provides utility functions for checking and parsing arguments.

Checks if the provided argument is a valid file and opens it.


\begin{DoxyParams}{Parameters}
{\em name} & The name of the argument (for error messages). \\
\hline
{\em file\+Ptr} & Pointer to a FILE$\ast$ that will be set to the opened file. \\
\hline
{\em opt\+Arg} & The argument string to check (should be a filename). \\
\hline
{\em mode} & The mode to open the file (e.\+g., \char`\"{}r\char`\"{} for read, \char`\"{}w\char`\"{} for write). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, non-\/zero on failure. 
\end{DoxyReturn}
\mbox{\Hypertarget{parseargs_8c_ab4f632f3c0aeabccd476e083ad2e81c9}\label{parseargs_8c_ab4f632f3c0aeabccd476e083ad2e81c9}} 
\index{parseargs.c@{parseargs.c}!checkUIntArg@{checkUIntArg}}
\index{checkUIntArg@{checkUIntArg}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{checkUIntArg()}{checkUIntArg()}}
{\footnotesize\ttfamily int check\+UInt\+Arg (\begin{DoxyParamCaption}\item[{int}]{name,  }\item[{unsigned int $\ast$}]{value,  }\item[{const char $\ast$}]{opt\+Arg }\end{DoxyParamCaption})}



Checks if the provided argument is a valid integer and parses it. 


\begin{DoxyParams}{Parameters}
{\em name} & The name of the argument (for error messages). \\
\hline
{\em value} & Pointer to an int that will be set to the parsed value. \\
\hline
{\em opt\+Arg} & The argument string to check (should be an integer). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, non-\/zero on failure. 
\end{DoxyReturn}
\mbox{\Hypertarget{parseargs_8c_aab971caa9b7eb0827483d98357cb1b13}\label{parseargs_8c_aab971caa9b7eb0827483d98357cb1b13}} 
\index{parseargs.c@{parseargs.c}!getDouble@{getDouble}}
\index{getDouble@{getDouble}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{getDouble()}{getDouble()}}
{\footnotesize\ttfamily double get\+Double (\begin{DoxyParamCaption}\item[{char $\ast$}]{ptr }\end{DoxyParamCaption})}



Parses a double from a string. 


\begin{DoxyParams}{Parameters}
{\em ptr} & The string to parse. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The parsed double value. 
\end{DoxyReturn}
\mbox{\Hypertarget{parseargs_8c_ade4b241bef609b19381dc4baff3c380e}\label{parseargs_8c_ade4b241bef609b19381dc4baff3c380e}} 
\index{parseargs.c@{parseargs.c}!getDoublesFromStdin@{getDoublesFromStdin}}
\index{getDoublesFromStdin@{getDoublesFromStdin}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{getDoublesFromStdin()}{getDoublesFromStdin()}}
{\footnotesize\ttfamily int get\+Doubles\+From\+Stdin (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{max\+Count,  }\item[{double $\ast$}]{arr }\end{DoxyParamCaption})}



Reads one line from stdin and parses up to max\+Count doubles into array. 

Reads doubles from standard input until EOF or max\+Count is reached.

Returns the number of doubles stored (\texorpdfstring{$>$}{>}=0), or -\/1 on I/\+O/memory error. \mbox{\Hypertarget{parseargs_8c_a109804a71dfeacda0de64e0b8fb182e2}\label{parseargs_8c_a109804a71dfeacda0de64e0b8fb182e2}} 
\index{parseargs.c@{parseargs.c}!getInt@{getInt}}
\index{getInt@{getInt}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{getInt()}{getInt()}}
{\footnotesize\ttfamily int get\+Int (\begin{DoxyParamCaption}\item[{char $\ast$}]{ptr }\end{DoxyParamCaption})}



Parses an integer from a string. 


\begin{DoxyParams}{Parameters}
{\em ptr} & The string to parse. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The parsed integer value. 
\end{DoxyReturn}
\mbox{\Hypertarget{parseargs_8c_a22a89b0e4e695c3783e15f00652d5193}\label{parseargs_8c_a22a89b0e4e695c3783e15f00652d5193}} 
\index{parseargs.c@{parseargs.c}!getIntsFromFile@{getIntsFromFile}}
\index{getIntsFromFile@{getIntsFromFile}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{getIntsFromFile()}{getIntsFromFile()}}
{\footnotesize\ttfamily int get\+Ints\+From\+File (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{max\+Count,  }\item[{int $\ast$}]{arr,  }\item[{FILE $\ast$}]{file }\end{DoxyParamCaption})}



Reads integers from file until EOF or max\+Count is reached. 


\begin{DoxyParams}{Parameters}
{\em max\+Count} & The maximum number of integers to read. \\
\hline
{\em arr} & Pointer to an array where the read integers will be stored. \\
\hline
{\em file} & Pointer to read integers from \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of integers successfully read. 
\end{DoxyReturn}
\mbox{\Hypertarget{parseargs_8c_affe148b16953fa74822c7b24207ca5c7}\label{parseargs_8c_affe148b16953fa74822c7b24207ca5c7}} 
\index{parseargs.c@{parseargs.c}!parseArguments@{parseArguments}}
\index{parseArguments@{parseArguments}!parseargs.c@{parseargs.c}}
\doxysubsubsection{\texorpdfstring{parseArguments()}{parseArguments()}}
{\footnotesize\ttfamily void parse\+Arguments (\begin{DoxyParamCaption}\item[{int}]{argc,  }\item[{char $\ast$}]{argv\mbox{[}$\,$\mbox{]},  }\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg }\end{DoxyParamCaption})}



Parses command line arguments and fills the \mbox{\hyperlink{structCapConfig}{Cap\+Config}} struct. 


\begin{DoxyParams}{Parameters}
{\em argc} & The number of command line arguments. \\
\hline
{\em argv} & The array of command line argument strings. \\
\hline
{\em cfg} & Pointer to a \mbox{\hyperlink{structCapConfig}{Cap\+Config}} struct that will be filled with the parsed configuration. \\
\hline
\end{DoxyParams}
