Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
internal_io.h
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
20// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/internal_io.h $
21// $Author: mhoffe $
22// $Revision: #1 $
23// $DateTime: 2003/07/03 11:55:26 $
24//
25// ©2003 Electronic Arts
26//
27// Internal header: I/O classes
29#ifdef _MSC_VER
30# pragma once
31#endif
32#ifndef INTERNAL_IO_H // Include guard
33#define INTERNAL_IO_H
34
36class DebugIOCon: public DebugIOInterface
37{
42 bool m_allocatedConsole;
43
47 char m_input[256];
48
52 unsigned m_inputUsed;
53
59 unsigned m_inputRead;
60
61public:
62 explicit DebugIOCon(void);
63 virtual ~DebugIOCon();
64 virtual int Read(char *buf, int maxchar);
65 virtual void Write(StringType type, const char *src, const char *str);
66 virtual void EmergencyFlush(void) {}
67 virtual void Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
68 unsigned argn, const char * const * argv);
69 static DebugIOInterface *Create(void);
70 virtual void Delete(void);
71};
72
74class DebugIOFlat: public DebugIOInterface
75{
77 class OutputStream
78 {
79 OutputStream(const OutputStream&);
80 OutputStream& operator=(const OutputStream&);
81
83 char *m_fileName;
84
86 HANDLE m_fileHandle;
87
89 bool m_limitedFileSize;
90
92 char *m_buffer;
93
95 unsigned m_bufferUsed;
96
98 unsigned m_bufferSize;
99
101 unsigned m_nextChar;
102
103 // these are private so that we are forced to use Create/Destroy
104 OutputStream(const char *filename, unsigned maxSize);
105 ~OutputStream();
106
113 void InternalWrite(const char *src, unsigned len);
114
115 public:
116
123 static OutputStream *Create(const char *filename, unsigned maxSize);
124
134 void Delete(const char *path=NULL);
135
141 const char *GetFilename(void) { return m_fileName; }
142
148 void Write(const char *src);
149
153 void Flush(void);
154 };
155
157 struct SplitListEntry
158 {
160 SplitListEntry *next;
161
163 unsigned stringTypes;
164
166 char items[256];
167
169 char name[256];
170
172 OutputStream *stream;
173 };
174
176 struct StreamListEntry
177 {
179 StreamListEntry *next;
180
182 OutputStream *stream;
183 };
184
186 SplitListEntry *m_firstSplit;
187
189 SplitListEntry **m_lastSplitPtr;
190
192 StreamListEntry *m_firstStream;
193
195 StreamListEntry **m_lastStreamPtr;
196
198 char m_baseFilename[256];
199
201 char m_copyDir[256];
202
210 static void ExpandMagic(const char *src, const char *splitName, char *buf);
211
212public:
213 explicit DebugIOFlat(void);
214 virtual ~DebugIOFlat();
215 virtual int Read(char *buf, int maxchar) { return 0; }
216 virtual void Write(StringType type, const char *src, const char *str);
217 virtual void EmergencyFlush(void);
218 virtual void Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
219 unsigned argn, const char * const * argv);
220 static DebugIOInterface *Create(void);
221 virtual void Delete(void);
222};
223
225class DebugIONet: public DebugIOInterface
226{
228 HANDLE m_pipe;
229
230public:
231 explicit DebugIONet(void);
232 virtual ~DebugIONet();
233 virtual int Read(char *buf, int maxchar);
234 virtual void Write(StringType type, const char *src, const char *str);
235 virtual void EmergencyFlush(void);
236 virtual void Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
237 unsigned argn, const char * const * argv);
238 static DebugIOInterface *Create(void);
239 virtual void Delete(void);
240};
241
243class DebugIOOds: public DebugIOInterface
244{
245public:
246 explicit DebugIOOds(void) {}
247 virtual int Read(char *buf, int maxchar) { return 0; }
248 virtual void Write(StringType type, const char *src, const char *str);
249 virtual void EmergencyFlush(void) {}
250 virtual void Execute(class Debug& dbg, const char *cmd, bool structuredCmd,
251 unsigned argn, const char * const * argv) {}
252 static DebugIOInterface *Create(void);
253 virtual void Delete(void);
254};
255
256#endif // INTERNAL_IO_H
#define NULL
Definition BaseType.h:92
Debug module main class (singleton).
Definition debug_debug.h:45
static DebugIOInterface * Create(void)
virtual void Write(StringType type, const char *src, const char *str)
Write out some characters differentiated by the log string type.
virtual ~DebugIOCon()
virtual void Execute(class Debug &dbg, const char *cmd, bool structuredCmd, unsigned argn, const char *const *argv)
I/O class specific command.
virtual void EmergencyFlush(void)
Emergency shutdown function.
Definition internal_io.h:66
virtual void Delete(void)
Destroys the current I/O class instance.
virtual int Read(char *buf, int maxchar)
Retrieves up to the given number of characters from a command input source.
virtual void Delete(void)
Destroys the current I/O class instance.
virtual void EmergencyFlush(void)
Emergency shutdown function.
virtual int Read(char *buf, int maxchar)
Retrieves up to the given number of characters from a command input source.
static DebugIOInterface * Create(void)
virtual void Write(StringType type, const char *src, const char *str)
Write out some characters differentiated by the log string type.
virtual ~DebugIOFlat()
virtual void Execute(class Debug &dbg, const char *cmd, bool structuredCmd, unsigned argn, const char *const *argv)
I/O class specific command.
Debug I/O interface.
Definition debug_io.h:47
StringType
List of possible log string types.
Definition debug_io.h:67
static DebugIOInterface * Create(void)
virtual void Write(StringType type, const char *src, const char *str)
Write out some characters differentiated by the log string type.
virtual void Delete(void)
Destroys the current I/O class instance.
virtual int Read(char *buf, int maxchar)
Retrieves up to the given number of characters from a command input source.
virtual ~DebugIONet()
virtual void Execute(class Debug &dbg, const char *cmd, bool structuredCmd, unsigned argn, const char *const *argv)
I/O class specific command.
virtual void EmergencyFlush(void)
Emergency shutdown function.
DebugIOOds(void)
static DebugIOInterface * Create(void)
virtual void Delete(void)
Destroys the current I/O class instance.
virtual void Write(StringType type, const char *src, const char *str)
Write out some characters differentiated by the log string type.
virtual void EmergencyFlush(void)
Emergency shutdown function.
virtual int Read(char *buf, int maxchar)
Retrieves up to the given number of characters from a command input source.
virtual void Execute(class Debug &dbg, const char *cmd, bool structuredCmd, unsigned argn, const char *const *argv)
I/O class specific command.