aboutsummaryrefslogtreecommitdiff
path: root/libio/stdio.h
diff options
context:
space:
mode:
Diffstat (limited to 'libio/stdio.h')
-rw-r--r--libio/stdio.h101
1 files changed, 74 insertions, 27 deletions
diff --git a/libio/stdio.h b/libio/stdio.h
index 10bd6e5..3acaa8b 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -41,8 +41,15 @@ __BEGIN_DECLS
#if !defined __FILE_defined && defined __need_FILE
+__BEGIN_NAMESPACE_STD
/* The opaque type of streams. This is the definition used elsewhere. */
typedef struct _IO_FILE FILE;
+__END_NAMESPACE_STD
+#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
+ || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
+ || defined __USE_POSIX2
+__USING_NAMESPACE_STD(FILE)
+#endif
# define __FILE_defined 1
#endif /* FILE not defined. */
@@ -76,11 +83,13 @@ typedef _G_va_list va_list;
#endif
/* The type of the second argument to `fgetpos' and `fsetpos'. */
+__BEGIN_NAMESPACE_STD
#ifndef __USE_FILE_OFFSET64
typedef _G_fpos_t fpos_t;
#else
typedef _G_fpos64_t fpos_t;
#endif
+__END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
typedef _G_fpos64_t fpos64_t;
#endif
@@ -130,20 +139,23 @@ typedef _G_fpos64_t fpos64_t;
/* Standard streams. */
-extern FILE *stdin; /* Standard input stream. */
-extern FILE *stdout; /* Standard output stream. */
-extern FILE *stderr; /* Standard error output stream. */
+extern struct _IO_FILE *stdin; /* Standard input stream. */
+extern struct _IO_FILE *stdout; /* Standard output stream. */
+extern struct _IO_FILE *stderr; /* Standard error output stream. */
/* C89/C99 say they're macros. Make them happy. */
#define stdin stdin
#define stdout stdout
#define stderr stderr
+__BEGIN_NAMESPACE_STD
/* Remove file FILENAME. */
extern int remove (__const char *__filename) __THROW;
/* Rename file OLD to NEW. */
extern int rename (__const char *__old, __const char *__new) __THROW;
+__END_NAMESPACE_STD
+__BEGIN_NAMESPACE_STD
/* Create a temporary file and open it read/write. */
#ifndef __USE_FILE_OFFSET64
extern FILE *tmpfile (void) __THROW;
@@ -154,11 +166,14 @@ extern FILE *__REDIRECT (tmpfile, (void) __THROW, tmpfile64);
# define tmpfile tmpfile64
# endif
#endif
+
+/* Generate a temporary filename. */
+extern char *tmpnam (char *__s) __THROW;
+__END_NAMESPACE_STD
+
#ifdef __USE_LARGEFILE64
extern FILE *tmpfile64 (void) __THROW;
#endif
-/* Generate a temporary filename. */
-extern char *tmpnam (char *__s) __THROW;
#ifdef __USE_MISC
/* This is the reentrant variant of `tmpnam'. The only difference is
@@ -180,10 +195,12 @@ extern char *tempnam (__const char *__dir, __const char *__pfx)
#endif
+__BEGIN_NAMESPACE_STD
/* Close STREAM. */
extern int fclose (FILE *__stream) __THROW;
/* Flush STREAM, or all streams if STREAM is NULL. */
extern int fflush (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
#ifdef __USE_MISC
/* Faster versions when locking is not required. */
@@ -196,6 +213,7 @@ extern int fcloseall (void) __THROW;
#endif
+__BEGIN_NAMESPACE_STD
#ifndef __USE_FILE_OFFSET64
/* Open a file and create a new stream for it. */
extern FILE *fopen (__const char *__restrict __filename,
@@ -218,6 +236,7 @@ extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
# define freopen freopen64
# endif
#endif
+__END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
extern FILE *fopen64 (__const char *__restrict __filename,
__const char *__restrict __modes) __THROW;
@@ -249,6 +268,7 @@ extern FILE *open_memstream (char **__restrict __bufloc,
#endif
+__BEGIN_NAMESPACE_STD
/* If BUF is NULL, make STREAM unbuffered.
Else make it use buffer BUF, of size BUFSIZ. */
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
@@ -257,6 +277,7 @@ extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
else allocate an internal buffer N bytes long. */
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
int __modes, size_t __n) __THROW;
+__END_NAMESPACE_STD
#ifdef __USE_BSD
/* If BUF is NULL, make STREAM unbuffered.
@@ -269,6 +290,7 @@ extern void setlinebuf (FILE *__stream) __THROW;
#endif
+__BEGIN_NAMESPACE_STD
/* Write formatted output to STREAM. */
extern int fprintf (FILE *__restrict __stream,
__const char *__restrict __format, ...) __THROW;
@@ -287,8 +309,10 @@ extern int vprintf (__const char *__restrict __format, _G_va_list __arg)
/* Write formatted output to S from argument list ARG. */
extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
_G_va_list __arg) __THROW;
+__END_NAMESPACE_STD
#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
+__BEGIN_NAMESPACE_C99
/* Maximum chars of output to write in MAXLEN. */
extern int snprintf (char *__restrict __s, size_t __maxlen,
__const char *__restrict __format, ...)
@@ -297,6 +321,7 @@ extern int snprintf (char *__restrict __s, size_t __maxlen,
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
__const char *__restrict __format, _G_va_list __arg)
__THROW __attribute__ ((__format__ (__printf__, 3, 0)));
+__END_NAMESPACE_C99
#endif
#ifdef __USE_GNU
@@ -321,6 +346,7 @@ extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
#endif
+__BEGIN_NAMESPACE_STD
/* Read formatted input from STREAM. */
extern int fscanf (FILE *__restrict __stream,
__const char *__restrict __format, ...) __THROW;
@@ -329,8 +355,10 @@ extern int scanf (__const char *__restrict __format, ...) __THROW;
/* Read formatted input from S. */
extern int sscanf (__const char *__restrict __s,
__const char *__restrict __format, ...) __THROW;
+__END_NAMESPACE_STD
#ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
/* Read formatted input from S into argument list ARG. */
extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
_G_va_list __arg)
@@ -344,15 +372,18 @@ extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
extern int vsscanf (__const char *__restrict __s,
__const char *__restrict __format, _G_va_list __arg)
__THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
+__END_NAMESPACE_C99
#endif /* Use ISO C9x. */
+__BEGIN_NAMESPACE_STD
/* Read a character from STREAM. */
extern int fgetc (FILE *__stream) __THROW;
extern int getc (FILE *__stream) __THROW;
/* Read a character from stdin. */
extern int getchar (void) __THROW;
+__END_NAMESPACE_STD
/* The C standard explicitly says this is a macro, so we always do the
optimization for it. */
@@ -370,12 +401,14 @@ extern int fgetc_unlocked (FILE *__stream) __THROW;
#endif /* Use MISC. */
+__BEGIN_NAMESPACE_STD
/* Write a character to STREAM. */
extern int fputc (int __c, FILE *__stream) __THROW;
extern int putc (int __c, FILE *__stream) __THROW;
/* Write a character to stdout. */
extern int putchar (int __c) __THROW;
+__END_NAMESPACE_STD
/* The C standard explicitly says this can be a macro,
so we always do the optimization for it. */
@@ -402,20 +435,22 @@ extern int putw (int __w, FILE *__stream) __THROW;
#endif
+__BEGIN_NAMESPACE_STD
/* Get a newline-terminated string of finite length from STREAM. */
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
__THROW;
+/* Get a newline-terminated string from stdin, removing the newline.
+ DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
+extern char *gets (char *__s) __THROW;
+__END_NAMESPACE_STD
+
#ifdef __USE_GNU
/* This function does the same as `fgets' but does not lock the stream. */
extern char *fgets_unlocked (char *__restrict __s, int __n,
FILE *__restrict __stream) __THROW;
#endif
-/* Get a newline-terminated string from stdin, removing the newline.
- DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
-extern char *gets (char *__s) __THROW;
-
#ifdef __USE_GNU
/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
@@ -437,16 +472,11 @@ extern _IO_ssize_t getline (char **__restrict __lineptr,
#endif
+__BEGIN_NAMESPACE_STD
/* Write a string to STREAM. */
extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
__THROW;
-#ifdef __USE_GNU
-/* This function does the same as `fputs' but does not lock the stream. */
-extern int fputs_unlocked (__const char *__restrict __s,
- FILE *__restrict __stream) __THROW;
-#endif
-
/* Write a string, followed by a newline, to stdout. */
extern int puts (__const char *__s) __THROW;
@@ -461,6 +491,13 @@ extern size_t fread (void *__restrict __ptr, size_t __size,
/* Write chunks of generic data to STREAM. */
extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s) __THROW;
+__END_NAMESPACE_STD
+
+#ifdef __USE_GNU
+/* This function does the same as `fputs' but does not lock the stream. */
+extern int fputs_unlocked (__const char *__restrict __s,
+ FILE *__restrict __stream) __THROW;
+#endif
#ifdef __USE_MISC
/* Faster versions when locking is not necessary. */
@@ -471,26 +508,41 @@ extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
#endif
+__BEGIN_NAMESPACE_STD
/* Seek to a certain position on STREAM. */
extern int fseek (FILE *__stream, long int __off, int __whence) __THROW;
/* Return the current position of STREAM. */
extern long int ftell (FILE *__stream) __THROW;
/* Rewind to the beginning of STREAM. */
extern void rewind (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
/* The Single Unix Specification, Version 2, specifies an alternative,
more adequate interface for the two functions above which deal with
file offset. `long int' is not the right type. These definitions
are originally defined in the Large File Support API. */
-#ifndef __USE_FILE_OFFSET64
-# ifdef __USE_LARGEFILE
+#ifdef __USE_LARGEFILE
+# ifndef __USE_FILE_OFFSET64
/* Seek to a certain position on STREAM. */
extern int fseeko (FILE *__stream, __off_t __off, int __whence) __THROW;
/* Return the current position of STREAM. */
extern __off_t ftello (FILE *__stream) __THROW;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (fseeko,
+ (FILE *__stream, __off64_t __off, int __whence) __THROW,
+ fseeko64);
+extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
+# else
+# define fseeko fseeko64
+# define ftello ftello64
+# endif
# endif
+#endif
+__BEGIN_NAMESPACE_STD
+#ifndef __USE_FILE_OFFSET64
/* Get STREAM's position. */
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
__THROW;
@@ -498,26 +550,17 @@ extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
extern int fsetpos (FILE *__stream, __const fpos_t *__pos) __THROW;
#else
# ifdef __REDIRECT
-# ifdef __USE_LARGEFILE
-extern int __REDIRECT (fseeko,
- (FILE *__stream, __off64_t __off, int __whence) __THROW,
- fseeko64);
-extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
-# endif
extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
fpos_t *__restrict __pos) __THROW, fgetpos64);
extern int __REDIRECT (fsetpos,
(FILE *__stream, __const fpos_t *__pos) __THROW,
fsetpos64);
# else
-# ifdef __USE_LARGEFILE
-# define fseeko fseeko64
-# define ftello ftello64
-# endif
# define fgetpos fgetpos64
# define fsetpos fsetpos64
# endif
#endif
+__END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence) __THROW;
@@ -527,12 +570,14 @@ extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos) __THROW;
#endif
+__BEGIN_NAMESPACE_STD
/* Clear the error and EOF indicators for STREAM. */
extern void clearerr (FILE *__stream) __THROW;
/* Return the EOF indicator for STREAM. */
extern int feof (FILE *__stream) __THROW;
/* Return the error indicator for STREAM. */
extern int ferror (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
#ifdef __USE_MISC
/* Faster versions when locking is not required. */
@@ -542,8 +587,10 @@ extern int ferror_unlocked (FILE *__stream) __THROW;
#endif
+__BEGIN_NAMESPACE_STD
/* Print a message describing the meaning of the value of errno. */
extern void perror (__const char *__s) __THROW;
+__END_NAMESPACE_STD
/* Provide the declarations for `sys_errlist' and `sys_nerr' if they
are available on this system. Even if available, these variables