diff options
author | Pwn20wnd <pwn20wndstuff@gmail.com> | 2019-03-09 23:30:26 +0300 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2019-03-20 23:27:12 -1000 |
commit | 7bca6ad19e54e2edc4ec9cfa10da20a26e294334 (patch) | |
tree | 9805a17e7d5ecdedc2aeb0a0328c6b2df1b26828 /kernel_call/log.c | |
parent | 4abbd1f554d3f1a185fd7079ee84944f1b0a355b (diff) |
Merge pwn's changes to support arm64e via rebase
Diffstat (limited to 'kernel_call/log.c')
-rwxr-xr-x | kernel_call/log.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/kernel_call/log.c b/kernel_call/log.c new file mode 100755 index 0000000..0ff5f01 --- /dev/null +++ b/kernel_call/log.c @@ -0,0 +1,37 @@ +/* + * log.c + * Brandon Azad + */ +#include "log.h" + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +void +log_internal(char type, const char *format, ...) { + if (log_implementation != NULL) { + va_list ap; + va_start(ap, format); + log_implementation(type, format, ap); + va_end(ap); + } +} + +// The default logging implementation prints to stderr with a nice hacker prefix. +static void +log_stderr(char type, const char *format, va_list ap) { + char *message = NULL; + vasprintf(&message, format, ap); + assert(message != NULL); + switch (type) { + case 'D': type = 'D'; break; + case 'I': type = '+'; break; + case 'W': type = '!'; break; + case 'E': type = '-'; break; + } + fprintf(stderr, "[%c] %s\n", type, message); + free(message); +} + +void (*log_implementation)(char type, const char *format, va_list ap) = log_stderr; |