Datasheet

API In CPP
129
}
/********************************************************************
* Read Sentence Block from the socket...keeps reading sentences
* until it encounters !done, !trap or !fatal from the socket
********************************************************************/
void MikrotikAPI::ReadBlock(Block &block)
{
Sentence sentence;
block.Clear();
DEBUG ? printf("ReadBlock\n") : 0;
do {
ReadSentence(sentence);
DEBUG ? printf("ReadSentence succeeded.\n") : 0;
block.AddSentence(sentence);
DEBUG ? printf("AddSentenceToBlock succeeded\n") : 0;
} while (sentence.GetReturnType() == NONE);
DEBUG ? printf("ReadBlock completed successfully\n") : 0;
}
/********************************************************************
* MD5 helper function to convert an md5 hex char representation to
* binary representation.
********************************************************************/
string MikrotikAPI::MD5ToBinary(const string &strHex)
{
string strReturn;
// 32 bytes in szHex?
if (strHex.length() != 32) {
return strReturn;
}
char binWork[3];
for (int i = 0; i < 32; i += 2) {
binWork[0] = strHex[i];
binWork[1] = strHex[i + 1];
binWork[2] = 0;
DEBUG ? printf("binWork = %s\n", binWork) : 0;
strReturn[i / 2] = HexStringToChar(binWork);