www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2007/08/03/18:00:13.1

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1/8/SBIJIb8yf5ugT5abtU6QkoeNUtgDAe33lDvdK
DyKIS3eYme5rzs
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: Re: fseeko and ftello
User-Agent: KMail/1.9.5
MIME-Version: 1.0
Date: Sat, 4 Aug 2007 00:05:08 +0200
Message-Id: <200708040005.08488.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

>> fseeko() and ftello() are both declared in stdio.h an require off_t, so I
>> have replaced the inclusion of djtypes.h with types.h in stdio.h.  If this
>> is not wanted/correct, please let me know how to solve the issue.
>
> Nope, what you want to do is add a __DJ_off_t chunk to stdio much like
> there already is for __DJ_size_t.  As per ISO specs, headers can't
> include each other, so we use things like djtypes.h to stay properly
> namespace-clean.

OK. I hope this time the thing is a lttle bit better.


2007-08-03  Juan Manuell Guerrero  <juan DOT guerrero AT gmx DOT de>

	* include/stdio.h: Declaration of fseeko and ftello and
	__DJ_off_t definition added.
	* src/docs/kb/wc204.txi: Add fseeko and ftello reference.
	* src/libc/ansi/stdio/fseeko.c: Definition of fseeko.
	* src/libc/ansi/stdio/fseeko.txh: Function description added.
	* src/libc/ansi/stdio/ftello.c: Definition of ftello.
	* src/libc/ansi/stdio/ftello.txh: Function description added.
	* src/libc/ansi/stdio/makefile: Add fseeko and ftello.


diff -aprNU3 djgpp.orig/include/stdio.h djgpp/include/stdio.h
--- djgpp.orig/include/stdio.h	2007-08-03 19:57:48 +0000
+++ djgpp/include/stdio.h	2007-08-03 22:55:46 +0000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2007 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
@@ -41,6 +42,11 @@ __DJ_va_list
 #define _VA_LIST
 #endif
 
+#ifndef _OFF_T
+__DJ_off_t
+#define _OFF_T
+#endif
+
 #ifndef _SIZE_T
 __DJ_size_t
 #define _SIZE_T
