Files
config-parser/doc/latex/config_8c.tex
jonathan santis a05c9ce786 update doc
2025-05-21 09:46:06 +02:00

150 lines
10 KiB
TeX

\doxysection{config.\+c File Reference}
\hypertarget{config_8c}{}\label{config_8c}\index{config.c@{config.c}}
{\ttfamily \#include "{}config.\+h"{}}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item
int \mbox{\hyperlink{config_8c_aae86bc3f3ebba4d6aba3ca1392c0126a}{check\+Section}} (char \texorpdfstring{$\ast$}{*}str, char delimiter\+Left, char delimiter\+Right, char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}section\+Name)
\begin{DoxyCompactList}\small\item\em Here we check if the given string contains a section for example \mbox{[}SECTIONName\mbox{]} here delimiter\+Left is \mbox{[} and delimiter\+Right is \mbox{]} if a section is found, the section name will be written to section\+Name. \end{DoxyCompactList}\item
int \mbox{\hyperlink{config_8c_a699e504c1ab9ceffb828dbf365a5e374}{get\+Str\+At\+Pos}} (char \texorpdfstring{$\ast$}{*}str, int from\+Pos, int to\+Pos, char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name, int size\+Name)
\begin{DoxyCompactList}\small\item\em Here we get / cut from from\+Pos to to\+Pos and write it to an address. \end{DoxyCompactList}\item
int \mbox{\hyperlink{config_8c_ab0b547ee554d9b305adc1b2ad85080a3}{get\+Name\+Value\+Pair}} (char \texorpdfstring{$\ast$}{*}str, char left\+Delimiter\+Pos, char right\+Delimiter\+Pos, char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name, char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}value, int size\+Name, int size\+Value)
\begin{DoxyCompactList}\small\item\em Input\+: \end{DoxyCompactList}\item
int \mbox{\hyperlink{config_8c_a15a5f64f830221feac0af723899208b2}{parse\+Config}} (char \texorpdfstring{$\ast$}{*}original\+Buffer, struct \mbox{\hyperlink{structconfigEntry}{config\+Entry}} \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}entry, int config\+Size\+Count, int \texorpdfstring{$\ast$}{*}returned\+Count)
\end{DoxyCompactItemize}
\doxysubsection{Function Documentation}
\Hypertarget{config_8c_aae86bc3f3ebba4d6aba3ca1392c0126a}\index{config.c@{config.c}!checkSection@{checkSection}}
\index{checkSection@{checkSection}!config.c@{config.c}}
\doxysubsubsection{\texorpdfstring{checkSection()}{checkSection()}}
{\footnotesize\ttfamily \label{config_8c_aae86bc3f3ebba4d6aba3ca1392c0126a}
int check\+Section (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{str}{, }\item[{char}]{delimiter\+Left}{, }\item[{char}]{delimiter\+Right}{, }\item[{char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}}]{section\+Name}{}\end{DoxyParamCaption})}
Here we check if the given string contains a section for example \mbox{[}SECTIONName\mbox{]} here delimiter\+Left is \mbox{[} and delimiter\+Right is \mbox{]} if a section is found, the section name will be written to section\+Name.
Input\+:
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}str\+: the string to check \\
\hline
{\em char} & delimiter\+Left\+: the left delimiter to check for \\
\hline
{\em char} & delimiter\+Right\+: the right delimiter to check for\\
\hline
\end{DoxyParams}
Output\+:
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}section\+Name\+: if found the section Name of the section\\
\hline
\end{DoxyParams}
Return\+:
\begin{DoxyParams}{Parameters}
{\em int} & status\+\_\+code\+: one of the following values\+: \\
\hline
\end{DoxyParams}
Definition at line \mbox{\hyperlink{config_8c_source_l00024}{24}} of file \mbox{\hyperlink{config_8c_source}{config.\+c}}.
\Hypertarget{config_8c_ab0b547ee554d9b305adc1b2ad85080a3}\index{config.c@{config.c}!getNameValuePair@{getNameValuePair}}
\index{getNameValuePair@{getNameValuePair}!config.c@{config.c}}
\doxysubsubsection{\texorpdfstring{getNameValuePair()}{getNameValuePair()}}
{\footnotesize\ttfamily \label{config_8c_ab0b547ee554d9b305adc1b2ad85080a3}
int get\+Name\+Value\+Pair (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{str}{, }\item[{char}]{left\+Delimiter\+Pos}{, }\item[{char}]{right\+Delimiter\+Pos}{, }\item[{char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}}]{name}{, }\item[{char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}}]{value}{, }\item[{int}]{size\+Name}{, }\item[{int}]{size\+Value}{}\end{DoxyParamCaption})}
Input\+:
Here we get a "{}pair"{} of data, parsed from \texorpdfstring{$\ast$}{*}str, witch consists of a keyname and a keyvalue. These are written to the pointers at char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name and char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}value. These pair can be in the form of\+: ~\newline
ex1\+: ~\newline
NAME=VALUE ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$^\wedge$}{\string^}\+\_\+\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$^\wedge$}{\string^} ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$\vert$}{|}\+\_\+\+\_\+\+\_\+\+\_\+\+\_\+\+Here we have no delimiter this means right\+Delimiter\+Pos must be NULL ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\+This is the left delimiter ~\newline
ex2\+: ~\newline
name(value) ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$^\wedge$}{\string^}\+\_\+\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$^\wedge$}{\string^} ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\texorpdfstring{$\vert$}{|}\+\_\+\+\_\+\+\_\+\+\_\+\+\_\+\+This is the right\+Delimiter\+Pos and must be \textquotesingle{})\textquotesingle{} ~\newline
\+\_\+\+\_\+\+\_\+\+\_\+\+This is left\+Delimiter\+Pos which must be \textquotesingle{}(\textquotesingle{} ~\newline
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}str\+: the line in the form of a string where a key value pair is stored \\
\hline
{\em char} & left\+Delimiter\+Pos\+: the left delimiter for example \textquotesingle{}=\textquotesingle{} \\
\hline
{\em char} & right\+Delimiter\+Pos\+: the right delimiter can be NULL in most cases, if NULL we assume that there is only one delimiter, which is in this case the left\+Delimiter\+Pos\\
\hline
\end{DoxyParams}
Output\+:
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name\+: The address where we store the name of the Key \\
\hline
{\em char} & \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}value\+: The address where we store the key value \\
\hline
{\em int} & size\+Name\+: for size checking against memory allocated at \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name \\
\hline
{\em int} & size\+Value\+: for size checking against memory allocated at \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}value\\
\hline
\end{DoxyParams}
Return\+: \begin{DoxyReturn}{Returns}
will return NO\+\_\+\+ERROR (0) if successfull. If not it will return the error of the subroutine
\end{DoxyReturn}
Definition at line \mbox{\hyperlink{config_8c_source_l00151}{151}} of file \mbox{\hyperlink{config_8c_source}{config.\+c}}.
\Hypertarget{config_8c_a699e504c1ab9ceffb828dbf365a5e374}\index{config.c@{config.c}!getStrAtPos@{getStrAtPos}}
\index{getStrAtPos@{getStrAtPos}!config.c@{config.c}}
\doxysubsubsection{\texorpdfstring{getStrAtPos()}{getStrAtPos()}}
{\footnotesize\ttfamily \label{config_8c_a699e504c1ab9ceffb828dbf365a5e374}
int get\+Str\+At\+Pos (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{str}{, }\item[{int}]{from\+Pos}{, }\item[{int}]{to\+Pos}{, }\item[{char \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}}]{name}{, }\item[{int}]{size\+Name}{}\end{DoxyParamCaption})}
Here we get / cut from from\+Pos to to\+Pos and write it to an address.
Input\+:
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}str\+: the string to cut \\
\hline
{\em int} & from\+Pos\+: from which position we want to copy, the pos is included and zero indexed \\
\hline
{\em int} & to\+Pos\+: to which position we want to copy, the pos is included and zero indexed\\
\hline
\end{DoxyParams}
Output\+:
\begin{DoxyParams}{Parameters}
{\em char} & \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name\+: here we will write the section name to\\
\hline
\end{DoxyParams}
Input\+:
\begin{DoxyParams}{Parameters}
{\em int} & size\+Name\+: the size of the user allocated buffer at \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}name \\
\hline
\end{DoxyParams}
Definition at line \mbox{\hyperlink{config_8c_source_l00098}{98}} of file \mbox{\hyperlink{config_8c_source}{config.\+c}}.
\Hypertarget{config_8c_a15a5f64f830221feac0af723899208b2}\index{config.c@{config.c}!parseConfig@{parseConfig}}
\index{parseConfig@{parseConfig}!config.c@{config.c}}
\doxysubsubsection{\texorpdfstring{parseConfig()}{parseConfig()}}
{\footnotesize\ttfamily \label{config_8c_a15a5f64f830221feac0af723899208b2}
int parse\+Config (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{original\+Buffer}{, }\item[{struct \mbox{\hyperlink{structconfigEntry}{config\+Entry}} \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}}]{entry}{, }\item[{int}]{config\+Size\+Count}{, }\item[{int \texorpdfstring{$\ast$}{*}}]{returned\+Count}{}\end{DoxyParamCaption})}
Given a null terminated buffer of content(ex. from a file) an parse it with a default syntax of\+: Sections -\/\texorpdfstring{$>$}{>} \mbox{[}SECTIONNAME\mbox{]} name / value -\/\texorpdfstring{$>$}{>} name=value
Input\+: char \texorpdfstring{$\ast$}{*}original\+Buffer\+: the buffer which holds the string for parsing. struct \doxylink{structconfigEntry}{config\+Entry} \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}entry\+: a user allocated buffer to which we write the parsed config data. int config\+Size\+Count\+: the user allocated size of \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*}entry. Output\+: int \texorpdfstring{$\ast$}{*}returned\+Count\+: to this variable the function writes the count of struct, which will be required to store all alavaible data.
Note\+: The funtion returns the maximum allowed data structures, determined by config\+Size\+Count. All data which exceeds will be dropped. To get the whole data we run the funtion a second time with the realloced config\+Size\+Count in the size of \mbox{[}returned\+Count\mbox{]} structures.
Definition at line \mbox{\hyperlink{config_8c_source_l00215}{215}} of file \mbox{\hyperlink{config_8c_source}{config.\+c}}.