| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 1.91

 

istoken

#include "sflstr.h"
int
istoken (
    char **strLine,
    const char *strtoken,
    int *iWasToken)

Synopsis

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

Source Code - (sflstr.c)

{
   int iRet;
   char cChar;

   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;
}

| << | < | > | >> iMatix Copyright © 1996-98 iMatix