tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: fun (not so much) with funopen
On 03/16/12 09:07, Christos Zoulas wrote:
Hello,
As some of you might have noted, recently we changed the API/ABI of funopen(3)
from:
FILE *funopen(const void *cookie,
int (*readf)(void *cookie, char *buf, int len),
int (*writef)(void *cookie, const char *buf, int len),
fpos_t (*seekf)(void *cookie, fpos_t offs, int whence),
to:
FILE *funopen(const void *cookie,
int (*readf)(void *cookie, char *buf, int len),
int (*writef)(void *cookie, const char *buf, int len),
off_t (*seekf)(void *cookie, off_t offs, int whence),
int (*closef)(void *cookie));
int (*closef)(void *cookie));
This change broke both binary and source compatibility with the previous
Bad idea. funopen() needs to be a wrapper around something with the
new functionality. And, as long as you are doing that, it
makes *MUCH* more sense to go with an interface that takes
a ops structure:
struct user_io_ops {
int (*readf)(void *, char *, int);
...
};
extern FILE * uio_fopen(void * cookie, struct user_io_ops*);
inline static FILE *
funopen(const void *cookie,
int (*readf)(void *cookie, char *buf, int len),
int (*writef)(void *cookie, const char *buf, int len),
fpos_t (*seekf)(void *cookie, fpos_t offs, int whence))
{
struct user_io_ops uio = {
.readf = readf, .writef = writef, .seekf = seekf };
return uio_fopen(cookie, &uio);
}
What do you think?
If you're going to break something, then go whole hog and fix it so
you won't have to break the API ever again. :)
Home |
Main Index |
Thread Index |
Old Index