From 30b2092fcb3283a42447e47a549e216fd90945ec Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 4 Jul 2002 19:33:54 +0000 Subject: 2002-07-04 Jeff Johnston * libc/include/stdio.h: Add new prototypes. * libc/stdio/Makefile.am: Add fseeko.c and ftello.c. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/fseek.c: Add fseeko documentation. * libc/stdio/ftell.c: Add ftello documentation. * libc/stdio/fseeko.c: New file. * libc/stdio/ftello.c: New file. --- newlib/libc/stdio/Makefile.am | 2 ++ newlib/libc/stdio/Makefile.in | 40 +++++++++++++++++++++------------------- newlib/libc/stdio/fseek.c | 18 ++++++++++++++---- newlib/libc/stdio/fseeko.c | 28 ++++++++++++++++++++++++++++ newlib/libc/stdio/ftell.c | 23 ++++++++++++++++------- newlib/libc/stdio/ftello.c | 26 ++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 30 deletions(-) create mode 100644 newlib/libc/stdio/fseeko.c create mode 100644 newlib/libc/stdio/ftello.c (limited to 'newlib/libc/stdio') diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index 8e3f719ba..1053de25a 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -27,8 +27,10 @@ LIB_SOURCES = \ freopen.c \ fscanf.c \ fseek.c \ + fseeko.c \ fsetpos.c \ ftell.c \ + ftello.c \ fvwrite.c \ fwalk.c \ fwrite.c \ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index df8e5e7c7..35178a89a 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -131,8 +131,10 @@ LIB_SOURCES = \ freopen.c \ fscanf.c \ fseek.c \ + fseeko.c \ fsetpos.c \ ftell.c \ + ftello.c \ fvwrite.c \ fwalk.c \ fwrite.c \ @@ -278,14 +280,14 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@flags.$(OBJEXT) fopen.$(OBJEXT) fprintf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@fputc.$(OBJEXT) fputs.$(OBJEXT) fread.$(OBJEXT) \ @USE_LIBTOOL_FALSE@freopen.$(OBJEXT) fscanf.$(OBJEXT) fseek.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fsetpos.$(OBJEXT) ftell.$(OBJEXT) fvwrite.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@fwalk.$(OBJEXT) fwrite.$(OBJEXT) getc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getchar.$(OBJEXT) getc_u.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getchar_u.$(OBJEXT) getdelim.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getline.$(OBJEXT) gets.$(OBJEXT) getw.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@iprintf.$(OBJEXT) makebuf.$(OBJEXT) mktemp.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@perror.$(OBJEXT) printf.$(OBJEXT) putc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@putchar.$(OBJEXT) putc_u.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fseeko.$(OBJEXT) fsetpos.$(OBJEXT) ftell.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@ftello.$(OBJEXT) fvwrite.$(OBJEXT) fwalk.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@fwrite.$(OBJEXT) getc.$(OBJEXT) getchar.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getc_u.$(OBJEXT) getchar_u.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getdelim.$(OBJEXT) getline.$(OBJEXT) gets.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getw.$(OBJEXT) iprintf.$(OBJEXT) makebuf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mktemp.$(OBJEXT) perror.$(OBJEXT) printf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@putc.$(OBJEXT) putchar.$(OBJEXT) putc_u.$(OBJEXT) \ @USE_LIBTOOL_FALSE@putchar_u.$(OBJEXT) puts.$(OBJEXT) putw.$(OBJEXT) \ @USE_LIBTOOL_FALSE@refill.$(OBJEXT) remove.$(OBJEXT) rename.$(OBJEXT) \ @USE_LIBTOOL_FALSE@rewind.$(OBJEXT) rget.$(OBJEXT) scanf.$(OBJEXT) \ @@ -307,17 +309,17 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \ @USE_LIBTOOL_TRUE@fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo \ @USE_LIBTOOL_TRUE@fputs.lo fread.lo freopen.lo fscanf.lo fseek.lo \ -@USE_LIBTOOL_TRUE@fsetpos.lo ftell.lo fvwrite.lo fwalk.lo fwrite.lo \ -@USE_LIBTOOL_TRUE@getc.lo getchar.lo getc_u.lo getchar_u.lo getdelim.lo \ -@USE_LIBTOOL_TRUE@getline.lo gets.lo getw.lo iprintf.lo makebuf.lo \ -@USE_LIBTOOL_TRUE@mktemp.lo perror.lo printf.lo putc.lo putchar.lo \ -@USE_LIBTOOL_TRUE@putc_u.lo putchar_u.lo puts.lo putw.lo refill.lo \ -@USE_LIBTOOL_TRUE@remove.lo rename.lo rewind.lo rget.lo scanf.lo \ -@USE_LIBTOOL_TRUE@setbuf.lo setbuffer.lo setlinebuf.lo setvbuf.lo \ -@USE_LIBTOOL_TRUE@siprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \ -@USE_LIBTOOL_TRUE@tmpfile.lo tmpnam.lo ungetc.lo vasprintf.lo \ -@USE_LIBTOOL_TRUE@vfscanf.lo vprintf.lo vscanf.lo vsnprintf.lo \ -@USE_LIBTOOL_TRUE@vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo +@USE_LIBTOOL_TRUE@fseeko.lo fsetpos.lo ftell.lo ftello.lo fvwrite.lo \ +@USE_LIBTOOL_TRUE@fwalk.lo fwrite.lo getc.lo getchar.lo getc_u.lo \ +@USE_LIBTOOL_TRUE@getchar_u.lo getdelim.lo getline.lo gets.lo getw.lo \ +@USE_LIBTOOL_TRUE@iprintf.lo makebuf.lo mktemp.lo perror.lo printf.lo \ +@USE_LIBTOOL_TRUE@putc.lo putchar.lo putc_u.lo putchar_u.lo puts.lo \ +@USE_LIBTOOL_TRUE@putw.lo refill.lo remove.lo rename.lo rewind.lo \ +@USE_LIBTOOL_TRUE@rget.lo scanf.lo setbuf.lo setbuffer.lo setlinebuf.lo \ +@USE_LIBTOOL_TRUE@setvbuf.lo siprintf.lo snprintf.lo sprintf.lo \ +@USE_LIBTOOL_TRUE@sscanf.lo stdio.lo tmpfile.lo tmpnam.lo ungetc.lo \ +@USE_LIBTOOL_TRUE@vasprintf.lo vfscanf.lo vprintf.lo vscanf.lo \ +@USE_LIBTOOL_TRUE@vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 27f527545..8912dd60c 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -17,14 +17,17 @@ /* FUNCTION -<>---set file position +<>, <>---set file position INDEX fseek +INDEX + fseeko ANSI_SYNOPSIS #include int fseek(FILE *<[fp]>, long <[offset]>, int <[whence]>) + int fseeko(FILE *<[fp]>, off_t <[offset]>, int <[whence]>) TRAD_SYNOPSIS #include @@ -33,12 +36,17 @@ TRAD_SYNOPSIS long <[offset]>; int <[whence]>; + int fseeko(<[fp]>, <[offset]>, <[whence]>) + FILE *<[fp]>; + off_t <[offset]>; + int <[whence]>; + DESCRIPTION Objects of type <> can have a ``position'' that records how much of the file your program has already read. Many of the <> functions depend on this position, and many change it as a side effect. -You can use <> to set the position for the file identified by +You can use <>/<> to set the position for the file identified by <[fp]>. The value of <[offset]> determines the new position, in one of three ways selected by the value of <[whence]> (defined as macros in `<>'): @@ -53,10 +61,10 @@ from the beginning of the file) desired. <[offset]> must be positive. <[offset]> can meaningfully be either positive (to increase the size of the file) or negative. -See <> to determine the current file position. +See <>/<> to determine the current file position. RETURNS -<> returns <<0>> when successful. If <> fails, the +<>/<> return <<0>> when successful. On failure, the result is <>. The reason for failure is indicated in <>: either <> (the stream identified by <[fp]> doesn't support repositioning) or <> (invalid file position). @@ -64,6 +72,8 @@ repositioning) or <> (invalid file position). PORTABILITY ANSI C requires <>. +<> is defined by the Single Unix specification. + Supporting OS subroutines required: <>, <>, <>, <>, <>, <>, <>. */ diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c new file mode 100644 index 000000000..0697a5fc7 --- /dev/null +++ b/newlib/libc/stdio/fseeko.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2002, Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include + +int +fseeko (fp, offset, whence) + register FILE *fp; + off_t offset; + int whence; +{ + /* for now we simply cast since off_t should be long */ + return fseek (fp, (long)offset, whence); +} diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 8066acc3b..af17e248e 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -17,37 +17,44 @@ /* FUNCTION -<>---return position in a stream or file +<>, <>---return position in a stream or file INDEX ftell +INDEX + ftello ANSI_SYNOPSIS #include long ftell(FILE *<[fp]>); + off_t ftello(FILE *<[fp]>); TRAD_SYNOPSIS #include long ftell(<[fp]>) FILE *<[fp]>; + off_t ftello(<[fp]>) + FILE *<[fp]>; + DESCRIPTION Objects of type <> can have a ``position'' that records how much of the file your program has already read. Many of the <> functions depend on this position, and many change it as a side effect. -The result of <> is the current position for a file +The result of <>/<> is the current position for a file identified by <[fp]>. If you record this result, you can later -use it with <> to return the file to this -position. +use it with <>/<> to return the file to this +position. The difference between <> and <> is that +<> returns <> and < returns <>. -In the current implementation, <> simply uses a character +In the current implementation, <>/<> simply uses a character count to represent the file position; this is the same number that would be recorded by <>. RETURNS -<> returns the file position, if possible. If it cannot do -this, it returns <<-1L>>. Failure occurs on streams that do not support +<>/<> return the file position, if possible. If they cannot do +this, they return <<-1L>>. Failure occurs on streams that do not support positioning; the global <> indicates this condition with the value <>. @@ -58,6 +65,8 @@ acceptable as an argument to <>. In particular, other conforming C implementations may return a different result from <> than what <> records. +<> is defined by the Single Unix specification. + No supporting OS subroutines are required. */ diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c new file mode 100644 index 000000000..474c78834 --- /dev/null +++ b/newlib/libc/stdio/ftello.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2002, Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include + +off_t +_DEFUN (ftello, (fp), + register FILE * fp) +{ + /* for now we simply cast since off_t should be long */ + return (off_t)ftell (fp); +} -- cgit v1.2.3