Add basic serialization of the message

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

View File

@@ -1,3 +1,5 @@
#include <czmq.h>
enum guestfs_inspect_command_const {
GUESTFS_COMMAND_LS,
/* GUESTFS_COMMAND_TOUCH, */
@@ -6,6 +8,7 @@ enum guestfs_inspect_command_const {
};
struct guestfs_ls_args {
size_t paths_length;
char **paths;
};
struct guestfs_cat_args {};
@@ -27,3 +30,22 @@ static char *endpoint() {
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;
}