This repository has been archived by the owner on Jun 11, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "log.h" | ||
#include "memory.h" | ||
#include <stdarg.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#define MAX_SIZE 4096 | ||
|
||
static void (*g_puts)(const char *string) = NULL; | ||
|
||
static void | ||
logv(const char *format, va_list ap) | ||
{ | ||
char * buffer = memoryTemp(MAX_SIZE); | ||
vsnprintf(buffer, MAX_SIZE, format, ap); | ||
g_puts(buffer); | ||
} | ||
|
||
void | ||
logPrintf(const char *format, ... ) | ||
{ | ||
va_list ap; | ||
va_start(ap,format); | ||
logv(format, ap); | ||
va_end(ap); | ||
} | ||
|
||
void | ||
logFatal(const char *format, ... ) | ||
{ | ||
va_list ap; | ||
va_start(ap,format); | ||
logv(format, ap); | ||
va_end(ap); | ||
exit(1); | ||
} | ||
|
||
void logInject(void (*_puts)(const char *string)) | ||
{ | ||
g_puts = _puts; | ||
} | ||
|
||
static void | ||
logerr(const char *string) | ||
{ | ||
fputs(string, stderr); | ||
} | ||
|
||
int | ||
logInit(void) | ||
{ | ||
logInject(logerr); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef windsoul_log_h | ||
#define windsoul_log_h | ||
|
||
void logPrintf(const char *format, ... ); | ||
void logFatal(const char *format, ... ); | ||
void logInject(void (*puts)(const char *string)); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "log.h" | ||
#include "test.h" | ||
|
||
void | ||
test() | ||
{ | ||
logPrintf("Hello World"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef windsoul_test_module_h | ||
#define windsoul_test_module_h | ||
|
||
static void test(void); | ||
|
||
int _setInit(void); | ||
int _atomInit(void); | ||
int _mapInit(void); | ||
int _logInit(void); | ||
|
||
int | ||
main() | ||
{ | ||
if (_setInit()) return 1; | ||
if (_atomInit()) return 1; | ||
if (_mapInit()) return 1; | ||
if (_logInit()) return 1; | ||
|
||
test(); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
#endif |