Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
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 61... Line 91...
61
 * constant is used.
91
 * constant is used.
62
 *
92
 *
63
 ***=== FUNCTIONS ============================================================
93
 ***=== FUNCTIONS ============================================================
64
 *
94
 *
65
 ** Function:	void			ostream_setup
95
 ** Function:	void			ostream_setup
66
 *			PROTO_S ((void))
96
 *			(void)
67
 ** Exceptions:
97
 ** Exceptions:
68
 *
98
 *
69
 * This function initialises the output stream facility.  It should be called
99
 * This function initialises the output stream facility.  It should be called
70
 * before any other ostream manipulation function.
100
 * before any other ostream manipulation function.
71
 *
101
 *
72
 ** Function:	void			ostream_init
102
 ** Function:	void			ostream_init
73
 *			PROTO_S ((OStreamP ostream))
103
 *			(OStreamP ostream)
74
 ** Exceptions:
104
 ** Exceptions:
75
 *
105
 *
76
 * This function initialises the specified ostream not to write to any file.
106
 * This function initialises the specified ostream not to write to any file.
77
 *
107
 *
78
 ** Function:	BoolT			ostream_open
108
 ** Function:	BoolT			ostream_open
79
 *			PROTO_S ((OStreamP ostream, CStringP name))
109
 *			(OStreamP ostream, CStringP name)
80
 ** Exceptions:
110
 ** Exceptions:
81
 *
111
 *
82
 * This function initialises the specified ostream to write to the file with
112
 * This function initialises the specified ostream to write to the file with
83
 * the specified name.  If the file cannot be opened, the function returns
113
 * the specified name.  If the file cannot be opened, the function returns
84
 * false.  If the file is opened successfully, the function returns true.  The
114
 * false.  If the file is opened successfully, the function returns true.  The
85
 * name should not be modified or deallocated until the ostream has been
115
 * name should not be modified or deallocated until the ostream has been
86
 * closed.  The initial buffering state of the ostream is fully buffered.
116
 * closed.  The initial buffering state of the ostream is fully buffered.
87
 *
117
 *
88
 ** Function:	BoolT			ostream_is_open
118
 ** Function:	BoolT			ostream_is_open
89
 *			PROTO_S ((OStreamP ostream))
119
 *			(OStreamP ostream)
90
 ** Exceptions:
120
 ** Exceptions:
91
 *
121
 *
92
 * This function returns true if the specified ostream is writing to a file,
122
 * This function returns true if the specified ostream is writing to a file,
93
 * and false otherwise.
123
 * and false otherwise.
94
 *
124
 *
95
 ** Function:	void			ostream_buffer
125
 ** Function:	void			ostream_buffer
96
 *			PROTO_S ((OStreamP ostream))
126
 *			(OStreamP ostream)
97
 ** Exceptions:
127
 ** Exceptions:
98
 *
128
 *
99
 * This function sets the buffering state of the specified ostream to fully
129
 * This function sets the buffering state of the specified ostream to fully
100
 * buffered.
130
 * buffered.
101
 *
131
 *
102
 ** Function:	void			ostream_unbuffer
132
 ** Function:	void			ostream_unbuffer
103
 *			PROTO_S ((OStreamP ostream))
133
 *			(OStreamP ostream)
104
 *
134
 *
105
 * This function sets the buffering state of the specified ostream to
135
 * This function sets the buffering state of the specified ostream to
106
 * unbuffered.
136
 * unbuffered.
107
 *
137
 *
108
 ** Function:	void			ostream_close
138
 ** Function:	void			ostream_close
109
 *			PROTO_S ((OStreamP ostream))
139
 *			(OStreamP ostream)
110
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
140
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
111
 *
141
 *
112
 * This function closes the specified ostream.
142
 * This function closes the specified ostream.
113
 *
143
 *
114
 ** Function:	void			ostream_flush
144
 ** Function:	void			ostream_flush
115
 *			PROTO_S ((OStreamP ostream))
145
 *			(OStreamP ostream)
116
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
146
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
117
 *
147
 *
118
 * This function flushes the ostream's output buffer.
148
 * This function flushes the ostream's output buffer.
119
 *
149
 *
120
 ** Function:	CStringP		ostream_name
