-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add license and documentation comments
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() */ | ||
|
||
|
@@ -6,6 +26,7 @@ | |
#include "interface.h" | ||
#include "map.h" | ||
|
||
|
||
int get_count() | ||
{ | ||
int count = 0; | ||
|
@@ -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")) { | ||
|
@@ -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(); | ||
|