1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
/*
* Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
*/
/*
*
* filtprog.c -- hi level support for filters using different techniques
*
*/
#include <filter.h>
/*
*
* FilterProgStart -- start the filtering process
*
*/
#ifdef ANSI_FUNC
int
FilterProgStart (Filter filter)
#else
int FilterProgStart(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* call the technique-specific routine */
if( filter->filt_start )
return((filter->filt_start)(filter));
else{
return(0);
}
}
/*
*
* FilterProgOpen -- return filter program as a file for writing
*
*/
#ifdef ANSI_FUNC
int
FilterProgOpen (Filter filter)
#else
int FilterProgOpen(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* check the mode for known techniques and load drivers */
switch( filter->method ){
case METHOD_C:
FilterProgLoad_C(filter);
break;
default:
gerror(stderr, "unknown filter technique: %d\n", filter->method);
return(0);
}
/* call the technique-specific routine */
if( filter->filt_open ){
return((filter->filt_open)(filter));
}
else{
return(1);
}
}
/*
*
* FilterProgPrepend -- prepend to the filter
*
*/
#ifdef ANSI_FUNC
int
FilterProgPrepend (Filter filter)
#else
int FilterProgPrepend(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* call the technique-specific routine */
if( filter->filt_prepend )
return((filter->filt_prepend)(filter));
else
return(1);
}
/*
*
* FilterProgWrite -- write the symbols
*
*/
#ifdef ANSI_FUNC
int
FilterProgWrite (Filter filter)
#else
int FilterProgWrite(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* call the technique-specific routine */
if( filter->filt_write )
return((filter->filt_write)(filter));
else
return(1);
}
/*
*
* FilterProgAppend -- append the filter program body
*
*/
#ifdef ANSI_FUNC
int
FilterProgAppend (Filter filter)
#else
int FilterProgAppend(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* call the technique-specific routine */
if( filter->filt_append )
return((filter->filt_append)(filter));
else
return(1);
}
/*
*
* FilterProgClose -- close the filter program file
*
*/
#ifdef ANSI_FUNC
int
FilterProgClose (Filter filter)
#else
int FilterProgClose(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* debugging only */
if( filter->debug >= 2 )
return(1);
/* call the technique-specific routine */
if( filter->filt_close )
return((filter->filt_close)(filter));
else
return(1);
}
/*
*
* FilterProgCompile -- compile the filter program
*
*/
#ifdef ANSI_FUNC
int
FilterProgCompile (Filter filter)
#else
int FilterProgCompile(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* debugging only */
if( filter->debug >= 2 )
return(1);
/* call the technique-specific routine */
if( filter->filt_compile )
return((filter->filt_compile)(filter));
else
return(1);
}
/*
*
* FilterProgEnd -- end the filtering process
*
*/
#ifdef ANSI_FUNC
int
FilterProgEnd (Filter filter)
#else
int FilterProgEnd(filter)
Filter filter;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(0);
/* call the technique-specific routine */
if( filter->filt_end )
return((filter->filt_end)(filter));
else{
return(0);
}
}
/*
*
* FilterLexName -- return the "in-expression" name
*
*/
#ifdef ANSI_FUNC
char *
FilterLexName (Filter filter, char *name)
#else
char *FilterLexName(filter, name)
Filter filter;
char *name;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(name);
/* call the technique-specific routine */
if( filter->filt_name )
return((filter->filt_name)(filter, name));
else
return(name);
}
/*
*
* FilterLexRoutine1 -- return the beginning of the routine string
*
*/
#ifdef ANSI_FUNC
char *
FilterLexRoutine1 (Filter filter, char *name)
#else
char *FilterLexRoutine1(filter, name)
Filter filter;
char *name;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(NULL);
/* call the technique-specific routine */
if( filter->filt_routine1 )
return((filter->filt_routine1)(filter, name));
else
return(name);
}
/*
*
* FilterLexRoutine2 -- return the beginning of the routine string
*
*/
#ifdef ANSI_FUNC
char *
FilterLexRoutine2 (Filter filter, char *name)
#else
char *FilterLexRoutine2(filter, name)
Filter filter;
char *name;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(NULL);
/* call the technique-specific routine */
if( filter->filt_routine2 )
return((filter->filt_routine2)(filter, name));
else
return(name);
}
/*
*
* FilterLexRegion1 -- return the beginning of the region string
*
*/
#ifdef ANSI_FUNC
char *
FilterLexRegion1 (Filter filter, char *name)
#else
char *FilterLexRegion1(filter, name)
Filter filter;
char *name;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(NULL);
/* call the technique-specific region */
if( filter->filt_region1 )
return((filter->filt_region1)(filter, name));
else
return(name);
}
/*
*
* FilterLexRegion2 -- return the end of the region string
*
*/
#ifdef ANSI_FUNC
char *
FilterLexRegion2 (Filter filter, char *name)
#else
char *FilterLexRegion2(filter, name)
Filter filter;
char *name;
#endif
{
/* make sure we have something to play with */
if( filter == NULL)
return(NULL);
/* call the technique-specific region */
if( filter->filt_region2 )
return((filter->filt_region2)(filter, name));
else
return(name);
}
|