building the init command struct

This commit is contained in:
jmjatlanta 2016-10-26 21:13:32 -05:00
parent 1d324cf391
commit a38c3a8253
6 changed files with 65 additions and 16 deletions

View file

@ -7,9 +7,16 @@ int get_init_command(struct command* cmd) {
// arguments
// initialize an array of arguments with size of 1
struct argument argument;
init_string_argument(&argument, "default-config", 0, 0, "Initialize with the given configuration");
int retVal = init_string_argument(&argument, "default-config", 0, 0, "Initialize with the given configuration");
argument.enable_stdin = 1;
struct argument* array[1] = { &argument };
struct argument* array[] = { &argument };
cmd->arguments = array;
cmd->argument_count = 1;
return retVal;
}
int uninit_command(struct command* cmd) {
for(int i = 0; i < cmd->argument_count; i++)
uninit_argument(cmd->arguments[i]);
return 0;
}

View file

@ -6,6 +6,18 @@
#include "../../commands/command.h"
/***
* Returns a command structure customized for the init command
* @param command the struct to fill
* @returns 0 on failure, otherwise 1
*/
int get_init_command(struct command* command);
/***
* Uninitializes all the dynamic memory caused by get_init_command
* @param command the struct
* @returns 0 on failure, otherwise 1
*/
int uninit_command(struct command* command);
#endif