This file is indexed.

/usr/include/ucommon/stream.h is in libucommon-dev 3.2.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This file is part of GNU uCommon C++.
//
// GNU uCommon C++ is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU uCommon C++ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Any ucommon streaming classes that are built from std::streamio facilities
 * and that support ANSI C++ stream operators.
 * @file ucommon/stream.h
 */

#if defined(OLD_STDCPP) || defined(NEW_STDCPP)
#ifndef	_UCOMMON_STREAM_H_
#define	_UCOMMON_STREAM_H_

#ifndef	_UCOMMON_THREAD_H_
#include <ucommon/thread.h>
#endif

#ifndef	_UCOMMON_SOCKET_H_
#include <ucommon/socket.h>
#endif

#ifndef	_UCOMMON_FSYS_H_
#include <ucommon/fsys.h>
#endif

#include <iostream>

NAMESPACE_UCOMMON

/**
 * Streamable tcp connection between client and server.  The tcp stream
 * class can represent a client connection to a server or an instance of
 * a service generated by a tcp listener.  As a stream class, data can 
 * be manipulated using the << and >> operators.
 *
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT tcpstream : protected std::streambuf, public std::iostream
{
private:
	__LOCAL void allocate(unsigned size);
	__LOCAL	void reset(void);

protected:
	socket_t so;
	timeout_t timeout;
	size_t bufsize;
	char *gbuf, *pbuf;

	/**
	 * Release the tcp stream and destroy the underlying socket.
	 */
	void release(void);

    /**
     * This streambuf method is used to load the input buffer
     * through the established tcp socket connection.
     *
     * @return char from get buffer, EOF if not connected.
     */
    int underflow();

    /**
     * This streambuf method is used for doing unbuffered reads
     * through the establish tcp socket connection when in interactive mode.
     * Also this method will handle proper use of buffers if not in
     * interative mode.
     *
     * @return char from tcp socket connection, EOF if not connected.
     */
    int uflow();

    /**
     * This streambuf method is used to write the output
     * buffer through the established tcp connection.
     *
     * @param ch char to push through.
     * @return char pushed through.
     */
    int overflow(int ch);

public:
	/**
	 * Copy constructor...
	 * @param copy for object.
	 */
	tcpstream(const tcpstream& copy);

	/**
	 * Create a stream from an existing tcp listener.
	 * @param listener to accept connection from.
	 * @param segsize for tcp segments and buffering.
	 * @param timeout for socket i/o operations.
	 */
	tcpstream(ListenSocket& listener, unsigned segsize = 536, timeout_t timeout = 0);

	/**
	 * Create an unconnected tcp stream object that is idle until opened.
	 * @param family of protocol to create.
	 * @param timeout for socket i/o operations.
	 */
	tcpstream(int family = PF_INET, timeout_t timeout = 0);

	/**
	 * A convenience constructor that creates a connected tcp stream directly
	 * from an address.  The socket is constructed to match the type of the
	 * the address family in the socket address that is passed.
	 * @param address of service to connect to.
	 * @param segsize for tcp segments and buffering.
	 * @param timeout for socket i/o operations.
	 */
	tcpstream(Socket::address& address, unsigned segsize = 536, timeout_t timeout = 0);

	/**
	 * Destroy a tcp stream.
	 */
	virtual ~tcpstream();

	/**
	 * See if stream connection is active.
	 * @return true if stream is active.
	 */
	inline operator bool() const
		{return so != INVALID_SOCKET && bufsize > 0;};

	/**
	 * See if stream is disconnected.
	 * @return true if stream disconnected.
	 */
	inline bool operator!() const
		{return so == INVALID_SOCKET || bufsize == 0;};

	/**
	 * Open a stream connection to a tcp service.
	 * @param address of service to access.
	 * @param segment buffering size to use.
	 */
	void open(Socket::address& address, unsigned segment = 536);

	/**
	 * Close an active stream connection.  This does not release the
	 * socket but is a disconnect.
	 */
	void close(void);

	/**
	 * Flush the stream input and output buffers, writes pending output.
	 * @return 0 on success, or error code.
	 */
	int sync(void);	
};

/**
 * Streamable tcp connection between client and server.  The tcp stream
 * class can represent a client connection to a server or an instance of
 * a service generated by a tcp listener.  As a stream class, data can 
 * be manipulated using the << and >> operators.
 *
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT pipestream : protected std::streambuf, public std::iostream
{
public:
	typedef enum {
		RDONLY,
		WRONLY,
		RDWR
	} access_t;

private:
	__LOCAL void allocate(size_t size, access_t mode);

protected:
	fsys_t rd, wr;
	pid_t pid;
	size_t bufsize;
	char *gbuf, *pbuf;

	/**
	 * Release the stream, detach/do not wait for the process.
	 */
	void release(void);

    /**
     * This streambuf method is used to load the input buffer
     * through the established pipe connection.
     *
     * @return char from get buffer, EOF if not connected.
     */
    int underflow();

    /**
     * This streambuf method is used for doing unbuffered reads
     * through the establish tcp socket connection when in interactive mode.
     * Also this method will handle proper use of buffers if not in
     * interative mode.
     *
     * @return char from pipe connection, EOF if not connected.
     */
    int uflow();

    /**
     * This streambuf method is used to write the output
     * buffer through the established pipe connection.
     *
     * @param ch char to push through.
     * @return char pushed through.
     */
    int overflow(int ch);

