Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
mydebug.cpp
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
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 <stdlib.h>
20
#include "
mydebug.h
"
21
#include "streamer.h"
22
#include "odevice.h"
23
24
25
// static MyMsgManager *msg_manager=NULL;
26
27
// static int paranoid_enabled=0;
28
static
ostream *paranoid_ostream=
NULL
;
29
static
Streamer
paranoid_streamer;
30
31
// Don't dare touch this semaphore in application code!
32
#ifdef USE_SEM
33
Sem4
MyDebugLibSemaphore
;
34
#else
35
CritSec
MyDebugLibSemaphore
;
36
#endif
37
38
39
int
MyMsgManager::setAllStreams
(
OutputDevice
*device)
40
{
41
if
(device==
NULL
)
42
return
(1);
43
44
MYDEBUGLOCK
;
45
paranoid_streamer.setOutputDevice(device);
46
delete
(paranoid_ostream);
47
paranoid_ostream=
new
ostream(¶noid_streamer);
48
49
MYDEBUGUNLOCK
;
50
51
return
(0);
52
}
53
54
55
int
MyMsgManager::setParanoidStream
(
OutputDevice
*device)
56
{
57
if
(device==
NULL
)
58
return
(1);
59
60
MYDEBUGLOCK
;
61
paranoid_streamer.setOutputDevice(device);
62
delete
(paranoid_ostream);
63
paranoid_ostream=
new
ostream(¶noid_streamer);
64
MYDEBUGUNLOCK
;
65
66
return
(0);
67
}
68
69
70
71
72
ostream *
MyMsgManager::paranoidStream
(
void
)
73
{
74
return
(paranoid_ostream);
75
}
76
77
78
int
MyMsgManager::ReplaceAllStreams
(
FileD
*
output_device
,
char
*device_filename,
char
*copy_filename)
79
{
80
MYDEBUGLOCK
;
81
82
delete
(paranoid_ostream);
83
84
if
(
output_device
!=
NULL
)
85
{
86
delete
(
output_device
);
87
output_device
=
NULL
;
88
}
89
90
rename(device_filename, copy_filename);
91
92
// FileD new_device(device_filename);
93
output_device
=
new
FileD
(device_filename);
94
95
paranoid_streamer.setOutputDevice(
output_device
);
96
paranoid_ostream =
new
ostream(¶noid_streamer);
97
98
MYDEBUGUNLOCK
;
99
100
return
(0);
101
}
NULL
#define NULL
Definition
BaseType.h:92
CritSec
Definition
critsec.h:44
FileD
Definition
filed.h:25
MyMsgManager::paranoidStream
static ostream * paranoidStream(void)
Definition
mydebug.cpp:72
MyMsgManager::setAllStreams
static int setAllStreams(OutputDevice *device)
Definition
mydebug.cpp:39
MyMsgManager::ReplaceAllStreams
static int ReplaceAllStreams(FileD *output_device, char *device_filename, char *copy_filename)
Definition
mydebug.cpp:78
MyMsgManager::setParanoidStream
static int setParanoidStream(OutputDevice *device)
Definition
mydebug.cpp:55
OutputDevice
Definition
odevice.h:25
Sem4
Definition
sem4.h:43
Streamer
Definition
streamer.h:40
output_device
OutputDevice * output_device
Definition
main.cpp:59
MyDebugLibSemaphore
Sem4 MyDebugLibSemaphore
Definition
mydebug.cpp:33
mydebug.h
MYDEBUGLOCK
#define MYDEBUGLOCK
Definition
mydebug.h:88
MYDEBUGUNLOCK
#define MYDEBUGUNLOCK
Definition
mydebug.h:89
Code
Tools
matchbot
mydebug.cpp
Generated by
1.13.2