Add basic serialization of the message
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
#include <czmq.h>
|
||||||
|
|
||||||
enum guestfs_inspect_command_const {
|
enum guestfs_inspect_command_const {
|
||||||
GUESTFS_COMMAND_LS,
|
GUESTFS_COMMAND_LS,
|
||||||
/* GUESTFS_COMMAND_TOUCH, */
|
/* GUESTFS_COMMAND_TOUCH, */
|
||||||
@@ -6,6 +8,7 @@ enum guestfs_inspect_command_const {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct guestfs_ls_args {
|
struct guestfs_ls_args {
|
||||||
|
size_t paths_length;
|
||||||
char **paths;
|
char **paths;
|
||||||
};
|
};
|
||||||
struct guestfs_cat_args {};
|
struct guestfs_cat_args {};
|
||||||
@@ -27,3 +30,22 @@ static char *endpoint() {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static zmsg_t *command_to_zmsg(struct guestfs_inpsect_command *command) {
|
||||||
|
zmsg_t *res = zmsg_new();
|
||||||
|
|
||||||
|
zmsg_pushstr(res, command->name);
|
||||||
|
zmsg_pushmem(res, &(command->command), sizeof(command->command));
|
||||||
|
|
||||||
|
switch (command->command) {
|
||||||
|
case GUESTFS_COMMAND_LS:
|
||||||
|
zmsg_pushmem(res, &(command->args.ls.paths_length), sizeof(command->args.ls.paths_length));
|
||||||
|
|
||||||
|
for (size_t i = 0; i < (command->args.ls.paths_length); i++) {
|
||||||
|
zmsg_pushstr(res, command->args.ls.paths[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user