public:
	/**
	 * Create an unopened pipe stream.
	 */
	pipestream();

	/**
	 * Create child process and start pipe.
	 * @param command to pass.
	 * @param access mode of pipe stream.
	 * @param env to create in child.
	 * @param size of buffer.
	 */
	pipestream(const char *command, access_t access, const char **env = NULL, size_t size = 512);

	/**
	 * Destroy a pipe stream.
	 */
	virtual ~pipestream();

	/**
	 * See if stream connection is active.
	 * @return true if stream is active.
	 */
	inline operator bool() const
		{return (bufsize > 0);};

	/**
	 * See if stream is disconnected.
	 * @return true if stream disconnected.
	 */
	inline bool operator!() const
		{return bufsize == 0;};

	/**
	 * Open a stream connection to a pipe service.
	 * @param command to execute.
	 * @param access mode of stream.
	 * @param env to create in child process.
	 * @param buffering size to use.
	 */
	void open(const char *command, access_t access, const char **env = NULL, size_t buffering = 512);

	/**
	 * Close an active stream connection.  This waits for the child to
	 * terminate.
	 */
	void close(void);

	/**
	 * Force terminate child and close.
	 */
	void terminate(void);

	/**
	 * Flush the stream input and output buffers, writes pending output.
	 * @return 0 on success, or error code.
	 */
	int sync(void);	
};

/**
 * Streamable tcp connection between client and server.  The tcp stream
 * class can represent a client connection to a server or an instance of
 * a service generated by a tcp listener.  As a stream class, data can 
 * be manipulated using the << and >> operators.
 *
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT filestream : protected std::streambuf, public std::iostream
{
public:
	typedef enum {
		RDONLY,
		WRONLY,
		RDWR
	} access_t;

private:
	__LOCAL void allocate(size_t size, fsys::access_t mode);

protected:
	fsys_t fd;
	fsys::access_t ac;
	size_t bufsize;
	char *gbuf, *pbuf;

    /**
     * This streambuf method is used to load the input buffer
     * through the established pipe connection.
     *
     * @return char from get buffer, EOF if not connected.
     */
    int underflow();

    /**
     * This streambuf method is used for doing unbuffered reads
     * through the establish tcp socket connection when in interactive mode.
     * Also this method will handle proper use of buffers if not in
     * interative mode.
     *
     * @return char from pipe connection, EOF if not connected.
     */
    int uflow();

    /**
     * This streambuf method is used to write the output
     * buffer through the established pipe connection.
     *
     * @param ch char to push through.
     * @return char pushed through.
     */
    int overflow(int ch);

public:
	/**
	 * Create an unopened pipe stream.
	 */
	filestream();

	/**
	 * Create duplicate stream.
	 */
	filestream(const filestream& copy);

	/**
	 * Create file stream.
	 */
	filestream(const char *path, fsys::access_t access, unsigned mode, size_t bufsize);

	/**
	 * Open file stream.
	 */
	filestream(const char *path, fsys::access_t access, size_t bufsize);

	/**
	 * Destroy a file stream.
	 */
	virtual ~filestream();

	/**
	 * See if stream connection is active.
	 * @return true if stream is active.
	 */
	inline operator bool() const
		{return (bufsize > 0);};

	/**
	 * See if stream is disconnected.
	 * @return true if stream disconnected.
	 */
	inline bool operator!() const
		{return bufsize == 0;};

	/**
	 * Open a stream connection to a tcp service.
	 */
	void open(const char *filename, fsys::access_t access, size_t buffering = 512);

	/**
	 * Create a stream connection to a tcp service.
	 */
	void create(const char *filename, fsys::access_t access, unsigned mode, size_t buffering = 512);

	/**
	 * Close an active stream connection.
	 */
	void close(void);

	/**
	 * Seek position.
	 */
	void seek(fsys::offset_t offset);

	/**
	 * Flush the stream input and output buffers, writes pending output.
	 * @return 0 on success, or error code.
	 */
	int sync(void);	

	/**
	 * Get error flag from last i/o operation.
	 * @return last error.
     */
	inline int error(void) const
		{return fd.getError();};
};

END_NAMESPACE

#endif
#endif