summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2023-10-24 13:55:58 -0400
committerLouie S <louie@example.com>2023-10-24 13:55:58 -0400
commit0a2844c40a3907fe1207aed5ce89416dd06c5637 (patch)
tree740b1f3d868c366c63df647623cccc131197527b
parent4cc4ba6bc250e8981a6fb3f6e6b96945a16628e5 (diff)
Added debug configuration option
-rw-r--r--.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idxbin520 -> 0 bytes
-rw-r--r--.cache/clangd/index/holder.h.A6A9759559698491.idxbin454 -> 0 bytes
-rw-r--r--.cache/clangd/index/main.c.B35546292B5EA1F4.idxbin3652 -> 0 bytes
-rw-r--r--.cache/clangd/index/ring.h.D0AA315870801682.idxbin872 -> 0 bytes
-rw-r--r--.gitignore1
-rw-r--r--config.h.in3
-rw-r--r--config.h.in~61
-rwxr-xr-xconfigure24
-rw-r--r--configure.ac11
-rw-r--r--src/main.c39
10 files changed, 60 insertions, 79 deletions
diff --git a/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx b/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx
deleted file mode 100644
index aa95afc..0000000
--- a/.cache/clangd/index/config.h.B6F0A2CF7C7268D5.idx
+++ /dev/null
Binary files differ
diff --git a/.cache/clangd/index/holder.h.A6A9759559698491.idx b/.cache/clangd/index/holder.h.A6A9759559698491.idx
deleted file mode 100644
index 9f59667..0000000
--- a/.cache/clangd/index/holder.h.A6A9759559698491.idx
+++ /dev/null
Binary files differ
diff --git a/.cache/clangd/index/main.c.B35546292B5EA1F4.idx b/.cache/clangd/index/main.c.B35546292B5EA1F4.idx
deleted file mode 100644
index 02a1be3..0000000
--- a/.cache/clangd/index/main.c.B35546292B5EA1F4.idx
+++ /dev/null
Binary files differ
diff --git a/.cache/clangd/index/ring.h.D0AA315870801682.idx b/.cache/clangd/index/ring.h.D0AA315870801682.idx
deleted file mode 100644
index 304b0bb..0000000
--- a/.cache/clangd/index/ring.h.D0AA315870801682.idx
+++ /dev/null
Binary files differ
diff --git a/.gitignore b/.gitignore
index 490cac5..0e87bc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.cache
.cache/*
+*~
diff --git a/config.h.in b/config.h.in
index 031bab0..61ea3f8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
+/* Enable debug printing */
+#undef DEBUG
+
/* Define to 1 if a SysV or X/Open compatible Curses library is present */
#undef HAVE_CURSES
diff --git a/config.h.in~ b/config.h.in~
deleted file mode 100644
index 031bab0..0000000
--- a/config.h.in~
+++ /dev/null
@@ -1,61 +0,0 @@
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if a SysV or X/Open compatible Curses library is present */
-#undef HAVE_CURSES
-
-/* Define to 1 if library supports color (enhanced functions) */
-#undef HAVE_CURSES_COLOR
-
-/* Define to 1 if library supports X/Open Enhanced functions */
-#undef HAVE_CURSES_ENHANCED
-
-/* Define to 1 if <curses.h> is present */
-#undef HAVE_CURSES_H
-
-/* Define to 1 if library supports certain obsolete features */
-#undef HAVE_CURSES_OBSOLETE
-
-/* Define to 1 if the Ncurses library is present */
-#undef HAVE_NCURSES
-
-/* Define to 1 if the NcursesW library is present */
-#undef HAVE_NCURSESW
-
-/* Define to 1 if <ncursesw/curses.h> is present */
-#undef HAVE_NCURSESW_CURSES_H
-
-/* Define to 1 if <ncursesw.h> is present */
-#undef HAVE_NCURSESW_H
-
-/* Define to 1 if <ncurses/curses.h> is present */
-#undef HAVE_NCURSES_CURSES_H
-
-/* Define to 1 if <ncurses.h> is present */
-#undef HAVE_NCURSES_H
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Title to print at the top */
-#undef TITLE
-
-/* Version number of package */
-#undef VERSION
diff --git a/configure b/configure
index 55bbf15..9e18f98 100755
--- a/configure
+++ b/configure
@@ -678,6 +678,7 @@ ac_user_opts='
enable_option_checking
with_ncurses
with_ncursesw
+enable_debug
enable_dependency_tracking
enable_silent_rules
'
@@ -1309,6 +1310,7 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-debug enable debug output (disabled by default)
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
@@ -3918,6 +3920,28 @@ if test "x$ax_cv_curses" != xyes; then
as_fn_error $? "requires an X/Open-compatible Curses library" "$LINENO" 5
fi
+# enables/disables
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then :
+ enableval=$enable_debug; enable_debug=${enableval}
+else
+ enable_debug=no
+fi
+
+if test "x$enable_debug" = xyes; then
+
+cat >>confdefs.h <<_ACEOF
+#define DEBUG 1
+_ACEOF
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define DEBUG 0
+_ACEOF
+
+fi
+
# Setup Automake
am__api_version='1.16'
diff --git a/configure.ac b/configure.ac
index 356ff6e..694f712 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,17 @@ if test "x$ax_cv_curses" != xyes; then
AC_MSG_ERROR([requires an X/Open-compatible Curses library])
fi
+# enables/disables
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug], [enable debug output (disabled by default)])],
+ [enable_debug=${enableval}],
+ [enable_debug=no])
+if test "x$enable_debug" = xyes; then
+ AC_DEFINE_UNQUOTED([DEBUG], [1], [Enable debug printing])
+else
+ AC_DEFINE_UNQUOTED([DEBUG], [0], [Enable debug printing])
+fi
+
# Setup Automake
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([
diff --git a/src/main.c b/src/main.c
index 4039aa3..4e74d19 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,5 @@
#include <curses.h>
+#include <stdbool.h>
#include <string.h>
#include "config.h"
@@ -86,24 +87,26 @@ void draw_body() {
*/
// DEBUG
- mvprintw(0, 0, "tower 1: %c %c %c", (towers[0].rings[0] ? 'X' : '_'), (towers[0].rings[1] ? 'X' : '_'), (towers[0].rings[2] ? 'X' : '_'));
- mvprintw(1, 0, "tower 2: %c %c %c", (towers[1].rings[0] ? 'X' : '_'), (towers[1].rings[1] ? 'X' : '_'), (towers[1].rings[2] ? 'X' : '_'));
- mvprintw(2, 0, "tower 3: %c %c %c", (towers[2].rings[0] ? 'X' : '_'), (towers[2].rings[1] ? 'X' : '_'), (towers[2].rings[2] ? 'X' : '_'));
- mvprintw(3, 0, "ring 1:");
- mvprintw(4, 2, "location: %d", rings[0].location);
- mvprintw(5, 2, "held: %d", rings[0].held);
- mvprintw(6, 2, "size: %d", rings[0].size);
- mvprintw(7, 2, "ascii: %s", rings[0].ascii);
- mvprintw(8, 0, "ring 2:");
- mvprintw(9, 2, "location: %d", rings[1].location);
- mvprintw(10, 2, "held: %d", rings[1].held);
- mvprintw(11, 2, "size: %d", rings[1].size);
- mvprintw(12, 2, "ascii: %s", rings[1].ascii);
- mvprintw(13, 0, "ring 3:");
- mvprintw(14, 2, "location: %d", rings[2].location);
- mvprintw(15, 2, "held: %d", rings[2].held);
- mvprintw(16, 2, "size: %d", rings[2].size);
- mvprintw(17, 2, "ascii: %s", rings[2].ascii);
+ if(DEBUG) {
+ mvprintw(0, 0, "tower 1: %c %c %c", (towers[0].rings[0] ? 'X' : '_'), (towers[0].rings[1] ? 'X' : '_'), (towers[0].rings[2] ? 'X' : '_'));
+ mvprintw(1, 0, "tower 2: %c %c %c", (towers[1].rings[0] ? 'X' : '_'), (towers[1].rings[1] ? 'X' : '_'), (towers[1].rings[2] ? 'X' : '_'));
+ mvprintw(2, 0, "tower 3: %c %c %c", (towers[2].rings[0] ? 'X' : '_'), (towers[2].rings[1] ? 'X' : '_'), (towers[2].rings[2] ? 'X' : '_'));
+ mvprintw(3, 0, "ring 1:");
+ mvprintw(4, 2, "location: %d", rings[0].location);
+ mvprintw(5, 2, "held: %d", rings[0].held);
+ mvprintw(6, 2, "size: %d", rings[0].size);
+ mvprintw(7, 2, "ascii: %s", rings[0].ascii);
+ mvprintw(8, 0, "ring 2:");
+ mvprintw(9, 2, "location: %d", rings[1].location);
+ mvprintw(10, 2, "held: %d", rings[1].held);
+ mvprintw(11, 2, "size: %d", rings[1].size);
+ mvprintw(12, 2, "ascii: %s", rings[1].ascii);
+ mvprintw(13, 0, "ring 3:");
+ mvprintw(14, 2, "location: %d", rings[2].location);
+ mvprintw(15, 2, "held: %d", rings[2].held);
+ mvprintw(16, 2, "size: %d", rings[2].size);
+ mvprintw(17, 2, "ascii: %s", rings[2].ascii);
+ }
}
void draw_tower(int ring_index, int startx, int starty) {