Skip to content

Commit

Permalink
Add license and documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
coditva committed Nov 22, 2017
1 parent 3eb788b commit 2e37f16
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
33 changes: 33 additions & 0 deletions include/command.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
/*
* include/command.c
* Declare the interface for taking and executing commands
*
* Copyright (C) 2017 Utkarsh Mahshwari <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef COMMAND_H_0TNF49V3
#define COMMAND_H_0TNF49V3


/**
* Ask user for input and build the command
* @return The pointer to the command
*/
command_t * command_get();


/**
* Execute the command on the given map
* @param The pointer to the map
* @patam The pointer to the command
*/
void command_exec(const map_t *, const command_t *);


#endif /* end of include guard: COMMAND_H_0TNF49V3 */
25 changes: 23 additions & 2 deletions src/command.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* src/command.c
* Defile the module for taking and executing commands
*
* Copyright (C) 2017 Utkarsh Mahshwari <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h> /* for malloc(), NULL */
#include <string.h> /* for strcmp() */

Expand All @@ -6,6 +26,7 @@
#include "interface.h"
#include "map.h"


int get_count()
{
int count = 0;
Expand Down Expand Up @@ -101,7 +122,7 @@ command_t * get_command_line()
return NULL;
}

command = (command_t *) malloc(sizeof(command));
command = (command_t *) malloc(sizeof(command_t));
line = interface_input_command();

if (!strcmp(line, "quit") || !strcmp(line, "q")) {
Expand Down Expand Up @@ -130,7 +151,7 @@ command_t * command_get()
return command;

/* else build the command */
command = (command_t *) malloc(sizeof(command));
command = (command_t *) malloc(sizeof(command_t));
command -> type = COMMAND_OTHER;
command -> count = get_count();
command -> oper = get_oper();
Expand Down

0 comments on commit 2e37f16

Please sign in to comment.