bool skipBox(FILE * newData) { char readVal[16]; long long unsigned int pos = ftell(newData); if (fread(readVal, 4, 1, newData)) { uint64_t size = calcBoxSize(readVal); if (size == 1) { if (fread(readVal + 4, 12, 1, newData)) { size = 0 + ntohl(((int *)readVal)[2]); size <<= 32; size += ntohl(((int *)readVal)[3]); } else { return false; } } else if (size == 0) { fseek(newData, 0, SEEK_END); return true; } DONTEVEN_MSG("skipping size 0x%.8lX", size); if (fseek(newData, pos + size, SEEK_SET) == 0) { return true; } else { return false; } } else { return false; } }
/// Appends this data block to the internal std::deque of std::string objects. /// It is automatically split every BUFFER_BLOCKSIZE bytes. void Socket::Buffer::append(const char * newdata, const unsigned int newdatasize) { unsigned int i = 0, j = 0; while (i < newdatasize) { j = i; while (j < newdatasize && j - i <= BUFFER_BLOCKSIZE) { j++; if (newdata[j - 1] == '\n') { break; } } if (i != j) { DONTEVEN_MSG("Adding a block of size %d", j-i); data.push_front(std::string(newdata + i, (size_t)(j - i))); i = j; } else { break; } } if (data.size() > 5000) { DEBUG_MSG(DLVL_WARN, "Warning: After %d new bytes, buffer has %d parts containing over %u bytes!", newdatasize, (int)data.size(), bytes(9000)); } }