- SI->Log(DEBUG,"We dont yet have an expected amount");
- /* We have enough to read an int */
- char sz[4];
- for (int i = 0; i < 4; i++)
- {
- sz[i] = buffer.front();
- buffer.pop_front();
- }
- int* size = (int*)sz;
- amount_expected = ntohl(*size);
- SI->Log(DEBUG,"Expected amount is %d", amount_expected);
+ /* We have enough to read an int -
+ * Yes, this is safe, but its ugly. Give me
+ * a nicer way to read 4 bytes from a binary
+ * stream, and push them into a 32 bit int,
+ * and i'll consider replacing this.
+ */
+ amount_expected = ntohl((buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0]);
+ buffer = buffer.substr(4);