Add deserialize function
This commit is contained in:
@@ -49,3 +49,26 @@ static zmsg_t *command_to_zmsg(struct guestfs_inpsect_command *command) {
|
|||||||
return res;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user