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;
28static ostream *paranoid_ostream=NULL;
29static Streamer paranoid_streamer;
30
31// Don't dare touch this semaphore in application code!
32#ifdef USE_SEM
34#else
36#endif
37
38
40{
41 if (device==NULL)
42 return(1);
43
45 paranoid_streamer.setOutputDevice(device);
46 delete(paranoid_ostream);
47 paranoid_ostream=new ostream(&paranoid_streamer);
48
50
51 return(0);
52}
53
54
56{
57 if (device==NULL)
58 return(1);
59
61 paranoid_streamer.setOutputDevice(device);
62 delete(paranoid_ostream);
63 paranoid_ostream=new ostream(&paranoid_streamer);
65
66 return(0);
67}
68
69
70
71
73{
74 return(paranoid_ostream);
75}
76
77
78int MyMsgManager::ReplaceAllStreams(FileD * output_device, char *device_filename, char *copy_filename)
79{
81
82 delete(paranoid_ostream);
83
84 if (output_device != NULL)
85 {
86 delete(output_device);
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(&paranoid_streamer);
97
99
100 return(0);
101}
#define NULL
Definition BaseType.h:92
Definition filed.h:25
static ostream * paranoidStream(void)
Definition mydebug.cpp:72
static int setAllStreams(OutputDevice *device)
Definition mydebug.cpp:39
static int ReplaceAllStreams(FileD *output_device, char *device_filename, char *copy_filename)
Definition mydebug.cpp:78
static int setParanoidStream(OutputDevice *device)
Definition mydebug.cpp:55
Definition sem4.h:43
OutputDevice * output_device
Definition main.cpp:59
Sem4 MyDebugLibSemaphore
Definition mydebug.cpp:33
#define MYDEBUGLOCK
Definition mydebug.h:88
#define MYDEBUGUNLOCK
Definition mydebug.h:89