On BSD, fpos_t is typedef'd to off_t but some systems use a struct.
This means fpos_t is not a portable function argument or return value.
Both FreeBSD and the Linux libbsd funopen() have switched to off_t
for this--we should too. From Joe Nelson. OK deraadt@
-/* $OpenBSD: csh.c,v 1.47 2020/08/30 22:23:47 mortimer Exp $ */
+/* $OpenBSD: csh.c,v 1.48 2022/01/05 20:57:27 millert Exp $ */
/* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */
/*-
extern char **environ;
static int readf(void *, char *, int);
-static fpos_t seekf(void *, fpos_t, int);
+static off_t seekf(void *, off_t, int);
static int writef(void *, const char *, int);
static int closef(void *);
static int srccat(Char *, Char *);
return write(DESC(oreo), buf, siz);
}
-static fpos_t
-seekf(void *oreo, fpos_t off, int whence)
+static off_t
+seekf(void *oreo, off_t off, int whence)
{
return lseek(DESC(oreo), off, whence);
}
-/* $OpenBSD: stdio.h,v 1.54 2020/09/11 17:56:41 naddy Exp $ */
+/* $OpenBSD: stdio.h,v 1.55 2022/01/05 20:57:27 millert Exp $ */
/* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */
/*-
FILE *funopen(const void *,
int (*)(void *, char *, int),
int (*)(void *, const char *, int),
- fpos_t (*)(void *, fpos_t, int),
+ off_t (*)(void *, off_t, int),
int (*)(void *));
__END_DECLS
#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
-.\" $OpenBSD: funopen.3,v 1.18 2015/11/04 21:30:13 tedu Exp $
+.\" $OpenBSD: funopen.3,v 1.19 2022/01/05 20:57:27 millert Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: November 4 2015 $
+.Dd $Mdocdate: January 5 2022 $
.Dt FUNOPEN 3
.Os
.Sh NAME
.Ft FILE *
.Fn funopen "const void *cookie" "int (*readfn)(void *, char *, int)" \
"int (*writefn)(void *, const char *, int)" \
- "fpos_t (*seekfn)(void *, fpos_t, int)" \
+ "off_t (*seekfn)(void *, off_t, int)" \
"int (*closefn)(void *)"
.Ft FILE *
.Fn fropen "const void *cookie" "int (*readfn)(void *, char *, int)"
.Fa cookie
argument specified to
.Fn funopen
-in place of the traditional file descriptor argument and that
-the seek function takes an
-.Li fpos_t
-argument and not an
-.Li off_t
-argument.
+in place of the traditional file descriptor argument.
.Pp
Read and write I/O functions are allowed to change the underlying buffer
on fully buffered or line buffered streams by calling
-/* $OpenBSD: funopen.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: funopen.c,v 1.10 2022/01/05 20:57:27 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
FILE *
funopen(const void *cookie, int (*readfn)(void *, char *, int),
int (*writefn)(void *, const char *, int),
- fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *))
+ off_t (*seekfn)(void *, off_t, int), int (*closefn)(void *))
{
FILE *fp;
int flags;