@@ -89,8 +95,10 @@ size_t	fread(void *_ptr, size_t _size, s
 FILE *	freopen(const char *_filename, const char *_mode, FILE *_stream);
 int	fscanf(FILE *_stream, const char *_format, ...);
 int	fseek(FILE *_stream, long _offset, int _mode);
+int	fseeko(FILE *_stream, off_t _offset, int _mode);
 int	fsetpos(FILE *_stream, const fpos_t *_pos);
 long	ftell(FILE *_stream);
+off_t	ftello(FILE *_stream);
 size_t	fwrite(const void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
 int	getc(FILE *_stream);
 int	getchar(void);
diff -aprNU3 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi
--- djgpp.orig/src/docs/kb/wc204.txi	2005-05-11 20:06:08 +0000
+++ djgpp/src/docs/kb/wc204.txi	2007-08-03 22:51:12 +0000
@@ -1094,3 +1094,8 @@ formats for @code{"%x"} and @code{"%X"} 
 
 @pindex djasm AT r{, cr4 register}
 @code{djasm} recognises the fourth control register, @code{cr4}.
+
+@findex fseeko
+@findex ftello
+Functions @code{fseeko} and @code{ftello} added.
+
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/fseeko.c djgpp/src/libc/ansi/stdio/fseeko.c
--- djgpp.orig/src/libc/ansi/stdio/fseeko.c	1970-01-01 00:00:00 +0000
+++ djgpp/src/libc/ansi/stdio/fseeko.c	2007-08-03 22:51:12 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2007 DJ Delorie, see COPYING.DJ for details */
+#include <stdio.h>
+
+int
+fseeko(FILE *f, off_t offset, int ptrname)
+{
+  /*  As long as off_t is equal long, a cast should be enough.  */
+
+  return fseek(f, (long)offset, ptrname);
+}
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/fseeko.txh djgpp/src/libc/ansi/stdio/fseeko.txh
--- djgpp.orig/src/libc/ansi/stdio/fseeko.txh	1970-01-01 00:00:00 +0000
+++ djgpp/src/libc/ansi/stdio/fseeko.txh	2007-08-03 22:51:12 +0000
@@ -0,0 +1,51 @@
+@node fseeko, stdio
+@findex fseeko
+@subheading Syntax
+
+@example
+#include <stdio.h>
+
+int fseeko(FILE *file, off_t offset, int mode);
+@end example
+
+@subheading Description
+
+The @code{fseeko} function is equivalent to the @code{fseek}
+function except that the @var{offset} argument is of type off_t.
+This function moves the file pointer for @var{file} according to
+@var{mode}:
+
+@table @code
+
+@item SEEK_SET
+
+The file pointer is moved to the offset specified.
+
+@item SEEK_CUR
+
+The file pointer is moved relative to its current position.
+
+@item SEEK_END
+
+The file pointer is moved to a position @var{offset} bytes from the end
+of the file.  The offset is usually nonpositive in this case. 
+
+@end table
+
+For further information see the documentation for the @code{fseek} function
+(@pxref{fseek}).
+
+@subheading Return Value
+
+Zero if successful, nonzero if not. 
+
+@subheading Portability
+
+@portability ansi, posix
+
+@subheading Example
+
+@example
+fseeko(stdin, 12, SEEK_CUR); /* skip 12 bytes */
+@end example
+
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/ftello.c djgpp/src/libc/ansi/stdio/ftello.c
--- djgpp.orig/src/libc/ansi/stdio/ftello.c	1970-01-01 00:00:00 +0000
+++ djgpp/src/libc/ansi/stdio/ftello.c	2007-08-03 22:51:12 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2007 DJ Delorie, see COPYING.DJ for details */
+#include <stdio.h>
+
+off_t
+ftello(FILE *f)
+{
+  /*  As long as off_t is equal long, a cast should be enough.  */
+
+  return (off_t)ftell(f);
+}
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/ftello.txh djgpp/src/libc/ansi/stdio/ftello.txh
--- djgpp.orig/src/libc/ansi/stdio/ftello.txh	1970-01-01 00:00:00 +0000
+++ djgpp/src/libc/ansi/stdio/ftello.txh	2007-08-03 22:51:12 +0000
@@ -0,0 +1,33 @@
+@node ftello, stdio
+@findex ftello
+@subheading Syntax
+
+@example
+#include <stdio.h>
+
+off_t ftello(FILE *file);
+@end example
+
+@subheading Description
+The @code{ftello} function is equivalent to the @code{ftell}
+function except that the return value is of type off_t.
+Returns the current file position for @code{file}.  This is suitable for
+a future call to @code{fseeko}.
+
+For further information see the documentation for the @code{ftell} function
+(@pxref{ftell}).
+
+@subheading Return Value
+
+The file position, or -1 on error. 
+
+@subheading Portability
+
+@portability ansi, posix
+
+@subheading Example
+
+@example
+off_t p = ftello(stdout);
+@end example
+
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/makefile djgpp/src/libc/ansi/stdio/makefile
--- djgpp.orig/src/libc/ansi/stdio/makefile	2001-05-21 20:25:48 +0000
+++ djgpp/src/libc/ansi/stdio/makefile	2007-08-03 22:51:12 +0000
@@ -1,3 +1,4 @@
+# Copyright (C) 2007 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
@@ -25,8 +26,10 @@ SRC += freopen.c
 SRC += frlist.c
 SRC += fscanf.c
 SRC += fseek.c
+SRC += fseeko.c
 SRC += fsetpos.c
 SRC += ftell.c
+SRC += ftello.c
 SRC += fwalk.c
 SRC += fwrite.c
 SRC += getc.c

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019