Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 55... Line 85...
55
#include "output.h"
85
#include "output.h"
56
 
86
 
57
/*--------------------------------------------------------------------------*/
87
/*--------------------------------------------------------------------------*/
58
 
88
 
59
void
89
void
60
out_info_init PROTO_N ((info, prog))
90
out_info_init(OutputInfoP info, CStringP prog)
61
	      PROTO_T (OutputInfoP info X
-
 
62
		       CStringP    prog)
-
 
63
{
91
{
64
    info->prog_name       = prog;
92
    info->prog_name       = prog;
65
    info->current_ostream = NIL (OStreamP);
93
    info->current_ostream = NIL(OStreamP);
66
    info->istreams        = NIL (IStreamP);
94
    info->istreams        = NIL(IStreamP);
67
    info->ostreams        = NIL (OStreamP);
95
    info->ostreams        = NIL(OStreamP);
68
    info->input_names     = NIL (CStringP *);
96
    info->input_names     = NIL(CStringP *);
69
    info->output_names    = NIL (CStringP *);
97
    info->output_names    = NIL(CStringP *);
70
    info->tab_width       = 8;
98
    info->tab_width       = 8;
71
}
99
}
72
 
100
 
73
#ifdef FS_FAST
101
#ifdef FS_FAST
74
#undef out_info_get_prog_name
102
#undef out_info_get_prog_name
75
#endif /* defined (FS_FAST) */
103
#endif /* defined (FS_FAST) */
76
CStringP
104
CStringP
77
out_info_get_prog_name PROTO_N ((info))
105
out_info_get_prog_name(OutputInfoP info)
78
		       PROTO_T (OutputInfoP info)
-
 
79
{
106
{
80
    return (info->prog_name);
107
    return(info->prog_name);
81
}
108
}
82
#ifdef FS_FAST
109
#ifdef FS_FAST
83
#define out_info_get_prog_name(o) ((o)->prog_name)
110
#define out_info_get_prog_name(o)	((o)->prog_name)
84
#endif /* defined (FS_FAST) */
111
#endif /* defined (FS_FAST) */
85
 
112
 
86
void
113
void
87
out_info_set_current_ostream PROTO_N ((info, i))
114
out_info_set_current_ostream(OutputInfoP info, unsigned i)
88
			     PROTO_T (OutputInfoP info X
-
 
89
				      unsigned    i)
-
 
90
{
115
{
91
    info->current_ostream = &(info->ostreams [i]);
116
    info->current_ostream = &(info->ostreams[i]);
92
}
117
}
93
 
118
 
94
#ifdef FS_FAST
119
#ifdef FS_FAST
95
#undef out_info_get_current_ostream
120
#undef out_info_get_current_ostream
96
#endif /* defined (FS_FAST) */
121
#endif /* defined (FS_FAST) */
97
OStreamP
122
OStreamP
98
out_info_get_current_ostream PROTO_N ((info))
123
out_info_get_current_ostream(OutputInfoP info)
99
			     PROTO_T (OutputInfoP info)
-
 
100
{
124
{
101
    return (info->current_ostream);
125
    return(info->current_ostream);
102
}
126
}
103
#ifdef FS_FAST
127
#ifdef FS_FAST
104
#define out_info_get_current_ostream(o) ((o)->current_ostream)
128
#define out_info_get_current_ostream(o)	((o)->current_ostream)
105
#endif /* defined (FS_FAST) */
129
#endif /* defined (FS_FAST) */
106
 
130
 
107
void
131
void
108
out_info_set_num_input_files PROTO_N ((info, size))
132
out_info_set_num_input_files(OutputInfoP info, unsigned size)
109
			     PROTO_T (OutputInfoP info X
-
 
110
				      unsigned    size)
-
 
111
{
133
{
112
    info->istreams    = ALLOCATE_VECTOR (IStreamT, size);
134
    info->istreams    = ALLOCATE_VECTOR(IStreamT, size);
113
    info->input_names = ALLOCATE_VECTOR (CStringP, size);
135
    info->input_names = ALLOCATE_VECTOR(CStringP, size);
114
}
136
}
115
 
137
 
116
void
138
void
117
out_info_set_num_output_files PROTO_N ((info, size))
139
out_info_set_num_output_files(OutputInfoP info, unsigned size)
118
			      PROTO_T (OutputInfoP info X
-
 
119
				       unsigned    size)
