Audiovox P965 Arkusz Danych Strona 126

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 280
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 125
API In CPP
123
DEBUG ? writeSentence.Print() : 0;
WriteSentence(writeSentence);
ReadSentence(readSentence);
DEBUG ? readSentence.Print() : 0;
if (readSentence.GetReturnType() == DONE) {
return 1;
}
}
return 0;
}
/********************************************************************
* Encode message length and write it out to the socket
********************************************************************/
void MikrotikAPI::WriteLength(int messageLength)
{
char *encodedLengthData; // encoded length to send to the api socket
char *lengthData; // exactly what is in memory at &iLen integer
encodedLengthData = (char *)calloc(sizeof(int), 1);
// set cLength address to be same as messageLength
lengthData = (char *)&messageLength;
DEBUG ? printf("Length of word is %d\n", messageLength) : 0;
// write 1 byte
if (messageLength < 0x80) {
encodedLengthData[0] = (char)messageLength;
write (fdSock, encodedLengthData, 1);
} else if (messageLength < 0x4000) { // write 2 bytes
DEBUG ? printf("messageLength < 0x4000.\n") : 0;
if (littleEndian) {
encodedLengthData[0] = lengthData[1] | 0x80;
encodedLengthData[1] = lengthData[0];
} else {
encodedLengthData[0] = lengthData[2] | 0x80;
encodedLengthData[1] = lengthData[3];
}
write (fdSock, encodedLengthData, 2);
} else if (messageLength < 0x200000) { // write 3 bytes
DEBUG ? printf("messageLength < 0x200000.\n") : 0;
Przeglądanie stron 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 279 280

Komentarze do niniejszej Instrukcji

Brak uwag