From 17178535cc9df5e834dfd43e3b2b919e02e5798d Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 26 Oct 2023 19:53:29 -0400 Subject: Initial commit --- include/utils.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 include/utils.h (limited to 'include/utils.h') diff --git a/include/utils.h b/include/utils.h new file mode 100644 index 0000000..eb7604c --- /dev/null +++ b/include/utils.h @@ -0,0 +1,43 @@ +#ifndef OHMYCAL_UTILS_H +#define OHMYCAL_UTILS_H +#include +#include +#include +#include +#include +#include +#include +#include "system.h" + +#if defined(__WIN32__) +#define PATH_ENV_VAR "path" +#define DIR_SEP "\\" +#define PATH_SEP ";" +#else +#define PATH_ENV_VAR "PATH" +#define DIR_SEP "/" +#define PATH_SEP ":" +#endif + +typedef int (ReaderFn)(size_t line, char **); + +int pushd(const char *path); +int popd(void); +char *expandpath(const char *_path); +int rmtree(char *_path); +char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn *readerFn); +char *path_basename(char *path); +char *find_program(const char *name); +int touch(const char *filename); +int git_clone(struct Process *proc, char *url, char *destdir, char *gitref); +char *git_describe(const char *path); + +#define OMC_MSG_NOP 1 << 0 +#define OMC_MSG_ERROR 1 << 1 +#define OMC_MSG_WARN 1 << 2 +#define OMC_MSG_L1 1 << 3 +#define OMC_MSG_L2 1 << 4 +#define OMC_MSG_L3 1 << 5 +int msg(unsigned type, char *fmt, ...); + +#endif //OHMYCAL_UTILS_H -- cgit