-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1992, 1993, 1996, 1997 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
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, 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;
stream->__io_funcs.__close = NULL;
/* Can't seek outside the buffer. */
stream->__io_funcs.__seek = NULL;
+ /* There is no associated file descriptor to fetch. */
+ stream->__io_funcs.__fileno = NULL;
stream->__seen = 1;
{
int save = errno;
(void) fclose (stream);
- errno = save;
+ __set_errno (save);
return NULL;
}
}
(stream->__mode.__read ? stream->__bufsize : 0));
stream->__put_limit = (stream->__buffer +
(stream->__mode.__write ? stream->__bufsize : 0));
- stream->__fileno = -1;
- stream->__cookie = &stream->__fileno;
+ stream->__cookie = NULL;
if (stream->__mode.__append)
{
stream->__bufp = p;
}
else if (stream->__mode.__truncate)
- memset ((PTR) stream->__buffer, 0, len);
+ memset ((void *) stream->__buffer, 0, len);
return stream;
}