Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
straw.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
/***********************************************************************************************
20
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21
***********************************************************************************************
22
* *
23
* Project Name : Command & Conquer *
24
* *
25
* $Archive:: /G/wwlib/STRAW.CPP $*
26
* *
27
* $Author:: Eric_c $*
28
* *
29
* $Modtime:: 4/15/99 10:16a $*
30
* *
31
* $Revision:: 2 $*
32
* *
33
*---------------------------------------------------------------------------------------------*
34
* Functions: *
35
* Straw::Get_From -- Connect one straw segment to another. *
36
* Straw::Get -- Fetch some data from the straw chain. *
37
* Straw::~Straw -- Destructor for a straw segment. *
38
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40
#include "
always.h
"
41
#include "
straw.h
"
42
#include <stddef.h>
43
//#include <string.h>
44
45
46
/***********************************************************************************************
47
* Straw::~Straw -- Destructor for a straw segment. *
48
* *
49
* This destructor will remove this segment from the straw chain. If there were any *
50
* connected segments to either side, they will be joined so that the straw chain will *
51
* still remain linked. *
52
* *
53
* INPUT: none *
54
* *
55
* OUTPUT: none *
56
* *
57
* WARNINGS: none *
58
* *
59
* HISTORY: *
60
* 07/03/1996 JLB : Created. *
61
*=============================================================================================*/
62
Straw::~Straw
(
void
)
63
{
64
if
(
ChainTo
!=
NULL
) {
65
ChainTo
->ChainFrom =
ChainFrom
;
66
}
67
if
(
ChainFrom
!=
NULL
) {
68
ChainFrom
->Get_From(
ChainTo
);
69
}
70
71
ChainFrom
=
NULL
;
72
ChainTo
=
NULL
;
73
}
74
75
76
/***********************************************************************************************
77
* Straw::Get_From -- Connect one straw segment to another. *
78
* *
79
* Use this routine to connect straw segments together. The straw segment specified as the *
80
* parameter will be linked to the chain such that when data is requested, it will be *
81
* fetched from the specified link before being processed by this link. *
82
* *
83
* INPUT: straw -- Pointer to the straw segment that data will be fetched from. *
84
* *
85
* OUTPUT: none *
86
* *
87
* WARNINGS: none *
88
* *
89
* HISTORY: *
90
* 07/03/1996 JLB : Created. *
91
*=============================================================================================*/
92
void
Straw::Get_From
(
Straw
* straw)
93
{
94
if
(
ChainTo
!= straw) {
95
if
(straw !=
NULL
&& straw->
ChainFrom
!=
NULL
) {
96
straw->
ChainFrom
->
Get_From
(
NULL
);
97
straw->
ChainFrom
=
NULL
;
98
}
99
100
if
(
ChainTo
!=
NULL
) {
101
ChainTo
->ChainFrom =
NULL
;
102
}
103
104
ChainTo
= straw;
105
if
(
ChainTo
!=
NULL
) {
106
ChainTo
->ChainFrom =
this
;
107
}
108
}
109
}
110
111
112
/***********************************************************************************************
113
* Straw::Get -- Fetch some data from the straw chain. *
114
* *
115
* Use this routine to fetch some data from the straw. It is presumed that this routine *
116
* will be overridden to provide some useful functionality. At this level, the straw chain *
117
* merely passes the request on to the next straw in the chain. *
118
* *
119
* INPUT: source -- Pointer to the buffer to hold the requested data. *
120
* *
121
* length -- The number of bytes requested. *
122
* *
123
* OUTPUT: Returns with the number of bytes stored into the buffer. If the number returned *
124
* is less than the number requested, then this indicates that the straw data has *
125
* been exhausted. *
126
* *
127
* WARNINGS: none *
128
* *
129
* HISTORY: *
130
* 07/03/1996 JLB : Created. *
131
*=============================================================================================*/
132
int
Straw::Get
(
void
* source,
int
slen)
133
{
134
if
(
ChainTo
!=
NULL
) {
135
return
(
ChainTo
->Get(source, slen));
136
}
137
return
(0);
138
}
139
140
NULL
#define NULL
Definition
BaseType.h:92
always.h
STRAW.H
Straw::Get
virtual int Get(void *buffer, int slen)
Definition
straw.cpp:132
Straw::ChainTo
Straw * ChainTo
Definition
STRAW.H:63
Straw::ChainFrom
Straw * ChainFrom
Definition
STRAW.H:64
Straw::Get_From
virtual void Get_From(Straw *pipe)
Definition
straw.cpp:92
Straw::~Straw
virtual ~Straw(void)
Definition
straw.cpp:62
Straw::Straw
Straw(void)
Definition
STRAW.H:53
Code
Libraries
Source
WWVegas
WWLib
straw.cpp
Generated by
1.13.2