Example #1
0
void NetMessage::putUInt16(uint16_t value) {
	uint16_t net;
	uint8_t* dummy;
	net = htons(value);
	dummy = (uint8_t*)&net;
	putUInt8(dummy[0]);
	putUInt8(dummy[1]);
}
Example #2
0
void NetMessage::putUInt32(uint32_t value) {
	uint32_t net;
	uint8_t* dummy;
	net = htonl(value);
	dummy = (uint8_t*)&net;
	putUInt8(dummy[0]);
	putUInt8(dummy[1]);
	putUInt8(dummy[2]);
	putUInt8(dummy[3]);
}
Example #3
0
void NetMessage::putString(const std::string &value) {
	unsigned strSize = value.size();
	unsigned i;
	putUInt32(strSize);
	for (i = 0; i < strSize; i++) {
		putUInt8(value.c_str()[i]);
	}
}
Example #4
0
void MtpDataPacket::putString(const uint16_t* string) {
    int count = 0;
    for (int i = 0; i < 256; i++) {
        if (string[i])
            count++;
        else
            break;
    }
    putUInt8(count > 0 ? count + 1 : 0);
    for (int i = 0; i < count; i++)
        putUInt16(string[i]);
    // only terminate with zero if string is not empty
    if (count > 0)
        putUInt16(0);
}
Example #5
0
NetMessage::NetMessage(NetMessage* src) {
	unsigned i;
	unsigned srcBufferSize;
	uint8_t* srcBuffer;

	mem = NULL;
	memSize = 0;
	readOffset = 0;

	srcBufferSize = src->getBufferSize();
	srcBuffer = src->getBufferPointer();

	for (i = 0; i < srcBufferSize; i++) {
		putUInt8(srcBuffer[i]);
	}

	readOffset = src->readOffset; // see doc for OSG::BinaryMessage
}
Example #6
0
void MtpDataPacket::putAUInt8(const uint8_t* values, int count) {
    putUInt32(count);
    for (int i = 0; i < count; i++)
        putUInt8(*values++);
}