sl@0: /* LOCAL.H sl@0: * sl@0: * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1990 The Regents of the University of California. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms are permitted sl@0: * provided that the above copyright notice and this paragraph are sl@0: * duplicated in all such forms and that any documentation, sl@0: * advertising materials, and other materials related to such sl@0: * distribution and use acknowledge that the software was developed sl@0: * by the University of California, Berkeley. The name of the sl@0: * University may not be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. sl@0: * sl@0: * %W% (UofMD/Berkeley) %G% sl@0: */ sl@0: sl@0: /* sl@0: * Information local to this implementation of stdio, sl@0: * in particular, macros and private variables. sl@0: */ sl@0: sl@0: #include <_ansi.h> sl@0: #include sl@0: #include sl@0: #include sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: extern int __svfscanf (FILE *, const char *,va_list); sl@0: extern FILE* __sfp (struct _reent *); sl@0: extern int __sflags (struct _reent *,const wchar_t*, int*); sl@0: extern int __srefill (FILE *); sl@0: extern int __sread (void *, char *, int); sl@0: extern int __swrite (void *, char const *, int); sl@0: extern fpos_t __sseek (void *, fpos_t, int); sl@0: extern int __sclose (void *); sl@0: extern void __sinit (struct _reent *); sl@0: extern void __smakebuf (FILE *); sl@0: extern int _fwalk (struct _reent *, int (*)(FILE *)); sl@0: struct _glue* __sfmoreglue (struct _reent *,int n); sl@0: extern int __srefill (FILE *fp); sl@0: extern int __srget (FILE *fp); sl@0: extern int __swbuf (int c, FILE *fp); sl@0: sl@0: /** sl@0: Macros used inside the implementation of STDIO. These used to be in sl@0: the include file, but we want to hide them as much as sl@0: possible to give us a change to change the implementation if sl@0: necessary. sl@0: @internalComponent sl@0: */ sl@0: #define __sfeof(p) (((p)->_flags & __SEOF) != 0) sl@0: #define __sferror(p) (((p)->_flags & __SERR) != 0) sl@0: #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) sl@0: #define __sfileno(p) ((p)->_file) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define feof(p) __sfeof(p) sl@0: #define ferror(p) __sferror(p) sl@0: #define clearerr(p) __sclearerr(p) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) sl@0: #define __sputc(c, p) \ sl@0: (--(p)->_w < 0 ? \ sl@0: (p)->_w >= (p)->_lbfsize ? \ sl@0: (*(p)->_p = (unsigned char)(c)), *(p)->_p != '\n' ? \ sl@0: (int)*(p)->_p++ : \ sl@0: __swbuf('\n', p) : \ sl@0: __swbuf((int)(c), p) : \ sl@0: (*(p)->_p = (unsigned char)(c), (int)*(p)->_p++)) sl@0: sl@0: /** sl@0: Called by the main entry point fns to ensure stdio has been initialized. sl@0: @internalComponent sl@0: */ sl@0: #define CHECK_INIT(fp) /* done in the construction of the struct _reent */ sl@0: /* sl@0: #define CHECK_INIT(fp) \ sl@0: { \ sl@0: if ((fp)->_data == 0) \ sl@0: (fp)->_data = _REENT; \ sl@0: if (!(fp)->_data->__sdidinit) \ sl@0: __sinit ((fp)->_data); \ sl@0: } sl@0: */ sl@0: sl@0: /** sl@0: Return true iff the given FILE cannot be written now. sl@0: @internalComponent sl@0: */ sl@0: #define cantwrite(fp) \ sl@0: ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ sl@0: __swsetup(fp)) sl@0: sl@0: /** sl@0: Test whether the given stdio file has an active ungetc buffer; sl@0: release such a buffer, without restoring ordinary unread data. sl@0: @internalComponent sl@0: */ sl@0: #define HASUB(fp) ((fp)->_ub._base != NULL) sl@0: #define FREEUB(fp) { \ sl@0: if ((fp)->_ub._base != (fp)->_ubuf) \ sl@0: _free_r(fp->_data, (char *)(fp)->_ub._base); \ sl@0: (fp)->_ub._base = NULL; \ sl@0: } sl@0: sl@0: /** sl@0: Test for an fgetline() buffer. sl@0: @internalComponent sl@0: */ sl@0: #define HASLB(fp) ((fp)->_lb._base != NULL) sl@0: #define FREELB(fp) { _free_r(fp->_data,(char *)(fp)->_lb._base); (fp)->_lb._base = NULL; } sl@0: sl@0: /* sl@0: WARNING: _dcvt is defined in the stdlib directory, not here! sl@0: @internalComponent sl@0: */ sl@0: char *_dcvt (struct _reent *, char *, double, int, int, char, int); sl@0: char *_sicvt (char *, short, char); sl@0: char *_icvt (char *, int, char); sl@0: char *_licvt (char *, long, char); sl@0: #ifdef __GNUC__ sl@0: char *_llicvt (char *, long long, char); sl@0: #endif sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define CVT_BUF_SIZE 128 sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define NDYNAMIC 4 /* add four more whenever necessary */