150
 ** Function:	CStringP		ostream_name
121
 *			PROTO_S ((OStreamP ostream))
151
 *			(OStreamP ostream)
122
 ** Exceptions:
152
 ** Exceptions:
123
 *
153
 *
124
 * This function returns the name of the file that the specified ostream is
154
 * This function returns the name of the file that the specified ostream is
125
 * writing to.  The return value should not be modified or deallocated.
155
 * writing to.  The return value should not be modified or deallocated.
126
 *
156
 *
127
 ** Function:	unsigned		ostream_line
157
 ** Function:	unsigned		ostream_line
128
 *			PROTO_S ((OStreamP ostream))
158
 *			(OStreamP ostream)
129
 ** Exceptions:
159
 ** Exceptions:
130
 *
160
 *
131
 * This function returns one more than the number of newlines that have been
161
 * This function returns one more than the number of newlines that have been
132
 * written to the specified ostream.  The result is undefined if the stream
162
 * written to the specified ostream.  The result is undefined if the stream
133
 * is not open.
163
 * is not open.
134
 *
164
 *
135
 ** Function:	void			write_newline
165
 ** Function:	void			write_newline
136
 *			PROTO_S ((OStreamP ostream))
166
 *			(OStreamP ostream)
137
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
167
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
138
 *
168
 *
139
 * This function writes a newline to the specified ostream.
169
 * This function writes a newline to the specified ostream.
140
 *
170
 *
141
 ** Function:	void			write_tab
171
 ** Function:	void			write_tab
142
 *			PROTO_S ((OStreamP ostream))
172
 *			(OStreamP ostream)
143
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
173
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
144
 *
174
 *
145
 * This function writes a tab to the specified ostream.
175
 * This function writes a tab to the specified ostream.
146
 *
176
 *
147
 ** Function:	void			write_byte
177
 ** Function:	void			write_byte
148
 *			PROTO_S ((OStreamP ostream, ByteT c))
178
 *			(OStreamP ostream, ByteT c)
149
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
179
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
150
 *
180
 *
151
 * This function writes the specified byte to the specified ostream.
181
 * This function writes the specified byte to the specified ostream.
152
 *
182
 *
153
 ** Function:	void			write_char
183
 ** Function:	void			write_char
154
 *			PROTO_S ((OStreamP ostream, char c))
184
 *			(OStreamP ostream, char c)
155
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
185
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
156
 *
186
 *
157
 * This function writes the specified character to the specified ostream.
187
 * This function writes the specified character to the specified ostream.
158
 *
188
 *
159
 ** Function:	void			write_escaped_char
189
 ** Function:	void			write_escaped_char
160
 *			PROTO_S ((OStreamP ostream, char c))
190
 *			(OStreamP ostream, char c)
161
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
191
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
162
 *
192
 *
163
 * This function writes the specified character to the specified ostream.
193
 * This function writes the specified character to the specified ostream.
164
 * This differs from the ``write_char'' function, in that it will
194
 * This differs from the ``write_char'' function, in that it will
165
 * `pretty-print' non-printing characters.
195
 * `pretty-print' non-printing characters.
166
 *
196
 *
167
 ** Function:	void			write_int
197
 ** Function:	void			write_int
168
 *			PROTO_S ((OStreamP ostream, int i))
198
 *			(OStreamP ostream, int i)
169
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
199
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
170
 *
200
 *
171
 * This function writes the specified integer to the specified ostream.
201
 * This function writes the specified integer to the specified ostream.
172
 *
202
 *
173
 ** Function:	void			write_unsigned
203
 ** Function:	void			write_unsigned
174
 *			PROTO_S ((OStreamP ostream, unsigned i))
204
 *			(OStreamP ostream, unsigned i)
175
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
205
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
176
 *
206
 *
177
 * This function writes the specified unsigned integer to the specified
207
 * This function writes the specified unsigned integer to the specified
178
 * ostream.
208
 * ostream.
179
 *
209
 *
180
 ** Function:	void			write_cstring
210
 ** Function:	void			write_cstring
181
 *			PROTO_S ((OStreamP ostream, CStringP cstring))
211
 *			(OStreamP ostream, CStringP cstring)
182
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
212
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
183
 *
213
 *
184
 * This function writes the specified C string to the specified ostream.
