Ejemplo n.º 1
0
status_t
BNetworkAddress::Flatten(void* buffer, ssize_t size) const
{
	if (buffer == NULL || size < FlattenedSize())
		return B_BAD_VALUE;

	memcpy(buffer, &fAddress, Length());
	return B_OK;
}
Ejemplo n.º 2
0
status_t
BNetworkCookieJar::Flatten(void* buffer, ssize_t size) const
{
	if (FlattenedSize() > size)
		return B_ERROR;

	fFlattened.CopyInto(reinterpret_cast<char*>(buffer), 0,
		fFlattened.Length());
	reinterpret_cast<char*>(buffer)[fFlattened.Length()] = 0;

	return B_OK;
}
Ejemplo n.º 3
0
status_t
BStringContactField::Flatten(void* buffer, ssize_t size) const
{
	if (size < FlattenedSize())
		return B_ERROR;

	BMemoryIO flatData(buffer, size);
	status_t ret = BContactField::Flatten(&flatData);
	if (ret != B_OK)
		return ret;

	_AddStringToBuffer(&flatData, fValue);

	return B_OK;
}
Ejemplo n.º 4
0
bool
EMessenger::Flatten(char *buffer, size_t bufferSize) const
{
	if(buffer == NULL || bufferSize < FlattenedSize()) return false;

	e_bigtime_t handler_stamp = etk_get_handler_create_time_stamp(fHandlerToken);
	e_bigtime_t looper_stamp = etk_get_handler_create_time_stamp(fLooperToken);

	memcpy(buffer, &fTargetTeam, sizeof(eint64)); buffer += sizeof(eint64);
	memcpy(buffer, &fHandlerToken, sizeof(euint64)); buffer += sizeof(euint64);
	memcpy(buffer, &handler_stamp, sizeof(e_bigtime_t)); buffer += sizeof(e_bigtime_t);
	memcpy(buffer, &fLooperToken, sizeof(euint64)); buffer += sizeof(euint64);
	memcpy(buffer, &looper_stamp, sizeof(e_bigtime_t));

	return true;
}
Ejemplo n.º 5
0
status_t
BAddressContactField::Flatten(void* buffer, ssize_t size) const
{
	if (size < FlattenedSize())
		return B_ERROR;

	BMemoryIO flatData(buffer, size);
	status_t ret = BContactField::Flatten(&flatData);
	if (ret != B_OK)
		return ret;

	_AddStringToBuffer(&flatData, Value());

	flatData.Write(&fWellFormed, sizeof(fWellFormed));

	return B_OK;
}
Ejemplo n.º 6
0
status_t
BAffineTransform::Flatten(void* _buffer, ssize_t size) const
{
    if (_buffer == NULL || size < FlattenedSize())
        return B_BAD_VALUE;

    double* buffer = reinterpret_cast<double*>(_buffer);

    buffer[0] = sx;
    buffer[1] = shy;
    buffer[2] = shx;
    buffer[3] = sy;
    buffer[4] = tx;
    buffer[5] = ty;

    return B_OK;
}
Ejemplo n.º 7
0
status_t
BAffineTransform::Unflatten(type_code code, const void* _buffer, ssize_t size)
{
    if (_buffer == NULL || size < FlattenedSize() || code != TypeCode())
        return B_BAD_VALUE;

    const double* buffer = reinterpret_cast<const double*>(_buffer);

    sx = buffer[0];
    shy = buffer[1];
    shx = buffer[2];
    sy = buffer[3];
    tx = buffer[4];
    ty = buffer[5];

    return B_OK;
}
Ejemplo n.º 8
0
status_t
dormant_flavor_info::Flatten(void *buffer, ssize_t size) const
{
	if (size < FlattenedSize())
		return B_ERROR;

	char *buf = (char *)buffer;
	int32 nameLength = name ? (int32)strlen(name) : -1;
	int32 infoLength = info ? (int32)strlen(info) : -1;
	int32 inFormatCount = 0;
	size_t inFormatSize = 0;
	int32 outFormatCount = 0;
	size_t outFormatSize = 0;

	if ((kinds & B_BUFFER_CONSUMER) != 0 && in_format_count > 0
		&& in_formats != NULL) {
		if (in_format_count <= MAX_FLAVOR_IN_FORMAT_COUNT) {
			inFormatCount = in_format_count;
			inFormatSize = in_format_count * sizeof(media_format);
		} else {
			fprintf(stderr, "error dormant_flavor_info::Flatten: "
				"in_format_count is too large\n");
			return B_ERROR;
		}
	}

	if ((kinds & B_BUFFER_PRODUCER) != 0 && out_format_count > 0
		&& out_formats != NULL) {
		if (out_format_count <= MAX_FLAVOR_OUT_FORMAT_COUNT) {
			outFormatCount = out_format_count;
			outFormatSize = out_format_count * sizeof(media_format);
		} else {
			fprintf(stderr, "error dormant_flavor_info::Flatten: "
				"out_format_count is too large\n");
			return B_ERROR;
		}
	}

	// magic
	*(int32*)buf = FLATTEN_MAGIC; buf += sizeof(int32);

	// size
	*(int32*)buf = FlattenedSize(); buf += sizeof(int32);

	// struct flavor_info
	*(int32*)buf = nameLength; buf += sizeof(int32);
	if (nameLength > 0) {
		memcpy(buf, name, nameLength);
		buf += nameLength;
	}
	*(int32*)buf = infoLength; buf += sizeof(int32);
	if (infoLength > 0) {
		memcpy(buf, info, infoLength);
		buf += infoLength;
	}

	*(uint64*)buf = kinds; buf += sizeof(uint64);
	*(uint32*)buf = flavor_flags; buf += sizeof(uint32);
	*(int32*)buf = internal_id; buf += sizeof(int32);
	*(int32*)buf = possible_count; buf += sizeof(int32);
	*(int32*)buf = inFormatCount; buf += sizeof(int32);
	*(uint32*)buf = in_format_flags; buf += sizeof(uint32);

	// XXX FIXME! we should not!!! make flat copies	of media_format
	memcpy(buf, in_formats, inFormatSize); buf += inFormatSize;

	*(int32*)buf = outFormatCount; buf += sizeof(int32);
	*(uint32*)buf = out_format_flags; buf += sizeof(uint32);

	// XXX FIXME! we should not!!! make flat copies	of media_format
	memcpy(buf, out_formats, outFormatSize); buf += outFormatSize;

	*(dormant_node_info*)buf = node_info; buf += sizeof(dormant_node_info);

	return B_OK;
}