Update contrib.
3 * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
8 * Copyright (c) 1990 The Regents of the University of California.
11 * Redistribution and use in source and binary forms are permitted
12 * provided that the above copyright notice and this paragraph are
13 * duplicated in all such forms and that any documentation,
14 * advertising materials, and other materials related to such
15 * distribution and use acknowledge that the software was developed
16 * by the University of California, Berkeley. The name of the
17 * University may not be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * %W% (UofMD/Berkeley) %G%
27 * Information local to this implementation of stdio,
28 * in particular, macros and private variables.
38 extern int __svfscanf (FILE *, const char *,va_list);
39 extern FILE* __sfp (struct _reent *);
40 extern int __sflags (struct _reent *,const wchar_t*, int*);
41 extern int __srefill (FILE *);
42 extern int __sread (void *, char *, int);
43 extern int __swrite (void *, char const *, int);
44 extern fpos_t __sseek (void *, fpos_t, int);
45 extern int __sclose (void *);
46 extern void __sinit (struct _reent *);
47 extern void __smakebuf (FILE *);
48 extern int _fwalk (struct _reent *, int (*)(FILE *));
49 struct _glue* __sfmoreglue (struct _reent *,int n);
50 extern int __srefill (FILE *fp);
51 extern int __srget (FILE *fp);
52 extern int __swbuf (int c, FILE *fp);
55 Macros used inside the implementation of STDIO. These used to be in
56 the <stdio.h> include file, but we want to hide them as much as
57 possible to give us a change to change the implementation if
61 #define __sfeof(p) (((p)->_flags & __SEOF) != 0)
62 #define __sferror(p) (((p)->_flags & __SERR) != 0)
63 #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
64 #define __sfileno(p) ((p)->_file)
68 #define feof(p) __sfeof(p)
69 #define ferror(p) __sferror(p)
70 #define clearerr(p) __sclearerr(p)
74 #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
75 #define __sputc(c, p) \
77 (p)->_w >= (p)->_lbfsize ? \
78 (*(p)->_p = (unsigned char)(c)), *(p)->_p != '\n' ? \
81 __swbuf((int)(c), p) : \
82 (*(p)->_p = (unsigned char)(c), (int)*(p)->_p++))
85 Called by the main entry point fns to ensure stdio has been initialized.
88 #define CHECK_INIT(fp) /* done in the construction of the struct _reent */
90 #define CHECK_INIT(fp) \
92 if ((fp)->_data == 0) \
93 (fp)->_data = _REENT; \
94 if (!(fp)->_data->__sdidinit) \
95 __sinit ((fp)->_data); \
100 Return true iff the given FILE cannot be written now.
103 #define cantwrite(fp) \
104 ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
108 Test whether the given stdio file has an active ungetc buffer;
109 release such a buffer, without restoring ordinary unread data.
112 #define HASUB(fp) ((fp)->_ub._base != NULL)
113 #define FREEUB(fp) { \
114 if ((fp)->_ub._base != (fp)->_ubuf) \
115 _free_r(fp->_data, (char *)(fp)->_ub._base); \
116 (fp)->_ub._base = NULL; \
120 Test for an fgetline() buffer.
123 #define HASLB(fp) ((fp)->_lb._base != NULL)
124 #define FREELB(fp) { _free_r(fp->_data,(char *)(fp)->_lb._base); (fp)->_lb._base = NULL; }
127 WARNING: _dcvt is defined in the stdlib directory, not here!
130 char *_dcvt (struct _reent *, char *, double, int, int, char, int);
131 char *_sicvt (char *, short, char);
132 char *_icvt (char *, int, char);
133 char *_licvt (char *, long, char);
135 char *_llicvt (char *, long long, char);
140 #define CVT_BUF_SIZE 128
144 #define NDYNAMIC 4 /* add four more whenever necessary */