From 49b9f43c765ee336a229722b3414a5a247f8d6c7 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Sun, 3 Mar 2024 17:19:11 -0500 Subject: [PATCH] Initial branching by command in the client --- guestfs-inspect.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/guestfs-inspect.c b/guestfs-inspect.c index e3bbdf7..bacb6a2 100644 --- a/guestfs-inspect.c +++ b/guestfs-inspect.c @@ -32,16 +32,29 @@ int main(int argc, char **argv) { command->args.ls.paths[0] = calloc(strlen(argv[3] + 1), sizeof(char)); strcpy(command->args.ls.paths[0], argv[3]); break; + case GUESTFS_COMMAND_CAT: + command->args.cat.paths_length = 1; + command->args.cat.paths = calloc(1, sizeof(char *)); + command->args.cat.paths[0] = calloc(strlen(argv[3] + 1), sizeof(char)); + strcpy(command->args.cat.paths[0], argv[3]); + break; } zmsg_t *msg = command_to_zmsg(command); zmsg_send(&msg, daemon); - zmsg_t *rep = zmsg_recv(daemon); - char *res = zmsg_popstr(rep); - printf("Res:\n%s\n", res); - free(res); + // process reply + switch (command->command) { + case GUESTFS_COMMAND_LS: + char *res = zmsg_popstr(rep); + printf("Res:\n%s\n", res); + free(res); + break; + case GUESTFS_COMMAND_CAT: + break; + } + zmsg_destroy(&msg); zmsg_destroy(&rep); zsock_destroy(&daemon);