Initial branching by command in the client

This commit is contained in:
2024-03-03 17:19:11 -05:00
parent ebc07d0cf7
commit 49b9f43c76

View File

@@ -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);