mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Remove stale CSrvPackBuffer code
This commit is contained in:
@ -783,119 +783,3 @@ void NetVaultNode::SetBlob_1 (const uint8_t v[], uint32_t len) {
|
||||
void NetVaultNode::SetBlob_2 (const uint8_t v[], uint32_t len) {
|
||||
IVaultNodeSetBlob(kBlob_2, &blob_2, &blob_2Length, v, len);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CSrvPackBuffer
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
CSrvPackBuffer::CSrvPackBuffer (unsigned bytes) {
|
||||
m_data = (uint8_t *)malloc(bytes);
|
||||
m_pos = m_data;
|
||||
m_end = m_pos + bytes;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void * CSrvPackBuffer::Alloc (unsigned bytes) {
|
||||
ASSERT((signed) bytes >= 0);
|
||||
ASSERT(m_pos + bytes <= m_end);
|
||||
|
||||
uint8_t * pos = m_pos;
|
||||
m_pos += bytes;
|
||||
return pos;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CSrvPackBuffer::AddData (const void * ptr, unsigned bytes) {
|
||||
memcpy(Alloc(bytes), ptr, bytes);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CSrvPackBuffer::AddString (const wchar_t str[]) {
|
||||
AddData(str, StrBytes(str));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CSrvPackBuffer::AddDWordArray (const uint32_t * arr, unsigned count) {
|
||||
// Don't let large counts cause pointer wrap
|
||||
count &= 0x00ffffff;
|
||||
AddData(arr, count * sizeof(arr[0]));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
unsigned CSrvPackBuffer::Size () {
|
||||
return m_pos - m_data;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CSrvUnpackBuffer
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
CSrvUnpackBuffer::CSrvUnpackBuffer (const void * buffer, unsigned count) {
|
||||
m_pos = (const uint8_t *) buffer;
|
||||
m_end = m_pos + count;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
const void * CSrvUnpackBuffer::GetData (unsigned bytes) {
|
||||
for (;;) {
|
||||
const uint8_t * result = m_pos;
|
||||
m_pos += bytes;
|
||||
|
||||
if (m_pos < result)
|
||||
break;
|
||||
if (m_pos > m_end)
|
||||
break;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
m_end = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
const wchar_t * CSrvUnpackBuffer::GetString () {
|
||||
|
||||
if (m_end) {
|
||||
const wchar_t * end = (const wchar_t *) (m_end - sizeof(wchar_t) + 1);
|
||||
for (const wchar_t * cur = (const wchar_t *) m_pos; cur < end; ) {
|
||||
if (*cur++)
|
||||
continue;
|
||||
|
||||
const wchar_t * pos = (const wchar_t *) m_pos;
|
||||
m_pos = (const uint8_t *) cur;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
m_end = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
const uint32_t * CSrvUnpackBuffer::GetDWordArray (unsigned count) {
|
||||
// Don't let large counts cause pointer wrap
|
||||
if (count & 0x00ffffff)
|
||||
return (const uint32_t *)GetData(count * sizeof(uint32_t));
|
||||
|
||||
m_end = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
unsigned CSrvUnpackBuffer::BytesLeft () {
|
||||
return m_end ? m_end - m_pos : 0;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool CSrvUnpackBuffer::ParseError () {
|
||||
return !m_end;
|
||||
}
|
||||
|
@ -417,51 +417,3 @@ struct NetVaultNodeRef {
|
||||
bool seen;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//============================================================================
|
||||
// SrvPackBuffer
|
||||
//============================================================================
|
||||
|
||||
// Allocate a CSrvPackBuffer on the heap with one extra uint32_t to allow for padding
|
||||
#define SRV_ALLOC_BUFFER(bytes) \
|
||||
new(malloc(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \
|
||||
CSrvPackBuffer(bytes + sizeof(uint32_t))
|
||||
|
||||
// Allocate a CSrvPackBuffer on the stack with one extra uint32_t to allow for padding
|
||||
#define SRV_ALLOCA_BUFFER(bytes) \
|
||||
new(_alloca(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \
|
||||
CSrvPackBuffer(bytes + sizeof(uint32_t))
|
||||
|
||||
class CSrvPackBuffer {
|
||||
public:
|
||||
CSrvPackBuffer (unsigned bytes);
|
||||
|
||||
void * Alloc (unsigned bytes);
|
||||
void AddData (const void * ptr, unsigned bytes);
|
||||
void AddString (const wchar_t str[]);
|
||||
void AddDWordArray (const uint32_t * arr, unsigned count);
|
||||
// add new "Add..." methods here as needed
|
||||
|
||||
unsigned Size ();
|
||||
|
||||
private:
|
||||
uint8_t * m_pos;
|
||||
uint8_t * m_end;
|
||||
uint8_t * m_data;
|
||||
};
|
||||
|
||||
class CSrvUnpackBuffer {
|
||||
public:
|
||||
CSrvUnpackBuffer (const void * buffer, unsigned count);
|
||||
|
||||
const void * GetData (unsigned bytes);
|
||||
const wchar_t * GetString ();
|
||||
const uint32_t * GetDWordArray (unsigned count);
|
||||
|
||||
unsigned BytesLeft ();
|
||||
bool ParseError ();
|
||||
|
||||
private:
|
||||
const uint8_t * m_pos;
|
||||
const uint8_t * m_end;
|
||||
};
|
||||
|
Reference in New Issue
Block a user