-
 
120
{
140
{
121
    info->ostreams     = ALLOCATE_VECTOR (OStreamT, size);
141
    info->ostreams     = ALLOCATE_VECTOR(OStreamT, size);
122
    info->output_names = ALLOCATE_VECTOR (CStringP, size);
142
    info->output_names = ALLOCATE_VECTOR(CStringP, size);
123
}
143
}
124
 
144
 
125
#ifdef FS_FAST
145
#ifdef FS_FAST
126
#undef out_info_get_istream
146
#undef out_info_get_istream
127
#endif /* defined (FS_FAST) */
147
#endif /* defined (FS_FAST) */
128
IStreamP
148
IStreamP
129
out_info_get_istream PROTO_N ((info, i))
149
out_info_get_istream(OutputInfoP info, unsigned i)
130
		     PROTO_T (OutputInfoP info X
-
 
131
			      unsigned    i)
-
 
132
{
150
{
133
    return (&(info->istreams [i]));
151
    return(&(info->istreams[i]));
134
}
152
}
135
#ifdef FS_FAST
153
#ifdef FS_FAST
136
#define out_info_get_istream(o, i) (&((o)->istreams [(i)]))
154
#define out_info_get_istream(o, i)	(&((o)->istreams[(i)]))
137
#endif /* defined (FS_FAST) */
155
#endif /* defined (FS_FAST) */
138
 
156
 
139
#ifdef FS_FAST
157
#ifdef FS_FAST
140
#undef out_info_get_ostream
158
#undef out_info_get_ostream
141
#endif /* defined (FS_FAST) */
159
#endif /* defined (FS_FAST) */
142
OStreamP
160
OStreamP
143
out_info_get_ostream PROTO_N ((info, i))
161
out_info_get_ostream(OutputInfoP info, unsigned i)
144
		     PROTO_T (OutputInfoP info X
-
 
145
			      unsigned    i)
-
 
146
{
162
{
147
    return (&(info->ostreams [i]));
163
    return(&(info->ostreams[i]));
148
}
164
}
149
#ifdef FS_FAST
165
#ifdef FS_FAST
150
#define out_info_get_ostream(o, i) (&((o)->ostreams [(i)]))
166
#define out_info_get_ostream(o, i)	(&((o)->ostreams[(i)]))
151
#endif /* defined (FS_FAST) */
167
#endif /* defined (FS_FAST) */
152
 
168
 
153
#ifdef FS_FAST
169
#ifdef FS_FAST
154
#undef out_info_set_infile_name
170
#undef out_info_set_infile_name
155
#endif /* defined (FS_FAST) */
171
#endif /* defined (FS_FAST) */
156
void
172
void
157
out_info_set_infile_name PROTO_N ((info, i, name))
173
out_info_set_infile_name(OutputInfoP info, unsigned i, CStringP name)
158
			 PROTO_T (OutputInfoP info X
-
 
159
				  unsigned    i X
-
 
160
				  CStringP    name)
-
 
161
{
174
{
162
    info->input_names [i] = name;
175
    info->input_names[i] = name;
163
}
176
}
164
#ifdef FS_FAST
177
#ifdef FS_FAST
165
#define out_info_set_infile_name(o, i, s) ((o)->input_names [(i)] = (s))
178
#define out_info_set_infile_name(o, i, s)	((o)->input_names[(i)] = (s))
166
#endif /* defined (FS_FAST) */
179
#endif /* defined (FS_FAST) */
167
 
180
 
168
#ifdef FS_FAST
181
#ifdef FS_FAST
169
#undef out_info_get_infile_name
182
#undef out_info_get_infile_name
170
#endif /* defined (FS_FAST) */
183
#endif /* defined (FS_FAST) */
171
CStringP
184
CStringP
172
out_info_get_infile_name PROTO_N ((info, i))
185
out_info_get_infile_name(OutputInfoP info, unsigned i)
173
			 PROTO_T (OutputInfoP info X
-
 
174
				  unsigned    i)
-
 
175
{
186
{
176
    return (info->input_names [i]);
187
    return(info->input_names[i]);
177
}
188
}
178
#ifdef FS_FAST
189
#ifdef FS_FAST
179
#define out_info_get_infile_name(o, i) ((o)->input_names [(i)])
190
#define out_info_get_infile_name(o, i)	((o)->input_names[(i)])
180
#endif /* defined (FS_FAST) */
191
#endif /* defined (FS_FAST) */
181
 