214
 * This function writes the specified C string to the specified ostream.
185
 *
215
 *
186
 ** Function:	void			write_bytes
216
 ** Function:	void			write_bytes
187
 *			PROTO_S ((OStreamP ostream, ByteP bytes,
217
 *			(OStreamP ostream, ByteP bytes,
188
 *				  unsigned length))
218
 *				  unsigned length)
189
 ** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
219
 ** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
190
 *
220
 *
191
 * This function writes the specified sequence of bytes (of the specified
221
 * This function writes the specified sequence of bytes (of the specified
192
 * length) to the specified ostream.
222
 * length) to the specified ostream.
193
 *
223
 *
194
 ** Function:	void			write_chars
224
 ** Function:	void			write_chars
195
 *			PROTO_S ((OStreamP ostream, CStringP chars,
225
 *			(OStreamP ostream, CStringP chars,
196
 *				  unsigned length))
226
 *				  unsigned length)
197
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
227
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
198
 *
228
 *
199
 * This function writes the specified sequence of characters (of the specified
229
 * This function writes the specified sequence of characters (of the specified
200
 * length) to the specified ostream.
230
 * length) to the specified ostream.
201
 *
231
 *
202
 ** Function:	void			write_escaped_chars
232
 ** Function:	void			write_escaped_chars
203
 *			PROTO_S ((OStreamP ostream, CStringP chars,
233
 *			(OStreamP ostream, CStringP chars,
204
 *				  unsigned length))
234
 *				  unsigned length)
205
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
235
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
206
 *
236
 *
207
 * This function writes the specified sequence of characters (of the specified
237
 * This function writes the specified sequence of characters (of the specified
208
 * length) to the specified ostream.  This differs from the ``write_chars''
238
 * length) to the specified ostream.  This differs from the ``write_chars''
209
 * function, in that it will `pretty-print' non-printing characters.
239
 * function, in that it will `pretty-print' non-printing characters.
210
 *
240
 *
211
 ** Function:	void			write_system_error
241
 ** Function:	void			write_system_error
212
 *			PROTO_S ((OStreamP ostream));
242
 *			(OStreamP ostream);
213
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
243
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
214
 *
244
 *
215
 * This function writes a string containing a description of the current
245
 * This function writes a string containing a description of the current
216
 * system error (as defined by the ``errno'' global variable) to the specified
246
 * system error (as defined by the ``errno'' global variable) to the specified
217
 * ostream.
247
 * ostream.
218
 *
248
 *
219
 ** Function:	void			write_pointer
249
 ** Function:	void			write_pointer
220
 *			PROTO_S ((OStreamP ostream, GenericP pointer));
250
 *			(OStreamP ostream, GenericP pointer);
221
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
251
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
222
 *
252
 *
223
 * This function writes a string containing the address of the object pointed
253
 * This function writes a string containing the address of the object pointed
224
 * to by the pointer to the specified ostream.
254
 * to by the pointer to the specified ostream.
225
 *
255
 *
Line 265... Line 295...
265
    unsigned			line;
295
    unsigned			line;
266
} OStreamT, *OStreamP;
296
} OStreamT, *OStreamP;
267
 
297
 
268
/*--------------------------------------------------------------------------*/
298
/*--------------------------------------------------------------------------*/
269
 
299
 
270
extern ExceptionP		XX_ostream_write_error;
300
extern ExceptionP	 XX_ostream_write_error;
271
extern OStreamT		 *const ostream_output;
301
extern OStreamT		*const ostream_output;
272
extern OStreamT		 *const ostream_error;
302
extern OStreamT		*const ostream_error;
273
 
303
 
274
/*--------------------------------------------------------------------------*/
304
/*--------------------------------------------------------------------------*/
275
 
305
 
276
extern void			ostream_setup
306
extern void		ostream_setup(void);
277
	PROTO_S ((void));
-
 
278
extern void			ostream_init
307
extern void		ostream_init(OStreamP);
279
	PROTO_S ((OStreamP));
-
 
280
extern BoolT			ostream_open
308
extern BoolT		ostream_open(OStreamP, CStringP);
281
	PROTO_S ((OStreamP, CStringP));
-
 
