add doxygen configuration
This commit is contained in:
52
config.c
52
config.c
@@ -3,22 +3,24 @@
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
#include<errno.h>
|
||||
/*
|
||||
* Here we check if the given string contains a section
|
||||
|
||||
/**
|
||||
* @brief Here we check if the given string contains a section
|
||||
* for example [SECTIONName] here delimiterLeft is [ and delimiterRight is ]
|
||||
* if a section is found, the section name will be written to sectionName
|
||||
*
|
||||
* Input:
|
||||
* char **str: the string to check
|
||||
* char delimiterLeft: the left delimiter to check for
|
||||
* char delimiterRight: the right delimiter to check for
|
||||
* Output:
|
||||
* char **sectionName: if found the section Name of the section
|
||||
* Return:
|
||||
* int status_code: one of the following values:
|
||||
* @brief Input:
|
||||
* @param char **str: the string to check
|
||||
* @param char delimiterLeft: the left delimiter to check for
|
||||
* @param char delimiterRight: the right delimiter to check for
|
||||
*
|
||||
* @brief Output:
|
||||
* @param char **sectionName: if found the section Name of the section
|
||||
*
|
||||
* @brief Return:
|
||||
* @param int status_code: one of the following values:
|
||||
*
|
||||
*/
|
||||
|
||||
int checkSection(char *str,char delimiterLeft,char delimiterRight,char **sectionName)
|
||||
{
|
||||
char section[MAX_LEN_SECTIONNAME];
|
||||
@@ -80,7 +82,8 @@ int checkSection(char *str,char delimiterLeft,char delimiterRight,char **section
|
||||
}
|
||||
return NO_SECTION;
|
||||
}
|
||||
/*
|
||||
|
||||
/**
|
||||
* Here we get / cut from fromPos to toPos and write it to an address
|
||||
*
|
||||
* Input:
|
||||
@@ -92,7 +95,6 @@ int checkSection(char *str,char delimiterLeft,char delimiterRight,char **section
|
||||
* Input:
|
||||
* int sizeName: the size of the user allocated buffer at **name
|
||||
*/
|
||||
|
||||
int getStrAtPos(char *str,int fromPos,int toPos,char **name,int sizeName)
|
||||
{
|
||||
if(*name == NULL)
|
||||
@@ -116,7 +118,8 @@ int getStrAtPos(char *str,int fromPos,int toPos,char **name,int sizeName)
|
||||
ptr_name[j+1]='\0';
|
||||
return NO_ERROR;
|
||||
}
|
||||
/*
|
||||
|
||||
/**
|
||||
*Here we get a "pair" of data, parsed from *str, witch consists of a keyname and a keyvalue.
|
||||
*These are written to the pointers at char **name and char **value.
|
||||
*These pair can be in the form of:
|
||||
@@ -145,7 +148,6 @@ int getStrAtPos(char *str,int fromPos,int toPos,char **name,int sizeName)
|
||||
* will return NO_ERROR (0) if successfull.
|
||||
* If not it will return the error of the subroutine
|
||||
*/
|
||||
|
||||
int getNameValuePair(char *str,char leftDelimiterPos,char rightDelimiterPos,char **name,char **value,int sizeName,int sizeValue)
|
||||
{
|
||||
if(*name == NULL || *value == NULL)
|
||||
@@ -194,8 +196,22 @@ int getNameValuePair(char *str,char leftDelimiterPos,char rightDelimiterPos,char
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given a null terminated buffer of content(ex. from a file) an parse it with a default syntax of:
|
||||
* Sections -> [SECTIONNAME]
|
||||
* name / value -> name=value
|
||||
*
|
||||
* Input:
|
||||
* char *originalBuffer: the buffer which holds the string for parsing.
|
||||
* struct configEntry **entry: a user allocated buffer to which we write the parsed config data.
|
||||
* int configSizeCount: the user allocated size of **entry.
|
||||
* Output:
|
||||
* int *returnedCount: 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 configSizeCount. All data which exceeds will be dropped.
|
||||
* To get the whole data we run the funtion a second time with the realloced configSizeCount in the size of [returnedCount] structures.
|
||||
*/
|
||||
int parseConfig(char *originalBuffer,struct configEntry **entry,int configSizeCount,int *returnedCount)
|
||||
{
|
||||
int state=ST_INIT;
|
||||
@@ -249,7 +265,7 @@ int parseConfig(char *originalBuffer,struct configEntry **entry,int configSizeCo
|
||||
{
|
||||
int error = errno;
|
||||
printf("MALLOC:%d\n",error);
|
||||
//return error;
|
||||
return error;
|
||||
}
|
||||
memset(keyName,0,MAX_LEN_SECTIONNAME);
|
||||
memset(keyValue,0,MAX_LEN_SECTIONNAME);
|
||||
|
||||
Reference in New Issue
Block a user