Add deserialize function

This commit is contained in:
2024-03-03 15:46:18 -05:00
parent 8a814b1d93
commit a4b56107aa

View File

@@ -49,3 +49,26 @@ static zmsg_t *command_to_zmsg(struct guestfs_inpsect_command *command) {
return res;
}
static struct guestfs_inpsect_command *zmsg_to_command(zmsg_t *msg) {
struct guestfs_inpsect_command *res = malloc(sizeof(struct guestfs_inpsect_command));
res->name = zmsg_popstr(msg);
zframe_t *next = zmsg_pop(msg);
res->command = *(zframe_data(next));
free(next);
switch (res->command) {
case GUESTFS_COMMAND_LS:
next = zmsg_pop(msg);
res->args.ls.paths_length = *(zframe_data(next));
free(next);
res->args.ls.paths = calloc(res->args.ls.paths_length, sizeof(char *));
for (size_t i = 0; i < res->args.ls.paths_length; i++) {
res->args.ls.paths[i] = zmsg_popstr(msg);
}
break;
}
return res;
}