-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Add SIGNO to SET. */
int
-DEFUN(sigaddset, (set, signo), sigset_t *set AND int signo)
+sigaddset (set, signo)
+ sigset_t *set;
+ int signo;
{
if (set == NULL || signo <= 0 || signo >= NSIG)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Add SIGNO to SET. */
int
-DEFUN(sigdelset, (set, signo), sigset_t *set AND int signo)
+sigdelset (set, signo)
+ sigset_t *set;
+ int signo;
{
if (set == NULL || signo <= 0 || signo >= NSIG)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Clear all signals from SET. */
int
-DEFUN(sigemptyset, (set), sigset_t *set)
+sigemptyset (set)
+ sigset_t *set;
{
if (set == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Set all signals in SET. */
int
-DEFUN(sigfillset, (set), sigset_t *set)
+sigfillset (set)
+ sigset_t *set;
{
if (set == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Return 1 if SIGNO is in SET, 0 if not. */
int
-DEFUN(sigismember, (set, signo), CONST sigset_t *set AND int signo)
+sigismember (set, signo)
+ const sigset_t *set;
+ int signo;
{
if (set == NULL || signo <= 0 || signo >= NSIG)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
-/* Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
/* Close a stream. */
int
-DEFUN(fclose, (stream), register FILE *stream)
+fclose (stream)
+ register FILE *stream;
{
int status;
if (!__validfp(stream))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
-
+
if (stream->__mode.__write &&
/* Flush the buffer. */
__flshfp (stream, EOF) == EOF)
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Return non-zero if STREAM has its EOF indicator set. */
int
-DEFUN(feof, (stream), FILE *stream)
+feof (stream)
+ FILE *stream;
{
- if (!__validfp(stream))
+ if (!__validfp (stream))
{
- errno = EINVAL;
- return(-1);
+ __set_errno (EINVAL);
+ return -1;
}
- return(stream->__eof);
+ return stream->__eof;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Return non-zero if STREAM has its error indicator set. */
int
-DEFUN(ferror, (stream), FILE *stream)
+ferror (stream)
+ FILE *stream;
{
- if (!__validfp(stream))
+ if (!__validfp (stream))
{
- errno = EINVAL;
- return(-1);
+ __set_errno (EINVAL);
+ return -1;
}
- return(stream->__error);
+ return stream->__error;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
/* Flush STREAM's buffer.
If STREAM is NULL, flush the buffers of all streams that are writing. */
int
-DEFUN(fflush, (stream), register FILE *stream)
+fflush (stream)
+ register FILE *stream;
{
if (stream == NULL)
{
int lossage = 0;
for (stream = __stdio_head; stream != NULL; stream = stream->__next)
- if (__validfp(stream) && stream->__mode.__write)
- lossage |= fflush(stream) == EOF;
+ if (__validfp (stream) && stream->__mode.__write)
+ lossage |= fflush (stream) == EOF;
return lossage ? EOF : 0;
}
- if (!__validfp(stream) || !stream->__mode.__write)
+ if (!__validfp (stream) || !stream->__mode.__write)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
- return __flshfp(stream, EOF);
+ return __flshfp (stream, EOF);
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Read a character from STREAM. */
int
-DEFUN(fgetc, (stream), FILE *stream)
+fgetc (stream)
+ FILE *stream;
{
- if (!__validfp(stream) || !stream->__mode.__read)
+ if (!__validfp (stream) || !stream->__mode.__read)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
- return __getc(stream);
+ return __getc (stream);
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Put the current position of STREAM in *POS. */
int
-DEFUN(fgetpos, (stream, pos), FILE *stream AND fpos_t *pos)
+fgetpos (stream, pos)
+ FILE *stream;
+ fpos_t *pos;
{
- if (!__validfp(stream) || pos == NULL)
+ if (!__validfp (stream) || pos == NULL)
{
- errno = EINVAL;
- return(-1);
+ __set_errno (EINVAL);
+ return -1;
}
- *pos = ftell(stream);
+ *pos = ftell (stream);
if (*pos < 0L)
- return(-1);
- return(0);
+ return -1;
+ return 0;
}
-/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
to S, the function returns NULL without appending the null character.
If there is a file error, always return NULL. */
char *
-DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream)
+fgets (s, n, stream)
+ char *s;
+ int n;
+ register FILE *stream;
{
register char *p = s;
- if (!__validfp(stream) || s == NULL || n <= 0)
+ if (!__validfp (stream) || s == NULL || n <= 0)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
{
/* Unbuffered stream. Not much optimization to do. */
register int c = 0;
- while (--n > 0 && (c = getc (stream)) != EOF)
+ while (--n > 0 && (c = getc (stream)) != EOF)
if ((*p++ = c) == '\n')
break;
if (c == EOF && (p == s || ferror (stream)))
size_t i;
char *found;
- i = stream->__get_limit - stream->__bufp;
+ i = stream->__get_limit - stream->__bufp;
if (i == 0)
{
/* Refill the buffer. */
*p = '\0';
return s;
}
- i = stream->__get_limit - stream->__bufp;
+ i = stream->__get_limit - stream->__bufp;
}
if (i > n)
-/* Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Return the system file descriptor associated with STREAM. */
int
-DEFUN(fileno, (stream), FILE *stream)
+fileno (stream)
+ FILE *stream;
{
extern void __stdio_check_funcs __P ((FILE *));
if (! __validfp (stream))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
if (stream->__io_funcs.__fileno == NULL)
{
#ifdef EOPNOTSUPP
- errno = EOPNOTSUPP;
+ __set_errno (EOPNOTSUPP);
#else
- errno = ENOSYS;
+ __set_errno (ENOSYS);
#endif
return -1;
}
-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
/* Defined in fopen.c. */
-extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr));
+extern int __getmode __P ((const char *mode, __io_mode *mptr));
/* Open a new stream that will read and/or write from the buffer in
S, which is of LEN bytes. If the mode indicates appending, the
to read, attempted writes always return an output error and attempted
reads always return end-of-file. */
FILE *
-DEFUN(fmemopen, (s, len, mode),
- PTR s AND size_t len AND CONST char *mode)
+fmemopen (s, len, mode)
+ void *s;
+ size_t len;
+ const char *mode;
{
__io_mode m;
register FILE *stream;
{
int save = errno;
(void) fclose (stream);
- errno = save;
+ __set_errno (save);
return NULL;
}
}
stream->__bufp = p;
}
else if (stream->__mode.__truncate)
- memset ((PTR) stream->__buffer, 0, len);
+ memset ((void *) stream->__buffer, 0, len);
return stream;
}
-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
-#define badmode() return ((errno = EINVAL), 0)
+#define badmode() return ((__set_errno (EINVAL)), 0)
/* Dissect the given mode string into an __io_mode. */
int
-DEFUN(__getmode, (mode, mptr), CONST char *mode AND __io_mode *mptr)
+__getmode (mode, mptr)
+ const char *mode;
+ __io_mode *mptr;
{
register unsigned char i;
if (mode == NULL)
badmode ();
- memset ((PTR) mptr, 0, sizeof (*mptr));
+ memset ((void *) mptr, 0, sizeof (*mptr));
switch (*mode)
{
\f
/* Open a new stream on the given file. */
FILE *
-DEFUN(fopen, (filename, mode), CONST char *filename AND CONST char *mode)
+fopen (filename, mode)
+ const char *filename;
+ const char *mode;
{
FILE *stream;
__io_mode m;
if (filename == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
{
int save = errno;
(void) fclose (stream);
- errno = save;
+ __set_errno (save);
return NULL;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Write the character C to STREAM. */
int
-DEFUN(fputc, (c, stream), int c AND FILE *stream)
+fputc (c, stream)
+ int c;
+ FILE *stream;
{
- if (!__validfp(stream) || !stream->__mode.__write)
+ if (!__validfp (stream) || !stream->__mode.__write)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
- return __putc(c, stream);
+ return __putc (c, stream);
}
-/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
/* Read NMEMB chunks of SIZE bytes each from STREAM into P. */
size_t
-DEFUN(fread, (p, size, nmemb, stream),
- PTR p AND size_t size AND size_t nmemb AND register FILE *stream)
+fread (p, size, nmemb, stream)
+ void *p;
+ size_t size;
+ size_t nmemb;
+ register FILE *stream;
{
register char *ptr = (char *) p;
register size_t to_read = size * nmemb;
size_t bytes = to_read;
- if (!__validfp(stream) || !stream->__mode.__read)
+ if (!__validfp (stream) || !stream->__mode.__read)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return 0;
}
- if (feof(stream) || ferror(stream))
+ if (feof (stream) || ferror (stream))
return 0;
if (p == NULL || to_read == 0)
return 0;
/* This stream has never been seen before, or it has a character
pushed back. Call __fillbf to deal with those cases. Life will
be simpler after this call. */
- int c = __fillbf(stream);
+ int c = __fillbf (stream);
if (c == EOF)
return 0;
*ptr++ = c;
copy = to_read;
to_read -= copy;
if (copy > 20)
- memcpy((PTR) ptr, (PTR) stream->__bufp, copy);
+ memcpy((void *) ptr, (void *) stream->__bufp, copy);
else
{
register size_t i;
while (to_read > 0)
{
register int count;
- count = (*stream->__io_funcs.__read)(stream->__cookie,
- ptr, to_read);
+ count = (*stream->__io_funcs.__read) (stream->__cookie,
+ ptr, to_read);
if (count > 0)
{
to_read -= count;
}
else
{
- int c = __fillbf(stream);
+ int c = __fillbf (stream);
if (c == EOF)
return (bytes - to_read) / size;
*ptr++ = (char) c;
-/* Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Replace STREAM, opening it on FILENAME. */
FILE *
-DEFUN(freopen, (filename, mode, stream),
- CONST char *filename AND CONST char *mode AND register FILE *stream)
+freopen (filename, mode, stream)
+ const char *filename;
+ const char *mode;
+ register FILE *stream;
{
__io_mode m;
- PTR cookie;
+ void *cookie;
if (!__getmode (mode, &m))
{
(void) fclose (stream);
- errno = EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
{
int save = errno;
(void) fclose (stream);
- errno = save;
+ __set_errno (save);
return NULL;
}
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
is SEEK_SET, the end of the file is it is SEEK_END,
or the current position if it is SEEK_CUR. */
int
-DEFUN(fseek, (stream, offset, whence),
- register FILE *stream AND long int offset AND int whence)
+fseek (stream, offset, whence)
+ register FILE *stream;
+ long int offset;
+ int whence;
{
long int o;
if (!__validfp (stream))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
switch (whence)
{
default:
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
case SEEK_END:
for, and then look where that is. */
if (stream->__io_funcs.__seek == NULL)
{
- errno = ESPIPE;
+ __set_errno (ESPIPE);
return EOF;
}
else
if (o < 0)
{
/* Negative file position is meaningless. */
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
But it makes more sense for fseek to to fail with ESPIPE
than for the next reading or writing operation to fail
that way. */
- errno = ESPIPE;
+ __set_errno (ESPIPE);
return EOF;
}
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Set the file position of STREAM to *POS. */
int
-DEFUN(fsetpos, (stream, pos), FILE *stream AND CONST fpos_t *pos)
+fsetpos (stream, pos)
+ FILE *stream;
+ const fpos_t *pos;
{
if (pos == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
- return fseek(stream, *pos, SEEK_SET);
+ return fseek (stream, *pos, SEEK_SET);
}
-/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1994, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Return the offset in bytes from the beginning
of the file of the file position of STREAM. */
long int
-DEFUN(ftell, (stream), FILE *stream)
+ftell (stream)
+ FILE *stream;
{
long int pos;
if (!__validfp (stream))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1L;
}
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
/* Write NMEMB chunks of SIZE bytes each from PTR onto STREAM. */
size_t
-DEFUN(fwrite, (ptr, size, nmemb, stream),
- CONST PTR ptr AND size_t size AND
- size_t nmemb AND register FILE *stream)
+fwrite (ptr, size, nmemb, stream)
+ const void *ptr;
+ size_t size;
+ size_t nmemb;
+ register FILE *stream;
{
- register CONST unsigned char *p = (CONST unsigned char *) ptr;
+ register const unsigned char *p = (const unsigned char *) ptr;
register size_t to_write = size * nmemb;
register size_t written = 0;
int newlinep;
if (!__validfp (stream) || !stream->__mode.__write)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return 0;
}
goto done;
}
- errno = save;
+ __set_errno (save);
}
if (stream->__buffer == NULL && default_func &&
{
int count = (stream->__io_funcs.__write == NULL ? to_write :
(*stream->__io_funcs.__write) (stream->__cookie,
- (CONST char *) p,
+ (const char *) p,
to_write));
if (count > 0)
{
buffer_space = stream->__bufsize - (stream->__bufp - stream->__buffer);
newlinep = (stream->__linebuf &&
- memchr ((CONST PTR) p, '\n', to_write) != NULL);
+ memchr ((const void *) p, '\n', to_write) != NULL);
if (newlinep && stream->__bufp == stream->__buffer &&
stream->__offset == stream->__target)
*stream->__bufp++ = *p++;
else
{
- memcpy ((PTR) stream->__bufp, (PTR) p, n);
+ memcpy ((void *) stream->__bufp, (void *) p, n);
stream->__bufp += n;
p += n;
}
-/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
null terminator), or -1 on error or EOF. */
ssize_t
-DEFUN(__getdelim, (lineptr, n, terminator, stream),
- char **lineptr AND size_t *n AND int terminator AND FILE *stream)
+__getdelim (lineptr, n, terminator, stream)
+ char **lineptr;
+ size_t *n;
+ int terminator;
+ FILE *stream;
{
char *line, *p;
size_t size, copy;
if (!__validfp (stream) || lineptr == NULL || n == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
size_t i;
char *found;
- i = stream->__get_limit - stream->__bufp;
+ i = stream->__get_limit - stream->__bufp;
if (i == 0)
{
/* Refill the buffer. */
if (c == terminator)
goto win;
--copy;
- i = stream->__get_limit - stream->__bufp;
+ i = stream->__get_limit - stream->__bufp;
}
if (i > copy)
-/* Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
/* Read a newline-terminated string from stdin into S,
removing the trailing newline. Return S or NULL. */
char *
-DEFUN(gets, (s), char *s)
+gets (s)
+ char *s;
{
register char *p = s;
register int c;
FILE *stream = stdin;
- if (!__validfp(stream) || p == NULL)
+ if (!__validfp (stream) || p == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
- if (feof(stream) || ferror(stream))
+ if (feof (stream) || ferror (stream))
return NULL;
- while ((c = getchar()) != EOF)
+ while ((c = getchar ()) != EOF)
if (c == '\n')
break;
else
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
libraries) compiled with Unix header files to work with the GNU C
library. */
-#include <ansidecl.h>
#include <stdio.h>
#include <errno.h>
In a Unix stdio FILE `_cnt' is the first element.
In a GNU stdio or glued FILE, the first element is the magic number. */
int
-DEFUN(_filbuf, (file), unix_FILE *file)
+_filbuf (file)
+ unix_FILE *file;
{
switch (++file->glue.magic) /* Compensate for Unix getc's decrement. */
{
default:
/* Bogus stream. */
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
}
/* Called by the Unix stdio `putc' macro. Much like getc, above. */
int
-DEFUN(_flsbuf, (c, file),
- int c AND unix_FILE *file)
+_flsbuf (c, file)
+ int c;
+ unix_FILE *file;
{
/* Compensate for putc's decrement. */
switch (++file->glue.magic)
return putc (c, (FILE *) file);
default:
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
}
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
/* Make sure that FP has its functions set. */
void
-DEFUN(__stdio_check_funcs, (fp), register FILE *fp)
+__stdio_check_funcs (fp)
+ register FILE *fp;
{
if (!fp->__seen)
{
If no buffer is set (and the stream is not made explicitly
unbuffered), we allocate a buffer below, using the bufsize
set by this function. */
- extern void EXFUN(__stdio_init_stream, (FILE *));
+ extern void __stdio_init_stream __P ((FILE *));
fp->__room_funcs = __default_room_functions;
fp->__io_funcs = __default_io_functions;
__stdio_init_stream (fp);
/* Figure out what kind of buffering (none, line, or full)
and what buffer size to give FP. */
static void
-DEFUN(init_stream, (fp), register FILE *fp)
+init_stream (fp)
+ register FILE *fp;
{
__stdio_check_funcs (fp);
save = errno;
while (fp->__bufsize >= MIN_BUFSIZE)
{
- fp->__buffer = (char *) malloc(fp->__bufsize);
+ fp->__buffer = (char *) malloc (fp->__bufsize);
if (fp->__buffer == NULL)
fp->__bufsize /= 2;
else
break;
}
- errno = save;
+ __set_errno (save);
if (fp->__buffer == NULL)
{
/* Determine the current file position of STREAM if it is unknown. */
int
-DEFUN(__stdio_check_offset, (stream), FILE *stream)
+__stdio_check_offset (stream)
+ FILE *stream;
{
init_stream (stream);
if (stream->__io_funcs.__seek == NULL)
{
/* Unknowable. */
- errno = ESPIPE;
+ __set_errno (ESPIPE);
return EOF;
}
else
{
/* Unknown. Find it out. */
fpos_t pos = (fpos_t) 0;
- if ((*stream->__io_funcs.__seek)(stream->__cookie,
- &pos, SEEK_CUR) < 0)
+ if ((*stream->__io_funcs.__seek) (stream->__cookie,
+ &pos, SEEK_CUR) < 0)
{
if (errno == ESPIPE)
/* Object is incapable of seeking. */
seeking as necessary and updating its `offset' field.
Sets ferror(FP) (and possibly errno) for errors. */
static void
-DEFUN(seek_to_target, (fp), FILE *fp)
+seek_to_target (fp)
+ FILE *fp;
{
int save = errno;
if (__stdio_check_offset (fp) == EOF)
{
if (errno == ESPIPE)
- errno = save;
+ __set_errno (save);
else
fp->__error = 1;
}
if (fp->__io_funcs.__seek == NULL)
{
/* We can't seek! */
- errno = ESPIPE;
+ __set_errno (ESPIPE);
fp->__error = 1;
}
else
{
fpos_t pos = fp->__target;
- if ((*fp->__io_funcs.__seek)(fp->__cookie, &pos, SEEK_SET) < 0)
+ if ((*fp->__io_funcs.__seek) (fp->__cookie, &pos, SEEK_SET) < 0)
/* Seek failed! */
fp->__error = 1;
else
#ifdef EGRATUITOUS
/* It happens in the Hurd when the io server doesn't
obey the protocol for io_seek. */
- errno = EGRATUITOUS;
+ __set_errno (EGRATUITOUS);
#else
/* I don't think this can happen in Unix. */
- errno = ESPIPE; /* ??? */
+ __set_errno (ESPIPE); /* ??? */
#endif
fp->__error = 1;
}
flushed to avoid a system call for a single character.
This is the default `output room' function. */
static void
-DEFUN(flushbuf, (fp, c),
- register FILE *fp AND int c)
+flushbuf (fp, c)
+ register FILE *fp;
+ int c;
{
int flush_only = c == EOF;
size_t buffer_written;
!fp->__mode.__append)
{
int save = errno;
- CONST int aligned = (fp->__buffer == NULL ||
- __stdio_check_offset(fp) == EOF ||
+ const int aligned = (fp->__buffer == NULL ||
+ __stdio_check_offset (fp) == EOF ||
fp->__target % fp->__bufsize == 0);
- errno = save;
+ __set_errno (save);
if (!aligned)
{
/* Move to a block (buffer size) boundary and read in a block.
Then the output will be written as a whole block, too. */
- CONST size_t o = fp->__target % fp->__bufsize;
+ const size_t o = fp->__target % fp->__bufsize;
fp->__target -= o;
- if ((*fp->__room_funcs.__input)(fp) == EOF && ferror(fp))
+ if ((*fp->__room_funcs.__input) (fp) == EOF && ferror (fp))
return;
else
- __clearerr(fp);
+ __clearerr (fp);
if (fp->__get_limit - fp->__buffer < o)
/* Oops. We didn't read enough (probably because we got EOF).
if (!ferror(fp))
{
/* Write out the buffered data. */
- wrote = (*fp->__io_funcs.__write)(fp->__cookie, fp->__buffer,
- to_write);
+ wrote = (*fp->__io_funcs.__write) (fp->__cookie, fp->__buffer,
+ to_write);
if (wrote > 0)
{
if (fp->__mode.__append)
fp->__bufp = fp->__buffer;
/* If we're not just flushing, write the last character, C. */
- if (!flush_only && !ferror(fp))
+ if (!flush_only && !ferror (fp))
{
if (fp->__buffer == NULL || (fp->__linebuf && (unsigned char) c == '\n'))
{
fp->__get_limit = fp->__buffer;
}
- if (feof(fp) || ferror(fp))
+ if (feof (fp) || ferror (fp))
fp->__bufp = fp->__put_limit;
}
/* Fill the buffer for FP and return the first character read (or EOF).
This is the default `input_room' function. */
static int
-DEFUN(fillbuf, (fp), register FILE *fp)
+fillbuf (fp)
+ register FILE *fp;
{
/* How far into the buffer we read we want to start bufp. */
size_t buffer_offset = 0;
}
seek_to_target (fp);
}
- errno = save;
+ __set_errno (save);
}
- while (!ferror(fp) && !feof(fp) && nread <= buffer_offset)
+ while (!ferror (fp) && !feof (fp) && nread <= buffer_offset)
{
/* Try to fill the buffer. */
- int count = (*fp->__io_funcs.__read)(fp->__cookie, buffer, to_read);
+ int count = (*fp->__io_funcs.__read) (fp->__cookie, buffer, to_read);
if (count == 0)
fp->__eof = 1;
else if (count < 0)
if (fp->__buffer == NULL)
/* There is no buffer, so return the character we read
without all the buffer pointer diddling. */
- return (feof(fp) || ferror(fp)) ? EOF : c;
+ return (feof (fp) || ferror (fp)) ? EOF : c;
/* Reset the buffer pointer to the beginning of the buffer
(plus whatever offset we may have set above). */
end:;
- if (feof(fp) || ferror(fp))
+ if (feof (fp) || ferror (fp))
{
/* Set both end pointers to the beginning of the buffer so
the next i/o call will force a call to __fillbf/__flshfp. */
extern __io_seek_fn __stdio_seek;
extern __io_close_fn __stdio_close;
extern __io_fileno_fn __stdio_fileno;
-CONST __io_functions __default_io_functions =
+const __io_functions __default_io_functions =
{
__stdio_read, __stdio_write, __stdio_seek, __stdio_close, __stdio_fileno
};
-CONST __room_functions __default_room_functions =
+const __room_functions __default_room_functions =
{
fillbuf, flushbuf
};
/* Flush the buffer for FP and also write C if FLUSH_ONLY is nonzero.
This is the function used by putc and fflush. */
int
-DEFUN(__flshfp, (fp, c),
- register FILE *fp AND int c)
+__flshfp (fp, c)
+ register FILE *fp;
+ int c;
{
int flush_only = c == EOF;
- if (!__validfp(fp) || !fp->__mode.__write)
+ if (!__validfp (fp) || !fp->__mode.__write)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
- if (ferror(fp))
+ if (ferror (fp))
return EOF;
if (fp->__pushed_back)
}
/* Make sure the stream is initialized (has functions and buffering). */
- init_stream(fp);
+ init_stream (fp);
/* Do this early, so a `putc' on such a stream will never return success. */
if (fp->__room_funcs.__output == NULL)
/* Fill the buffer for FP and return the first character read.
This is the function used by getc. */
int
-DEFUN(__fillbf, (fp), register FILE *fp)
+__fillbf (fp)
+ register FILE *fp;
{
register int c;
fpos_t new_target;
- if (!__validfp(fp) || !fp->__mode.__read)
+ if (!__validfp (fp) || !fp->__mode.__read)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
}
/* Make sure the stream is initialized (has functions and buffering). */
- init_stream(fp);
+ init_stream (fp);
/* If we're trying to read the first character of a new
line of input from an unbuffered or line buffered stream,
fp->__target = new_target;
- if (ferror(fp))
+ if (ferror (fp))
c = EOF;
else if (fp->__room_funcs.__input != NULL)
{
- c = (*fp->__room_funcs.__input)(fp);
+ c = (*fp->__room_funcs.__input) (fp);
if (fp->__buffer == NULL)
/* This is an unbuffered stream, so the target sync above
won't do anything the next time around. Instead, note that
/* Nuke a stream, but don't kill its link in the chain. */
void
-DEFUN(__invalidate, (stream), register FILE *stream)
+__invalidate (stream)
+ register FILE *stream;
{
/* Save its link. */
register FILE *next = stream->__next;
/* Pulverize the fucker. */
- memset((PTR) stream, 0, sizeof(FILE));
+ memset((void *) stream, 0, sizeof(FILE));
/* Restore the deceased's link. */
stream->__next = next;
-/* Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Enlarge STREAM's buffer. */
static void
-DEFUN(enlarge_buffer, (stream, c),
- register FILE *stream AND int c)
+enlarge_buffer (stream, c)
+ register FILE *stream;
+ int c;
{
struct memstream_info *info = (struct memstream_info *) stream->__cookie;
size_t need;
newsize = need;
else
newsize = stream->__bufsize * 2;
- newbuf = (char *) realloc ((PTR) stream->__buffer, newsize);
+ newbuf = (char *) realloc ((void *) stream->__buffer, newsize);
if (newbuf == NULL)
{
stream->__error = 1;
if (need > 0)
{
/* We are extending the buffer after an fseek; zero-fill new space. */
- bzero (stream->__bufp, need);
+ memset (stream->__bufp, '\0', need);
stream->__bufp += need;
}
There is no external state to munge. */
static int
-DEFUN(seek, (cookie, pos, whence),
- PTR cookie AND fpos_t *pos AND int whence)
+seek (cookie, pos, whence)
+ void *cookie;
+ fpos_t *pos;
+ int whence;
{
switch (whence)
{
}
static int
-DEFUN(free_info, (cookie), PTR cookie)
+free_info (cookie)
+ void *cookie;
{
#if 0
struct memstream_info *info = (struct memstream_info *) cookie;
necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
and the number of characters written on fflush or fclose. */
FILE *
-DEFUN(open_memstream, (bufloc, sizeloc),
- char **bufloc AND size_t *sizeloc)
+open_memstream (bufloc, sizeloc)
+ char **bufloc;
+ size_t *sizeloc;
{
FILE *stream;
struct memstream_info *info;
if (bufloc == NULL || sizeloc == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
{
int save = errno;
(void) fclose (stream);
- errno = save;
+ __set_errno (save);
return NULL;
}
stream->__room_funcs.__output = enlarge_buffer;
stream->__io_funcs.__seek = seek;
stream->__io_funcs.__close = free_info;
- stream->__cookie = (PTR) info;
+ stream->__cookie = (void *) info;
stream->__userbuf = 1;
info->buffer = bufloc;
-/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
If MODE indicates full or line buffering, use BUF,
a buffer of SIZE bytes; if BUF is NULL, malloc a buffer. */
int
-DEFUN(setvbuf, (stream, buf, mode, size),
- FILE *stream AND char *buf AND int mode AND size_t size)
+setvbuf (stream, buf, mode, size)
+ FILE *stream;
+ char *buf;
+ int mode;
+ size_t size;
{
- if (!__validfp(stream))
+ if (!__validfp (stream))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
but we allow it to replace an old buffer, flushing it first. */
if (stream->__buffer != NULL)
{
- (void) fflush(stream);
+ (void) fflush (stream);
/* Free the old buffer if it was malloc'd. */
if (!stream->__userbuf)
free(stream->__buffer);
switch (mode)
{
default:
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
case _IONBF: /* Unbuffered. */
stream->__buffer = NULL;
case _IOFBF: /* Fully buffered. */
if (size == 0)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
stream->__bufsize = size;
if (buf != NULL)
stream->__userbuf = 1;
- else if ((buf = (char *) malloc(size)) == NULL)
+ else if ((buf = (char *) malloc (size)) == NULL)
return EOF;
stream->__buffer = buf;
break;
-/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
/* Push the character C back onto the input stream of STREAM. */
int
-DEFUN(ungetc, (c, stream), register int c AND register FILE *stream)
+ungetc (c, stream)
+ register int c;
+ register FILE *stream;
{
- if (!__validfp(stream) || !stream->__mode.__read)
+ if (!__validfp (stream) || !stream->__mode.__read)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return EOF;
}
-/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
/* Read formatted input from S according to the format
string FORMAT, using the argument list in ARG. */
int
-DEFUN(__vsscanf, (s, format, arg),
- CONST char *s AND CONST char *format AND va_list arg)
+__vsscanf (s, format, arg)
+ const char *s;
+ const char *format;
+ va_list arg;
{
FILE f;
if (s == NULL)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
- memset((PTR) &f, 0, sizeof(f));
+ memset ((void *) &f, 0, sizeof (f));
f.__magic = _IOMAGIC;
f.__mode.__read = 1;
f.__bufp = f.__buffer = (char *) s;
f.__room_funcs.__input = NULL;
f.__seen = 1;
- return __vfscanf(&f, format, arg);
+ return __vfscanf (&f, format, arg);
}