From e56374fa85ab5cac4c9a4b264ea994c750a2bae0 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 1 Jan 2022 19:19:47 +0100 Subject: [PATCH] Use uwu-common as submodule --- .gitmodules | 3 +++ README.md | 2 +- common | 1 + common/dl.h | 14 -------------- common/err.h | 27 --------------------------- common/file.h | 19 ------------------- common/str.h | 17 ----------------- src/load.c | 16 +--------------- 8 files changed, 6 insertions(+), 93 deletions(-) create mode 100644 .gitmodules create mode 160000 common delete mode 100644 common/dl.h delete mode 100644 common/err.h delete mode 100644 common/file.h delete mode 100644 common/str.h diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..10d1794 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "common"] + path = common + url = https://github.com/EliasFleckenstein03/uwu-common diff --git a/README.md b/README.md index bea6e21..703a9d8 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ It's turing complete and somewhat useable. To build: ``` -make +make all std ``` To run: diff --git a/common b/common new file mode 160000 index 0000000..a636a96 --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit a636a960a0866a94719aff01774b9533743ee072 diff --git a/common/dl.h b/common/dl.h deleted file mode 100644 index 143b422..0000000 --- a/common/dl.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _COMMON_DL_H_ -#define _COMMON_DL_H_ - -#include -#include "err.h" - -inline static void check_dlerror() -{ - char *err = dlerror(); - if (err) - error("library error: %s\n", err); -} - -#endif diff --git a/common/err.h b/common/err.h deleted file mode 100644 index b9faf11..0000000 --- a/common/err.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _COMMON_ERR_H_ -#define _COMMON_ERR_H_ - -#include -#include -#include - -static inline void error(const char *format, ...) -{ - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - exit(1); -} - -static inline void syserror(const char *call, FILE *file) -{ - perror(call); - - if (file) - fclose(file); - - exit(1); -} - -#endif diff --git a/common/file.h b/common/file.h deleted file mode 100644 index c5e8036..0000000 --- a/common/file.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _COMMON_FILE_H_ -#define _COMMON_FILE_H_ - -#include -#include - -inline static bool file_exists(const char *filename) -{ - FILE *f = fopen(filename, "r"); - - if (f) { - fclose(f); - return true; - } - - return false; -} - -#endif diff --git a/common/str.h b/common/str.h deleted file mode 100644 index fc5f587..0000000 --- a/common/str.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _COMMON_STR_H_ -#define _COMMON_STR_H_ - -#include -#include - -static inline char *asprintf_wrapper(const char *format, ...) -{ - va_list args; - va_start(args, format); - char *ptr; - vasprintf(&ptr, format, args); - va_end(args); - return ptr; -} - -#endif diff --git a/src/load.c b/src/load.c index 4a05915..4eee717 100644 --- a/src/load.c +++ b/src/load.c @@ -2,31 +2,17 @@ #include #include #include -#include #include #include "common/err.h" #include "common/str.h" #include "common/file.h" #include "common/dl.h" +#include "common/dir.h" #include "load.h" #include "parse.h" #define DEBUG 0 -// helper functions - -static char *dirname_wrapper(const char *name) -{ - char *copy = strdup(name); - char *result = dirname(copy); - char *result_copy = strdup(result); - - free(copy); - return result_copy; -} - -// type definitions - typedef struct { char *name; -- 2.44.0