Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/utilities/sid/output.c – Rev 6

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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