1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 23:35:36 -08:00

funopen(): change seekfn argument to use off_t, not fpos_t

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@
This commit is contained in:
millert 2022-01-05 20:57:27 +00:00
parent 3c1fcd29c8
commit 6a97098401
4 changed files with 12 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $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 $ */
/*-
@ -153,7 +153,7 @@ bool tellwhat = 0;
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 *);
@ -1271,8 +1271,8 @@ writef(void *oreo, const char *buf, int siz)
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);
}

View File

@ -1,4 +1,4 @@
/* $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 $ */
/*-
@ -368,7 +368,7 @@ __BEGIN_DECLS
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)

View File

@ -1,4 +1,4 @@
.\" $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.
@ -29,7 +29,7 @@
.\" 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
@ -42,7 +42,7 @@
.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)"
@ -84,12 +84,7 @@ with the exceptions that they are passed the
.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

View File

@ -1,4 +1,4 @@
/* $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.
@ -38,7 +38,7 @@
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;