Commit c06facae authored by nextime's avatar nextime

starting rewrite

parent 8d9b2ff9
......@@ -520,22 +520,18 @@ BYTE DMDomainMatch( BYTE *ControlStr,
BYTE ControlLen)
{
BYTE ControlStatus=DOMAIN_STATUS_HOME;
BYTE ControlIdx=0u;
BYTE ControlStartIdx=0u;
BYTE DomainSaveStatus=DOMAIN_STATUS_HOME;
BYTE DomainStatus=DOMAIN_CYCLE_CONTROL;
BYTE MatchStatus=TRUE;
BYTE MatchIdx=0u;
BYTE MatchIdxSave=0u;
BYTE flag=0u;
BYTE specialflag=DOMAIN_NULL;
BYTE SubStatus=SUB_STATUS_NONE;
BYTE ControlSpecialIdx;
BYTE MatchSpecialIdx;
BYTE ControlIdx=0u;
BYTE mstart=0u;
BYTE cstart=0u;
BYTE mlen=0u;
BYTE clen=0u;
BYTE ctype=DOMAIN_STATUS_HOME;
if(ControlLen > DOMAIN_MAXLEN)
ControlLen=DOMAIN_MAXLEN;
#if defined(__GNUC__)
if(ControlLen==0 || strlen((const char *)MatchStr)==0)
return FALSE;
......@@ -549,946 +545,51 @@ BYTE DMDomainMatch( BYTE *ControlStr,
ControlStr, (unsigned int)DOMAIN_MAXLEN, MatchStr);
#endif
while(ControlLen > ControlIdx || DOMAIN_MAXLEN > MatchIdx)
{
#if defined(__18CXX)
ClrWdt();
#endif
if((ControlIdx >= ControlLen || ControlStatus==DOMAIN_STATUS_END)
&& DomainStatus==DOMAIN_CYCLE_CONTROL)
{
DomainStatus=DOMAIN_CYCLE_MATCH;
DomainSaveStatus=ControlStatus;
ControlStatus=DOMAIN_STATUS_END;
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch: CONTROL STRING IS OVER AT CYCLE START %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
}
#if defined(__18CXX)
if(strlen(MatchStr) <= MatchIdx)
#else
if(strlen((const char *)MatchStr) <= MatchIdx)
#endif
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch: MATCH STRING IS OVER AT CYCLE START %d (%c) %d %d\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx),
(int)strlen((const char *)MatchStr), MatchIdx);
#endif
if(ControlStatus==DOMAIN_STATUS_END
&& (
(DomainStatus==TRUE && ControlIdx==ControlStartIdx)
|| (DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE && ControlIdx!=ControlStartIdx)
|| DomainSaveStatus==DOMAIN_STATUS_STAR
|| DomainSaveStatus==DOMAIN_STATUS_HOME
)
)
{
return TRUE;
}
if (ControlStatus==DOMAIN_STATUS_END
&& DomainStatus==DOMAIN_CYCLE_MATCH)
return MatchStatus;
if(*(ControlStr+ControlIdx)==DOMAIN_SEPARATOR)
return FALSE;
}
if(DomainStatus==DOMAIN_CYCLE_CONTROL)
{
if(MatchStatus==FALSE &&
DomainSaveStatus==DOMAIN_STATUS_STAR)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: Continue for STAR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
SubStatus=STAR_STATUS_CONTINUE;
} else if ( MatchStatus==TRUE )
{
SubStatus=SUB_STATUS_NONE;
}
// execute the Control parse part
switch(*(ControlStr+ControlIdx))
{
case DOMAIN_NULL:
switch(ControlStatus)
{
case DOMAIN_STATUS_HOME:
case DOMAIN_STATUS_STAR:
case DOMAIN_STATUS_LIST_STAR_STOP:
case DOMAIN_STATUS_EQUAL:
case DOMAIN_STATUS_NEGATE_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_END %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
DomainStatus=DOMAIN_CYCLE_MATCH;
DomainSaveStatus=ControlStatus;
ControlStatus=DOMAIN_STATUS_END;
break;
case DOMAIN_STATUS_LIST_STOP:
case DOMAIN_STATUS_LIST_NEGATE_STOP:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_END LIST %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
if(MatchStatus==DOMAIN_STATUS_LIST_TRUE)
{
if(ControlStatus==DOMAIN_STATUS_LIST_STOP)
ControlStartIdx=ControlIdx;
else
ControlStartIdx++;
}
DomainStatus=DOMAIN_CYCLE_MATCH;
DomainSaveStatus=ControlStatus;
ControlStatus=DOMAIN_STATUS_END;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: NULL DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
break;
case DOMAIN_SEPARATOR:
switch(ControlStatus)
{
case DOMAIN_STATUS_STAR:
case DOMAIN_STATUS_LIST_STOP:
case DOMAIN_STATUS_LIST_NEGATE_STOP:
case DOMAIN_STATUS_LIST_STAR_STOP:
case DOMAIN_STATUS_EQUAL:
case DOMAIN_STATUS_NEGATE_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_SEPARATOR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
DomainStatus=DOMAIN_CYCLE_MATCH;
DomainSaveStatus=ControlStatus;
ControlStatus=DOMAIN_STATUS_SEPARATOR;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: SEPARATOR DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
break;
case DOMAIN_STAR:
switch(ControlStatus)
{
case DOMAIN_STATUS_HOME:
case DOMAIN_STATUS_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_STAR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_STAR;
break;
case DOMAIN_STATUS_LIST_START:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_STAR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_STAR;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: STAR DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
break;
case DOMAIN_NEGATION:
switch(ControlStatus)
if(ControlIdx==0u || *(ControlStr+ControlIdx-1)==DOMAIN_SEPARATOR)
{
case DOMAIN_STATUS_HOME:
case DOMAIN_STATUS_SEPARATOR:
ControlStatus=DOMAIN_STATUS_NEGATE;
ControlStartIdx=ControlIdx+1u;
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_NEGATE %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: NEGATION DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
break;
case DOMAIN_LIST_START:
switch(ControlStatus)
{
case DOMAIN_STATUS_HOME:
case DOMAIN_STATUS_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_START %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStartIdx=ControlIdx+1u;
ControlStatus=DOMAIN_STATUS_LIST_START;
break;
case DOMAIN_STATUS_NEGATE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_NEGATE_START %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStartIdx=ControlIdx+1u;
ControlStatus=DOMAIN_STATUS_LIST_NEGATE_START;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: LIST_START DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
MatchStatus=FALSE;
SubStatus=LIST_STATUS_START;
break;
case DOMAIN_LIST_STOP:
switch(ControlStatus)
{
case DOMAIN_STATUS_LIST_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_STOP %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_STOP;
break;
case DOMAIN_STATUS_LIST_STAR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_STAR_STOP %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_STAR_STOP;
break;
case DOMAIN_STATUS_LIST_NEGATE_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_NEGATE_STOP %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_NEGATE_STOP;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: LIST_STOP_DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
ctype=DOMAIN_STATUS_NEGATE;
} else {
ctype=DOMAIN_STATUS_END;
DomainStatus==DOMAIN_CYCLE_MATCH;
}
break;
case DOMAIN_LIST_SEPARATOR:
switch(ControlStatus)
case DOMAIN_LIST_START:
if(ControlIdx==0u || *(ControlStr+ControlIdx-1)==DOMAIN_SEPARATOR)
{
case DOMAIN_STATUS_LIST_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_SEPARATOR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_SEPARATOR;
if(MatchStatus==DOMAIN_STATUS_LIST_TRUE)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST ALREADY TRUE AT SEPARATOR\n");
#endif
SubStatus=SUB_STATUS_NONE;
} else {
DomainSaveStatus=ControlStatus;
DomainStatus=DOMAIN_CYCLE_MATCH;
}
break;
case DOMAIN_STATUS_LIST_NEGATE_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_NEGATE_SEPARATOR %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx));
#endif
ControlStatus=DOMAIN_STATUS_LIST_NEGATE_SEPARATOR;
if(MatchStatus==DOMAIN_STATUS_LIST_TRUE)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_NEGATE_LIST ALREADY TRUE AT SEPARATOR\n");
#endif
SubStatus=SUB_STATUS_NONE;
} else {
DomainSaveStatus=ControlStatus;
DomainStatus=DOMAIN_CYCLE_MATCH;
}
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: LIST_SEPARATOR DEFAULT %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
return FALSE;
ctype=DOMAIN_STATUS_LIST_START;
} else if(ControlIdx>0u && *(ControlStr+ControlIdx-1)==DOMAIN_NEGATION) {
ctype=DOMAIN_STATUS_LIST_NEGATE_START;
} else {
ctype=DOMAIN_STATUS_END;
}
break;
default:
switch(ControlStatus)
{
case DOMAIN_STATUS_HOME:
case DOMAIN_STATUS_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_EQUAL %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
ControlStatus=DOMAIN_STATUS_EQUAL;
ControlStartIdx=ControlIdx;
break;
case DOMAIN_STATUS_LIST_START:
case DOMAIN_STATUS_LIST_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_PARSE %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
ControlStatus=DOMAIN_STATUS_LIST_PARSE;
break;
case DOMAIN_STATUS_NEGATE:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_NEGATE_PARSE %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
ControlStatus=DOMAIN_STATUS_NEGATE_PARSE;
break;
case DOMAIN_STATUS_LIST_NEGATE_START:
case DOMAIN_STATUS_LIST_NEGATE_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DOMAIN_STATUS_LIST_NEGATE_PARSE %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
ControlStatus=DOMAIN_STATUS_LIST_NEGATE_PARSE;
break;
case DOMAIN_STATUS_LIST_NEGATE_PARSE:
case DOMAIN_STATUS_NEGATE_PARSE:
case DOMAIN_STATUS_LIST_PARSE:
case DOMAIN_STATUS_EQUAL:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: CHAR PARSE %d (%c)\n",
ControlIdx, (unsigned int)*(ControlStr+ControlIdx) );
#endif
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Control: DEFAULT DEFAULT %d (%c)\n", ControlIdx,
(unsigned int)*(ControlStr+ControlIdx));
#endif
return FALSE;
}
}
} else {
if(DomainStatus==DOMAIN_CYCLE_MATCH)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("ENTERING MATCH CYCLE %d\n", DomainSaveStatus);
#endif
flag=FALSE;
MatchStatus=FALSE;
if(DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE
|| DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_SEPARATOR
|| DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP)
DomainStatus=FALSE;
else
DomainStatus=TRUE;
if(SubStatus==STAR_STATUS_CONTINUE)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("SAVING ControlStartIdx cause of STAR CONTINUE STATUS\n");
#endif
switch(DomainSaveStatus)
{
case DOMAIN_STATUS_LIST_NEGATE_STOP:
case DOMAIN_STATUS_LIST_NEGATE_SEPARATOR:
#if defined(__GNUC__) && defined(DEBUG)
printf("NEGATION LIST PRECEEDED BY A STAR\n");
#endif
case DOMAIN_STATUS_NEGATE_PARSE:
#if defined(__GNUC__) && defined(DEBUG)
printf("NEGATION PRECEEDED BY A STAR: SPECIAL CASE\n");
#endif
/*
- Count how many levels remain after the negation
on the control string
- count how many levels we have in the match string
to be parsed
- check if the negation string appears in the
difference between the control and the match remaining
levels, assuming the first is more than the second.
at this point, if the result is found, return FALSE,
if the result isn't found, continue as usual.
*/
// Count how many levels there are in the Match string
// staring from one as we are at the next level compared
// comparing to the control
SubStatus=1;
MatchSpecialIdx=MatchIdx;
while(MatchSpecialIdx<DOMAIN_MAXLEN)
{
if(*(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR)
{
SubStatus++;
} else if(*(MatchStr+MatchSpecialIdx)==DOMAIN_NULL)
break;
MatchSpecialIdx++;
}
// Substract the Control levels remaining after the negation
ControlSpecialIdx=ControlIdx;
specialflag=SubStatus;
while(ControlSpecialIdx<ControlLen)
{
if(!SubStatus)
break;
if(*(ControlStr+ControlSpecialIdx)==DOMAIN_SEPARATOR)
{
SubStatus--;
}
ControlSpecialIdx++;
}
#if defined(__GNUC__) && defined(DEBUG)
printf("check negation for %d levels \n", SubStatus);
#endif
if(specialflag==SubStatus &&
(DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE ||
DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP))
{
// a special case in the special case.
// The negation is at the last level in the control string.
#if defined(__GNUC__) && defined(DEBUG)
printf("NEGATION IS IN THE LAST CONTROL LEVEL\n");
#endif
DomainSaveStatus=DOMAIN_STATUS_STAR_NEGATION_END;
}
// match all levels we have to check for negation
ControlSpecialIdx=ControlStartIdx;
MatchSpecialIdx=MatchIdx;
MatchStatus=TRUE;
specialflag=SubStatus;
while(SubStatus)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("level %d: %c - %c\n", SubStatus,
(unsigned int)*(ControlStr+ControlSpecialIdx),
(unsigned int)*(MatchStr+MatchSpecialIdx));
#endif
if(*(ControlStr+ControlSpecialIdx)==DOMAIN_SEPARATOR
|| *(ControlStr+ControlSpecialIdx)==DOMAIN_NULL
|| ControlSpecialIdx>=ControlLen
|| *(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_SEPARATOR
|| *(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_STOP
|| *(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR
|| *(MatchStr+MatchSpecialIdx)==DOMAIN_NULL
|| MatchSpecialIdx>=DOMAIN_MAXLEN)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("level separator or terminator found\n");
#endif
if(MatchStatus
&& (
(
(*(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR
|| *(MatchStr+MatchSpecialIdx)==DOMAIN_NULL
|| MatchSpecialIdx>DOMAIN_MAXLEN)
&& (*(ControlStr+ControlSpecialIdx)==DOMAIN_SEPARATOR
|| *(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_SEPARATOR
|| *(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_STOP))
||
(SubStatus<=1 &&
(*(ControlStr+ControlSpecialIdx)==DOMAIN_NULL
|| ControlSpecialIdx>=ControlLen)
)
)
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("NEGATION MATCH FOUND!\n");
#endif
return FALSE;
}
else
{
if((*(ControlStr+ControlSpecialIdx)==DOMAIN_NULL
|| ControlSpecialIdx>=ControlLen)
&& SubStatus<=1)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("NEGATION MATCH NOT FOUND AND CONTROL END!\n");
#endif
return TRUE;
}
MatchStatus=TRUE;
}
ControlSpecialIdx=ControlStartIdx;
SubStatus--;
if(*(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR)
MatchSpecialIdx++;
else
{
// Move Match cursor to the next level
while(TRUE)
{
if(*(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR)
{
MatchSpecialIdx++;
break;
} else if(*(MatchStr+MatchSpecialIdx)==DOMAIN_NULL
|| MatchSpecialIdx>=DOMAIN_MAXLEN)
{
break;
}
MatchSpecialIdx++;
}
}
} else {
if(*(MatchStr+MatchSpecialIdx)!=*(ControlStr+ControlSpecialIdx)
&& MatchStatus==TRUE)
MatchStatus=FALSE;
ControlSpecialIdx++;
MatchSpecialIdx++;
}
if(!SubStatus
&& (DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_SEPARATOR
|| DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP
)
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("Manage NEGATION LIST\n");
#endif
ControlSpecialIdx=ControlStartIdx;
while(TRUE)
{
if(*(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_SEPARATOR)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("LIST SEPARATOR, continue with negation list\n");
#endif
SubStatus=specialflag;
MatchSpecialIdx=MatchIdx;
ControlSpecialIdx++;
break;
}
if(*(ControlStr+ControlSpecialIdx)==DOMAIN_LIST_STOP)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("LIST STOP, done negation list\n");
#endif
ControlSpecialIdx++;
DomainSaveStatus=DOMAIN_STATUS_LIST_NEGATE_STOP;
break;
}
ControlSpecialIdx++;
}
//MatchSpecialIdx=MatchIdx;
if(ControlSpecialIdx>=ControlLen || *(ControlStr+ControlSpecialIdx)==DOMAIN_NULL)
DomainSaveStatus=DOMAIN_STATUS_STAR_NEGATION_END;
//else if(*(ControlStr+ControlSpecialIdx)==DOMAIN_SEPARATOR)
// ControlSpecialIdx++;
ControlStartIdx=ControlSpecialIdx;
ControlIdx=ControlSpecialIdx;
// NEXTIME
}
}
if(DomainSaveStatus==DOMAIN_STATUS_STAR_NEGATION_END)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("CONTROL LAST LEVEL AND CONTROL END\n");
#endif
return TRUE;
}
// If we are here the special case is over,
// and we don't have a match.
// So, we must continue to the next level!
// Move MatchIdx to the right level
#if defined(__GNUC__) && defined(DEBUG)
printf("SPECIAL CASE IS OVER, MOVING INDICES TO GO BACK IN NORMAL MODE (%c)\n",
(unsigned int)*(ControlStr+ControlSpecialIdx));
#endif
while(TRUE)
{
if(MatchSpecialIdx==0
|| *(MatchStr+MatchSpecialIdx)==DOMAIN_SEPARATOR)
break;
MatchSpecialIdx--;
}
MatchIdx=MatchSpecialIdx;
SubStatus=SUB_STATUS_NONE;
specialflag=ControlSpecialIdx;
MatchStatus=FALSE;
ControlStatus=DOMAIN_STATUS_SEPARATOR;
break;
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("NOT A SPECIAL CASE %d %d %d %d\n", ControlIdx, MatchIdx, ControlStartIdx, MatchSpecialIdx);
#endif
// Isn't a special case!
MatchStatus=FALSE;
specialflag=ControlStartIdx;
MatchIdxSave=MatchIdx;
//MatchIdx=MatchSpecialIdx;
}
} //else if(SubStatus==LIST_STATUS_START)
if(SubStatus==LIST_STATUS_START)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("SAVING MatchIdx cause of LIST_START STATUS\n");
#endif
//SubStatus=MatchIdx;
MatchIdxSave=MatchIdx;
}
}
// execute the Match parse part
switch(*(MatchStr+MatchIdx))
{
case DOMAIN_SEPARATOR:
if((ControlStatus==DOMAIN_STATUS_SEPARATOR && DomainStatus==TRUE)
|| (DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE && ControlIdx!=ControlStartIdx)
|| (DomainSaveStatus==DOMAIN_STATUS_STAR)
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: TRUE SEPARATOR %d %d %d \n", DomainStatus,
ControlStatus, DomainSaveStatus);
#endif
if(DomainSaveStatus==DOMAIN_STATUS_STAR)
MatchStatus=FALSE;
else
{
if(ControlStartIdx!=ControlIdx && DomainSaveStatus==DOMAIN_STATUS_EQUAL)
{
return FALSE;
}
MatchStatus=TRUE;
}
MatchIdx++;
DomainStatus=DOMAIN_CYCLE_CONTROL;
break;
} else if(DomainStatus==TRUE
&& ((DomainSaveStatus==DOMAIN_STATUS_LIST_SEPARATOR
&& ControlIdx==ControlStartIdx)
|| ( DomainSaveStatus==DOMAIN_STATUS_LIST_STOP
&& ControlIdx==ControlStartIdx+1u)))
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: LIST SEPARATOR/STOP TRUE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
if(*(ControlStr+ControlIdx)==DOMAIN_NULL
|| ControlIdx>=DOMAIN_MAXLEN) // XXX Uhmmm isn't there a better way?
return FALSE;
MatchStatus=DOMAIN_STATUS_LIST_TRUE;
DomainStatus=DOMAIN_CYCLE_CONTROL;
break;
} else if((DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_SEPARATOR
&& (DomainStatus==TRUE || ControlIdx!=ControlStartIdx))
|| (DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP
&& (DomainStatus==TRUE || ControlIdx!=ControlStartIdx+1u))
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: SEPARATOR LIST SEPARATOR/STOP TRUE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
if(*(ControlStr+ControlIdx)==DOMAIN_NULL
|| ControlIdx>=DOMAIN_MAXLEN) // XXX Uhmmm isn't there a better way?
return FALSE;
DomainStatus=DOMAIN_CYCLE_CONTROL;
if(DomainSaveStatus!=DOMAIN_STATUS_LIST_NEGATE_STOP)
MatchIdx=MatchIdxSave;
else
MatchIdx++;
ControlStartIdx++;
break;
} else if(ControlStatus==DOMAIN_STATUS_LIST_SEPARATOR)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: SEPARATOR LIST SEPARATOR FALSE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
MatchIdx=MatchIdxSave;
DomainStatus=DOMAIN_CYCLE_CONTROL;
ControlStartIdx=ControlIdx+1u;
break;
} else if(SubStatus==STAR_STATUS_CONTINUE)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: FALSE SEPARATOR BUT STAR %d %d %d \n", DomainStatus,
ControlStatus, DomainSaveStatus);
#endif
MatchStatus=FALSE;
ControlStartIdx=specialflag;
if(DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE)
DomainStatus=FALSE;
else
DomainStatus=TRUE;
break;
}
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: FALSE SEPARATOR %d %d %d %d %d %d %d\n", DomainStatus,
ControlStatus, DomainSaveStatus, SubStatus, ControlIdx, ControlStartIdx, MatchIdx);
#endif
return FALSE;
case DOMAIN_NULL:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: NULL %d %d %d %d %d %d %d\n",
DomainStatus, ControlStatus, DomainSaveStatus, SubStatus,
ControlIdx, ControlStartIdx, MatchIdx);
#endif
if(ControlStatus==DOMAIN_STATUS_END
&& (
(DomainStatus==TRUE && ControlIdx==ControlStartIdx)
|| (DomainSaveStatus==DOMAIN_STATUS_NEGATE_PARSE && ControlIdx!=ControlStartIdx)
|| DomainSaveStatus==DOMAIN_STATUS_STAR
|| DomainSaveStatus==DOMAIN_STATUS_HOME
)
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: NULL TRUE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
return TRUE;
} else if(DomainStatus==TRUE
&& ((DomainSaveStatus==DOMAIN_STATUS_LIST_SEPARATOR
&& ControlIdx==ControlStartIdx)
|| ( DomainSaveStatus==DOMAIN_STATUS_LIST_STOP
&& ControlIdx==ControlStartIdx+1u)))
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: NULL LIST SEPARATOR/STOP TRUE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
if(*(ControlStr+ControlIdx)==DOMAIN_NULL
|| ControlIdx>=DOMAIN_MAXLEN) // XXX Uhmmm isn't there a better way?
return TRUE;
MatchStatus=DOMAIN_STATUS_LIST_TRUE;
DomainStatus=DOMAIN_CYCLE_CONTROL;
break;
} else if((DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_SEPARATOR
&& (DomainStatus==TRUE || ControlIdx!=ControlStartIdx))
|| (DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP
&& (DomainStatus==TRUE || ControlIdx!=ControlStartIdx+1u))
)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: NULL LIST NEGATE SEPARATOR TRUE %d %d %d %d %d\n",
ControlStartIdx, ControlIdx, DomainSaveStatus, DomainStatus, MatchIdx);
#endif
if((*(ControlStr+ControlIdx)==DOMAIN_NULL || ControlIdx>=DOMAIN_MAXLEN)
&& DomainSaveStatus==DOMAIN_STATUS_LIST_NEGATE_STOP)
{
return TRUE;
}
//MatchStatus=DOMAIN_STATUS_LIST_TRUE;
DomainStatus=DOMAIN_CYCLE_CONTROL;
ControlStartIdx++;
if(DomainSaveStatus!=DOMAIN_STATUS_LIST_NEGATE_STOP)
MatchIdx=MatchIdxSave;
break;
} else if(ControlStatus==DOMAIN_STATUS_LIST_SEPARATOR)
{
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: NULL LIST SEPARATOR FALSE %d %d %d %d\n", DomainStatus,
ControlIdx, ControlStartIdx, DomainSaveStatus);
#endif
MatchIdx=MatchIdxSave;
DomainStatus=DOMAIN_CYCLE_CONTROL;
ControlStartIdx=ControlIdx+1u;
break;
}
return FALSE;
case DOMAIN_STAR:
case DOMAIN_NEGATION:
case DOMAIN_LIST_START:
case DOMAIN_LIST_SEPARATOR:
case DOMAIN_LIST_STOP:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: INVALID CHAR %d\n", DomainStatus);
#endif
return FALSE;
default:
switch(DomainSaveStatus)
{
case DOMAIN_STATUS_LIST_STOP:
case DOMAIN_STATUS_LIST_SEPARATOR:
case DOMAIN_STATUS_EQUAL:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: DEFAULT STATUS_EQUAL %d (%c) - %d (%c)\n", MatchIdx,
(unsigned int)*(MatchStr+MatchIdx),
ControlStartIdx, (unsigned int)*(ControlStr+ControlStartIdx));
#endif
if(*(MatchStr+MatchIdx)!=*(ControlStr+ControlStartIdx))
DomainStatus=FALSE;
//MatchStatus=FALSE;
ControlStartIdx++;
if(MatchIdx>=DOMAIN_MAXLEN-1)
{
if(DomainStatus==TRUE)
MatchStatus=TRUE;
}
break;
case DOMAIN_STATUS_LIST_NEGATE_STOP:
case DOMAIN_STATUS_LIST_NEGATE_SEPARATOR:
case DOMAIN_STATUS_NEGATE_PARSE:
if( ControlStartIdx>2u
&& DomainSaveStatus!=DOMAIN_STATUS_NEGATE_PARSE
&& (*(ControlStr+ControlStartIdx-2u)==DOMAIN_LIST_SEPARATOR
|| *(ControlStr+ControlStartIdx-2u)==DOMAIN_LIST_SEPARATOR)
&& flag==FALSE)
{
ControlStartIdx--;
}
if(DomainSaveStatus!=DOMAIN_STATUS_NEGATE_PARSE)
flag=TRUE;
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: DEFAULT STATUS_NEGATE_PARSE %d (%c) - %d (%c)\n",
MatchIdx, (unsigned int)*(MatchStr+MatchIdx),
ControlStartIdx, (unsigned int)*(ControlStr+ControlStartIdx));
#endif
if(*(MatchStr+MatchIdx)!=*(ControlStr+ControlStartIdx))
{
DomainStatus=TRUE;
if(ControlStartIdx>=ControlLen)
MatchStatus=TRUE;
}
ControlStartIdx++;
break;
case DOMAIN_STATUS_STAR:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: DEFAULT STATUS_STAR %d (%c)- %d (%c)\n",
MatchIdx, (unsigned int)*(MatchStr+MatchIdx),
ControlStartIdx, (unsigned int)*(ControlStr+ControlStartIdx));
#endif
DomainStatus=TRUE;
MatchStatus=FALSE;
if(ControlStatus==DOMAIN_STATUS_END)
return TRUE;
ControlStartIdx++;
break;
case DOMAIN_STATUS_LIST_STAR_STOP:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: DEFAULT LIST_STAR_STOP %d (%c)- %d (%c)\n",
MatchIdx, (unsigned int)*(MatchStr+MatchIdx),
ControlStartIdx, (unsigned int)*(ControlStr+ControlStartIdx));
#endif
if(ControlStatus==DOMAIN_STATUS_END)
return TRUE;
MatchStatus=TRUE;
break;
/*
case DOMAIN_STATUS_LIST_NEGATE_STOP:
*/
default:
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch Match: DEFAULT DEFAULT %d (%c) - %d (%c)\n",
MatchIdx, (unsigned int)*(MatchStr+MatchIdx),
ControlStartIdx, (unsigned int)*(ControlStr+ControlStartIdx));
#endif
return FALSE;
}
clen++;
}
}
if(DomainStatus==DOMAIN_CYCLE_CONTROL)
ControlIdx++;
else if(DomainStatus!=DOMAIN_CYCLE_MATCH)
}
else if(DomainStatus==DOMAIN_CYCLE_MATCH)
{
MatchIdx++;
}
}
#if defined(__GNUC__) && defined(DEBUG)
printf("DMDomainMatch RETURN OUTSIDE MAIN LOOP\n");
printf("DMDomainMatch RETURN OUTSIDE LOOP\n");
#endif
return MatchStatus;
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment