Datasheet

API In CPP
128
// deallocate szTmpWord
delete [] tmpWord;
DEBUG ? printf("Word = %s\n", strWordOut.c_str()) : 0;
}
}
/********************************************************************
* Read a Sentence from the socket
* A Sentence struct is returned
********************************************************************/
void MikrotikAPI::ReadSentence(Sentence &sentenceOut)
{
DEBUG ? printf("ReadSentence\n") : 0;
sentenceOut.Clear();
string strWord;
ReadWord(strWord);
while (!strWord.empty()) {
sentenceOut.AddWord(strWord);
// check to see if we can get a return value from the API
if (strWord.find("!done") != string::npos) {
DEBUG ? printf("return Sentence contains !done\n") : 0;
sentenceOut.SetReturnType(DONE);
} else if (strWord.find("!trap") != string::npos) {
DEBUG ? printf("return Sentence contains !trap\n") : 0;
sentenceOut.SetReturnType(TRAP);
} else if (strWord.find("!fatal") != string::npos) {
DEBUG ? printf("return Sentence contains !fatal\n") : 0;
sentenceOut.SetReturnType(FATAL);
}
ReadWord(strWord);
}
// if any errors, get the next sentence
if (sentenceOut.GetReturnType() == TRAP || sentenceOut.GetReturnType() == FATAL) {
ReadSentence(sentenceOut);
}
if (DEBUG) {
for (int i = 0; i < sentenceOut.Length(); ++i) {
printf("stReturnSentence.szSentence[%d] = %s\n", i, sentenceOut[i].c_str());
}
}