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/tendra4/src/tools/tld/ostream.h – Rev 2

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
/*
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
/**** ostream.h --- Output stream handling.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 **** Commentary:
36
 *
37
 ***=== INTRODUCTION =========================================================
38
 *
39
 * This file specifies the interface to the output stream facility.
40
 *
41
 ***=== TYPES ================================================================
42
 *
43
 ** Type:	OStreamT
44
 ** Type:	OStreamP
45
 ** Repr:	<private>
46
 *
47
 * This is the output stream type.
48
 *
49
 ***=== CONSTANTS ============================================================
50
 *
51
 ** Constant:	ostream_output
52
 *
53
 * This is the standard output stream.  Its initial buffering state is
54
 * undefined.  The ``ostream_setup'' function must be called before this
55
 * constant is used.
56
 *
57
 ** Constant:	ostream_error
58
 *
59
 * This is the standard error stream.  Its initial buffering state is
60
 * undefined.  The ``ostream_setup'' function must be called before this
61
 * constant is used.
62
 *
63
 ***=== FUNCTIONS ============================================================
64
 *
65
 ** Function:	void			ostream_setup
66
 *			PROTO_S ((void))
67
 ** Exceptions:
68
 *
69
 * This function initialises the output stream facility.  It should be called
70
 * before any other ostream manipulation function.
71
 *
72
 ** Function:	void			ostream_init
73
 *			PROTO_S ((OStreamP ostream))
74
 ** Exceptions:
75
 *
76
 * This function initialises the specified ostream not to write to any file.
77
 *
78
 ** Function:	BoolT			ostream_open
79
 *			PROTO_S ((OStreamP ostream, CStringP name))
80
 ** Exceptions:
81
 *
82
 * 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
84
 * 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
86
 * closed.  The initial buffering state of the ostream is fully buffered.
87
 *
88
 ** Function:	BoolT			ostream_is_open
89
 *			PROTO_S ((OStreamP ostream))
90
 ** Exceptions:
91
 *
92
 * This function returns true if the specified ostream is writing to a file,
93
 * and false otherwise.
94
 *
95
 ** Function:	void			ostream_buffer
96
 *			PROTO_S ((OStreamP ostream))
97
 ** Exceptions:
98
 *
99
 * This function sets the buffering state of the specified ostream to fully
100
 * buffered.
101
 *
102
 ** Function:	void			ostream_unbuffer
103
 *			PROTO_S ((OStreamP ostream))
104
 *
105
 * This function sets the buffering state of the specified ostream to
106
 * unbuffered.
107
 *
108
 ** Function:	void			ostream_close
109
 *			PROTO_S ((OStreamP ostream))
110
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
111
 *
112
 * This function closes the specified ostream.
113
 *
114
 ** Function:	void			ostream_flush
115
 *			PROTO_S ((OStreamP ostream))
116
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
117
 *
118
 * This function flushes the ostream's output buffer.
119
 *
120
 ** Function:	CStringP		ostream_name
121
 *			PROTO_S ((OStreamP ostream))
122
 ** Exceptions:
123
 *
124
 * 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.
126
 *
127
 ** Function:	unsigned		ostream_line
128
 *			PROTO_S ((OStreamP ostream))
129
 ** Exceptions:
130
 *
131
 * 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
133
 * is not open.
134
 *
135
 ** Function:	void			write_newline
136
 *			PROTO_S ((OStreamP ostream))
137
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
138
 *
139
 * This function writes a newline to the specified ostream.
140
 *
141
 ** Function:	void			write_tab
142
 *			PROTO_S ((OStreamP ostream))
143
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
144
 *
145
 * This function writes a tab to the specified ostream.
146
 *
147
 ** Function:	void			write_byte
148
 *			PROTO_S ((OStreamP ostream, ByteT c))
149
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
150
 *
151
 * This function writes the specified byte to the specified ostream.
152
 *
153
 ** Function:	void			write_char
154
 *			PROTO_S ((OStreamP ostream, char c))
155
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
156
 *
157
 * This function writes the specified character to the specified ostream.
158
 *
159
 ** Function:	void			write_escaped_char
160
 *			PROTO_S ((OStreamP ostream, char c))
161
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
162
 *
163
 * This function writes the specified character to the specified ostream.
164
 * This differs from the ``write_char'' function, in that it will
165
 * `pretty-print' non-printing characters.
166
 *
167
 ** Function:	void			write_int
168
 *			PROTO_S ((OStreamP ostream, int i))
169
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
170
 *
171
 * This function writes the specified integer to the specified ostream.
172
 *
173
 ** Function:	void			write_unsigned
174
 *			PROTO_S ((OStreamP ostream, unsigned i))
175
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
176
 *
177
 * This function writes the specified unsigned integer to the specified
178
 * ostream.
179
 *
180
 ** Function:	void			write_cstring
181
 *			PROTO_S ((OStreamP ostream, CStringP cstring))
182
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
183
 *
184
 * This function writes the specified C string to the specified ostream.
185
 *
186
 ** Function:	void			write_bytes
187
 *			PROTO_S ((OStreamP ostream, ByteP bytes,
188
 *				  unsigned length))
189
 ** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
190
 *
191
 * This function writes the specified sequence of bytes (of the specified
192
 * length) to the specified ostream.
193
 *
194
 ** Function:	void			write_chars
195
 *			PROTO_S ((OStreamP ostream, CStringP chars,
196
 *				  unsigned length))
197
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
198
 *
199
 * This function writes the specified sequence of characters (of the specified
200
 * length) to the specified ostream.
201
 *
202
 ** Function:	void			write_escaped_chars
203
 *			PROTO_S ((OStreamP ostream, CStringP chars,
204
 *				  unsigned length))
205
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
206
 *
207
 * This function writes the specified sequence of characters (of the specified
208
 * length) to the specified ostream.  This differs from the ``write_chars''
209
 * function, in that it will `pretty-print' non-printing characters.
210
 *
211
 ** Function:	void			write_system_error
212
 *			PROTO_S ((OStreamP ostream));
213
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
214
 *
215
 * This function writes a string containing a description of the current
216
 * system error (as defined by the ``errno'' global variable) to the specified
217
 * ostream.
218
 *
219
 ** Function:	void			write_pointer
220
 *			PROTO_S ((OStreamP ostream, GenericP pointer));
221
 ** Exceptions:	XX_dalloc_no_memory, XX_ostream_write_error
222
 *
223
 * This function writes a string containing the address of the object pointed
224
 * to by the pointer to the specified ostream.
225
 *
226
 ***=== EXCEPTIONS ===========================================================
227
 *
228
 ** Exception:	XX_ostream_write_error (CStringP name)
229
 *
230
 * This exception is raised if a write attempt fails.  The data thrown is a
231
 * copy of the name of the file on which the error occured.  The copy should
232
 * be deallocated when finished with.
233
 *
234
 **** Change Log:
235
 * $Log: ostream.h,v $
236
 * Revision 1.1.1.1  1998/01/17  15:57:18  release
237
 * First version to be checked into rolling release.
238
 *
239
 * Revision 1.2  1994/12/12  11:45:50  smf
240
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
241
 * OSSG C Coding Standards.
242
 *
243
 * Revision 1.1.1.1  1994/07/25  16:06:12  smf
244
 * Initial import of os-interface shared files.
245
 *
246
**/
247
 
