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