192
 
182
#ifdef FS_FAST
193
#ifdef FS_FAST
183
#undef out_info_set_outfile_name
194
#undef out_info_set_outfile_name
184
#endif /* defined (FS_FAST) */
195
#endif /* defined (FS_FAST) */
185
void
196
void
186
out_info_set_outfile_name PROTO_N ((info, i, name))
197
out_info_set_outfile_name(OutputInfoP info, unsigned i, CStringP name)
187
			  PROTO_T (OutputInfoP info X
-
 
188
				   unsigned    i X
-
 
189
				   CStringP    name)
-
 
190
{
198
{
191
    info->output_names [i] = name;
199
    info->output_names[i] = name;
192
}
200
}
193
#ifdef FS_FAST
201
#ifdef FS_FAST
194
#define out_info_set_outfile_name(o, i, s) ((o)->output_names [(i)] = (s))
202
#define out_info_set_outfile_name(o, i, s)	((o)->output_names[(i)] = (s))
195
#endif /* defined (FS_FAST) */
203
#endif /* defined (FS_FAST) */
196
 
204
 
197
#ifdef FS_FAST
205
#ifdef FS_FAST
198
#undef out_info_get_outfile_name
206
#undef out_info_get_outfile_name
199
#endif /* defined (FS_FAST) */
207
#endif /* defined (FS_FAST) */
200
CStringP
208
CStringP
201
out_info_get_outfile_name PROTO_N ((info, i))
209
out_info_get_outfile_name(OutputInfoP info, unsigned i)
202
			  PROTO_T (OutputInfoP info X
-
 
203
				   unsigned    i)
-
 
204
{
210
{
205
    return (info->output_names [i]);
211
    return(info->output_names[i]);
206
}
212
}
207
#ifdef FS_FAST
213
#ifdef FS_FAST
208
#define out_info_get_outfile_name(o, i) ((o)->output_names [(i)])
214
#define out_info_get_outfile_name(o, i)	((o)->output_names[(i)])
209
#endif /* defined (FS_FAST) */
215
#endif /* defined (FS_FAST) */
210
 
216
 
211
#ifdef FS_FAST
217
#ifdef FS_FAST
212
#undef out_info_set_tab_width
218
#undef out_info_set_tab_width
213
#endif /* defined (FS_FAST) */
219
#endif /* defined (FS_FAST) */
214
void
220
void
215
out_info_set_tab_width PROTO_N ((info, width))
221
out_info_set_tab_width(OutputInfoP info, unsigned width)
216
		       PROTO_T (OutputInfoP info X
-
 
217
				unsigned    width)
-
 
218
{
222
{
219
    info->tab_width = width;
223
    info->tab_width = width;
220
}
224
}
221
#ifdef FS_FAST
225
#ifdef FS_FAST
222
#define out_info_set_tab_width(o, w) ((o)->tab_width = (w))
226
#define out_info_set_tab_width(o, w)	((o)->tab_width = (w))
223
#endif /* defined (FS_FAST) */
227
#endif /* defined (FS_FAST) */
224
 
228
 
225
void
229
void
226
output_indent PROTO_N ((info, indent))
230
output_indent(OutputInfoP info, unsigned indent)
227
	      PROTO_T (OutputInfoP info X
-
 
228
		       unsigned    indent)
-
 
229
{
231
{
230
    OStreamP ostream    = out_info_get_current_ostream (info);
232
    OStreamP ostream    = out_info_get_current_ostream(info);
231
    unsigned tab_width  = info->tab_width;
233
    unsigned tab_width  = info->tab_width;
232
    unsigned num_tabs   = (indent / tab_width);
234
    unsigned num_tabs   = (indent / tab_width);
233
    unsigned num_spaces = (indent % tab_width);
235
    unsigned num_spaces = (indent % tab_width);
234
 
236
 
235
    while (num_tabs --) {
237
    while (num_tabs --) {
236
	write_tab (ostream);
238
	write_tab(ostream);
237
    }
239
    }
238
    while (num_spaces --) {
240
    while (num_spaces --) {
239
	write_char (ostream, ' ');
241
	write_char(ostream, ' ');
240
    }
242
    }
241
}
243
}
242

244

243
/*
245
/*
244
 * Local variables(smf):
246
 * Local variables(smf):