248
/****************************************************************************/
249
 
250
 
251
#ifndef H_OSTREAM
252
#define H_OSTREAM
253
 
254
#include "os-interface.h"
255
#include "dalloc.h"
256
#include "exception.h"
257
 
258
/*--------------------------------------------------------------------------*/
259
 
260
typedef struct OStreamT {
261
    FILE		       *file;
262
    CStringP			name;
263
    unsigned			line;
264
} OStreamT, *OStreamP;
265
 
266
/*--------------------------------------------------------------------------*/
267
 
268
extern ExceptionP		XX_ostream_write_error;
269
extern OStreamT		 *const ostream_output;
270
extern OStreamT		 *const ostream_error;
271
 
272
/*--------------------------------------------------------------------------*/
273
 
274
extern void			ostream_setup
275
	PROTO_S ((void));
276
extern void			ostream_init
277
	PROTO_S ((OStreamP));
278
extern BoolT			ostream_open
279
	PROTO_S ((OStreamP, CStringP));
280
extern BoolT			ostream_is_open
281
	PROTO_S ((OStreamP));
282
extern void			ostream_buffer
283
	PROTO_S ((OStreamP));
284
extern void			ostream_unbuffer
285
	PROTO_S ((OStreamP));
286
extern void			ostream_close
287
	PROTO_S ((OStreamP));
288
extern void			ostream_flush
289
	PROTO_S ((OStreamP));
290
extern CStringP			ostream_name
291
	PROTO_S ((OStreamP));
292
extern unsigned			ostream_line
293
	PROTO_S ((OStreamP));
294
 
295
extern void			write_newline
296
	PROTO_S ((OStreamP));
297
extern void			write_tab
298
	PROTO_S ((OStreamP));
299
extern void			write_byte
300
	PROTO_S ((OStreamP, ByteT));
301
extern void			write_char
302
	PROTO_S ((OStreamP, char));
303
extern void			write_escaped_char
304
	PROTO_S ((OStreamP, char));
305
extern void			write_int
306
	PROTO_S ((OStreamP, int));
307
extern void			write_unsigned
308
	PROTO_S ((OStreamP, unsigned));
309
extern void			write_cstring
310
	PROTO_S ((OStreamP, CStringP));
311
extern void			write_bytes
312
	PROTO_S ((OStreamP, ByteP, unsigned));
313
extern void			write_chars
314
	PROTO_S ((OStreamP, CStringP, unsigned));
315
extern void			write_escaped_chars
316
	PROTO_S ((OStreamP, CStringP, unsigned));
317
extern void			write_system_error
318
	PROTO_S ((OStreamP));
319
extern void			write_pointer
320
	PROTO_S ((OStreamP, GenericP));
321
 
322
/*--------------------------------------------------------------------------*/
323
 
324
#ifdef FS_FAST
325
#define ostream_init(os) ((os)->name = NIL (CStringP))
326
#define ostream_is_open(os) ((os)->name != NIL (CStringP))
327
#define ostream_name(os) ((os)->name)
328
#define ostream_line(os) ((os)->line)
329
#endif /* defined (FS_FAST) */
330
 
331
#endif /* !defined (H_OSTREAM) */