- new directory traversal method
- using debug output from debug.h
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "xmalloc.h"
|
||||
#include "cfunction_if.h"
|
||||
#include "cfile_parser_loc.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS 10
|
||||
|
||||
@@ -107,10 +108,10 @@ STATIC void printMatchGroup(char *aString, regmatch_t *aMatchGroup)
|
||||
{
|
||||
if (aMatchGroup[i].rm_so < aMatchGroup[i].rm_eo)
|
||||
{
|
||||
printf("[%02d](%.3ld - %.3ld)[%03d]:", i, aMatchGroup[i].rm_so, aMatchGroup[i].rm_eo, (int) (aMatchGroup[i].rm_eo - aMatchGroup[i].rm_so));
|
||||
DEBUG_LOG_APPEND(1, "[%02d](%.3ld - %.3ld)[%03d]:", i, aMatchGroup[i].rm_so, aMatchGroup[i].rm_eo, (int) (aMatchGroup[i].rm_eo - aMatchGroup[i].rm_so));
|
||||
strlcpy(match, &aString[aMatchGroup[i].rm_so], (size_t) (aMatchGroup[i].rm_eo - aMatchGroup[i].rm_so + 1));
|
||||
printf("%s", match);
|
||||
printf("\n");
|
||||
DEBUG_LOG_APPEND(1, "%s", match);
|
||||
DEBUG_LOG_APPEND(1, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -417,18 +418,18 @@ STATIC int8_t removeCcomments(char *aLine)
|
||||
return cBlockRemoval(aLine, CPARS_COMMENT_BLOCK_START, CPARS_COMMENT_BLOCK_END, &helper, true);
|
||||
}
|
||||
|
||||
STATIC int8_t evaluateParameter(char **aParameter, cfunction_t *aFunction)
|
||||
STATIC int8_t evaluateParameter(char *aParameter, cfunction_t *aFunction)
|
||||
{
|
||||
char *token = NULL;
|
||||
regmatch_t matchGroup[CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS];
|
||||
cfunction_parameter_t *tempParameter = NULL;
|
||||
|
||||
if (NULL == aParameter || NULL == *aParameter || NULL == aFunction)
|
||||
if (NULL == aParameter || NULL == aFunction)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
token = strtok(*aParameter, ",");
|
||||
token = strtok(aParameter, ",");
|
||||
while (token)
|
||||
{
|
||||
if (0 == regexec(®Xparameter, token, CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS, matchGroup, 0))
|
||||
@@ -454,8 +455,6 @@ STATIC int8_t evaluateParameter(char **aParameter, cfunction_t *aFunction)
|
||||
token = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
free(*aParameter);
|
||||
*aParameter = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -489,21 +488,22 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
if (0 == regexec(®XmlEnd, aLine, maxGroup, matchGroup, REG_NOTEOL))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_REGULAR;
|
||||
printf("[ mle]");
|
||||
DEBUG_LOG_APPEND(1, "[ mle]");
|
||||
functionEnd = true;
|
||||
}
|
||||
else if (0 == regexec(®XmlProto, aLine, maxGroup, matchGroup, REG_NOTEOL))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_PROTO;
|
||||
printf("[ mlp]");
|
||||
DEBUG_LOG_APPEND(1, "[ mlp]");
|
||||
functionEnd = true;
|
||||
}
|
||||
else if (0 == regexec(®XmlPar, aLine, maxGroup, matchGroup, REG_NOTEOL))
|
||||
{
|
||||
printf("[ ml+]");
|
||||
DEBUG_LOG_APPEND(1, "[ ml+]");
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG_APPEND(1, "[ na ]");
|
||||
tempFunctionType = CFUNCTION_TYPE_UNDEF;
|
||||
functionEnd = true;
|
||||
}
|
||||
@@ -513,23 +513,23 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
else if (0 == regexec(®Xsl, aLine, maxGroup, matchGroup, REG_NOTEOL) && CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_REGULAR;
|
||||
printf("[ sl ]");
|
||||
DEBUG_LOG_APPEND(1, "[ sl ]");
|
||||
}
|
||||
else if (0 == regexec(®XmlStart, aLine, maxGroup, matchGroup, REG_NOTEOL) && CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_REGULAR;
|
||||
printf("[ mls]");
|
||||
DEBUG_LOG_APPEND(1, "[ mls]");
|
||||
++cfile_parser_functionLine;
|
||||
}
|
||||
else if (0 == regexec(®Xproto, aLine, maxGroup, matchGroup, REG_NOTEOL) && CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_PROTO;
|
||||
printf("[prot]");
|
||||
DEBUG_LOG_APPEND(1, "[prot]");
|
||||
}
|
||||
else if (0 == regexec(®X, aLine, maxGroup, matchGroup, REG_NOTEOL) && CFILE_PARSER_IS_MATCHGROUP_FUNCTION(matchGroup))
|
||||
{
|
||||
tempFunctionType = CFUNCTION_TYPE_UNDEF;
|
||||
printf("[ fuX]");
|
||||
DEBUG_LOG_APPEND(1, "[ fuX]");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -546,11 +546,11 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
if (matchGroup[i].rm_so < matchGroup[i].rm_eo)
|
||||
{
|
||||
if (0 < i)
|
||||
printf(" ");
|
||||
printf("[%02d](%.3ld - %.3ld)[%03d]: ", i, matchGroup[i].rm_so, matchGroup[i].rm_eo, (int) (matchGroup[i].rm_eo - matchGroup[i].rm_so));
|
||||
DEBUG_LOG_APPEND(1, " ");
|
||||
DEBUG_LOG_APPEND(1, "[%02d](%.3ld - %.3ld)[%03d]: ", i, matchGroup[i].rm_so, matchGroup[i].rm_eo, (int) (matchGroup[i].rm_eo - matchGroup[i].rm_so));
|
||||
strlcpy(match, &aLine[matchGroup[i].rm_so], (size_t) (matchGroup[i].rm_eo - matchGroup[i].rm_so + 1));
|
||||
printf("%s", match);
|
||||
printf("\n");
|
||||
DEBUG_LOG_APPEND(1, "%s", match);
|
||||
DEBUG_LOG_APPEND(1, "\n");
|
||||
}
|
||||
}
|
||||
if (functionEnd)
|
||||
@@ -601,7 +601,9 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
// return evaluated function
|
||||
if (0 == cfile_parser_functionLine)
|
||||
{
|
||||
evaluateParameter(¶meterStorage, cfile_parser_function);
|
||||
evaluateParameter(parameterStorage, cfile_parser_function);
|
||||
free(parameterStorage);
|
||||
parameterStorage = NULL;
|
||||
cfunction_t *funTemp = cfile_parser_function;
|
||||
cfile_parser_function = NULL;
|
||||
return funTemp;
|
||||
|
Reference in New Issue
Block a user