| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * Copyright (C) 2024 Descent Developers |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include <cstdio> |
| 21 | #include <cstdlib> |
| 22 | #include <cstring> |
| 23 | |
| 24 | #include "debug.h"cxx . . $ `<file>/ddebug/debug.h`/ |
| 25 | |
| 26 | void Debug_LogClosecxx . . $ Debug_LogClose(49f6e7a06ebc5aa8).(); |
| 27 | |
| 28 | FILE *Debug_logfilecxx . . $ Debug_logfile. = nullptr; |
| 29 | |
| 30 | bool Debug_Logfilecxx . . $ Debug_Logfile(c5f7da30cbc0f4e9).(const char *filename) { |
| 31 | if (Debug_logfilecxx . . $ Debug_logfile. == nullptr) { |
| 32 | Debug_logfilecxx . . $ Debug_logfile. = fopen(filename, "w"); |
| 33 | if (Debug_logfilecxx . . $ Debug_logfile. == nullptr) { |
| 34 | Debug_MessageBoxcxx . . $ Debug_MessageBox(9ee5302023219b2d).(OSMBOX_OKcxx . . $ OSMBOX_OK., "Debug", "FYI Logfile couldn't be created."); |
| 35 | return false; |
| 36 | } |
| 37 | atexit(Debug_LogClosecxx . . $ Debug_LogClose(49f6e7a06ebc5aa8).); |
| 38 | } |
| 39 | Debug_LogWritecxx . . $ Debug_LogWrite(85c52e162fed56f9).("BEGINNING LOG\n\n"); |
| 40 | |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | void Debug_LogWritecxx . . $ Debug_LogWrite(85c52e162fed56f9).(const char *str) { |
| 45 | if (Debug_logfilecxx . . $ Debug_logfile.) |
| 46 | fwrite(str, strlen(str), 1, Debug_logfilecxx . . $ Debug_logfile.); |
| 47 | } |
| 48 | |
| 49 | void Debug_LogClosecxx . . $ Debug_LogClose(49f6e7a06ebc5aa8).() { |
| 50 | if (Debug_logfilecxx . . $ Debug_logfile.) { |
| 51 | Debug_LogWritecxx . . $ Debug_LogWrite(85c52e162fed56f9).("\nEND LOG"); |
| 52 | fclose(Debug_logfilecxx . . $ Debug_logfile.); |
| 53 | Debug_logfilecxx . . $ Debug_logfile. = nullptr; |
| 54 | } |
| 55 | } |