Start branching based on the command type
This commit is contained in:
@@ -24,10 +24,15 @@ int main(int argc, char **argv) {
|
|||||||
command->name = calloc(strlen(argv[1]) + 1, sizeof(char));
|
command->name = calloc(strlen(argv[1]) + 1, sizeof(char));
|
||||||
strcpy(command->name, argv[1]);
|
strcpy(command->name, argv[1]);
|
||||||
command->command = parse_command(argv[2]);
|
command->command = parse_command(argv[2]);
|
||||||
|
|
||||||
|
switch (command->command) {
|
||||||
|
case GUESTFS_COMMAND_LS:
|
||||||
command->args.ls.paths_length = 1;
|
command->args.ls.paths_length = 1;
|
||||||
command->args.ls.paths = calloc(1, sizeof(char *));
|
command->args.ls.paths = calloc(1, sizeof(char *));
|
||||||
command->args.ls.paths[0] = calloc(strlen(argv[3] + 1), sizeof(char));
|
command->args.ls.paths[0] = calloc(strlen(argv[3] + 1), sizeof(char));
|
||||||
strcpy(command->args.ls.paths[0], argv[3]);
|
strcpy(command->args.ls.paths[0], argv[3]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
zmsg_t *msg = command_to_zmsg(command);
|
zmsg_t *msg = command_to_zmsg(command);
|
||||||
zmsg_send(&msg, daemon);
|
zmsg_send(&msg, daemon);
|
||||||
@@ -40,10 +45,7 @@ int main(int argc, char **argv) {
|
|||||||
zmsg_destroy(&msg);
|
zmsg_destroy(&msg);
|
||||||
zmsg_destroy(&rep);
|
zmsg_destroy(&rep);
|
||||||
zsock_destroy(&daemon);
|
zsock_destroy(&daemon);
|
||||||
free(command->name);
|
command_destroy(&command);
|
||||||
free(command->args.ls.paths[0]);
|
|
||||||
free(command->args.ls.paths);
|
|
||||||
free(command);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user