|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflstr.h"
int
istoken (
char **strLine,
const char *strtoken,
int *iWasToken)
Eats strToEat from strBuff only if it begins with contents of strToEat, and returns a 0 or 1 to tell what it did.
char strBuff[] = { "select * from mytbl;" };
int iWasToken;
istoken (&strBuff, "SELECT", &iWasToken);
On return here iWasToken would == 1, and strBuff would be:
" * from mytbl;"
If the token is not found, then strBuff will not be affected, and
a 0 will be returned.
Submitted by Scott Beasley <jscottb@infoave.com>
{
int iRet;
char cChar;
ASSERT (strLine);
ASSERT (strtoken);
ASSERT (iWasToken);
iRet = lexncmp (*strLine, strtoken, strlen (strtoken));
if (!iRet)
{
cChar = *(*strLine + strlen (strtoken));
if (!isalpha ((int)cChar)&& cChar != '_')
{
iRet = *iWasToken = 1;
strcpy (*strLine, (*strLine + strlen (strtoken)));
}
else
iRet = *iWasToken = 0;
}
else
iRet = *iWasToken = 0;
return iRet;
}
| | << | < | > | >> |
|