aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-24 09:54:44 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-24 09:54:44 +0100
commit97f4a83cc8d24de4b6c1d16c93e2d955a134ad83 (patch)
treebb0a3cda797a70c4ef5bf6754dd7527d2ec66867
parent2fe4352955042ef5415f6830d8c9d05d39159b7e (diff)
global verbosity
-rw-r--r--voerbak/diewertje.c3
-rw-r--r--voerbak/messages.c5
-rw-r--r--voerbak/messages.h8
-rw-r--r--voerbak/solvers.c1
-rw-r--r--voerbak/voerbak.c5
-rw-r--r--voerbak/voerbak.h3
6 files changed, 14 insertions, 11 deletions
diff --git a/voerbak/diewertje.c b/voerbak/diewertje.c
index 93a8596..6290b5c 100644
--- a/voerbak/diewertje.c
+++ b/voerbak/diewertje.c
@@ -1,8 +1,9 @@
#include <stdio.h>
#include "board.h"
+#include "voerbak.h"
int diewertje(Board *b) {
- printf("Got a diewertje request, from a board that's %dx%d\n", b->width, b->height);
+ verbosity >= 2 && printf("Got a diewertje request, from a board that's %dx%d\n", b->width, b->height);
return 2;
}
diff --git a/voerbak/messages.c b/voerbak/messages.c
index abb387a..efcac94 100644
--- a/voerbak/messages.c
+++ b/voerbak/messages.c
@@ -2,7 +2,8 @@
#include <stdbool.h>
#include "messages.h"
+#include "voerbak.h"
-void parseMessage(char* message, int verbosity) {
- verbosity > 2 && printf("Got message: \"%s\"\n", message);
+void parseMessage(char* message) {
+ verbosity >= 2 && printf("Got message: \"%s\"\n", message);
}
diff --git a/voerbak/messages.h b/voerbak/messages.h
index dd7b325..5ddc1c5 100644
--- a/voerbak/messages.h
+++ b/voerbak/messages.h
@@ -1,12 +1,6 @@
/**
* @brief Parse special message
- *
- * 0: embedded
- * 1: print help messages (human mode)
- * 2: debug mode
- *
* @param message
- * @param verbosity
*/
-void parseMessage(char*, int);
+void parseMessage(char*);
diff --git a/voerbak/solvers.c b/voerbak/solvers.c
index e3aab12..1d288f3 100644
--- a/voerbak/solvers.c
+++ b/voerbak/solvers.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include "board.h"
+#include "voerbak.h"
#include "diewertje.h"
diff --git a/voerbak/voerbak.c b/voerbak/voerbak.c
index 2782163..0b564c0 100644
--- a/voerbak/voerbak.c
+++ b/voerbak/voerbak.c
@@ -10,8 +10,11 @@
#define EMPTY ""
+int verbosity = 0;
+
int main(int argc, char* argv[]) {
struct arguments arguments = argparse(argc, argv);
+ verbosity = arguments.verbosity;
Board *gameBoard = createBoard(arguments.width, arguments.height);
@@ -22,7 +25,7 @@ int main(int argc, char* argv[]) {
strcpy(message, EMPTY);
while (scanf("%d", &move) == 1 || scanf("%s", message) == 1) {
if (strlen(message) != 0) {
- parseMessage(message, arguments.verbosity);
+ parseMessage(message);
strcpy(message, EMPTY); // clear message
continue;
diff --git a/voerbak/voerbak.h b/voerbak/voerbak.h
index a828d02..29ae118 100644
--- a/voerbak/voerbak.h
+++ b/voerbak/voerbak.h
@@ -2,5 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
+/** @brief Verbosity (shared across entire program) */
+extern int verbosity;
+
/** @brief Main function */
int main();