summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-15 22:56:35 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-16 00:07:31 +0200
commitb1e81de69e08c04b8d78ce7f6a7687d395550b35 (patch)
treee9d89f1165b1cdcebfeaa3592c64834acdf9a1bc
parent5c726aea53703620aa4a44cfe3c16bcb2d4cc06a (diff)
downloadtris-b1e81de69e08c04b8d78ce7f6a7687d395550b35.tar.gz
tris-b1e81de69e08c04b8d78ce7f6a7687d395550b35.zip
Add util
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/main/util.c34
-rw-r--r--src/main/util.h25
3 files changed, 62 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index feda5cf..6ceab8e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,8 @@ find_package(OpenGL REQUIRED)
add_executable(tris
src/main/main.c
src/main/ui/ui.h
- src/main/ui/x11/ui.c)
+ src/main/ui/x11/ui.c
+ src/main/util.h
+ src/main/util.c)
target_link_libraries(tris PRIVATE X11 GL GLX)
diff --git a/src/main/util.c b/src/main/util.c
new file mode 100644
index 0000000..30492ea
--- /dev/null
+++ b/src/main/util.c
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of Tris Game.
+ *
+ * Tris Game 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.
+ *
+ * Tris Game 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 Tris Game. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+void
+log_error(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ fprintf(stderr, "ERROR: ");
+ vfprintf(stderr, format, args);
+ fprintf(stderr, "\n");
+
+ va_end(args);
+}
diff --git a/src/main/util.h b/src/main/util.h
new file mode 100644
index 0000000..9113892
--- /dev/null
+++ b/src/main/util.h
@@ -0,0 +1,25 @@
+/*-
+ * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of Tris Game.
+ *
+ * Tris Game 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.
+ *
+ * Tris Game 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 Tris Game. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __UTIL_H__
+#define __UTIL_H__
+
+void log_error(const char *msg, ...);
+
+#endif /* __UTIL_H__ */