2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the University of California, Berkeley. The name of the
|
|
|
|
* University may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* @(#)stdio.h 5.3 (Berkeley) 3/15/86
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: to fit things in six character monocase externals, the
|
|
|
|
* stdio code uses the prefix `__s' for stdio objects, typically
|
|
|
|
* followed by a three-character attempt at a mnemonic.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STDIO_H_
|
|
|
|
#define _STDIO_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
|
|
|
|
|
|
|
#define _FSTDIO /* ``function stdio'' */
|
|
|
|
|
|
|
|
#define __need_size_t
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#define __need___va_list
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
/*
|
2002-07-18 07:25:44 +08:00
|
|
|
* <sys/reent.h> defines __FILE, _fpos_t.
|
2000-02-18 03:39:52 +08:00
|
|
|
* They must be defined there because struct _reent needs them (and we don't
|
|
|
|
* want reent.h to include this file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/reent.h>
|
2002-06-22 02:29:23 +08:00
|
|
|
#include <sys/types.h>
|
2002-05-08 08:12:49 +08:00
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_BEGIN_STD_C
|
|
|
|
|
2002-07-18 07:25:44 +08:00
|
|
|
typedef __FILE FILE;
|
|
|
|
|
2003-03-08 04:41:49 +08:00
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#ifdef __CYGWIN_USE_BIG_TYPES__
|
|
|
|
typedef _fpos64_t fpos_t;
|
|
|
|
#else
|
|
|
|
typedef _fpos_t fpos_t;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
typedef _fpos_t fpos_t;
|
2002-07-18 07:25:44 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
|
|
|
typedef _fpos64_t fpos64_t;
|
|
|
|
#endif
|
2003-03-08 04:41:49 +08:00
|
|
|
#endif /* !__CYGWIN__ */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2002-06-22 02:29:23 +08:00
|
|
|
#include <sys/stdio.h>
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#define __SLBF 0x0001 /* line buffered */
|
|
|
|
#define __SNBF 0x0002 /* unbuffered */
|
|
|
|
#define __SRD 0x0004 /* OK to read */
|
|
|
|
#define __SWR 0x0008 /* OK to write */
|
|
|
|
/* RD and WR are never simultaneously asserted */
|
|
|
|
#define __SRW 0x0010 /* open for reading & writing */
|
|
|
|
#define __SEOF 0x0020 /* found EOF */
|
|
|
|
#define __SERR 0x0040 /* found error */
|
|
|
|
#define __SMBF 0x0080 /* _buf is from malloc */
|
|
|
|
#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
|
|
|
|
#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
|
|
|
|
#define __SOPT 0x0400 /* do fseek() optimisation */
|
|
|
|
#define __SNPT 0x0800 /* do not do fseek() optimisation */
|
|
|
|
#define __SOFF 0x1000 /* set iff _offset is in fact correct */
|
|
|
|
#define __SMOD 0x2000 /* true => fgetline modified _p text */
|
2003-05-13 17:46:48 +08:00
|
|
|
#if defined(__CYGWIN__)
|
2002-07-18 07:25:44 +08:00
|
|
|
# define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
2002-07-18 07:25:44 +08:00
|
|
|
#define __SL64 0x8000 /* is 64-bit offset large file */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The following three definitions are for ANSI C, which took them
|
|
|
|
* from System V, which stupidly took internal interface macros and
|
|
|
|
* made them official arguments to setvbuf(), without renaming them.
|
|
|
|
* Hence, these ugly _IOxxx names are *supposed* to appear in user code.
|
|
|
|
*
|
|
|
|
* Although these happen to match their counterparts above, the
|
|
|
|
* implementation does not rely on that (so these could be renumbered).
|
|
|
|
*/
|
|
|
|
#define _IOFBF 0 /* setvbuf should set fully buffered */
|
|
|
|
#define _IOLBF 1 /* setvbuf should set line buffered */
|
|
|
|
#define _IONBF 2 /* setvbuf should set unbuffered */
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EOF (-1)
|
|
|
|
|
2001-08-03 06:28:40 +08:00
|
|
|
#ifdef __BUFSIZ__
|
|
|
|
#define BUFSIZ __BUFSIZ__
|
|
|
|
#else
|
|
|
|
#define BUFSIZ 1024
|
|
|
|
#endif
|
|
|
|
|
2001-02-01 04:11:48 +08:00
|
|
|
#ifdef __FOPEN_MAX__
|
|
|
|
#define FOPEN_MAX __FOPEN_MAX__
|
|
|
|
#else
|
|
|
|
#define FOPEN_MAX 20
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __FILENAME_MAX__
|
|
|
|
#define FILENAME_MAX __FILENAME_MAX__
|
|
|
|
#else
|
|
|
|
#define FILENAME_MAX 1024
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __L_tmpnam__
|
|
|
|
#define L_tmpnam __L_tmpnam__
|
|
|
|
#else
|
|
|
|
#define L_tmpnam FILENAME_MAX
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef __STRICT_ANSI__
|
|
|
|
#define P_tmpdir "/tmp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SEEK_SET
|
|
|
|
#define SEEK_SET 0 /* set file offset to offset */
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_CUR
|
|
|
|
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_END
|
|
|
|
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TMP_MAX 26
|
|
|
|
|
2002-05-17 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Copy and install headers from sys/machine/include
directory. Also pass $toollibdir to lower-level directories.
* Makefile.in: Regenerated.
* libc/include/stdio.h[!_REENT_ONLY]: Change stdin, stdout, and
stderr to use _REENT macro instead of _impure_ptr directly.
* libc/include/sys/config.h[__i386__][__linux__]: Define
__DYNAMIC_REENT__.
* libc/include/sys/reent.h[!_REENT_ONLY]: Change _REENT macro to be
call to __getreent() function if !__SINGLE_THREAD__ and
__DYNAMIC_REENT__ is set.
* libc/reent/Makefile.am: Add support for getreent.c.
* libc/reent/Makefile.in: Regenerated.
* libc/string/strerror.c: Add check if EOPNOTSUPP and ENOTSUP are same.
* libc/sys/linux/Makefile.am: Add support for new files.
* libc/sys/linux/configure.in: Add $EXTRA_DIRS variable.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/configure: Ditto.
* libc/sys/linux/io.c: Add poll syscall. Also weak-alias
__close, __read, __write, __poll, __open, __lseek, __fcntl from
their __libc_ counterparts.
* libc/sys/linux/io64.c: Add __libc_ prefix to lseek64 and open64
and weak-alias to regular names.
* libc/sys/linux/pread64.c: Rename to __libc_pread64 and weak-alias
to pread64 and __pread64.
* libc/sys/linux/process.c: Weak_alias __libc_getpid to __getpid.
* libc/sys/linux/pwrite64.c: Rename to __libc_pwrite64 and
weak-alias to pwrite64.
* libc/sys/linux/sched.c: Weak-alias __libc_sched_getparam,
__libc_sched_getscheduler, __libc_sched_get_priority_max,
__libc_sched_get_priority_min, and __libc_sched_setschedule to
name with __ instead of __libc_.
* libc/sys/linux/siglongjmp.c: Include <machine/weakalias.h>.
Rename siglongjmp to __libc_siglongjmp and weak-alias to siglongjmp.
Call __libc_longjmp instead of longjmp, from __libc_siglongjmp.
* libc/sys/linux/signal.c: Rename raise to __libc_raise and weak-alias
to raise.
* libc/sys/linux/socket.c: Weak-alias __libc_connect to __connect and
__libc_send to __send.
* libc/sys/linux/time.c: Weak-alias __libc_gettimeofday to
__gettimeofday.
* libc/sys/linux/wait.c: Rename wait to __libc_wait and weak-alias
it to wait. Rename wait3 to __libc_wait3 and weak-alias it to wait3.
* libc/sys/linux/include/setjmp.h: Use __jmp_buf in sigjmp_buf
type and typedef __jmp_buf to jmp_buf.
* libc/sys/linux/machine/i386/Makefile.am: Add syscalls.c and
setjmp.S.
* libc/sys/linux/machine/i386/Makefile.in: Regenerated.
* libc/sys/linux/machine/i386/crt0.c: Add support to clear .bss
section.
* libc/sys/linux/machine/i386/socketcall.h: Change to use __libc_
prefix for function macros and then use weak_alias() to regular names.
* libc/sys/linux/machine/i386/syscall.h: Ditto.
* libc/sys/linux/sys/errno.h: Define EOPNOTSUP to be ENOTSUP.
* libc/sys/linux/sys/stdio.h: Define _flockfile and _funlockfile
to be flockfile() and funlockfile() respectively.
* libc/sys/linux/sys/types.h
* libc/reent/getreent.c: New file.
* libc/sys/linux/flockfile.c: Ditto.
* libc/sys/linux/funlockfile.c: Ditto.
* libc/sys/linux/getreent.c: Ditto.
* libc/sys/linux/pread.c: Ditto.
* libc/sys/linux/pwrite.c: Ditto.
* libc/sys/linux/raise.c: Ditto.
* libc/sys/linux/system.c: Ditto.
* libc/sys/linux/tcdrain.c: Ditto.
* libc/sys/linux/machine/i386/i386mach.h: Ditto.
* libc/sys/linux/machine/i386/setjmp.S: Ditto.
* libc/sys/linux/machine/i386/syscalls.c: Ditto.
* libc/sys/linux/machine/i386/weakalias.h: Ditto.
* libc/sys/linux/machine/i386/include/setjmp.h: Ditto.
2002-05-18 07:39:39 +08:00
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
#define stdin (_REENT->_stdin)
|
|
|
|
#define stdout (_REENT->_stdout)
|
|
|
|
#define stderr (_REENT->_stderr)
|
|
|
|
#else /* _REENT_ONLY */
|
2000-02-18 03:39:52 +08:00
|
|
|
#define stdin (_impure_ptr->_stdin)
|
|
|
|
#define stdout (_impure_ptr->_stdout)
|
|
|
|
#define stderr (_impure_ptr->_stderr)
|
2002-05-17 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Copy and install headers from sys/machine/include
directory. Also pass $toollibdir to lower-level directories.
* Makefile.in: Regenerated.
* libc/include/stdio.h[!_REENT_ONLY]: Change stdin, stdout, and
stderr to use _REENT macro instead of _impure_ptr directly.
* libc/include/sys/config.h[__i386__][__linux__]: Define
__DYNAMIC_REENT__.
* libc/include/sys/reent.h[!_REENT_ONLY]: Change _REENT macro to be
call to __getreent() function if !__SINGLE_THREAD__ and
__DYNAMIC_REENT__ is set.
* libc/reent/Makefile.am: Add support for getreent.c.
* libc/reent/Makefile.in: Regenerated.
* libc/string/strerror.c: Add check if EOPNOTSUPP and ENOTSUP are same.
* libc/sys/linux/Makefile.am: Add support for new files.
* libc/sys/linux/configure.in: Add $EXTRA_DIRS variable.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/configure: Ditto.
* libc/sys/linux/io.c: Add poll syscall. Also weak-alias
__close, __read, __write, __poll, __open, __lseek, __fcntl from
their __libc_ counterparts.
* libc/sys/linux/io64.c: Add __libc_ prefix to lseek64 and open64
and weak-alias to regular names.
* libc/sys/linux/pread64.c: Rename to __libc_pread64 and weak-alias
to pread64 and __pread64.
* libc/sys/linux/process.c: Weak_alias __libc_getpid to __getpid.
* libc/sys/linux/pwrite64.c: Rename to __libc_pwrite64 and
weak-alias to pwrite64.
* libc/sys/linux/sched.c: Weak-alias __libc_sched_getparam,
__libc_sched_getscheduler, __libc_sched_get_priority_max,
__libc_sched_get_priority_min, and __libc_sched_setschedule to
name with __ instead of __libc_.
* libc/sys/linux/siglongjmp.c: Include <machine/weakalias.h>.
Rename siglongjmp to __libc_siglongjmp and weak-alias to siglongjmp.
Call __libc_longjmp instead of longjmp, from __libc_siglongjmp.
* libc/sys/linux/signal.c: Rename raise to __libc_raise and weak-alias
to raise.
* libc/sys/linux/socket.c: Weak-alias __libc_connect to __connect and
__libc_send to __send.
* libc/sys/linux/time.c: Weak-alias __libc_gettimeofday to
__gettimeofday.
* libc/sys/linux/wait.c: Rename wait to __libc_wait and weak-alias
it to wait. Rename wait3 to __libc_wait3 and weak-alias it to wait3.
* libc/sys/linux/include/setjmp.h: Use __jmp_buf in sigjmp_buf
type and typedef __jmp_buf to jmp_buf.
* libc/sys/linux/machine/i386/Makefile.am: Add syscalls.c and
setjmp.S.
* libc/sys/linux/machine/i386/Makefile.in: Regenerated.
* libc/sys/linux/machine/i386/crt0.c: Add support to clear .bss
section.
* libc/sys/linux/machine/i386/socketcall.h: Change to use __libc_
prefix for function macros and then use weak_alias() to regular names.
* libc/sys/linux/machine/i386/syscall.h: Ditto.
* libc/sys/linux/sys/errno.h: Define EOPNOTSUP to be ENOTSUP.
* libc/sys/linux/sys/stdio.h: Define _flockfile and _funlockfile
to be flockfile() and funlockfile() respectively.
* libc/sys/linux/sys/types.h
* libc/reent/getreent.c: New file.
* libc/sys/linux/flockfile.c: Ditto.
* libc/sys/linux/funlockfile.c: Ditto.
* libc/sys/linux/getreent.c: Ditto.
* libc/sys/linux/pread.c: Ditto.
* libc/sys/linux/pwrite.c: Ditto.
* libc/sys/linux/raise.c: Ditto.
* libc/sys/linux/system.c: Ditto.
* libc/sys/linux/tcdrain.c: Ditto.
* libc/sys/linux/machine/i386/i386mach.h: Ditto.
* libc/sys/linux/machine/i386/setjmp.S: Ditto.
* libc/sys/linux/machine/i386/syscalls.c: Ditto.
* libc/sys/linux/machine/i386/weakalias.h: Ditto.
* libc/sys/linux/machine/i386/include/setjmp.h: Ditto.
2002-05-18 07:39:39 +08:00
|
|
|
#endif /* _REENT_ONLY */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define _stdin_r(x) ((x)->_stdin)
|
|
|
|
#define _stdout_r(x) ((x)->_stdout)
|
|
|
|
#define _stderr_r(x) ((x)->_stderr)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions defined in ANSI C standard.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define __VALIST __gnuc_va_list
|
|
|
|
#else
|
|
|
|
#define __VALIST char*
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FILE * _EXFUN(tmpfile, (void));
|
|
|
|
char * _EXFUN(tmpnam, (char *));
|
|
|
|
int _EXFUN(fclose, (FILE *));
|
|
|
|
int _EXFUN(fflush, (FILE *));
|
|
|
|
FILE * _EXFUN(freopen, (const char *, const char *, FILE *));
|
|
|
|
void _EXFUN(setbuf, (FILE *, char *));
|
|
|
|
int _EXFUN(setvbuf, (FILE *, char *, int, size_t));
|
|
|
|
int _EXFUN(fprintf, (FILE *, const char *, ...));
|
|
|
|
int _EXFUN(fscanf, (FILE *, const char *, ...));
|
|
|
|
int _EXFUN(printf, (const char *, ...));
|
|
|
|
int _EXFUN(scanf, (const char *, ...));
|
|
|
|
int _EXFUN(sscanf, (const char *, const char *, ...));
|
|
|
|
int _EXFUN(vfprintf, (FILE *, const char *, __VALIST));
|
|
|
|
int _EXFUN(vprintf, (const char *, __VALIST));
|
|
|
|
int _EXFUN(vsprintf, (char *, const char *, __VALIST));
|
|
|
|
int _EXFUN(fgetc, (FILE *));
|
|
|
|
char * _EXFUN(fgets, (char *, int, FILE *));
|
|
|
|
int _EXFUN(fputc, (int, FILE *));
|
|
|
|
int _EXFUN(fputs, (const char *, FILE *));
|
|
|
|
int _EXFUN(getc, (FILE *));
|
|
|
|
int _EXFUN(getchar, (void));
|
|
|
|
char * _EXFUN(gets, (char *));
|
|
|
|
int _EXFUN(putc, (int, FILE *));
|
|
|
|
int _EXFUN(putchar, (int));
|
|
|
|
int _EXFUN(puts, (const char *));
|
|
|
|
int _EXFUN(ungetc, (int, FILE *));
|
|
|
|
size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
|
|
|
|
size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
|
2003-03-15 02:39:05 +08:00
|
|
|
#ifdef _COMPILING_NEWLIB
|
|
|
|
int _EXFUN(fgetpos, (FILE *, _fpos_t *));
|
|
|
|
#else
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(fgetpos, (FILE *, fpos_t *));
|
2003-03-15 02:39:05 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(fseek, (FILE *, long, int));
|
2003-03-15 02:39:05 +08:00
|
|
|
#ifdef _COMPILING_NEWLIB
|
|
|
|
int _EXFUN(fsetpos, (FILE *, const _fpos_t *));
|
|
|
|
#else
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(fsetpos, (FILE *, const fpos_t *));
|
2003-03-15 02:39:05 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
long _EXFUN(ftell, ( FILE *));
|
|
|
|
void _EXFUN(rewind, (FILE *));
|
|
|
|
void _EXFUN(clearerr, (FILE *));
|
|
|
|
int _EXFUN(feof, (FILE *));
|
|
|
|
int _EXFUN(ferror, (FILE *));
|
|
|
|
void _EXFUN(perror, (const char *));
|
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
FILE * _EXFUN(fopen, (const char *_name, const char *_type));
|
|
|
|
int _EXFUN(sprintf, (char *, const char *, ...));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(remove, (const char *));
|
|
|
|
int _EXFUN(rename, (const char *, const char *));
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
#ifndef __STRICT_ANSI__
|
2003-03-15 02:39:05 +08:00
|
|
|
#ifdef _COMPILING_NEWLIB
|
|
|
|
int _EXFUN(fseeko, (FILE *, _off_t, int));
|
|
|
|
_off_t _EXFUN(ftello, ( FILE *));
|
|
|
|
#else
|
2002-07-05 03:33:54 +08:00
|
|
|
int _EXFUN(fseeko, (FILE *, off_t, int));
|
|
|
|
off_t _EXFUN(ftello, ( FILE *));
|
2003-03-15 02:39:05 +08:00
|
|
|
#endif
|
2004-11-24 08:45:41 +08:00
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
int _EXFUN(asiprintf, (char **, const char *, ...));
|
|
|
|
int _EXFUN(asprintf, (char **, const char *, ...));
|
2006-05-24 03:57:31 +08:00
|
|
|
#ifndef dprintf
|
2005-10-12 07:59:32 +08:00
|
|
|
int _EXFUN(dprintf, (int, const char *, ...));
|
2006-05-24 03:57:31 +08:00
|
|
|
#endif
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(fcloseall, (_VOID));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(fiprintf, (FILE *, const char *, ...));
|
2006-05-19 02:07:19 +08:00
|
|
|
int _EXFUN(fiscanf, (FILE *, const char *, ...));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(iprintf, (const char *, ...));
|
2006-05-19 02:07:19 +08:00
|
|
|
int _EXFUN(iscanf, (const char *, ...));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(siprintf, (char *, const char *, ...));
|
2006-05-19 02:07:19 +08:00
|
|
|
int _EXFUN(siscanf, (const char *, const char *, ...));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(snprintf, (char *, size_t, const char *, ...));
|
|
|
|
int _EXFUN(sniprintf, (char *, size_t, const char *, ...));
|
2001-04-21 06:50:51 +08:00
|
|
|
char * _EXFUN(tempnam, (const char *, const char *));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(vasiprintf, (char **, const char *, __VALIST));
|
2002-07-05 02:56:17 +08:00
|
|
|
int _EXFUN(vasprintf, (char **, const char *, __VALIST));
|
2005-10-12 07:59:32 +08:00
|
|
|
int _EXFUN(vdprintf, (int, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST));
|
|
|
|
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(vfscanf, (FILE *, const char *, __VALIST));
|
2005-09-02 23:39:29 +08:00
|
|
|
int _EXFUN(viprintf, (const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(viscanf, (const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(vscanf, (const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(vsscanf, (const char *, const char *, __VALIST));
|
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines in POSIX 1003.1.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __STRICT_ANSI__
|
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
FILE * _EXFUN(fdopen, (int, const char *));
|
|
|
|
#endif
|
|
|
|
int _EXFUN(fileno, (FILE *));
|
|
|
|
int _EXFUN(getw, (FILE *));
|
|
|
|
int _EXFUN(pclose, (FILE *));
|
|
|
|
FILE * _EXFUN(popen, (const char *, const char *));
|
2001-02-09 08:32:43 +08:00
|
|
|
int _EXFUN(putw, (int, FILE *));
|
2000-02-18 03:39:52 +08:00
|
|
|
void _EXFUN(setbuffer, (FILE *, char *, int));
|
|
|
|
int _EXFUN(setlinebuf, (FILE *));
|
2002-05-09 03:11:22 +08:00
|
|
|
int _EXFUN(getc_unlocked, (FILE *));
|
|
|
|
int _EXFUN(getchar_unlocked, (void));
|
|
|
|
void _EXFUN(flockfile, (FILE *));
|
|
|
|
int _EXFUN(ftrylockfile, (FILE *));
|
|
|
|
void _EXFUN(funlockfile, (FILE *));
|
|
|
|
int _EXFUN(putc_unlocked, (int, FILE *));
|
|
|
|
int _EXFUN(putchar_unlocked, (int));
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Recursive versions of the above.
|
|
|
|
*/
|
|
|
|
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...));
|
2002-07-05 02:56:17 +08:00
|
|
|
int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...));
|
2005-10-12 07:59:32 +08:00
|
|
|
int _EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...));
|
2002-07-23 07:53:50 +08:00
|
|
|
int _EXFUN(_fcloseall_r, (struct _reent *));
|
2000-02-18 03:39:52 +08:00
|
|
|
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
|
|
|
|
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
|
2004-04-09 06:26:50 +08:00
|
|
|
int _EXFUN(_fclose_r, (struct _reent *, FILE *));
|
2006-06-15 04:49:11 +08:00
|
|
|
char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...));
|
2006-06-15 04:49:11 +08:00
|
|
|
int _EXFUN(_fputc_r, (struct _reent *, int, FILE *));
|
|
|
|
int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
|
|
|
|
size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...));
|
2004-04-24 04:06:03 +08:00
|
|
|
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
|
|
|
|
long _EXFUN(_ftell_r, (struct _reent *, FILE *));
|
2006-06-15 04:49:11 +08:00
|
|
|
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *));
|
|
|
|
int _EXFUN(_getc_r, (struct _reent *, FILE *));
|
|
|
|
int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_getchar_r, (struct _reent *));
|
2006-06-15 04:49:11 +08:00
|
|
|
int _EXFUN(_getchar_unlocked_r, (struct _reent *));
|
2000-02-18 03:39:52 +08:00
|
|
|
char * _EXFUN(_gets_r, (struct _reent *, char *));
|
|
|
|
int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_mkstemp_r, (struct _reent *, char *));
|
|
|
|
char * _EXFUN(_mktemp_r, (struct _reent *, char *));
|
|
|
|
void _EXFUN(_perror_r, (struct _reent *, const char *));
|
|
|
|
int _EXFUN(_printf_r, (struct _reent *, const char *, ...));
|
2006-06-15 04:49:11 +08:00
|
|
|
int _EXFUN(_putc_r, (struct _reent *, int, FILE *));
|
|
|
|
int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *));
|
|
|
|
int _EXFUN(_putchar_unlocked_r, (struct _reent *, int));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_putchar_r, (struct _reent *, int));
|
|
|
|
int _EXFUN(_puts_r, (struct _reent *, const char *));
|
|
|
|
int _EXFUN(_remove_r, (struct _reent *, const char *));
|
|
|
|
int _EXFUN(_rename_r, (struct _reent *,
|
|
|
|
const char *_old, const char *_new));
|
|
|
|
int _EXFUN(_scanf_r, (struct _reent *, const char *, ...));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...));
|
|
|
|
int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...));
|
|
|
|
int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...));
|
2000-02-18 03:39:52 +08:00
|
|
|
char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));
|
|
|
|
FILE * _EXFUN(_tmpfile_r, (struct _reent *));
|
|
|
|
char * _EXFUN(_tmpnam_r, (struct _reent *, char *));
|
2004-05-04 01:27:56 +08:00
|
|
|
int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST));
|
2002-07-05 02:56:17 +08:00
|
|
|
int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST));
|
2005-10-12 07:59:32 +08:00
|
|
|
int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST));
|
2004-05-08 05:00:41 +08:00
|
|
|
int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST));
|
2001-04-21 06:50:51 +08:00
|
|
|
int _EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST));
|
|
|
|
int _EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST));
|
2004-11-24 08:45:41 +08:00
|
|
|
int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2002-06-22 02:29:23 +08:00
|
|
|
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
|
|
|
|
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
|
|
|
|
|
2002-07-18 07:25:44 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
2003-08-27 02:09:43 +08:00
|
|
|
#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB)
|
2003-07-26 00:06:01 +08:00
|
|
|
FILE * _EXFUN(fdopen64, (int, const char *));
|
2002-07-18 07:25:44 +08:00
|
|
|
FILE * _EXFUN(fopen64, (const char *, const char *));
|
|
|
|
_off64_t _EXFUN(ftello64, (FILE *));
|
|
|
|
_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int));
|
|
|
|
int _EXFUN(fgetpos64, (FILE *, _fpos64_t *));
|
|
|
|
int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *));
|
|
|
|
FILE * _EXFUN(tmpfile64, (void));
|
|
|
|
|
2003-07-26 00:06:01 +08:00
|
|
|
FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *));
|
2002-07-18 07:25:44 +08:00
|
|
|
FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *));
|
|
|
|
_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *));
|
|
|
|
_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int));
|
|
|
|
int _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *));
|
|
|
|
int _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *));
|
|
|
|
FILE * _EXFUN(_tmpfile64_r, (struct _reent *));
|
2003-03-08 04:41:49 +08:00
|
|
|
#endif /* !__CYGWIN__ */
|
2002-07-18 07:25:44 +08:00
|
|
|
#endif /* __LARGE64_FILES */
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* Routines internal to the implementation.
|
|
|
|
*/
|
|
|
|
|
2006-06-15 04:49:11 +08:00
|
|
|
int _EXFUN(__srget_r, (struct _reent *, FILE *));
|
|
|
|
int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stdio function-access interface.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __STRICT_ANSI__
|
|
|
|
FILE *_EXFUN(funopen,(const _PTR _cookie,
|
|
|
|
int (*readfn)(_PTR _cookie, char *_buf, int _n),
|
|
|
|
int (*writefn)(_PTR _cookie, const char *_buf, int _n),
|
|
|
|
fpos_t (*seekfn)(_PTR _cookie, fpos_t _off, int _whence),
|
|
|
|
int (*closefn)(_PTR _cookie)));
|
|
|
|
|
|
|
|
#define fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0)
|
|
|
|
#define fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The __sfoo macros are here so that we can
|
|
|
|
* define function versions in the C library.
|
|
|
|
*/
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
|
2000-05-03 11:57:19 +08:00
|
|
|
|
|
|
|
#ifdef __SCLE
|
2006-06-16 00:08:09 +08:00
|
|
|
static __inline__ int __sgetc_r(struct _reent *__ptr, FILE *__p)
|
2000-05-03 11:57:19 +08:00
|
|
|
{
|
2006-06-15 04:49:11 +08:00
|
|
|
int __c = __sgetc_raw_r(__ptr, __p);
|
2000-05-03 11:57:19 +08:00
|
|
|
if ((__p->_flags & __SCLE) && (__c == '\r'))
|
|
|
|
{
|
2006-06-15 04:49:11 +08:00
|
|
|
int __c2 = __sgetc_raw_r(__ptr, __p);
|
2000-05-03 11:57:19 +08:00
|
|
|
if (__c2 == '\n')
|
|
|
|
__c = __c2;
|
|
|
|
else
|
|
|
|
ungetc(__c2, __p);
|
|
|
|
}
|
|
|
|
return __c;
|
|
|
|
}
|
|
|
|
#else
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifdef _never /* __GNUC__ */
|
|
|
|
/* If this inline is actually used, then systems using coff debugging
|
|
|
|
info get hopelessly confused. 21sept93 rich@cygnus.com. */
|
2006-06-15 04:49:11 +08:00
|
|
|
static __inline int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
2000-02-18 03:39:52 +08:00
|
|
|
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
|
|
|
|
return (*_p->_p++ = _c);
|
|
|
|
else
|
2006-06-15 04:49:11 +08:00
|
|
|
return (__swbuf_r(_ptr, _c, _p));
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* This has been tuned to generate reasonable code on the vax using pcc
|
|
|
|
*/
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_raw_r(__ptr, __c, __p) \
|
|
|
|
(--(__p)->_w < 0 ? \
|
|
|
|
(__p)->_w >= (__p)->_lbfsize ? \
|
|
|
|
(*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \
|
|
|
|
(int)*(__p)->_p++ : \
|
|
|
|
__swbuf_r(__ptr, '\n', __p) : \
|
|
|
|
__swbuf_r(__ptr, (int)(__c), __p) : \
|
|
|
|
(*(__p)->_p = (__c), (int)*(__p)->_p++))
|
2000-05-03 11:57:19 +08:00
|
|
|
#ifdef __SCLE
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_r(__ptr, __c, __p) \
|
|
|
|
((((__p)->_flags & __SCLE) && ((__c) == '\n')) \
|
|
|
|
? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \
|
|
|
|
__sputc_raw_r((__ptr), (__c), (__p)))
|
2000-05-03 11:57:19 +08:00
|
|
|
#else
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p)
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
|
|
|
|
#define __sferror(p) (((p)->_flags & __SERR) != 0)
|
|
|
|
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
|
|
|
|
#define __sfileno(p) ((p)->_file)
|
|
|
|
|
|
|
|
#define feof(p) __sfeof(p)
|
|
|
|
#define ferror(p) __sferror(p)
|
|
|
|
#define clearerr(p) __sclearerr(p)
|
|
|
|
|
|
|
|
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
|
|
|
|
#define fileno(p) __sfileno(p)
|
|
|
|
#endif
|
|
|
|
|
2000-05-24 07:51:54 +08:00
|
|
|
#ifndef __CYGWIN__
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef lint
|
2006-06-15 04:49:11 +08:00
|
|
|
#define getc(fp) __sgetc_r(_REENT, fp)
|
|
|
|
#define putc(x, fp) __sputc_r(_REENT, x, fp)
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif /* lint */
|
2000-05-24 07:51:54 +08:00
|
|
|
#endif /* __CYGWIN__ */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define getchar() getc(stdin)
|
|
|
|
#define putchar(x) putc(x, stdout)
|
|
|
|
|
|
|
|
#ifndef __STRICT_ANSI__
|
|
|
|
/* fast always-buffered version, true iff error */
|
|
|
|
#define fast_putc(x,p) (--(p)->_w < 0 ? \
|
2006-06-15 04:49:11 +08:00
|
|
|
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
|
2000-05-31 01:18:05 +08:00
|
|
|
#ifdef __CYGWIN__
|
2000-02-18 03:39:52 +08:00
|
|
|
#define L_ctermid 16
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_END_STD_C
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif /* _STDIO_H_ */
|