Debian Codegraph @

misc/logfile.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <cstdarg>
20 #include <cstdio>
21
22 #include "logfile.h"cxx . . $ `<file>/misc/logfile.h`/
23
24 #ifdef _DEBUGcxx . . $ `<built-in>:479:9`!
25 static bool log_enablecxx . . $ log_enable. = true;
26 #else
27 static bool log_enable = false;
28 #endif
29
30 void log_Enablecxx . . $ log_Enable(b45ddcbc8423892c).(bool enable) { log_enablecxx . . $ log_enable. = true; }
31
32 void log_Disablecxx . . $ log_Disable(49f6e7a06ebc5aa8).() { log_enablecxx . . $ log_enable. = false; }
33
34 logfilecxx . . $ logfile#::logfilecxx . . $ logfile#logfile(49f6e7a06ebc5aa8).() { fpcxx . . $ logfile#fp. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; }
35
36 logfilecxx . . $ logfile#::~cxx . . $ logfile#`~logfile`(ced63f7c635d850d).logfilecxx . . $ logfile#() { endcxx . . $ logfile#end(49f6e7a06ebc5aa8).(); }
37
38 // restarts the logfile (opens a new one.)
39 void logfilecxx . . $ logfile#::startcxx . . $ logfile#start(2fa786934fe80e24).(const char *fname, const char *longname) {
40 if (log_enablecxx . . $ log_enable.) {
41 try {
42 fpcxx . . $ logfile#fp. = (FILE *)fopen(fname, "wt");
43 logfilecxx . . $ logfile#::printfcxx . . $ logfile#printf(326aeb464d16410c).("%s\n", longname);
44 } catch (...) {
45 fpcxx . . $ logfile#fp. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
46 }
47 }
48 }
49
50 void logfilecxx . . $ logfile#::endcxx . . $ logfile#end(49f6e7a06ebc5aa8).() {
51 if (fpcxx . . $ logfile#fp.) {
52 try {
53 fclose((FILE *)fpcxx . . $ logfile#fp.);
54 fpcxx . . $ logfile#fp. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
55 } catch (...) {
56 fpcxx . . $ logfile#fp. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
57 }
58 }
59 }
60
61 void logfilecxx . . $ logfile#::printfcxx . . $ logfile#printf(326aeb464d16410c).(const char *fmt, ...) {
62 if (fpcxx . . $ logfile#fp. && fmt) {
63 char msg[256];
64 stdcxx . . $ std/::va_listcxx . . $ std/va_list# arglist;
65 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(arglist, fmt);
66 stdcxx . . $ std/::vsnprintfcxx . . $ std/vsnprintf(348eb892742d8727).(msg, sizeof(msg), fmt, arglist);
67 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(arglist);
68
69 logfilecxx . . $ logfile#::putscxx . . $ logfile#puts(85c52e162fed56f9).(msg);
70 }
71 }
72
73 void logfilecxx . . $ logfile#::putscxx . . $ logfile#puts(85c52e162fed56f9).(const char *msg) {
74 if (fpcxx . . $ logfile#fp. && msg) {
75 try {
76 fputs(msg, (FILE *)fpcxx . . $ logfile#fp.);
77 } catch (...) {
78 endcxx . . $ logfile#end(49f6e7a06ebc5aa8).();
79 }
80 }
81 }
82
83 void logfilecxx . . $ logfile#::updatecxx . . $ logfile#update(49f6e7a06ebc5aa8).() {
84 if (fpcxx . . $ logfile#fp.) {
85 try {
86 fflush((FILE *)fpcxx . . $ logfile#fp.);
87 } catch (...) {
88 endcxx . . $ logfile#end(49f6e7a06ebc5aa8).();
89 }
90 }
91 }