Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

library/3236: type of funopen()

From: Kamo Hiroyasu <wd(at)ics.nara-wu.ac.jp>
Date: Fri Apr 25 2003 - 05:30:48 EDT


>Number: 3236
>Category: library
>Synopsis: disagreement among the definition, the declaration, and the document on funopen()
>Confidential: yes
Nara Women's University
>Environment:
        

	System      : OpenBSD 3.2
	Architecture: OpenBSD.sparc
	Machine     : sparc

>Description:
        

The definition, the declaration, and the document disagree on the type of funopen().

In /usr/src/lib/libc/stdio/funopen.c :

	FILE *
	funopen(cookie, readfn, writefn, seekfn, closefn)
		const void *cookie;
		int (*readfn)(), (*writefn)();
		fpos_t (*seekfn)(void *cookie, fpos_t off, int whence);
		int (*closefn)();
	{

In /usr/include/stdio.h :
	FILE	*funopen(const void *,
			int (*)(void *, char *, int),
			int (*)(void *, const char *, int),
			fpos_t (*)(void *, fpos_t, int),
			int (*)(void *));

In the manpage funopen(3):
	     FILE *
	     funopen(void *cookie, int (*readfn)(void *, char *, int),
		     int (*writefn)(void *, const char *, int),
		     fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));

>How-To-Repeat:
        

>Fix:
        

The current implementation discards `const'. So I choose the documentation.

  • src/include/stdio.h Wed Jan 1 04:03:33 2003 +++ src/include/stdio.h Fri Apr 25 18:05:35 2003 @@ -343,7 +343,7 @@
    • Stdio function-access interface. */ __BEGIN_DECLS -FILE *funopen(const void *, +FILE *funopen(void *, int (*)(void *, char *, int), int (*)(void *, const char *, int), fpos_t (*)(void *, fpos_t, int),
  • src/lib/libc/stdio/funopen.c Wed Feb 20 04:39:36 2002 +++ src/lib/libc/stdio/funopen.c Fri Apr 25 18:19:50 2003 @@ -44,10 +44,11 @@

 FILE *
 funopen(cookie, readfn, writefn, seekfn, closefn)

-	const void *cookie;
-	int (*readfn)(), (*writefn)();
+	void *cookie;
+	int (*readfn)(void *cookie, void *buf, size_t nbytes);
+	int (*writefn)(void *cookie, const void *buf, size_t nbytes);
 	fpos_t (*seekfn)(void *cookie, fpos_t off, int whence);
-	int (*closefn)();
+	int (*closefn)(void *cookie);
 {
 	register FILE *fp;
 	int flags;
@@ -68,7 +69,7 @@
 		return (NULL);
 	fp->_flags = flags;
 	fp->_file = -1;
-	fp->_cookie = (void *)cookie;
+	fp->_cookie = cookie;
 	fp->_read = readfn;
 	fp->_write = writefn;
 	fp->_seek = seekfn;

>Release-Note:
Received on Fri Apr 25 05:45:15 2003

Do you need help?X

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:55 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library