Compare commits
No commits in common. "05f7a1ae41d224c47b6cd26b814a7f86c0e96ba3" and "ec156a1b14d232be2d53f4efc57b68b906047ec2" have entirely different histories.
05f7a1ae41
...
ec156a1b14
2 changed files with 6 additions and 39 deletions
41
server.c
41
server.c
|
@ -277,44 +277,6 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
if (status_code == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
||||
printf("client '%s' (index=%d) now owns name '%s'\n", s->names[client->unique_name_index].name, i, name_str);
|
||||
}
|
||||
} else if (strcmp(member, "GetNameOwner") == 0) {
|
||||
char *name = TRY_NONNULL(char*, wire_get_string(&ctx, NULL), -1);
|
||||
int name_len = strlen(name);
|
||||
if (name_len < 1 || name_len > 256) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *name_str = string_dup(name);
|
||||
if (!name_str) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct jb_client *target = jb_server_name_find_client(s, destination_field->t.str);
|
||||
if (!target || target->unique_name_index < 0) {
|
||||
uint8_t error_reply_data[512];
|
||||
memset(error_reply_data, 0, 512);
|
||||
wire_context_t error_reply_ctx = {
|
||||
.byte_cursor = 0,
|
||||
.data = error_reply_data,
|
||||
.data_len = 511,
|
||||
};
|
||||
TRY_NONNEGATIVE(int, wire_compose_error(&error_reply_ctx, &msg, "org.freedesktop.DBus.Error.NameHasNoOwner"), -1);
|
||||
if (send(s->fds[i].fd, error_reply_data, error_reply_ctx.byte_cursor, 0) != error_reply_ctx.byte_cursor) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t *body_length;
|
||||
TRY_NONNEGATIVE(int, wire_compose_reply(&reply_ctx, &msg, "s", &body_length), -1);
|
||||
uint32_t body_start = reply_ctx.byte_cursor;
|
||||
TRY_NONNULL(char*, wire_set_string(&reply_ctx, s->names[target->unique_name_index].name), -1);
|
||||
*body_length = reply_ctx.byte_cursor - body_start;
|
||||
if (send(s->fds[i].fd, reply_data, reply_ctx.byte_cursor, 0) != reply_ctx.byte_cursor) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s\n", s->names[target->unique_name_index].name);
|
||||
} else {
|
||||
TRY_NONNEGATIVE(int, wire_compose_error(&reply_ctx, &msg, "org.freedesktop.DBus.Error.UnknownMethod"), -1);
|
||||
if (send(s->fds[i].fd, reply_data, reply_ctx.byte_cursor, 0) != reply_ctx.byte_cursor) {
|
||||
|
@ -345,6 +307,7 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
if (client->unique_name_index < 0 || !destination_field->present) {
|
||||
return -1;
|
||||
}
|
||||
printf("sending unicast message from %s\n", s->names[client->unique_name_index].name);
|
||||
struct jb_client *target = jb_server_name_find_client(s, destination_field->t.str);
|
||||
if (!target) {
|
||||
uint8_t error_reply_data[512];
|
||||
|
@ -354,7 +317,7 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
.data = error_reply_data,
|
||||
.data_len = 511,
|
||||
};
|
||||
TRY_NONNEGATIVE(int, wire_compose_error(&error_reply_ctx, &msg, "org.freedesktop.DBus.Error.NameHasNoOwner"), -1);
|
||||
TRY_NONNEGATIVE(int, wire_compose_error(&error_reply_ctx, &msg, "xyz.hippoz.jitterbug.NotImplemented"), -1);
|
||||
if (send(s->fds[i].fd, error_reply_data, error_reply_ctx.byte_cursor, 0) != error_reply_ctx.byte_cursor) {
|
||||
return -1;
|
||||
}
|
||||
|
|
4
wire.c
4
wire.c
|
@ -130,6 +130,8 @@ int wire_parse_message(wire_context_t *c, wire_message_t *msg)
|
|||
|
||||
size_t header_fields_end = c->byte_cursor + msg->header_fields_length;
|
||||
|
||||
printf(" > start parse!\n");
|
||||
|
||||
while (c->byte_cursor < header_fields_end) {
|
||||
uint8_t field_code = *TRY_NONNULL(uint8_t*, wire_get_u8(c), -1);
|
||||
TRY_NONNULL(char*, wire_get_signature(c, NULL), -1);
|
||||
|
@ -169,6 +171,8 @@ int wire_parse_message(wire_context_t *c, wire_message_t *msg)
|
|||
}
|
||||
}
|
||||
|
||||
printf(" > parsed!!\n");
|
||||
|
||||
/* header ends at 8 byte boundry */
|
||||
TRY_NONNULL(bool, wire_align(c, 8), -1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue