diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-10-31 12:01:51 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-10-31 12:01:51 -0400 |
commit | dafe7639674f3bfc66d3a116ec836c269c08f473 (patch) | |
tree | c6db769c5e0f71c476521353c95ec94df8b05530 | |
parent | fb8045411a2e594be39cf45f613cd8cef4a3ed7f (diff) | |
download | stasis-dafe7639674f3bfc66d3a116ec836c269c08f473.tar.gz |
msg() function is now type void
* Add debug_shell() function to interactively examine the runtime environment
-rw-r--r-- | include/utils.h | 6 | ||||
-rw-r--r-- | src/utils.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/include/utils.h b/include/utils.h index eb7604c..cdf4b4e 100644 --- a/include/utils.h +++ b/include/utils.h @@ -13,10 +13,12 @@ #define PATH_ENV_VAR "path" #define DIR_SEP "\\" #define PATH_SEP ";" +#define LINE_SEP "\r\n" #else #define PATH_ENV_VAR "PATH" #define DIR_SEP "/" #define PATH_SEP ":" +#define LINE_SEP "\n" #endif typedef int (ReaderFn)(size_t line, char **); @@ -32,12 +34,14 @@ 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_SUCCESS 0 #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, ...); +void msg(unsigned type, char *fmt, ...); +void debug_shell(); #endif //OHMYCAL_UTILS_H diff --git a/src/utils.c b/src/utils.c index c0bb28f..4e82a64 100644 --- a/src/utils.c +++ b/src/utils.c @@ -370,14 +370,14 @@ char *git_describe(const char *path) { #define OMC_COLOR_WHITE "\e[1;97m" #define OMC_COLOR_RESET "\e[0;37m\e[0m" -int msg(unsigned type, char *fmt, ...) { +void msg(unsigned type, char *fmt, ...) { FILE *stream = NULL; char header[255]; char status[255]; if (type & OMC_MSG_NOP) { // quiet mode - return 0; + return; } memset(header, 0, sizeof(header)); @@ -415,3 +415,10 @@ int msg(unsigned type, char *fmt, ...) { printf("%s", OMC_COLOR_RESET); va_end(args); } + +void debug_shell() { + msg(OMC_MSG_L1 | OMC_MSG_WARN, "ENTERING OMC DEBUG SHELL\n" OMC_COLOR_RESET); + system("/bin/bash -c 'PS1=\"(OMC DEBUG) \\W $ \" bash --norc --noprofile'"); + msg(OMC_MSG_L1 | OMC_MSG_WARN, "EXITING OMC DEBUG SHELL\n" OMC_COLOR_RESET); + exit(255); +} |