Added big endian support for R5 messages, minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15804 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-01-03 09:21:35 +00:00
parent f4a73641e0
commit 5c7f87685e
4 changed files with 12 additions and 9 deletions

View File

@ -92,13 +92,13 @@ BPrivate::dano_message_flattened_size(const char *buffer)
status_t
BPrivate::unflatten_dano_message(uint32 magic, BDataIO &stream,
BPrivate::unflatten_dano_message(uint32 format, BDataIO &stream,
BMessage &message)
{
TReadHelper reader(&stream);
message.MakeEmpty();
if (magic == kMessageFormatSwapped)
if (format == kMessageFormatSwapped)
reader.SetSwap(true);
ssize_t size;

View File

@ -17,7 +17,7 @@ class BDataIO;
namespace BPrivate {
status_t unflatten_dano_message(uint32 magic, BDataIO& stream, BMessage& message);
status_t unflatten_dano_message(uint32 format, BDataIO& stream, BMessage& message);
ssize_t dano_message_flattened_size(const char* buffer);
}

View File

@ -274,21 +274,24 @@ flatten_r5_message(const BMessage *message, BDataIO *stream, ssize_t *_size)
status_t
unflatten_r5_message(BMessage *message, const char *flatBuffer)
unflatten_r5_message(uint32 format, BMessage *message, const char *flatBuffer)
{
r5_message_header *r5header = (r5_message_header *)flatBuffer;
BMemoryIO stream(flatBuffer + 4, r5header->flattened_size - 4);
return unflatten_r5_message(message, &stream);
return unflatten_r5_message(format, message, &stream);
}
status_t
unflatten_r5_message(BMessage *message, BDataIO *stream)
unflatten_r5_message(uint32 format, BMessage *message, BDataIO *stream)
{
TReadHelper reader(stream);
BMessage::Private messagePrivate(message);
BMessage::message_header *header = messagePrivate.GetMessageHeader();
if (format == kR5MessageMagicSwapped)
reader.SetSwap(true);
// the stream is already advanced by the size of the "format"
r5_message_header r5header;
reader(((uint8 *)&r5header) + sizeof(uint32),
@ -364,7 +367,7 @@ unflatten_r5_message(BMessage *message, BDataIO *stream)
char nameBuffer[256];
reader(nameBuffer, nameLength);
nameBuffer[nameLength] = 0;
nameBuffer[nameLength] = '\0';
uint8 *buffer = (uint8 *)malloc(dataSize);
uint8 *pointer = buffer;

View File

@ -20,8 +20,8 @@ namespace BPrivate {
ssize_t r5_message_flattened_size(const BMessage *message);
status_t flatten_r5_message(const BMessage *message, char *buffer, ssize_t size);
status_t flatten_r5_message(const BMessage *message, BDataIO *stream, ssize_t *size);
status_t unflatten_r5_message(BMessage *message, const char *flatBuffer);
status_t unflatten_r5_message(BMessage *message, BDataIO *stream);
status_t unflatten_r5_message(uint32 format, BMessage *message, const char *flatBuffer);
status_t unflatten_r5_message(uint32 format, BMessage *message, BDataIO *stream);
}