diff options
Diffstat (limited to 'common')
m--------- | common | 0 | ||||
-rw-r--r-- | common/dl.h | 14 | ||||
-rw-r--r-- | common/err.h | 27 | ||||
-rw-r--r-- | common/file.h | 19 | ||||
-rw-r--r-- | common/str.h | 17 |
5 files changed, 0 insertions, 77 deletions
diff --git a/common b/common new file mode 160000 +Subproject a636a960a0866a94719aff01774b9533743ee07 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 <dlfcn.h> -#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 <stdio.h> -#include <stdlib.h> -#include <stdarg.h> - -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 <stdio.h> -#include <stdbool.h> - -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 <stdio.h> -#include <stdarg.h> - -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 |