Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**** output.c --- Target independent output routines.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 **** Commentary:
36
 *
37
 * This file implements some generic output routines.
38
 *
39
 **** Change Log:
40
 * $Log: output.c,v $
41
 * Revision 1.1.1.1  1998/01/17  15:57:46  release
42
 * First version to be checked into rolling release.
43
 *
44
 * Revision 1.2  1994/12/15  09:57:13  smf
45
 * Brought into line with OSSG C Coding Standards Document, as per
46
 * "CR94_178.sid+tld-update".
47
 *
48
 * Revision 1.1.1.1  1994/07/25  16:04:21  smf
49
 * Initial import of SID 1.8 non shared files.
50
 *
51
**/
52
 
53
/****************************************************************************/
54
 
55
#include "output.h"
56
 
57
/*--------------------------------------------------------------------------*/
58
 
59
void
60
out_info_init PROTO_N ((info, prog))
61
	      PROTO_T (OutputInfoP info X
62
		       CStringP    prog)
63
{
64
    info->prog_name       = prog;
65
    info->current_ostream = NIL (OStreamP);
66
    info->istreams        = NIL (IStreamP);
67
    info->ostreams        = NIL (OStreamP);
68
    info->input_names     = NIL (CStringP *);
69
    info->output_names    = NIL (CStringP *);
70
    info->tab_width       = 8;
71
}
72
 
73
#ifdef FS_FAST
74
#undef out_info_get_prog_name
75
#endif /* defined (FS_FAST) */
76
CStringP
77
out_info_get_prog_name PROTO_N ((info))
78
		       PROTO_T (OutputInfoP info)
79
{
80
    return (info->prog_name);
81
}
82
#ifdef FS_FAST
83
#define out_info_get_prog_name(o) ((o)->prog_name)
84
#endif /* defined (FS_FAST) */
85
 
86
void
87
out_info_set_current_ostream PROTO_N ((info, i))
88
			     PROTO_T (OutputInfoP info X
89
				      unsigned    i)
90
{
91
    info->current_ostream = &(info->ostreams [i]);
92
}
93
 
94
#ifdef FS_FAST
95
#undef out_info_get_current_ostream
96
#endif /* defined (FS_FAST) */
97
OStreamP
98
out_info_get_current_ostream PROTO_N ((info))
99
			     PROTO_T (OutputInfoP info)
100
{
101
    return (info->current_ostream);
102
}
103
#ifdef FS_FAST
104
#define out_info_get_current_ostream(o) ((o)->current_ostream)
105
#endif /* defined (FS_FAST) */
106
 
107
void
108
out_info_set_num_input_files PROTO_N ((info, size))
109
			     PROTO_T (OutputInfoP info X
110
				      unsigned    size)
111
{
112
    info->istreams    = ALLOCATE_VECTOR (IStreamT, size);
113
    info->input_names = ALLOCATE_VECTOR (CStringP, size);
114
}
115
 
116
void
117
out_info_set_num_output_files PROTO_N ((info, size))
118
			      PROTO_T (OutputInfoP info X
119
				       unsigned    size)
120
{
121
    info->ostreams     = ALLOCATE_VECTOR (OStreamT, size);
122
    info->output_names = ALLOCATE_VECTOR (CStringP, size);
123
}
124
 
125
#ifdef FS_FAST
126
#undef out_info_get_istream
127
#endif /* defined (FS_FAST) */
128
IStreamP
129
out_info_get_istream PROTO_N ((info, i))
130
		     PROTO_T (OutputInfoP info X
131
			      unsigned    i)
132
{
133
    return (&(info->istreams [i]));
134
}
135
#ifdef FS_FAST
136
#define out_info_get_istream(o, i) (&((o)->istreams [(i)]))
137
#endif /* defined (FS_FAST) */
138
 
