diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-08-21 22:57:35 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-08-21 22:57:35 +0000 |
commit | 28e9041cc224267271fbcd8db22bea115912365b (patch) | |
tree | a3b19970338bdae580faff126a716e1d5520400c /libio/stdio | |
parent | 5000a677980ebfb439f5349c5e269f7447dbab41 (diff) | |
download | gcc-28e9041cc224267271fbcd8db22bea115912365b.tar.gz |
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@14877 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libio/stdio')
31 files changed, 853 insertions, 0 deletions
diff --git a/libio/stdio/ChangeLog b/libio/stdio/ChangeLog new file mode 100644 index 00000000000..76ce5b7a875 --- /dev/null +++ b/libio/stdio/ChangeLog @@ -0,0 +1,93 @@ +Thu May 1 11:03:45 1997 Brendan Kehoe <brendan@lisa.cygnus.com> + + * stdio.h (TMP_MAX): Wrap it with #ifndef for now, since it can + get defined by <limits.h> (e.g., HP/UX and AIX). + +Wed Mar 12 08:51:37 1997 Gavin Koch <gavin@cygnus.com> + + * stdio.h: Use _IO_va_list rather than _G_va_list. + +Wed Jun 14 21:41:50 1995 Jason Merrill <jason@python.cygnus.com> + + * configure.in (LIBDIR): Set. + (MOSTLYCLEAN): Remove pic and stamp-picdir. + (stdio_objects): Also compile pic version. + + * Makefile.in (STDIO_OBJECTS): Remove getdelim.o. + +Wed May 10 03:05:53 1995 Jason Merrill <jason@python.cygnus.com> + + * vsnprintf.c (vsnprintf): Update to use _IO_JUMPS. + + * Makefile.in (STDIO_OBJECTS): Fix typo. + +Tue Oct 18 17:15:09 1994 Per Bothner <bothner@kalessin.cygnus.com> + + * getline.c, snprintf.c, vsnprintf.c: New files, providing + functionality of the GNU C C library. + * Makefile.in (STDIO_OBJECTS), configure.in: Add new files. + * stdio.h: Add new functions. + +Fri Oct 14 15:56:27 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Added vfscanf, vscanf, vsscanf, #ifndef __STRICT_ANSI__. + +Tue Aug 23 16:17:25 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Added comment, at hjl's request. + +Sun Aug 7 13:28:12 1994 H.J. Lu (hjl@nynexst.com) + + * stdio.h (getc, getchar, putc, putchar): New declarations. + Move macros after the declarations. + +Fri Aug 5 18:27:21 1994 H.J. Lu (hjl@nynexst.com) + + * clearerr.c, rewind.c, setfileno.c: + Add CHECK_FILE(fp, ) and remove COERCE_FILE(fp). + * feof.c, ferror.c, fgetc.c, fileno.c, fputc.c, getw.c, putw.c, + vfscanf.c: Add CHECK_FILE(fp, EOF) and remove COERCE_FILE(fp). + * freopen.c: Add CHECK_FILE(fp, NULL) and remove COERCE_FILE(fp). + * fseek.c, vfprintf.c: + Add CHECK_FILE(fp, -1) and remove COERCE_FILE(fp). + +Fri May 20 13:11:58 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Rename _ARGS macro to __P for better gnlibc and + BSD compatibility. + +Fri Nov 26 13:26:35 1993 Per Bothner (bothner@kalessin.cygnus.com) + + Bunch of little changes, many from H.J. Lu <hjl@nynexst.com>. + * feof.c, setbuf.c, vprintf.c, vcanf.c: #include <stdio.h>, + for error checking. + * fileno.c: #include libioP.h, not just libio.h. + * fputc.c: Fix typo. + * fseek.c, rewind.c: Use #include "...", not <...> ,for local files. + * getc.c, getchar.c, putc.c, putchar.c: New files, providing + non-macro versions of the standard macros. + * getw.c, putw.c, setfileno.c, setlinebuf.c: New files. + * Makefile.in (STDIO_OBJECTS): Add new files. + * vfscanf.c: Add missing new 4th arg to _IO_vfscanf call. + +Thu Oct 14 16:12:07 1993 Karen Christiansen (karen@deneb.cygnus.com) + + * configure.in: changed mv to mv -f + +Mon Oct 4 17:29:23 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in (stdio_renames): Add fgetpos, fsetpos, gets, + perror, setbuffer, ungetc. + * clearerr.c, ferror.c, fgetc.c, fileno.c, fputc.c, freopen.c, + fseek.c, popen.c, rewind.c, setbuf.c: New files. + * Makefile.in (STDIO_OBJECTS): Add new files. + * stdio.h: Use _IO_XXX instead of _G_XXX many places. + #include <libio.h> instead of <_stdio.h>, to get useful defs. + +Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * feof.c, vprintf.c, vscanf.c: Converted stub functions. + * configure.in (stdio_renamed): Removed feof. + Added sprintf sscanf vsscanf. + * ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog. + diff --git a/libio/stdio/Makefile.in b/libio/stdio/Makefile.in new file mode 100644 index 00000000000..8df66a7c193 --- /dev/null +++ b/libio/stdio/Makefile.in @@ -0,0 +1,23 @@ +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +# These are compiled from the corresponding ../ioFOO.c files. +STDIO_RENAMED_OBJECTS = ... filled in by configure ... +# These are the files that a libc would want. +STDIO_OBJECTS = $(STDIO_RENAMED_OBJECTS) \ + clearerr.o fdopen.o feof.o ferror.o fgetc.o fileno.o \ + fputc.o freopen.o fseek.o getc.o getchar.o getline.o getw.o \ + popen.o putc.o putchar.o putw.o rewind.o \ + setbuf.o setfileno.o setlinebuf.o snprintf.o \ + vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o + +CC_FOR_STDIO=$(CC) +CINCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -D__USE_GNU + +nothing: + +stdio.list: stamp-picdir $(STDIO_OBJECTS) + @echo "$(STDIO_OBJECTS)" >stdio.list + diff --git a/libio/stdio/clearerr.c b/libio/stdio/clearerr.c new file mode 100644 index 00000000000..ee9780bdaf5 --- /dev/null +++ b/libio/stdio/clearerr.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +void +clearerr(fp) + FILE* fp; +{ + CHECK_FILE(fp, /*nothing*/); + _IO_clearerr(fp); +} diff --git a/libio/stdio/configure.in b/libio/stdio/configure.in new file mode 100644 index 00000000000..21e920acf47 --- /dev/null +++ b/libio/stdio/configure.in @@ -0,0 +1,48 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs= +srctrigger=stdio.h +srcname="libio/stdio" +package_makefile_frag=../Make.pack + +# per-host: + +# per-target: + +LIBDIR=yes +TO_TOPDIR=../../ +ALL=nothing +MOSTLYCLEAN='*.o pic stamp-picdir core stdio.list' +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +# Certain files that are used to build a C library (such as fprintf.o) +# are compled from the same sources as the ioXXX versions (such as ioprintf.c). +# These lines add the appropriate rules. +# NOTE: We assume a C compiler that where -o with -c works. +# But these files are not built by default anyway ... + +# TODO: remove rename tmpfile tmpnam + +stdio_renames="fclose fflush fgetpos fgets fopen fprintf fputs fread \ + fscanf fsetpos ftell fwrite getdelim gets perror printf puts \ + scanf setbuffer setvbuf sprintf sscanf ungetc vsprintf vsscanf" +stdio_objects="" + +for file in $stdio_renames ; do + cat >>Makefile <<EOF +$file.o: \$(srcdir)/../io$file.c + if [ -n "\$(PICFLAG)" ]; then \\ + \$(CC_FOR_STDIO) \$(CFLAGS) \$(CINCLUDES) \$(PICFLAG) -c \\ + \$(srcdir)/../io$file.c -D_IO_$file=$file -o pic/$file.o; \\ + fi + \$(CC_FOR_STDIO) \$(CFLAGS) \$(CINCLUDES) -c \\ + \$(srcdir)/../io$file.c -D_IO_$file=$file -o $file.o +EOF + stdio_objects="$stdio_objects $file.o" +done +sed -e "/STDIO_RENAMED_OBJECTS =/s/=.*/=${stdio_objects}/" <Makefile >tmp +mv -f tmp Makefile diff --git a/libio/stdio/fdopen.c b/libio/stdio/fdopen.c new file mode 100644 index 00000000000..83e026ec7f7 --- /dev/null +++ b/libio/stdio/fdopen.c @@ -0,0 +1,9 @@ +#include "libioP.h" + +_IO_FILE * +fdopen (fd, mode) + int fd; + const char *mode; +{ + return _IO_fdopen (fd, mode); +} diff --git a/libio/stdio/feof.c b/libio/stdio/feof.c new file mode 100644 index 00000000000..bd30c175f3c --- /dev/null +++ b/libio/stdio/feof.c @@ -0,0 +1,34 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" +#include "stdio.h" + +int +feof(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, EOF); + return _IO_feof(fp); +} diff --git a/libio/stdio/ferror.c b/libio/stdio/ferror.c new file mode 100644 index 00000000000..ef95d7cd29d --- /dev/null +++ b/libio/stdio/ferror.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +int +ferror(fp) + FILE* fp; +{ + CHECK_FILE(fp, EOF); + return _IO_ferror(fp); +} diff --git a/libio/stdio/fgetc.c b/libio/stdio/fgetc.c new file mode 100644 index 00000000000..cf6410a887f --- /dev/null +++ b/libio/stdio/fgetc.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +int +fgetc(fp) + FILE *fp; +{ + CHECK_FILE(fp, EOF); + return _IO_getc(fp); +} diff --git a/libio/stdio/fileno.c b/libio/stdio/fileno.c new file mode 100644 index 00000000000..c0bc55ce9a1 --- /dev/null +++ b/libio/stdio/fileno.c @@ -0,0 +1,12 @@ +#include "libioP.h" +#include "stdio.h" + +int +fileno(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, EOF); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return EOF; + return _IO_fileno(fp); +} diff --git a/libio/stdio/fputc.c b/libio/stdio/fputc.c new file mode 100644 index 00000000000..e87b042bfba --- /dev/null +++ b/libio/stdio/fputc.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +int +fputc(c, fp) + int c; + FILE *fp; +{ + CHECK_FILE(fp, EOF); + return _IO_putc(c, fp); +} diff --git a/libio/stdio/freopen.c b/libio/stdio/freopen.c new file mode 100644 index 00000000000..da3dc1d6411 --- /dev/null +++ b/libio/stdio/freopen.c @@ -0,0 +1,14 @@ +#include "libioP.h" +#include "stdio.h" + +FILE* +freopen(filename, mode, fp) + const char* filename; + const char* mode; + FILE* fp; +{ + CHECK_FILE(fp, NULL); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return NULL; + return _IO_freopen(filename, mode, fp); +} diff --git a/libio/stdio/fseek.c b/libio/stdio/fseek.c new file mode 100644 index 00000000000..b80067da1c0 --- /dev/null +++ b/libio/stdio/fseek.c @@ -0,0 +1,12 @@ +#include "stdio.h" +#include "libioP.h" + +int +fseek(fp, offset, whence) + _IO_FILE* fp; + long int offset; + int whence; +{ + CHECK_FILE(fp, -1); + return _IO_fseek(fp, offset, whence); +} diff --git a/libio/stdio/getc.c b/libio/stdio/getc.c new file mode 100644 index 00000000000..9db0987f71c --- /dev/null +++ b/libio/stdio/getc.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +#undef getc + +int +getc(stream) + FILE *stream; +{ + return _IO_getc (stream); +} diff --git a/libio/stdio/getchar.c b/libio/stdio/getchar.c new file mode 100644 index 00000000000..88610dc49e2 --- /dev/null +++ b/libio/stdio/getchar.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +#undef getchar + +int +getchar () +{ + return _IO_getc (stdin); +} diff --git a/libio/stdio/getline.c b/libio/stdio/getline.c new file mode 100644 index 00000000000..6f4b677086e --- /dev/null +++ b/libio/stdio/getline.c @@ -0,0 +1,13 @@ +#include "libioP.h" +#include "stdio.h" + +/* NOTE: This geline function is different from _IO_getline. */ + +_IO_ssize_t +getline (lineptr, linelen, fp) + char** lineptr; + size_t* linelen; + FILE* fp; +{ + return _IO_getdelim (lineptr, linelen, '\n', fp); +} diff --git a/libio/stdio/getw.c b/libio/stdio/getw.c new file mode 100644 index 00000000000..1dfafbc1d4f --- /dev/null +++ b/libio/stdio/getw.c @@ -0,0 +1,13 @@ +#include "libioP.h" +#include "stdio.h" + +int +getw(fp) + FILE *fp; +{ + int w; + _IO_size_t bytes_read; + CHECK_FILE(fp, EOF); + bytes_read = _IO_sgetn (fp, (char*)&w, sizeof(w)); + return sizeof(w) == bytes_read ? w : EOF; +} diff --git a/libio/stdio/popen.c b/libio/stdio/popen.c new file mode 100644 index 00000000000..9f9f3f72f58 --- /dev/null +++ b/libio/stdio/popen.c @@ -0,0 +1,23 @@ +#include "libioP.h" +#include "stdio.h" +#include <errno.h> + +FILE * +popen(command, mode) + const char *command; const char *mode; +{ + return _IO_popen(command, mode); +} + +int +pclose(fp) + FILE *fp; +{ +#if 0 + /* Does not actually test that stream was created by popen(). Instead, + it depends on the filebuf::sys_close() virtual to Do The Right Thing. */ + if (fp is not a proc_file) + return -1; +#endif + return _IO_fclose(fp); +} diff --git a/libio/stdio/putc.c b/libio/stdio/putc.c new file mode 100644 index 00000000000..2a3dcc36867 --- /dev/null +++ b/libio/stdio/putc.c @@ -0,0 +1,12 @@ +#include "libioP.h" +#include "stdio.h" + +#undef putc + +int +putc(c, stream) + int c; + FILE *stream; +{ + return _IO_putc(c, stream); +} diff --git a/libio/stdio/putchar.c b/libio/stdio/putchar.c new file mode 100644 index 00000000000..a0a972fb539 --- /dev/null +++ b/libio/stdio/putchar.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" +#undef putchar + +int +putchar(c) + int c; +{ + return _IO_putc(c, stdout); +} diff --git a/libio/stdio/putw.c b/libio/stdio/putw.c new file mode 100644 index 00000000000..fd73261359c --- /dev/null +++ b/libio/stdio/putw.c @@ -0,0 +1,15 @@ +#include "libioP.h" +#include "stdio.h" + +#undef putw + +int +putw(w, fp) + int w; + FILE *fp; +{ + _IO_size_t written; + CHECK_FILE(fp, EOF); + written = _IO_sputn(fp, (const char *)&w, sizeof(w)); + return written == sizeof(w) ? 0 : EOF; +} diff --git a/libio/stdio/rewind.c b/libio/stdio/rewind.c new file mode 100644 index 00000000000..01fe20a75dd --- /dev/null +++ b/libio/stdio/rewind.c @@ -0,0 +1,10 @@ +#include "stdio.h" +#include "libioP.h" + +void +rewind(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, ); + _IO_rewind(fp); +} diff --git a/libio/stdio/setbuf.c b/libio/stdio/setbuf.c new file mode 100644 index 00000000000..5002e3d0733 --- /dev/null +++ b/libio/stdio/setbuf.c @@ -0,0 +1,9 @@ +#include "libioP.h" +#include "stdio.h" + +void +setbuf (fp, buf) + FILE *fp; char *buf; +{ + _IO_setbuffer(fp, buf, _IO_BUFSIZ); +} diff --git a/libio/stdio/setfileno.c b/libio/stdio/setfileno.c new file mode 100644 index 00000000000..f7ccc6fdd66 --- /dev/null +++ b/libio/stdio/setfileno.c @@ -0,0 +1,17 @@ +/* Some known programs (xterm, pdksh?) non-portably change the _file + field of s struct _iobuf. This kludge allows the same "functionality". + This code is an undocumented feature for iostream/stdio. Use it at + your own risk. */ + +#include "libioP.h" +#include "stdio.h" + +void +setfileno(fp, fd) + _IO_FILE* fp; + int fd; +{ + CHECK_FILE(fp, ); + if ((fp->_flags & _IO_IS_FILEBUF) != 0) + fp->_fileno = fd; +} diff --git a/libio/stdio/setlinebuf.c b/libio/stdio/setlinebuf.c new file mode 100644 index 00000000000..c447f954e9f --- /dev/null +++ b/libio/stdio/setlinebuf.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +#undef setlinebuf + +void +setlinebuf (stream) + FILE *stream; +{ + _IO_setvbuf(stream, NULL, 1, 0); +} diff --git a/libio/stdio/snprintf.c b/libio/stdio/snprintf.c new file mode 100644 index 00000000000..5c70a444112 --- /dev/null +++ b/libio/stdio/snprintf.c @@ -0,0 +1,51 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif + +int +snprintf +#ifdef __STDC__ + (char *string, _IO_size_t maxlen, const char *format, ...) +#else +(string, maxlen, format, va_alist) + char *string; + _IO_size_t maxlen; + char *format; + va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = vsnprintf(string, maxlen, format, args); + va_end(args); + return ret; +} diff --git a/libio/stdio/stdio.h b/libio/stdio/stdio.h new file mode 100644 index 00000000000..d1c41300b41 --- /dev/null +++ b/libio/stdio/stdio.h @@ -0,0 +1,181 @@ +/* This is part of the iostream/stdio library, providing -*- C -*- I/O. + Define ANSI C stdio on top of C++ iostreams. + Copyright (C) 1991, 1994 Free Software Foundation + +This 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. + + +This 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 this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* + * ANSI Standard: 4.9 INPUT/OUTPUT <stdio.h> + */ + +#ifndef _STDIO_H +#define _STDIO_H +#define _STDIO_USES_IOSTREAM + +#include <libio.h> + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL (void*)0 +#endif +#endif + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef BUFSIZ +#define BUFSIZ 1024 +#endif + +#define _IOFBF 0 /* Fully buffered. */ +#define _IOLBF 1 /* Line buffered. */ +#define _IONBF 2 /* No buffering. */ + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + + /* define size_t. Crud in case <sys/types.h> has defined it. */ +#if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE) +#if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h) +#if !defined(_GCC_SIZE_T) && !defined(_SIZET_) +#define _SIZE_T +#define _T_SIZE_ +#define _T_SIZE +#define __SIZE_T +#define _SIZE_T_ +#define ___int_size_t_h +#define _GCC_SIZE_T +#define _SIZET_ +typedef _IO_size_t size_t; +#endif +#endif +#endif + +typedef struct _IO_FILE FILE; +typedef _IO_fpos_t fpos_t; + +#define FOPEN_MAX _G_FOPEN_MAX +#define FILENAME_MAX _G_FILENAME_MAX +#ifndef TMP_MAX +#define TMP_MAX 999 /* Only limited by filename length */ +#endif + +#define L_ctermid 9 +#define L_cuserid 9 +#define P_tmpdir "/tmp" +#define L_tmpnam 20 + +/* For use by debuggers. These are linked in if printf or fprintf are used. */ +extern FILE *stdin, *stdout, *stderr; /* TODO */ + +#define stdin _IO_stdin +#define stdout _IO_stdout +#define stderr _IO_stderr + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __P +#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) +#define __P(args) args +#else +#define __P(args) () +#endif +#endif /*!__P*/ + +extern void clearerr __P((FILE*)); +extern int fclose __P((FILE*)); +extern int feof __P((FILE*)); +extern int ferror __P((FILE*)); +extern int fflush __P((FILE*)); +extern int fgetc __P((FILE *)); +extern int fgetpos __P((FILE* fp, fpos_t *pos)); +extern char* fgets __P((char*, int, FILE*)); +extern FILE* fopen __P((const char*, const char*)); +extern int fprintf __P((FILE*, const char* format, ...)); +extern int fputc __P((int, FILE*)); +extern int fputs __P((const char *str, FILE *fp)); +extern size_t fread __P((void*, size_t, size_t, FILE*)); +extern FILE* freopen __P((const char*, const char*, FILE*)); +extern int fscanf __P((FILE *fp, const char* format, ...)); +extern int fseek __P((FILE* fp, long int offset, int whence)); +extern int fsetpos __P((FILE* fp, const fpos_t *pos)); +extern long int ftell __P((FILE* fp)); +extern size_t fwrite __P((const void*, size_t, size_t, FILE*)); +extern int getc __P((FILE *)); +extern int getchar __P((void)); +extern char* gets __P((char*)); +extern void perror __P((const char *)); +extern int printf __P((const char* format, ...)); +extern int putc __P((int, FILE *)); +extern int putchar __P((int)); +extern int puts __P((const char *str)); +extern int remove __P((const char*)); +extern int rename __P((const char* _old, const char* _new)); +extern void rewind __P((FILE*)); +extern int scanf __P((const char* format, ...)); +extern void setbuf __P((FILE*, char*)); +extern void setlinebuf __P((FILE*)); +extern void setbuffer __P((FILE*, char*, int)); +extern int setvbuf __P((FILE*, char*, int mode, size_t size)); +extern int sprintf __P((char*, const char* format, ...)); +extern int sscanf __P((const char* string, const char* format, ...)); +extern FILE* tmpfile __P((void)); +extern char* tmpnam __P((char*)); +extern int ungetc __P((int c, FILE* fp)); +extern int vfprintf __P((FILE *fp, char const *fmt0, _IO_va_list)); +extern int vprintf __P((char const *fmt, _IO_va_list)); +extern int vsprintf __P((char* string, const char* format, _IO_va_list)); + +#ifndef __STRICT_ANSI__ +extern int vfscanf __P((FILE*, const char *, _IO_va_list)); +extern int vscanf __P((const char *, _IO_va_list)); +extern int vsscanf __P((const char *, const char *, _IO_va_list)); +#endif + +#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) +extern FILE *fdopen __P((int, const char *)); +extern int fileno __P((FILE*)); +extern FILE* popen __P((const char*, const char*)); +extern int pclose __P((FILE*)); +#endif + +#ifdef __USE_GNU +extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*)); +extern _IO_ssize_t getline __P ((char **, size_t *, FILE *)); + +extern int snprintf __P ((char *, size_t, const char *, ...)); +extern int vsnprintf __P ((char *, size_t, const char *, _IO_va_list)); +#endif + +extern int __underflow __P((struct _IO_FILE*)); +extern int __overflow __P((struct _IO_FILE*, int)); + +#define getc(fp) _IO_getc(fp) +#define putc(c, fp) _IO_putc(c, fp) +#define putchar(c) putc(c, stdout) +#define getchar() getc(stdin) + +#ifdef __cplusplus +} +#endif + +#endif /*!_STDIO_H*/ diff --git a/libio/stdio/vfprintf.c b/libio/stdio/vfprintf.c new file mode 100644 index 00000000000..fca62094452 --- /dev/null +++ b/libio/stdio/vfprintf.c @@ -0,0 +1,35 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" + +int +vfprintf(fp, format, args) + register _IO_FILE* fp; + char const *format; + _IO_va_list args; +{ + CHECK_FILE(fp, -1); + return _IO_vfprintf(fp, format, args); +} diff --git a/libio/stdio/vfscanf.c b/libio/stdio/vfscanf.c new file mode 100644 index 00000000000..1759ee5ee01 --- /dev/null +++ b/libio/stdio/vfscanf.c @@ -0,0 +1,36 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" +#include "stdio.h" + +int +vfscanf(fp, format, args) + register _IO_FILE* fp; + const char *format; + _IO_va_list args; +{ + CHECK_FILE(fp, EOF); + return _IO_vfscanf(fp, format, args, NULL); +} diff --git a/libio/stdio/vprintf.c b/libio/stdio/vprintf.c new file mode 100644 index 00000000000..784f0d9b8df --- /dev/null +++ b/libio/stdio/vprintf.c @@ -0,0 +1,33 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" +#include "stdio.h" + +int vprintf(format, args) + const char* format; + _IO_va_list args; +{ + return _IO_vfprintf(_IO_stdout, format, args); +} diff --git a/libio/stdio/vscanf.c b/libio/stdio/vscanf.c new file mode 100644 index 00000000000..4ef4b52a21c --- /dev/null +++ b/libio/stdio/vscanf.c @@ -0,0 +1,34 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" +#include "stdio.h" + +int +vscanf(format, args) + const char *format; + _IO_va_list args; +{ + return _IO_vfscanf(_IO_stdin, format, args, NULL); +} diff --git a/libio/stdio/vsnprintf.c b/libio/stdio/vsnprintf.c new file mode 100644 index 00000000000..8db41b76187 --- /dev/null +++ b/libio/stdio/vsnprintf.c @@ -0,0 +1,43 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "libioP.h" +#include "strfile.h" + +int +vsnprintf (string, maxlen, format, args) + char *string; + _IO_size_t maxlen; + const char *format; + _IO_va_list args; +{ + _IO_strfile sf; + int ret; + _IO_init((_IO_FILE*)&sf, 0); + _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; + _IO_str_init_static ((_IO_FILE*)&sf, string, maxlen - 1, string); + ret = _IO_vfprintf((_IO_FILE*)&sf, format, args); + *((_IO_FILE*)&sf)->_IO_write_ptr = '\0'; + return ret; +} |