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