139
#ifdef FS_FAST
140
#undef out_info_get_ostream
141
#endif /* defined (FS_FAST) */
142
OStreamP
143
out_info_get_ostream PROTO_N ((info, i))
144
		     PROTO_T (OutputInfoP info X
145
			      unsigned    i)
146
{
147
    return (&(info->ostreams [i]));
148
}
149
#ifdef FS_FAST
150
#define out_info_get_ostream(o, i) (&((o)->ostreams [(i)]))
151
#endif /* defined (FS_FAST) */
152
 
153
#ifdef FS_FAST
154
#undef out_info_set_infile_name
155
#endif /* defined (FS_FAST) */
156
void
157
out_info_set_infile_name PROTO_N ((info, i, name))
158
			 PROTO_T (OutputInfoP info X
159
				  unsigned    i X
160
				  CStringP    name)
161
{
162
    info->input_names [i] = name;
163
}
164
#ifdef FS_FAST
165
#define out_info_set_infile_name(o, i, s) ((o)->input_names [(i)] = (s))
166
#endif /* defined (FS_FAST) */
167
 
168
#ifdef FS_FAST
169
#undef out_info_get_infile_name
170
#endif /* defined (FS_FAST) */
171
CStringP
172
out_info_get_infile_name PROTO_N ((info, i))
173
			 PROTO_T (OutputInfoP info X
174
				  unsigned    i)
175
{
176
    return (info->input_names [i]);
177
}
178
#ifdef FS_FAST
179
#define out_info_get_infile_name(o, i) ((o)->input_names [(i)])
180
#endif /* defined (FS_FAST) */
181
 
182
#ifdef FS_FAST
183
#undef out_info_set_outfile_name
184
#endif /* defined (FS_FAST) */
185
void
186
out_info_set_outfile_name PROTO_N ((info, i, name))
187
			  PROTO_T (OutputInfoP info X
188
				   unsigned    i X
189
				   CStringP    name)
190
{
191
    info->output_names [i] = name;
192
}
193
#ifdef FS_FAST
194
#define out_info_set_outfile_name(o, i, s) ((o)->output_names [(i)] = (s))
195
#endif /* defined (FS_FAST) */
196
 
197
#ifdef FS_FAST
198
#undef out_info_get_outfile_name
199
#endif /* defined (FS_FAST) */
200
CStringP
201
out_info_get_outfile_name PROTO_N ((info, i))
202
			  PROTO_T (OutputInfoP info X
203
				   unsigned    i)
204
{
205
    return (info->output_names [i]);
206
}
207
#ifdef FS_FAST
208
#define out_info_get_outfile_name(o, i) ((o)->output_names [(i)])
209
#endif /* defined (FS_FAST) */
210
 
211
#ifdef FS_FAST
212
#undef out_info_set_tab_width
213
#endif /* defined (FS_FAST) */
214
void
215
out_info_set_tab_width PROTO_N ((info, width))
216
		       PROTO_T (OutputInfoP info X
217
				unsigned    width)
218
{
219
    info->tab_width = width;
220
}
221
#ifdef FS_FAST
222
#define out_info_set_tab_width(o, w) ((o)->tab_width = (w))
223
#endif /* defined (FS_FAST) */
224
 
225
void
226
output_indent PROTO_N ((info, indent))
227
	      PROTO_T (OutputInfoP info X
228
		       unsigned    indent)
229
{
230
    OStreamP ostream    = out_info_get_current_ostream (info);
231
    unsigned tab_width  = info->tab_width;
232
    unsigned num_tabs   = (indent / tab_width);
233
    unsigned num_spaces = (indent % tab_width);
234
 
235
    while (num_tabs --) {
236
	write_tab (ostream);
237
    }
238
    while (num_spaces --) {
239
	write_char (ostream, ' ');
240
    }
241
}
242
 
243
/*
244
 * Local variables(smf):
245
 * eval: (include::add-path-entry "../os-interface" "../library")
246
 * eval: (include::add-path-entry "../transforms" "../generated")
247
 * end:
248
**/