From a8c017767721fec8fd4ee53c1937e31e35dfac08 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 30 Apr 2002 22:00:59 +0000 Subject: 2002-04-30 Roland McGrath Removed old GNU stdio implementation; GNU libio is now the only option. * configure.in: Removed --enable-libio option and @stdio@ subst var. Define USE_IN_LIBIO unconditionally. * configure: Regenerated. * Makeconfig (stdio): Set to libio by default. * config.make.in (stdio): Variable removed. * sysdeps/unix/sysv/linux/configure.in: Don't set $stdio. * sysdeps/unix/sysv/linux/configure: Regenerated. * sysdeps/mach/hurd/configure.in: Don't test $stdio. * sysdeps/mach/hurd/configure: Regenerated. * stdio/.cvsignore: File removed. * stdio/Makefile: File removed. * stdio/Versions: File removed. * stdio/__fbufsize.c: File removed. * stdio/__flbf.c: File removed. * stdio/__fpending.c: File removed. * stdio/__fpurge.c: File removed. * stdio/__freadable.c: File removed. * stdio/__freading.c: File removed. * stdio/__fsetlocking.c: File removed. * stdio/__fwritable.c: File removed. * stdio/__fwriting.c: File removed. * stdio/clearerr.c: File removed. * stdio/fclose.c: File removed. * stdio/fcloseall.c: File removed. * stdio/feof.c: File removed. * stdio/ferror.c: File removed. * stdio/fflush.c: File removed. * stdio/fgetc.c: File removed. * stdio/fgetpos.c: File removed. * stdio/fgets.c: File removed. * stdio/fileno.c: File removed. * stdio/fmemopen.c: File removed. * stdio/fopen.c: File removed. * stdio/fopncook.c: File removed. * stdio/fputc.c: File removed. * stdio/fputs.c: File removed. * stdio/fread.c: File removed. * stdio/freopen.c: File removed. * stdio/fseek.c: File removed. * stdio/fsetpos.c: File removed. * stdio/ftell.c: File removed. * stdio/fwrite.c: File removed. * stdio/getc.c: File removed. * stdio/getchar.c: File removed. * stdio/getdelim.c: File removed. * stdio/gets.c: File removed. * stdio/glue.c: File removed. * stdio/internals.c: File removed. * stdio/linewrap.c: File removed. * stdio/linewrap.h: File removed. * stdio/memstream.c: File removed. * stdio/newstream.c: File removed. * stdio/obstream.c: File removed. * stdio/putc.c: File removed. * stdio/putchar.c: File removed. * stdio/puts.c: File removed. * stdio/rewind.c: File removed. * stdio/setbuf.c: File removed. * stdio/setbuffer.c: File removed. * stdio/setlinebuf.c: File removed. * stdio/setvbuf.c: File removed. * stdio/stdio.h: File removed. * stdio/ungetc.c: File removed. * stdio/vasprintf.c: File removed. * stdio/vscanf.c: File removed. * stdio/vsnprintf.c: File removed. * stdio/vsprintf.c: File removed. * stdio/vsscanf.c: File removed. * sysdeps/generic/defs.c: File removed. * sysdeps/generic/fdopen.c: File removed. * sysdeps/generic/pipestream.c: File removed. * sysdeps/generic/stdio_init.c: File removed. * sysdeps/generic/sysd-stdio.c: File removed. * sysdeps/generic/vdprintf.c: File removed. * sysdeps/mach/hurd/defs.c: File removed. * sysdeps/mach/hurd/fdopen.c: File removed. * sysdeps/mach/hurd/pipestream.c: File removed. * sysdeps/mach/hurd/stdio_init.c: File removed. * sysdeps/mach/hurd/sysd-stdio.c: File removed. * sysdeps/mach/hurd/vdprintf.c: File removed. * sysdeps/posix/defs.c: File removed. * sysdeps/posix/fdopen.c: File removed. * sysdeps/posix/pipestream.c: File removed. * sysdeps/posix/stdio_init.c: File removed. * sysdeps/posix/vdprintf.c: File removed. * sysdeps/unix/pipestream.c: File removed. * sysdeps/unix/sysv/sysd-stdio.c: File removed. * sysdeps/unix/sysv/sco3.2.4/pipestream.c: File removed. * sysdeps/unix/sysv/sysv4/pipestream.c: File removed. --- stdio/.cvsignore | 8 - stdio/Makefile | 46 --- stdio/Versions | 70 ----- stdio/__fbufsize.c | 25 -- stdio/__flbf.c | 25 -- stdio/__fpending.c | 25 -- stdio/__fpurge.c | 25 -- stdio/__freadable.c | 25 -- stdio/__freading.c | 26 -- stdio/__fsetlocking.c | 41 --- stdio/__fwritable.c | 25 -- stdio/__fwriting.c | 26 -- stdio/clearerr.c | 32 -- stdio/fclose.c | 60 ---- stdio/fcloseall.c | 37 --- stdio/feof.c | 39 --- stdio/ferror.c | 40 --- stdio/fflush.c | 47 --- stdio/fgetc.c | 35 --- stdio/fgetpos.c | 41 --- stdio/fgets.c | 125 -------- stdio/fileno.c | 50 --- stdio/fmemopen.c | 109 ------- stdio/fopen.c | 112 ------- stdio/fopncook.c | 49 --- stdio/fputc.c | 40 --- stdio/fputs.c | 35 --- stdio/fread.c | 135 -------- stdio/freopen.c | 75 ----- stdio/fseek.c | 179 ----------- stdio/fsetpos.c | 38 --- stdio/ftell.c | 54 ---- stdio/fwrite.c | 222 -------------- stdio/getc.c | 6 - stdio/getchar.c | 31 -- stdio/getdelim.c | 177 ----------- stdio/gets.c | 59 ---- stdio/glue.c | 112 ------- stdio/internals.c | 688 ----------------------------------------- stdio/linewrap.c | 521 ------------------------------- stdio/linewrap.h | 200 ------------ stdio/memstream.c | 176 ----------- stdio/newstream.c | 53 ---- stdio/obstream.c | 185 ----------- stdio/putc.c | 6 - stdio/putchar.c | 31 -- stdio/puts.c | 31 -- stdio/rewind.c | 32 -- stdio/setbuf.c | 29 -- stdio/setbuffer.c | 29 -- stdio/setlinebuf.c | 28 -- stdio/setvbuf.c | 88 ------ stdio/stdio.h | 832 -------------------------------------------------- stdio/ungetc.c | 59 ---- stdio/vasprintf.c | 85 ------ stdio/vscanf.c | 32 -- stdio/vsnprintf.c | 59 ---- stdio/vsprintf.c | 51 ---- stdio/vsscanf.c | 59 ---- 59 files changed, 5580 deletions(-) delete mode 100644 stdio/.cvsignore delete mode 100644 stdio/Makefile delete mode 100644 stdio/Versions delete mode 100644 stdio/__fbufsize.c delete mode 100644 stdio/__flbf.c delete mode 100644 stdio/__fpending.c delete mode 100644 stdio/__fpurge.c delete mode 100644 stdio/__freadable.c delete mode 100644 stdio/__freading.c delete mode 100644 stdio/__fsetlocking.c delete mode 100644 stdio/__fwritable.c delete mode 100644 stdio/__fwriting.c delete mode 100644 stdio/clearerr.c delete mode 100644 stdio/fclose.c delete mode 100644 stdio/fcloseall.c delete mode 100644 stdio/feof.c delete mode 100644 stdio/ferror.c delete mode 100644 stdio/fflush.c delete mode 100644 stdio/fgetc.c delete mode 100644 stdio/fgetpos.c delete mode 100644 stdio/fgets.c delete mode 100644 stdio/fileno.c delete mode 100644 stdio/fmemopen.c delete mode 100644 stdio/fopen.c delete mode 100644 stdio/fopncook.c delete mode 100644 stdio/fputc.c delete mode 100644 stdio/fputs.c delete mode 100644 stdio/fread.c delete mode 100644 stdio/freopen.c delete mode 100644 stdio/fseek.c delete mode 100644 stdio/fsetpos.c delete mode 100644 stdio/ftell.c delete mode 100644 stdio/fwrite.c delete mode 100644 stdio/getc.c delete mode 100644 stdio/getchar.c delete mode 100644 stdio/getdelim.c delete mode 100644 stdio/gets.c delete mode 100644 stdio/glue.c delete mode 100644 stdio/internals.c delete mode 100644 stdio/linewrap.c delete mode 100644 stdio/linewrap.h delete mode 100644 stdio/memstream.c delete mode 100644 stdio/newstream.c delete mode 100644 stdio/obstream.c delete mode 100644 stdio/putc.c delete mode 100644 stdio/putchar.c delete mode 100644 stdio/puts.c delete mode 100644 stdio/rewind.c delete mode 100644 stdio/setbuf.c delete mode 100644 stdio/setbuffer.c delete mode 100644 stdio/setlinebuf.c delete mode 100644 stdio/setvbuf.c delete mode 100644 stdio/stdio.h delete mode 100644 stdio/ungetc.c delete mode 100644 stdio/vasprintf.c delete mode 100644 stdio/vscanf.c delete mode 100644 stdio/vsnprintf.c delete mode 100644 stdio/vsprintf.c delete mode 100644 stdio/vsscanf.c (limited to 'stdio') diff --git a/stdio/.cvsignore b/stdio/.cvsignore deleted file mode 100644 index 602b74c1ae..0000000000 --- a/stdio/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -*.d *.o *.so *.po *.go stamp.* *.stamp *.ustamp *.udeps -*.gz *.Z *.tar *.tgz -=* -TODO COPYING* AUTHORS copyr-* copying.* -glibc-* - -mpn-copy.mk -distinfo diff --git a/stdio/Makefile b/stdio/Makefile deleted file mode 100644 index 53cf73cdb4..0000000000 --- a/stdio/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 1991,92,93,94,95,96,2001 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 Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 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 -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -# -# Specific makefile for stdio. -# -subdir := stdio - -headers := stdio.h linewrap.h - -routines := \ - feof ferror clearerr fileno \ - newstream fopen freopen fdopen fopncook fmemopen \ - setbuf setvbuf setbuffer setlinebuf \ - fseek ftell rewind fgetpos fsetpos \ - fread fwrite \ - ungetc \ - fgetc getc getchar \ - fputc putc putchar \ - fgets gets fputs puts \ - getdelim \ - fclose fcloseall fflush \ - vdprintf vsnprintf vsprintf vasprintf vsscanf vscanf \ - memstream obstream linewrap \ - __fbufsize __freading __fwriting __freadable __fwritable __flbf \ - __fpurge __fpending __fsetlocking \ - internals sysd-stdio pipestream stdio_init libc_fatal -aux := defs glue - - -include ../Rules diff --git a/stdio/Versions b/stdio/Versions deleted file mode 100644 index ccfda9c268..0000000000 --- a/stdio/Versions +++ /dev/null @@ -1,70 +0,0 @@ -libc { - GLIBC_2.0 { - # more or less standard functions - __fillbf; __flshfp; - - # functions used in inline functions or macros - __getdelim; __line_wrap_output; __line_wrap_update; - __vfscanf; __vsscanf; - - # variables in normal name space - stderr; stdin; stdout; - - # c* - clearerr; - - # f* - fclose; fcloseall; fdopen; feof; ferror; fflush; fgetc; fgetpos; fgets; - fileno; fmemopen; fopen; fopencookie; fputc; fputs; fread; freopen; - fseek; fsetpos; ftell; fwrite; - - # g* - getc; getchar; getdelim; gets; - - # l* - line_wrap_stream; line_unwrap_stream; line_wrapped; line_wrap_lmargin; - line_wrap_set_lmargin; line_wrap_rmargin; line_wrap_set_rmargin; - line_wrap_wmargin; line_wrap_set_wmargin; line_wrap_point; - - # o* - open_memstream; open_obstack_stream; obstack_printf; obstack_vprintf; - - # p* - pclose; popen; putc; putchar; puts; - - # r* - rewind; - - # s* - setbuf; setbuffer; setlinebuf; setvbuf; - - # u* - ungetc; - - # v* - vasprintf; vdprintf; vscanf; vsnprintf; vsprintf; vsscanf; - } - GLIBC_2.1 { - # functions used in other libraries - __asprintf; - - # c* - clearerr_unlocked; - - # f* - feof_unlocked; ferror_unlocked; fflush_unlocked; fgets_unlocked; - fileno_unlocked; fputc_unlocked; fputs_unlocked; - fread_unlocked; fwrite_unlocked; - - # g* - getc_unlocked; getchar_unlocked; - - # p* - putc_unlocked; putchar_unlocked; - } - GLIBC_2.2.4 { - # Functions to access FILE internals. - __fbufsize; __freading; __fwriting; __freadable; __fwritable; __flbf; - __fpurge; __fpending; __fsetlocking; _flushlbf; - } -} diff --git a/stdio/__fbufsize.c b/stdio/__fbufsize.c deleted file mode 100644 index ad42ee2427..0000000000 --- a/stdio/__fbufsize.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -size_t -__fbufsize (FILE *fp) -{ - return fp->__bufsize; -} diff --git a/stdio/__flbf.c b/stdio/__flbf.c deleted file mode 100644 index 9eb80abdbf..0000000000 --- a/stdio/__flbf.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -int -__flbf (FILE *fp) -{ - return fp->__linebuf; -} diff --git a/stdio/__fpending.c b/stdio/__fpending.c deleted file mode 100644 index 0e7b8f02f0..0000000000 --- a/stdio/__fpending.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -size_t -__fpending (FILE *fp) -{ - return (fp->__put_limit >= fp->__bufp ? fp->__bufp - fp->__buffer : 0); -} diff --git a/stdio/__fpurge.c b/stdio/__fpurge.c deleted file mode 100644 index db882b68f5..0000000000 --- a/stdio/__fpurge.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -void -__fpurge (FILE *fp) -{ - fp->__get_limit = fp->__put_limit = fp->__bufp = fp->__buffer; -} diff --git a/stdio/__freadable.c b/stdio/__freadable.c deleted file mode 100644 index 5674d5bef5..0000000000 --- a/stdio/__freadable.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -int -__freadable (FILE *fp) -{ - return !!fp->__mode.__read; -} diff --git a/stdio/__freading.c b/stdio/__freading.c deleted file mode 100644 index 16d0fd97f8..0000000000 --- a/stdio/__freading.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -int -__freading (FILE *fp) -{ - /* This is not really right for unbuffered streams. */ - return (!fp->__mode.__write || fp->__put_limit == fp->__buffer); -} diff --git a/stdio/__fsetlocking.c b/stdio/__fsetlocking.c deleted file mode 100644 index a0e40d71c9..0000000000 --- a/stdio/__fsetlocking.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include - -int -__fsetlocking (FILE *fp, int type) -{ - /* We don't really support locking. */ - - switch (type) - { - case FSETLOCKING_QUERY: - case FSETLOCKING_BYCALLER: - break; - case FSETLOCKING_INTERNAL: - abort (); - default: - __set_errno (EINVAL); - return -1; - } - - return FSETLOCKING_BYCALLER; -} diff --git a/stdio/__fwritable.c b/stdio/__fwritable.c deleted file mode 100644 index 396629542c..0000000000 --- a/stdio/__fwritable.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -int -__fwritable (FILE *fp) -{ - return !!fp->__mode.__write; -} diff --git a/stdio/__fwriting.c b/stdio/__fwriting.c deleted file mode 100644 index 36266ef34d..0000000000 --- a/stdio/__fwriting.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2001 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -int -__fwriting (FILE *fp) -{ - /* This is not really right for unbuffered streams. */ - return (!fp->__mode.__read || fp->__get_limit == fp->__buffer); -} diff --git a/stdio/clearerr.c b/stdio/clearerr.c deleted file mode 100644 index 02a1d77780..0000000000 --- a/stdio/clearerr.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1991, 1997, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -#undef clearerr - - -/* Clear the EOF and error indicators for STREAM. */ -void -clearerr (FILE *stream) -{ - __clearerr (stream); -} - -weak_alias (clearerr, clearerr_unlocked) diff --git a/stdio/fclose.c b/stdio/fclose.c deleted file mode 100644 index 6af0903f9b..0000000000 --- a/stdio/fclose.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 1991, 1995, 1996, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include - - -/* Close a stream. */ -int -fclose (stream) - FILE *stream; -{ - int status; - - if (!__validfp (stream)) - { - __set_errno (EINVAL); - return EOF; - } - - if (stream->__mode.__write && - /* Flush the buffer. */ - __flshfp (stream, EOF) == EOF) - return EOF; - - /* Free the buffer's storage. */ - if (stream->__buffer != NULL && !stream->__userbuf) - free (stream->__buffer); - - /* Close the system file descriptor. */ - if (stream->__io_funcs.__close != NULL) - status = (*stream->__io_funcs.__close) (stream->__cookie); - else if (!stream->__seen && stream->__cookie != NULL) - status = __stdio_close (stream->__cookie); - else - status = 0; - - /* Nuke the stream, making it available for re-use. */ - __invalidate (stream); - - return status < 0 ? EOF : 0; -} diff --git a/stdio/fcloseall.c b/stdio/fcloseall.c deleted file mode 100644 index b247506be1..0000000000 --- a/stdio/fcloseall.c +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include - - -/* Close a stream. */ -int -__fcloseall () -{ - /* Close all streams. */ - register FILE *f; - for (f = __stdio_head; f != NULL; f = f->__next) - if (__validfp(f)) - (void) fclose(f); - return 0; -} -weak_alias (__fcloseall, fcloseall) diff --git a/stdio/feof.c b/stdio/feof.c deleted file mode 100644 index 87d0463350..0000000000 --- a/stdio/feof.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1991, 1996, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -#undef feof -#undef feof_unlocked - -/* Return non-zero if STREAM has its EOF indicator set. */ -int -feof (stream) - FILE *stream; -{ - if (!__validfp (stream)) - { - __set_errno (EINVAL); - return -1; - } - - return stream->__eof; -} - -weak_alias (feof, feof_unlocked) diff --git a/stdio/ferror.c b/stdio/ferror.c deleted file mode 100644 index 5ccc9abb37..0000000000 --- a/stdio/ferror.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1991, 1996, 1997, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -#undef ferror -#undef ferror_unlocked - - -/* Return non-zero if STREAM has its error indicator set. */ -int -ferror (stream) - FILE *stream; -{ - if (!__validfp (stream)) - { - __set_errno (EINVAL); - return -1; - } - - return stream->__error; -} - -weak_alias (ferror, ferror_unlocked) diff --git a/stdio/fflush.c b/stdio/fflush.c deleted file mode 100644 index b184e187e2..0000000000 --- a/stdio/fflush.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 1991, 1996, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include - -/* Flush STREAM's buffer. - If STREAM is NULL, flush the buffers of all streams that are writing. */ -int -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; - return lossage ? EOF : 0; - } - - if (!__validfp (stream) || !stream->__mode.__write) - { - __set_errno (EINVAL); - return EOF; - } - - return __flshfp (stream, EOF); -} - -weak_alias(fflush, fflush_unlocked) diff --git a/stdio/fgetc.c b/stdio/fgetc.c deleted file mode 100644 index f196c3ddda..0000000000 --- a/stdio/fgetc.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1991, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - - -/* Read a character from STREAM. */ -int -fgetc (stream) - FILE *stream; -{ - if (!__validfp (stream) || !stream->__mode.__read) - { - __set_errno (EINVAL); - return EOF; - } - - return __getc (stream); -} diff --git a/stdio/fgetpos.c b/stdio/fgetpos.c deleted file mode 100644 index 647d63b999..0000000000 --- a/stdio/fgetpos.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 1991, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -#undef fgetpos - - -/* Put the current position of STREAM in *POS. */ -int -fgetpos (stream, pos) - FILE *stream; - fpos_t *pos; -{ - if (!__validfp (stream) || pos == NULL) - { - __set_errno (EINVAL); - return -1; - } - - *pos = ftell (stream); - if (*pos < 0L) - return -1; - return 0; -} diff --git a/stdio/fgets.c b/stdio/fgets.c deleted file mode 100644 index fbf5973a71..0000000000 --- a/stdio/fgets.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include - -/* Reads characters from STREAM into S, until either a newline character - is read, N - 1 characters have been read, or EOF is seen. Returns - the newline, unlike gets. Finishes by appending a null character and - returning S. If EOF is seen before any characters have been written - to S, the function returns NULL without appending the null character. - If there is a file error, always return NULL. */ -char * -fgets (s, n, stream) - char *s; - int n; - FILE *stream; -{ - register char *p = s; - - if (!__validfp (stream) || s == NULL || n <= 0) - { - __set_errno (EINVAL); - return NULL; - } - - if (ferror (stream)) - return NULL; - - if (stream->__buffer == NULL && stream->__userbuf) - { - /* Unbuffered stream. Not much optimization to do. */ - register int c = 0; - while (--n > 0 && (c = getc (stream)) != EOF) - if ((*p++ = c) == '\n') - break; - if (c == EOF && (p == s || ferror (stream))) - return NULL; - *p = '\0'; - return s; - } - - /* Leave space for the null. */ - --n; - - if (n > 0 && - (!stream->__seen || stream->__buffer == NULL || stream->__pushed_back)) - { - /* Do one with getc to allocate a buffer. */ - int c = getc (stream); - if (c == EOF) - return NULL; - *p++ = c; - if (c == '\n') - { - *p = '\0'; - return s; - } - else - --n; - } - - while (n > 0) - { - size_t i; - char *found; - - i = stream->__get_limit - stream->__bufp; - if (i == 0) - { - /* Refill the buffer. */ - int c = __fillbf (stream); - if (c == EOF) - break; - *p++ = c; - --n; - if (c == '\n') - { - *p = '\0'; - return s; - } - i = stream->__get_limit - stream->__bufp; - } - - if (i > (size_t) n) - i = n; - - found = (char *) __memccpy ((void *) p, stream->__bufp, '\n', i); - - if (found != NULL) - { - stream->__bufp += found - p; - p = found; - break; - } - - stream->__bufp += i; - n -= i; - p += i; - } - - if (p == s) - return NULL; - - *p = '\0'; - return ferror (stream) ? NULL : s; -} - -weak_alias (fgets, fgets_unlocked) diff --git a/stdio/fileno.c b/stdio/fileno.c deleted file mode 100644 index bfab916cb2..0000000000 --- a/stdio/fileno.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1991, 93, 94, 96, 97, 98 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -/* Return the system file descriptor associated with STREAM. */ -int -fileno (stream) - FILE *stream; -{ - extern void __stdio_check_funcs __P ((FILE *)); - - if (! __validfp (stream)) - { - __set_errno (EINVAL); - return -1; - } - - __stdio_check_funcs (stream); - - if (stream->__io_funcs.__fileno == NULL) - { -#ifdef EOPNOTSUPP - __set_errno (EOPNOTSUPP); -#else - __set_errno (ENOSYS); -#endif - return -1; - } - - return (*stream->__io_funcs.__fileno) (stream->__cookie); -} - -weak_alias(fileno, fileno_unlocked) diff --git a/stdio/fmemopen.c b/stdio/fmemopen.c deleted file mode 100644 index 1ae0e5b7ae..0000000000 --- a/stdio/fmemopen.c +++ /dev/null @@ -1,109 +0,0 @@ -/* 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include - - -/* Defined in fopen.c. */ -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 - buffer pointer is set to point to the first '\0' in the buffer. - If S is NULL, the buffer is allocated by malloc and will be freed - when the stream is closed. The only purpose of this is to write - things and then read what's been written. If LEN is zero, writes will - always return errors and reads will always return end-of-file. - - The stream is set up such that seeks and tells will always fail and - once the buffer is full of written characters or empty of characters - to read, attempted writes always return an output error and attempted - reads always return end-of-file. */ -FILE * -fmemopen (s, len, mode) - void *s; - size_t len; - const char *mode; -{ - __io_mode m; - register FILE *stream; - - if (!__getmode (mode, &m)) - return NULL; - - stream = __newstream (); - if (stream == NULL) - return NULL; - - stream->__mode = m; - - /* Input gets EOF. */ - stream->__room_funcs.__input = NULL; - /* Output gets error. */ - stream->__room_funcs.__output = NULL; - - /* Do nothing for close. */ - 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; - - stream->__userbuf = s != NULL && len > 0; - if (s == NULL) - { - s = malloc (len); - if (s == NULL) - { - int save = errno; - (void) fclose (stream); - __set_errno (save); - return NULL; - } - } - - stream->__buffer = (char *) s; - stream->__bufsize = len; - - stream->__bufp = stream->__buffer; - stream->__get_limit = (stream->__buffer + - (stream->__mode.__read ? stream->__bufsize : 0)); - stream->__put_limit = (stream->__buffer + - (stream->__mode.__write ? stream->__bufsize : 0)); - stream->__cookie = NULL; - - if (stream->__mode.__append) - { - char *p = memchr (stream->__bufp, '\0', - stream->__get_limit - stream->__bufp); - if (p == NULL) - stream->__bufp = stream->__get_limit; - else - stream->__bufp = p; - } - else if (stream->__mode.__truncate) - memset ((void *) stream->__buffer, 0, len); - - return stream; -} diff --git a/stdio/fopen.c b/stdio/fopen.c deleted file mode 100644 index 62e78e39bf..0000000000 --- a/stdio/fopen.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 96, 97, 98 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include - - -#define badmode() return ((__set_errno (EINVAL)), 0) - -/* Dissect the given mode string into an __io_mode. */ -int -__getmode (const char *mode, __io_mode *mptr) -{ - register unsigned char i; - - if (mode == NULL) - badmode (); - - memset ((void *) mptr, 0, sizeof (*mptr)); - - switch (*mode) - { - case 'a': - mptr->__write = mptr->__create = mptr->__append = 1; - break; - case 'w': - mptr->__write = mptr->__create = mptr->__truncate = 1; - break; - case 'r': - mptr->__read = 1; - break; - default: - badmode (); - } - - for (i = 1; i < 4; ++i) - { - switch (*++mode) - { - case '\0': - break; - case '+': - mptr->__read = mptr->__write = 1; - continue; - case 'b': - mptr->__binary = 1; - continue; - case 'x': - mptr->__exclusive = 1; - continue; - } - break; - } - - if (!mptr->__read && !mptr->__write) - badmode (); - - return 1; -} - -/* Open a new stream on the given file. */ -FILE * -fopen (filename, mode) - const char *filename; - const char *mode; -{ - FILE *stream; - __io_mode m; - - if (filename == NULL) - { - __set_errno (EINVAL); - return NULL; - } - - if (!__getmode (mode, &m)) - return NULL; - - stream = __newstream (); - if (stream == NULL) - return NULL; - - if (__stdio_open (filename, m, &stream->__cookie)) - { - int save = errno; - (void) fclose (stream); - __set_errno (save); - return NULL; - } - - stream->__mode = m; - - return stream; -} diff --git a/stdio/fopncook.c b/stdio/fopncook.c deleted file mode 100644 index adbbc48c0e..0000000000 --- a/stdio/fopncook.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 1991, 1992, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - - -/* Defined in fopen.c. */ -extern int __getmode __P ((const char *mode, __io_mode *mptr)); - -/* Open a new stream on the given magic cookie descriptor. */ -FILE * -fopencookie (cookie, mode, functions) - void *cookie; - const char *mode; - __io_functions functions; -{ - __io_mode m; - FILE *f; - - if (!__getmode (mode, &m)) - return NULL; - - f = __newstream (); - if (f == NULL) - return NULL; - - f->__cookie = cookie; - f->__mode = m; - f->__io_funcs = functions; - f->__room_funcs = __default_room_functions; - f->__seen = 1; - - return f; -} diff --git a/stdio/fputc.c b/stdio/fputc.c deleted file mode 100644 index 57d618cf07..0000000000 --- a/stdio/fputc.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1991, 1996, 1997, 1998, 1999 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - - -/* Write the character C to STREAM. */ -int -fputc (c, stream) - int c; - FILE *stream; -{ - if (!__validfp (stream) || !stream->__mode.__write) - { - __set_errno (EINVAL); - return EOF; - } - - return __putc (c, stream); -} - -#ifndef fputc -weak_alias (fputc, fputc_unlocked) -#endif diff --git a/stdio/fputs.c b/stdio/fputs.c deleted file mode 100644 index f2457f7fbd..0000000000 --- a/stdio/fputs.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1991, 1992, 1997, 1998 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include - - -/* Write the string S to STREAM. */ -int -fputs (const char *s, FILE *stream) -{ - const size_t len = strlen (s); - if (len == 1) - return putc (*s, stream) == EOF ? EOF : 0; - if (fwrite ((void *) s, 1, len, stream) != len) - return EOF; - return 0; -} -weak_alias (fputs, fputs_unlocked) diff --git a/stdio/fread.c b/stdio/fread.c deleted file mode 100644 index 528c567114..0000000000 --- a/stdio/fread.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include - - -#define default_func __default_room_functions.__input - -/* Read NMEMB chunks of SIZE bytes each from STREAM into P. */ -size_t -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) - { - __set_errno (EINVAL); - return 0; - } - if (feof (stream) || ferror (stream)) - return 0; - if (p == NULL || to_read == 0) - return 0; - - if (!stream->__seen || stream->__buffer == NULL || stream->__pushed_back) - { - /* 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); - if (c == EOF) - return 0; - *ptr++ = c; - if (--to_read == 0) - return 1; - } - - read_from_buffer:; - if (stream->__bufp < stream->__get_limit) - { - /* First off, empty out the buffer. */ - register size_t copy = stream->__get_limit - stream->__bufp; - if (copy > to_read) - copy = to_read; - to_read -= copy; - if (copy > 20) - memcpy((void *) ptr, (void *) stream->__bufp, copy); - else - { - register size_t i; - for (i = 0; i < copy; ++i) - ptr[i] = stream->__bufp[i]; - } - stream->__bufp += copy; - if (to_read == 0) - return nmemb; - ptr += copy; - } - - /* Reading directly into the user's buffer doesn't help when - using a user-specified input buffer filling/expanding function, - so we don't do it in that case. */ - if (to_read >= stream->__bufsize && - stream->__room_funcs.__input == default_func && - stream->__offset == stream->__target) - { - /* Read directly into the user's buffer. */ - if (stream->__io_funcs.__read != NULL) - while (to_read > 0) - { - register int count; - count = (*stream->__io_funcs.__read) (stream->__cookie, - ptr, to_read); - if (count > 0) - { - to_read -= count; - if (stream->__offset != -1) - { - stream->__offset += count; - stream->__target += count; - } - ptr += count; - } - else if (count == 0) - { - stream->__eof = 1; - break; - } - else - { - stream->__error = 1; - break; - } - } - else - stream->__eof = 1; - } - else - { - int c = __fillbf (stream); - if (c == EOF) - return (bytes - to_read) / size; - *ptr++ = (char) c; - --to_read; - if (to_read > 0) - goto read_from_buffer; - } - - return (bytes - to_read) / size; -} - -weak_alias (fread, fread_unlocked) diff --git a/stdio/freopen.c b/stdio/freopen.c deleted file mode 100644 index dc4ff3feb1..0000000000 --- a/stdio/freopen.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1991, 1994, 1995, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - - -/* Defined in fopen.c. */ -extern int __getmode __P ((const char *, __io_mode *)); - -/* Defined in sysd-stdio.c. */ -extern int __stdio_reopen __P ((const char *filename, __io_mode mode, - void *cookieptr, __io_close_fn closefn)); - -/* Replace STREAM, opening it on FILENAME. */ -FILE * -freopen (filename, mode, stream) - const char *filename; - const char *mode; - register FILE *stream; -{ - __io_mode m; - void *cookie; - - if (!__getmode (mode, &m)) - { - (void) fclose (stream); - __set_errno (EINVAL); - return NULL; - } - - if (stream->__mode.__write) - /* Flush the stream. */ - (void) fflush (stream); - - /* Open the file, attempting to preserve the old cookie value. */ - cookie = stream->__cookie; - if (__stdio_reopen (filename, m, &cookie, - stream->__seen ? - stream->__io_funcs.__close : - __stdio_close)) - { - int save = errno; - (void) fclose (stream); - __set_errno (save); - return NULL; - } - - /* Close the stream, first disabling its cookie close function because - __stdio_reopen has already dealt with closing the old cookie. */ - stream->__seen = 1; /* It might have no functions yet. */ - stream->__io_funcs.__close = NULL; - (void) fclose (stream); - - stream->__magic = _IOMAGIC; - stream->__cookie = cookie; - stream->__mode = m; - - return stream; -} diff --git a/stdio/fseek.c b/stdio/fseek.c deleted file mode 100644 index fb2e580fd0..0000000000 --- a/stdio/fseek.c +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 95, 96, 97 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - - -/* Move the file position of STREAM to OFFSET - bytes from the beginning of the file if WHENCE - is SEEK_SET, the end of the file is it is SEEK_END, - or the current position if it is SEEK_CUR. */ -int -fseek (stream, offset, whence) - register FILE *stream; - long int offset; - int whence; -{ - long int o; - - if (!__validfp (stream)) - { - __set_errno (EINVAL); - return EOF; - } - - /* Write out any pending data. */ - if (stream->__mode.__write && __flshfp (stream, EOF) == EOF) - return EOF; - - /* Make sure we know the current offset info. */ - stream->__offset = -1; - if (__stdio_check_offset (stream) == EOF) - return EOF; - - /* We are moving the file position, so we are no longer at EOF. */ - stream->__eof = 0; - - if (stream->__pushed_back) - { - /* Discard the character pushed back by ungetc. */ - stream->__bufp = stream->__pushback_bufp; - stream->__pushed_back = 0; - } - - /* Check the WHENCE argument for validity, and process OFFSET - into an absolute position in O. By the end of this switch, - either we have returned, or O contains an absolute position. */ - o = offset; - switch (whence) - { - default: - __set_errno (EINVAL); - return EOF; - - case SEEK_END: - /* We don't know where the end of the file is, - so seek to the position in the file the user asked - for, and then look where that is. */ - if (stream->__io_funcs.__seek == NULL) - { - __set_errno (ESPIPE); - return EOF; - } - else - { - fpos_t pos = (fpos_t) o; - if ((*stream->__io_funcs.__seek) - (stream->__cookie, &pos, SEEK_END) < 0) - { - if (errno == ESPIPE) - stream->__io_funcs.__seek = NULL; - return EOF; - } - stream->__offset = pos; - /* Make O be absolute, rather than - relative to the end of the file. */ - o = pos; - } - - /* Fall through to try an absolute seek. */ - - case SEEK_SET: - /* Make O be relative to the buffer. */ - o -= stream->__target; - /* Make O be relative to the current position in the buffer. */ - o -= stream->__bufp - stream->__buffer; - - /* Fall through to see if we can do it by - moving the pointer around in the buffer. */ - - case SEEK_CUR: - /* If the offset is small enough, we can just - move the pointer around in the buffer. */ - -#if 0 /* Why did I think this would ever work??? */ - if (stream->__put_limit > stream->__buffer) - { - /* We are writing. */ - if (stream->__bufp + o >= stream->__buffer && - stream->__put_limit > stream->__bufp + o && - stream->__get_limit > stream->__bufp + o) - { - /* We have read all the data we will change soon. - We can just move the pointer around. */ - stream->__bufp += o; - return 0; - } - else - { - /* Flush the buffer. */ - if (__flshfp(stream, EOF) == EOF) - return EOF; - } - } else -#endif - if (o < 0 ? - (-o <= stream->__bufp - stream->__buffer) : - (o <= stream->__get_limit - stream->__bufp)) - { - stream->__bufp += o; - return 0; - } - - /* Turn it into an absolute seek. */ - o += stream->__bufp - stream->__buffer; - o += stream->__target; - break; - } - - if (o < 0) - { - /* Negative file position is meaningless. */ - __set_errno (EINVAL); - return -1; - } - - /* O is now an absolute position, the new target. */ - stream->__target = o; - - /* Set bufp and both end pointers to the beginning of the buffer. - The next i/o will force a call to the input/output room function. */ - stream->__bufp - = stream->__get_limit = stream->__put_limit = stream->__buffer; - - /* Make sure __flshfp doesn't think the put_limit is at the beginning - of the buffer because of line-buffering magic. */ - stream->__linebuf_active = 0; - - /* If there is no seek function, seeks always fail. */ - if (stream->__io_funcs.__seek == NULL) - { - /* This is preemptive, since we don't actually do the seeking. - But it makes more sense for fseek to to fail with ESPIPE - than for the next reading or writing operation to fail - that way. */ - __set_errno (ESPIPE); - return EOF; - } - - /* Don't actually seek. The next reading or writing operation - will force a call to the input or output room function, - which will move to the target file position before reading or writing. */ - return 0; -} diff --git a/stdio/fsetpos.c b/stdio/fsetpos.c deleted file mode 100644 index 073644369f..0000000000 --- a/stdio/fsetpos.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 1991, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -#undef fsetpos - - -/* Set the file position of STREAM to *POS. */ -int -fsetpos (stream, pos) - FILE *stream; - const fpos_t *pos; -{ - if (pos == NULL) - { - __set_errno (EINVAL); - return EOF; - } - - return fseek (stream, *pos, SEEK_SET); -} diff --git a/stdio/ftell.c b/stdio/ftell.c deleted file mode 100644 index 03c3ebc332..0000000000 --- a/stdio/ftell.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1991, 1992, 1994, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - -/* Return the offset in bytes from the beginning - of the file of the file position of STREAM. */ -long int -ftell (stream) - FILE *stream; -{ - long int pos; - - if (!__validfp (stream)) - { - __set_errno (EINVAL); - return -1L; - } - - if (__stdio_check_offset (stream) == EOF) - return -1L; - - /* Start with the file position associated with the beginning - of our buffer. */ - pos = stream->__target; - - if (stream->__pushed_back) - /* ungetc was just called, so our real buffer pointer is squirreled - away in STREAM->__pushback_bufp, not in STREAM->__bufp as normal. - Calling u