1 /*------------------------------------------------------------\
2 | |
3 | Tool : RDS |
4 | |
5 | File : rdsdel.c |
6 | |
7 | Authors : Jacomme Ludovic |
8 | |
9 | Date : 27.06.95 |
10 | |
11 \------------------------------------------------------------*/
12 /*------------------------------------------------------------\
13 | |
14 | Include Files |
15 | |
16 \------------------------------------------------------------*/
17
18 # include <stdio.h>
19 # include <string.h>
20
21 # include <mut.h>
22 # include "rds.h"
23
24 # include "rdsdel.h"
25 # include "rdserror.h"
26
27 /*------------------------------------------------------------\
28 | |
29 | Constants |
30 | |
31 \------------------------------------------------------------*/
32 /*------------------------------------------------------------\
33 | |
34 | Types |
35 | |
36 \------------------------------------------------------------*/
37 /*------------------------------------------------------------\
38 | |
39 | Variables |
40 | |
41 \------------------------------------------------------------*/
42 /*------------------------------------------------------------\
43 | |
44 | Functions |
45 | |
46 \------------------------------------------------------------*/
47 /*------------------------------------------------------------\
48 | |
49 | Rds Del Functions |
50 | |
51 \------------------------------------------------------------*/
52 /*------------------------------------------------------------\
53 | |
54 | Rds Del Figure |
55 | |
56 \------------------------------------------------------------*/
57
delrdsfig(Name)58 int delrdsfig( Name )
59
60 char *Name;
61 {
62 rdsfig_list *Figure;
63 rdsfig_list **Previous;
64 rdsins_list *Instance;
65 rdsrec_list *Rectangle;
66 void *Save;
67 int Layer;
68
69 Name = namealloc( Name );
70 Previous = &HEAD_RDSFIG;
71
72 for ( Figure = HEAD_RDSFIG;
73 Figure != (rdsfig_list *)NULL;
74 Figure = Figure->NEXT )
75 {
76 if ( Figure->NAME == Name ) break;
77
78 Previous = &Figure->NEXT;
79 }
80
81 if ( Figure == (rdsfig_list *)NULL )
82
83 return( 0 );
84
85 *Previous = Figure->NEXT;
86
87 for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )
88 {
89 Rectangle = Figure->LAYERTAB[ Layer ];
90
91 while ( Rectangle != (rdsrec_list *)NULL )
92 {
93 Save = (void *)(Rectangle->NEXT);
94
95 freerdsrec( Rectangle, Figure->SIZE );
96
97 Rectangle = (rdsrec_list *)Save;
98 }
99 }
100
101 Instance = Figure->INSTANCE;
102
103 while ( Instance != (rdsins_list *)NULL )
104 {
105 for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )
106 {
107 Rectangle = Instance->LAYERTAB[ Layer ];
108
109 while ( Rectangle != (rdsrec_list *)NULL )
110 {
111 Save = (void *)(Rectangle->NEXT);
112
113 freerdsrec( Rectangle, Figure->SIZE );
114
115 Rectangle = (rdsrec_list *)Save;
116 }
117 }
118
119 Save = (void *)(Instance->NEXT);
120
121 freerdsins( Instance );
122
123 Instance = (rdsins_list *)Save;
124 }
125
126 freerdsfig( Figure );
127
128 return( 1 );
129 }
130
131 /*------------------------------------------------------------\
132 | |
133 | Rds Del Instance |
134 | |
135 \------------------------------------------------------------*/
136
delrdsins(Figure,Name)137 int delrdsins( Figure, Name )
138
139 rdsfig_list *Figure;
140 char *Name;
141 {
142 rdsins_list **Previous;
143 rdsins_list *Instance;
144 rdsrec_list *Rectangle;
145 void *Save;
146 int Layer;
147
148 Name = namealloc( Name );
149 Previous = &Figure->INSTANCE;
150
151 for ( Instance = Figure->INSTANCE;
152 Instance != (rdsins_list *)NULL;
153 Instance = Instance->NEXT )
154 {
155 if ( Instance->INSNAME == Name ) break;
156
157 Previous = &Instance->NEXT;
158 }
159
160 if ( Instance == (rdsins_list *)NULL )
161
162 return( 0 );
163
164 *Previous = Instance->NEXT;
165
166 for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )
167 {
168 Rectangle = Instance->LAYERTAB[ Layer ];
169
170 while ( Rectangle != (rdsrec_list *)NULL )
171 {
172 Save = (void *)(Rectangle->NEXT);
173
174 freerdsrec( Rectangle, Figure->SIZE );
175
176 Rectangle = (rdsrec_list *)Save;
177 }
178 }
179
180 freerdsins( Instance );
181
182 return( 1 );
183 }
184
185 /*------------------------------------------------------------\
186 | |
187 | Rds Del Rectangle In Instance |
188 | |
189 \------------------------------------------------------------*/
190
delrdsinsrec(Instance,Rectangle)191 int delrdsinsrec( Instance, Rectangle )
192
193 rdsins_list *Instance;
194 rdsrec_list *Rectangle;
195 {
196 rdsrec_list **Previous;
197 rdsrec_list *Scan;
198
199 Previous = &Instance->LAYERTAB[ GetRdsLayer( Rectangle ) ];
200
201 for ( Scan = Instance->LAYERTAB[ GetRdsLayer( Rectangle ) ];
202 Scan != (rdsrec_list *)NULL;
203 Scan = Scan->NEXT )
204 {
205 if ( Scan == Rectangle ) break;
206
207 Previous = &Scan->NEXT;
208 }
209
210 if ( Scan == (rdsrec_list *)NULL )
211
212 return( 0 );
213
214 *Previous = Rectangle->NEXT;
215
216 freerdsrec( Rectangle, Instance->SIZE );
217
218 return( 1 );
219 }
220
221 /*------------------------------------------------------------\
222 | |
223 | Rds Del Rectangle In Figure |
224 | |
225 \------------------------------------------------------------*/
226
delrdsfigrec(Figure,Rectangle)227 int delrdsfigrec( Figure, Rectangle )
228
229 rdsfig_list *Figure;
230 rdsrec_list *Rectangle;
231 {
232 rdsrec_list **Previous;
233 rdsrec_list *Scan;
234
235 Previous = &Figure->LAYERTAB[ GetRdsLayer( Rectangle ) ];
236
237 for ( Scan = Figure->LAYERTAB[ GetRdsLayer( Rectangle ) ];
238 Scan != (rdsrec_list *)NULL;
239 Scan = Scan->NEXT )
240 {
241 if ( Scan == Rectangle ) break;
242
243 Previous = &Scan->NEXT;
244 }
245
246 if ( Scan == (rdsrec_list *)NULL )
247
248 return( 0 );
249
250 *Previous = Rectangle->NEXT;
251
252 freerdsrec( Rectangle, Figure->SIZE );
253
254 return( 1 );
255 }
256
257