コード例 #1
0
ファイル: connection.c プロジェクト: giucam/wayland
int
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
{
	int size;
	uint32_t buffer_size;
	uint32_t *buffer;
	int result;

	if (copy_fds_to_connection(closure, connection))
		return -1;

	buffer_size = buffer_size_for_closure(closure);
	buffer = zalloc(buffer_size * sizeof buffer[0]);
	if (buffer == NULL)
		return -1;

	size = serialize_closure(closure, buffer, buffer_size);
	if (size < 0) {
		free(buffer);
		return -1;
	}

	result = wl_connection_write(connection, buffer, size);
	free(buffer);

	return result;
}
コード例 #2
0
ファイル: connection.c プロジェクト: CLowcay/wayland-terminal
void
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
{
	uint32_t size;

	size = closure->start[1] >> 16;
	wl_connection_write(connection, closure->start, size);
}
コード例 #3
0
ファイル: connection.c プロジェクト: Godmen/wayland-rpi
int
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
{
	uint32_t size;

	if (copy_fds_to_connection(closure, connection))
		return -1;

	size = closure->start[1] >> 16;

	return wl_connection_write(connection, closure->start, size);
}
コード例 #4
0
ファイル: connection.c プロジェクト: antognolli/wayland
int
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
{
	uint32_t buffer[256];
	int size;

	if (copy_fds_to_connection(closure, connection))
		return -1;

	size = serialize_closure(closure, buffer, 256);
	if (size < 0)
		return -1;

	return wl_connection_write(connection, buffer, size);
}
コード例 #5
0
ファイル: connection.c プロジェクト: qiuTED/wayland
void
wl_connection_vmarshal(struct wl_connection *connection,
		       struct wl_hash *objects, uint32_t obj_id,
		       uint32_t opcode, const char *types, va_list va)
{
	uint32_t *p;
	int i, id;
	const char *c;
	union wl_element values[20];
	struct wl_object *object;
	uint32_t data[64];
	int size;

	for (i = 0, c = types, size = 2 * sizeof(uint32_t); *c; i++) {
		switch (*c) {
		case 'i':
			values[i].uint32 = va_arg (va, int);
			size += sizeof (uint32_t);
			c++;
			break;
		case 's': {
			const char *s = va_arg (va, const char *);
			int length = strlen (s);
			values[i].string = s;
			size += sizeof (uint32_t);
			size += (length + 3) & ~3;
			c++;
			break;
		}
		case 'o':
			id = va_arg (va, int);
			object = wl_hash_lookup(objects, id);
			if (object == NULL)
				printf("unknown object (%d)\n", id);
			c++;
			values[i].uint32 = id;
			break;
#if 0
		case '{':
			id = va_arg (va, int);
			object = wl_hash_lookup(objects, id);
			if (object == NULL)
				printf("unknown object (%d)\n", id);
			c++;
			if (!strchrcmp (&c, '}', object->interface->name))
				printf("wrong object type\n");
			values[i].uint32 = id;
			break;
#endif
		case 'O':
			values[i].uint32 = id = va_arg (va, int);
			if (objects != NULL) {
				object = wl_hash_lookup(objects, id);
				if (object != NULL)
					printf("object already exists (%d)\n", id);
			}
			size += sizeof (uint32_t);
			c++;
			break;
		default:
			printf("unknown type %c\n", *c++);
			break;
		}
	}

	if (sizeof data < size) {
		printf("request too big, should malloc tmp buffer here\n");
		return;
	}
	data[0] = obj_id;
	data[1] = (size << 16) | (opcode & 65535);
	for (i = 0, c = types, p = &data[2]; *c; i++) {
		switch (*c) {
		case 'i':
		case 'o':
		case 'O':
			*p++ = values[i].uint32;
			c++;
			break;
		case 's': {
			const char *s = values[i].string;
			int length = strlen (s);
			*p++ = length;
			memcpy ((char *)p, s, length);
			p += (length + 3) >> 2;
			c++;
			break;
		}
		case '{':
			*p++ = values[i].uint32;
			c = strchr (c, '}');
			c++;
			break;
		default:
			printf("unknown type %c\n", *c++);
			break;
		}
	}
	wl_connection_write (connection, data, size);
}