1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCSYS/STDIO_T.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,114 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef _SYS_STDIO_T_H_
1.24 +#define _SYS_STDIO_T_H_
1.25 +#ifdef __cplusplus
1.26 +extern "C" {
1.27 +#endif
1.28 +
1.29 +#include <_ansi.h>
1.30 +
1.31 +/**
1.32 +Stdio buffers.
1.33 +@publishedAll
1.34 +@released
1.35 +*/
1.36 +struct __sbuf {
1.37 + unsigned char * _base;
1.38 + int _size;
1.39 +};
1.40 +
1.41 +/**
1.42 +We need fpos_t for the following, but it doesn't have a leading "_",
1.43 +so we use _fpos_t instead.
1.44 +@publishedAll
1.45 +@released
1.46 +*/
1.47 +
1.48 +typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */
1.49 + /* (and must be `long' for now) */
1.50 +
1.51 +/**
1.52 +Stdio state variables.
1.53 +
1.54 +The following always hold:
1.55 +
1.56 +if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
1.57 + _lbfsize is -_bf._size, else _lbfsize is 0
1.58 +if _flags&__SRD, _w is 0
1.59 + if _flags&__SWR, _r is 0
1.60 +
1.61 +This ensures that the getc and putc macros (or inline functions) never
1.62 +try to write or read from a file that is in `read' or `write' mode.
1.63 +(Moreover, they can, and do, automatically switch from read mode to
1.64 +write mode, and back, on "r+" and "w+" files.)
1.65 +
1.66 +_lbfsize is used only to make the inline line-buffered output stream
1.67 +code as compact as possible.
1.68 +
1.69 +_ub, _up, and _ur are used when ungetc() pushes back more characters
1.70 +than fit in the current _bf, or when ungetc() pushes back a character
1.71 +that does not match the previous one in _bf. When this happens,
1.72 +_ub._base becomes non-nil (i.e., a stream has ungetc() data iff
1.73 +_ub._base!=NULL) and _up and _ur save the current values of _p and _r.
1.74 +@publishedAll
1.75 +@released
1.76 +*/
1.77 +struct __sFILE {
1.78 + unsigned char *_p; /* current position in (some) buffer */
1.79 + int _r; /* read space left for getc() */
1.80 + int _w; /* write space left for putc() */
1.81 + short _flags; /* flags, below; this FILE is free if 0 */
1.82 + short _file; /* fileno, if Unix descriptor, else -1 */
1.83 + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
1.84 + int _lbfsize; /* 0 or -_bf._size, for inline putc */
1.85 +
1.86 + /* operations */
1.87 + void * _cookie; /* cookie passed to io functions */
1.88 +
1.89 + int (*_read) (void * _cookie, char *_buf, int _n);
1.90 + int (*_write)(void * _cookie, const char *_buf, int _n);
1.91 + _fpos_t (*_seek) (void * _cookie, _fpos_t _offset, int _whence);
1.92 + int (*_close)(void * _cookie);
1.93 +
1.94 + /* separate buffer for long sequences of ungetc() */
1.95 + struct __sbuf _ub; /* ungetc buffer */
1.96 + unsigned char * _up; /* saved _p when _p is doing ungetc data */
1.97 + int _ur; /* saved _r when _r is counting ungetc data */
1.98 +
1.99 + /* tricks to meet minimum requirements even when malloc() fails */
1.100 + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
1.101 + unsigned char _nbuf[1]; /* guarantee a getc() buffer */
1.102 +
1.103 + /* separate buffer for fgetline() when line crosses buffer boundary */
1.104 + struct __sbuf _lb; /* buffer for fgetline() */
1.105 +
1.106 + /* Unix stdio files get aligned to block boundaries on fseek() */
1.107 + int _blksize; /* stat.st_blksize (may be != _bf._size) */
1.108 + int _offset; /* current lseek offset */
1.109 +
1.110 + struct _reent * _data; /* pointer back to re-entrancy context block */
1.111 +};
1.112 +
1.113 +
1.114 +#ifdef __cplusplus
1.115 +}
1.116 +#endif
1.117 +#endif /* _SYS_STDIO_T_H_ */