1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDIO/LOCAL.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,144 @@
1.4 +/* LOCAL.H
1.5 + *
1.6 + * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
1.7 + * All rights reserved.
1.8 + */
1.9 +
1.10 +/*
1.11 + * Copyright (c) 1990 The Regents of the University of California.
1.12 + * All rights reserved.
1.13 + *
1.14 + * Redistribution and use in source and binary forms are permitted
1.15 + * provided that the above copyright notice and this paragraph are
1.16 + * duplicated in all such forms and that any documentation,
1.17 + * advertising materials, and other materials related to such
1.18 + * distribution and use acknowledge that the software was developed
1.19 + * by the University of California, Berkeley. The name of the
1.20 + * University may not be used to endorse or promote products derived
1.21 + * from this software without specific prior written permission.
1.22 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1.23 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1.24 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1.25 + *
1.26 + * %W% (UofMD/Berkeley) %G%
1.27 + */
1.28 +
1.29 +/*
1.30 + * Information local to this implementation of stdio,
1.31 + * in particular, macros and private variables.
1.32 + */
1.33 +
1.34 +#include <_ansi.h>
1.35 +#include <stdarg.h>
1.36 +#include <reent.h>
1.37 +#include <unistd.h>
1.38 +/**
1.39 +@internalComponent
1.40 +*/
1.41 +extern int __svfscanf (FILE *, const char *,va_list);
1.42 +extern FILE* __sfp (struct _reent *);
1.43 +extern int __sflags (struct _reent *,const wchar_t*, int*);
1.44 +extern int __srefill (FILE *);
1.45 +extern int __sread (void *, char *, int);
1.46 +extern int __swrite (void *, char const *, int);
1.47 +extern fpos_t __sseek (void *, fpos_t, int);
1.48 +extern int __sclose (void *);
1.49 +extern void __sinit (struct _reent *);
1.50 +extern void __smakebuf (FILE *);
1.51 +extern int _fwalk (struct _reent *, int (*)(FILE *));
1.52 +struct _glue* __sfmoreglue (struct _reent *,int n);
1.53 +extern int __srefill (FILE *fp);
1.54 +extern int __srget (FILE *fp);
1.55 +extern int __swbuf (int c, FILE *fp);
1.56 +
1.57 +/**
1.58 +Macros used inside the implementation of STDIO. These used to be in
1.59 +the <stdio.h> include file, but we want to hide them as much as
1.60 +possible to give us a change to change the implementation if
1.61 +necessary.
1.62 +@internalComponent
1.63 +*/
1.64 +#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
1.65 +#define __sferror(p) (((p)->_flags & __SERR) != 0)
1.66 +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
1.67 +#define __sfileno(p) ((p)->_file)
1.68 +/**
1.69 +@internalComponent
1.70 +*/
1.71 +#define feof(p) __sfeof(p)
1.72 +#define ferror(p) __sferror(p)
1.73 +#define clearerr(p) __sclearerr(p)
1.74 +/**
1.75 +@internalComponent
1.76 +*/
1.77 +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
1.78 +#define __sputc(c, p) \
1.79 + (--(p)->_w < 0 ? \
1.80 + (p)->_w >= (p)->_lbfsize ? \
1.81 + (*(p)->_p = (unsigned char)(c)), *(p)->_p != '\n' ? \
1.82 + (int)*(p)->_p++ : \
1.83 + __swbuf('\n', p) : \
1.84 + __swbuf((int)(c), p) : \
1.85 + (*(p)->_p = (unsigned char)(c), (int)*(p)->_p++))
1.86 +
1.87 +/**
1.88 +Called by the main entry point fns to ensure stdio has been initialized.
1.89 +@internalComponent
1.90 +*/
1.91 +#define CHECK_INIT(fp) /* done in the construction of the struct _reent */
1.92 +/*
1.93 +#define CHECK_INIT(fp) \
1.94 + { \
1.95 + if ((fp)->_data == 0) \
1.96 + (fp)->_data = _REENT; \
1.97 + if (!(fp)->_data->__sdidinit) \
1.98 + __sinit ((fp)->_data); \
1.99 + }
1.100 +*/
1.101 +
1.102 +/**
1.103 +Return true iff the given FILE cannot be written now.
1.104 +@internalComponent
1.105 +*/
1.106 +#define cantwrite(fp) \
1.107 + ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
1.108 + __swsetup(fp))
1.109 +
1.110 +/**
1.111 +Test whether the given stdio file has an active ungetc buffer;
1.112 +release such a buffer, without restoring ordinary unread data.
1.113 +@internalComponent
1.114 +*/
1.115 +#define HASUB(fp) ((fp)->_ub._base != NULL)
1.116 +#define FREEUB(fp) { \
1.117 + if ((fp)->_ub._base != (fp)->_ubuf) \
1.118 + _free_r(fp->_data, (char *)(fp)->_ub._base); \
1.119 + (fp)->_ub._base = NULL; \
1.120 +}
1.121 +
1.122 +/**
1.123 +Test for an fgetline() buffer.
1.124 +@internalComponent
1.125 +*/
1.126 +#define HASLB(fp) ((fp)->_lb._base != NULL)
1.127 +#define FREELB(fp) { _free_r(fp->_data,(char *)(fp)->_lb._base); (fp)->_lb._base = NULL; }
1.128 +
1.129 +/*
1.130 +WARNING: _dcvt is defined in the stdlib directory, not here!
1.131 +@internalComponent
1.132 +*/
1.133 +char *_dcvt (struct _reent *, char *, double, int, int, char, int);
1.134 +char *_sicvt (char *, short, char);
1.135 +char *_icvt (char *, int, char);
1.136 +char *_licvt (char *, long, char);
1.137 +#ifdef __GNUC__
1.138 +char *_llicvt (char *, long long, char);
1.139 +#endif
1.140 +/**
1.141 +@internalComponent
1.142 +*/
1.143 +#define CVT_BUF_SIZE 128
1.144 +/**
1.145 +@internalComponent
1.146 +*/
1.147 +#define NDYNAMIC 4 /* add four more whenever necessary */