OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [language/] [c/] [libc/] [stdio/] [v2_0/] [include/] [streambuf.hxx] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_LIBC_STDIO_STREAMBUF_HXX
2
#define CYGONCE_LIBC_STDIO_STREAMBUF_HXX
3
//===========================================================================
4
//
5
//      streambuf.hxx
6
//
7
//      Internal C library stdio stream buffer interface definitions
8
//
9
//===========================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//===========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    jlarmour
46
// Contributors:
47
// Date:         2000-04-19
48
// Purpose:
49
// Description:  This file implements the buffer class used by Cyg_StdioStream
50
//               for file buffers. It is simple, and not thread-safe - that
51
//               is better done at a higher level for our purposes.
52
// Usage:        #include 
53
//
54
//####DESCRIPTIONEND####
55
//
56
//===========================================================================
57
 
58
// CONFIGURATION
59
 
60
#include    // Configuration header
61
 
62
// Include buffered I/O?
63
#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
64
 
65
 
66
// INCLUDES
67
 
68
#include    // Common project-wide type definitions
69
#include                 // Cyg_ErrNo
70
 
71
 
72
// TYPE DEFINITIONS
73
 
74
 
75
class Cyg_StdioStreamBuffer
76
{
77
private:
78
    // Buffering data
79
 
80
#if defined(CYGSEM_LIBC_STDIO_SETVBUF_MALLOC)
81
    cyg_bool call_free;  // should we free the old buffer if set_buffer is
82
                         // called?
83
#else
84
    cyg_uint8 static_buffer[BUFSIZ]; // Static buffer used when we cannot
85
                                     // use malloc()/free().
86
#endif
87
 
88
    cyg_uint8 *buffer_bottom;
89
 
90
    cyg_ucount32 buffer_size;
91
 
92
    cyg_uint8 *buffer_top;
93
 
94
    cyg_uint8 *current_buffer_position;
95
 
96
public:
97
 
98
    // CONSTRUCTORS
99
 
100
    // You can change the size, or even supply your own buffer, although
101
    // this only has an effect with dynamic buffers. Otherwise it is
102
    // silently ignored
103
    Cyg_StdioStreamBuffer( cyg_ucount32 size=BUFSIZ,
104
                           cyg_uint8 *new_buffer=NULL );
105
 
106
 
107
    // DESTRUCTORS
108
 
109
    ~Cyg_StdioStreamBuffer();
110
 
111
    // METHODS
112
 
113
    // Set up the buffer. As with the constructor, supplying a new_buffer
114
    // only has an effect with dynamic buffers, although EINVAL is returned
115
    // in that case. ENOMEM may also be returned
116
    Cyg_ErrNo
117
    set_buffer( cyg_ucount32 size=BUFSIZ, cyg_uint8 *new_buffer=NULL );
118
 
119
    // Find out how much buffer space is in use
120
    cyg_ucount32
121
    get_buffer_space_used( void );
122
 
123
 
124
    // What total size is the current buffer set to be. Can be -1 if the
125
    // the buffer is invalid
126
    cyg_count32
127
    get_buffer_size( void );
128
 
129
 
130
    // get buffer address to read from, and return the number of bytes
131
    // available to read
132
    cyg_ucount32
133
    get_buffer_addr_to_read( cyg_uint8 **buffer );
134
 
135
    // when finished reading from said space, tell the buffer how much was
136
    // actually read
137
    void
138
    set_bytes_read( cyg_ucount32 bytes );
139
 
140
    // return address of buffer that can be used to write into, and its
141
    // available capacity
142
    cyg_ucount32
143
    get_buffer_addr_to_write( cyg_uint8 **buffer );
144
 
145
    // when finished writing into said space, tell the buffer how much was
146
    // actually written
147
    void
148
    set_bytes_written( cyg_ucount32 bytes );
149
 
150
    // just empty the whole buffer contents
151
    void
152
    drain_buffer( void );
153
}; // class Cyg_StdioStreamBuffer
154
 
155
// INLINE FUNCTIONS
156
 
157
#include 
158
 
159
 
160
#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
161
 
162
#endif // CYGONCE_LIBC_STDIO_STREAMBUF_HXX multiple inclusion protection
163
 
164
// EOF streambuf.hxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.