diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-07-01 09:26:06 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-07-01 09:26:39 -0300 |
| commit | 5cfe00df82a69f44187b1cd77fe3d6865cf3425f (patch) | |
| tree | 395527bb97a908035ef9d6b1eb354b591005264f /src/utils.cc | |
| parent | 6243967f1fac3af8ed3e72790cabed0f79978bdb (diff) | |
| download | game-5cfe00df82a69f44187b1cd77fe3d6865cf3425f.tar.gz game-5cfe00df82a69f44187b1cd77fe3d6865cf3425f.zip | |
`reader.cc`
Diffstat (limited to 'src/utils.cc')
| -rw-r--r-- | src/utils.cc | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/utils.cc b/src/utils.cc index 4a3523b..11aa048 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -2,8 +2,9 @@ #include <sys/stat.h> -static void (*ErrorFunction)(const char *Text) = NULL; -static void (*PrintFunction)(int Level, const char *Text) = NULL; +static TErrorFunction *ErrorFunction; +static TPrintFunction *PrintFunction; +static char StandardLogFile[4096]; void SetErrorFunction(TErrorFunction *Function){ ErrorFunction = Function; @@ -13,6 +14,36 @@ void SetPrintFunction(TPrintFunction *Function){ PrintFunction = Function; } +void SetStandardLogFile(const char *FileName){ + strcpy(StandardLogFile, FileName); +} + +void SilentHandler(const char *Text){ + // no-op +} + +void SilentHandler(int Level, const char *Text){ + // no-op +} + +void LogFileHandler(const char *Text){ + if(StandardLogFile[0] == 0){ + return; + } + + FILE *File = fopen(StandardLogFile, "at"); + if(File != NULL){ + fprintf(File, "%s", Text); + if(fclose(File) != 0){ + error("LogfileHandler: Fehler %d beim Schließen der Datei.\n", errno); + } + } +} + +void LogFileHandler(int Level, const char *Text){ + LogFileHandler(Text); +} + void error(const char *Text, ...){ char s[1024]; |
