summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-02-06 02:04:44 -0800
committerPreston Pan <preston@nullring.xyz>2023-02-06 02:04:44 -0800
commit762bf741fd6db043f06448a19b554cc4946777e6 (patch)
tree17b2089bb7cb574db685fcc42caee5cf30553d13
parentfdedca4e02bfcafc1cac049c98c8fa202f8d4c24 (diff)
add version message; change binary name
-rw-r--r--.gitignore2
-rw-r--r--Makefile11
-rwxr-xr-xsnakebin0 -> 25640 bytes
-rw-r--r--snake.c11
4 files changed, 19 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index a2d760c..bc54d59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
a.out
a.exe
*.swp
-snake
+snake3
diff --git a/Makefile b/Makefile
index a683251..e27b253 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,15 @@
CC=gcc
-CFLAGS=-I. -pthread -fsanitize=address
+CFLAGS=-I. -pthread
DESTDIR=/usr/local/bin
generate:
- $(CC) -o snake snake.c vector.c conio.c $(CFLAGS)
+ $(CC) -o snake3 snake.c vector.c conio.c $(CFLAGS)
install:
- cp snake $(DESTDIR)
+ cp snake3 $(DESTDIR)
clean:
- rm snake
+ rm snake3
+
+uninstall:
+ -rm $(DESTDIR)/snake3
diff --git a/snake b/snake
new file mode 100755
index 0000000..f7beaac
--- /dev/null
+++ b/snake
Binary files differ
diff --git a/snake.c b/snake.c
index 6b4201f..9a88d26 100644
--- a/snake.c
+++ b/snake.c
@@ -4,6 +4,8 @@
#include <pthread.h>
#include <signal.h> //handling ctrl-c
#include <sys/ioctl.h> //terminal size
+#include <string.h> // argument parsing
+
#include "vector.h"
#include "snake.h"
#include "conio.h"
@@ -23,6 +25,15 @@ vector_t foodPos;
vector_t lastMoveDir;
int main(int argc, char **argv) {
+ for (int i = 0; i < argc; i ++) {
+ if (strcmp("--version", argv[i]) == 0) {
+ printf("snake3, version 1.0\n");
+ printf("Copyright 2023 Kai Stevenson\n");
+ printf("This software was licensed under the MIT license;\n");
+ printf("for more information, see the license file.\n");
+ return 0;
+ }
+ }
//get terminal size
struct winsize win;
ioctl(fileno(stdout), TIOCGWINSZ, &win);