Datasheet

API in C using winsock
68
// 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;
}
}
// if any errors, get the next sentence
if (stReturnSentence.iReturnValue == TRAP || stReturnSentence.iReturnValue == FATAL)
{
readSentence(fdSock);
}
if (DEBUG)
{
for (i=0; i<stReturnSentence.iLength; i++)
{
printf("stReturnSentence.szSentence[%d] = %s\n", i, stReturnSentence.szSentence[i]);
}
}
return stReturnSentence;
}
/********************************************************************
* Read sentence block from the socket...keeps reading sentences
* until it encounters !done, !trap or !fatal from the socket
********************************************************************/
struct Block readBlock(int fdSock)
{
struct Sentence stSentence;
struct Block stBlock;
initializeBlock(&stBlock);