Datasheet

API in C
226
free(szTmpWord);
DEBUG ? printf("word = %s\n", szRetWord) : 0;
return szRetWord;
}
else
{
return NULL;
}
}
/********************************************************************
* Read a sentence from the socket
* A Sentence struct is returned
********************************************************************/
struct Sentence readSentence(int fdSock)
{
struct Sentence stReturnSentence;
char *szWord;
int i=0;
int iReturnLength=0;
DEBUG ? printf("readSentence\n") : 0;
initializeSentence(&stReturnSentence);
while (szWord = readWord(fdSock))
{
addWordToSentence(&stReturnSentence, szWord);
// check to see if we can get a return value from the API
if (strstr(szWord, "!done") != NULL)
{
DEBUG ? printf("return sentence contains !done\n") : 0;
stReturnSentence.iReturnValue = DONE;
}
else if (strstr(szWord, "!trap") != NULL)
{
DEBUG ? printf("return sentence contains !trap\n") : 0;
stReturnSentence.iReturnValue = TRAP;
}
else if (strstr(szWord, "!fatal") != NULL)
{
DEBUG ? printf("return sentence contains !fatal\n") : 0;
stReturnSentence.iReturnValue = FATAL;