282
extern BoolT			ostream_is_open
309
extern BoolT		ostream_is_open(OStreamP);
283
	PROTO_S ((OStreamP));
-
 
284
extern void			ostream_buffer
310
extern void		ostream_buffer(OStreamP);
285
	PROTO_S ((OStreamP));
-
 
286
extern void			ostream_unbuffer
311
extern void		ostream_unbuffer(OStreamP);
287
	PROTO_S ((OStreamP));
-
 
288
extern void			ostream_close
312
extern void		ostream_close(OStreamP);
289
	PROTO_S ((OStreamP));
-
 
290
extern void			ostream_flush
313
extern void		ostream_flush(OStreamP);
291
	PROTO_S ((OStreamP));
-
 
292
extern CStringP			ostream_name
314
extern CStringP		ostream_name(OStreamP);
293
	PROTO_S ((OStreamP));
-
 
294
extern CStringP			ostream_gen_name
315
extern CStringP		ostream_gen_name(OStreamP);
295
	PROTO_S ((OStreamP));
-
 
296
extern unsigned			ostream_line
316
extern unsigned		ostream_line(OStreamP);
297
	PROTO_S ((OStreamP));
-
 
298
 
317
 
299
extern void			write_newline
318
extern void		write_newline(OStreamP);
300
	PROTO_S ((OStreamP));
-
 
301
extern void			write_tab
319
extern void		write_tab(OStreamP);
302
	PROTO_S ((OStreamP));
-
 
303
extern void			write_byte
320
extern void		write_byte(OStreamP, ByteT);
304
	PROTO_S ((OStreamP, ByteT));
-
 
305
extern void			write_char
321
extern void		write_char(OStreamP, char);
306
	PROTO_S ((OStreamP, char));
-
 
307
extern void			write_escaped_char
322
extern void		write_escaped_char(OStreamP, char);
308
	PROTO_S ((OStreamP, char));
-
 
309
extern void			write_int
323
extern void		write_int(OStreamP, int);
310
	PROTO_S ((OStreamP, int));
-
 
311
extern void			write_unsigned
324
extern void		write_unsigned(OStreamP, unsigned);
312
	PROTO_S ((OStreamP, unsigned));
-
 
313
extern void			write_cstring
325
extern void		write_cstring(OStreamP, CStringP);
314
	PROTO_S ((OStreamP, CStringP));
-
 
315
extern void			write_bytes
-
 
316
	PROTO_S ((OStreamP, ByteP, unsigned));
326
extern void		write_bytes(OStreamP, ByteP, unsigned);
317
extern void			write_chars
-
 
318
	PROTO_S ((OStreamP, CStringP, unsigned));
327
extern void		write_chars(OStreamP, CStringP, unsigned);
319
extern void			write_escaped_chars
-
 
320
	PROTO_S ((OStreamP, CStringP, unsigned));
328
extern void		write_escaped_chars(OStreamP, CStringP, unsigned);
321
extern void			write_system_error
329
extern void		write_system_error(OStreamP);
322
	PROTO_S ((OStreamP));
-
 
323
extern void			write_pointer
330
extern void		write_pointer(OStreamP, GenericP);
324
	PROTO_S ((OStreamP, GenericP));
-
 
325
 
331
 
326
/*--------------------------------------------------------------------------*/
332
/*--------------------------------------------------------------------------*/
327
 
333
 
328
#ifdef FS_FAST
334
#ifdef FS_FAST
329
#define ostream_init(os) ((os)->name = NIL (CStringP))
335
#define ostream_init(os)	((os)->name = NIL(CStringP))
330
#define ostream_is_open(os) ((os)->name != NIL (CStringP))
336
#define ostream_is_open(os)	((os)->name != NIL(CStringP))
331
#define ostream_name(os) ((os)->name)
337
#define ostream_name(os)	((os)->name)
332
#define ostream_gen_name(os) ((os)->gen_name)
338
#define ostream_gen_name(os)	((os)->gen_name)
333
#define ostream_line(os) ((os)->line)
339
#define ostream_line(os)	((os)->line)
334
#endif /* defined (FS_FAST) */
340
#endif /* defined (FS_FAST) */
335
 
341
 
336
#endif /* !defined (H_OSTREAM) */
342
#endif /* !defined (H_OSTREAM) */