X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/4dfa55222d1fe433a6f5e0e8c67b1168a9cb1ee3..34b3f7e677dad923311b69d88e176e09686957ff:/iolayer.h diff --git a/iolayer.h b/iolayer.h index a17d0cec..ac49727d 100644 --- a/iolayer.h +++ b/iolayer.h @@ -32,35 +32,37 @@ typedef enum { FDSEEK, FDNOSEEK, BUFFER, CBSEEK, CBNOSEEK, BUFCHAIN } io_type; typedef int ssize_t; #endif -struct _io_glue; +struct io_glue; /* Callbacks we give out */ -typedef ssize_t(*readp) (struct _io_glue *ig, void *buf, size_t count); -typedef ssize_t(*writep)(struct _io_glue *ig, const void *buf, size_t count); -typedef off_t (*seekp) (struct _io_glue *ig, off_t offset, int whence); -typedef void (*closep)(struct _io_glue *ig); -typedef ssize_t(*sizep) (struct _io_glue *ig); +typedef ssize_t(*readp) (struct io_glue *ig, void *buf, size_t count); +typedef ssize_t(*writep)(struct io_glue *ig, const void *buf, size_t count); +typedef off_t (*seekp) (struct io_glue *ig, off_t offset, int whence); +typedef void (*closep)(struct io_glue *ig); +typedef ssize_t(*sizep) (struct io_glue *ig); typedef void (*closebufp)(void *p); /* Callbacks we get */ -typedef ssize_t(*readl) (int fd, void *buf, size_t count); -typedef ssize_t(*writel)(int fd, const void *buf, size_t count); -typedef off_t (*seekl) (int fd, off_t offset, int whence); -typedef ssize_t(*sizel) (int fd); +typedef ssize_t(*readl) (void *p, void *buf, size_t count); +typedef ssize_t(*writel)(void *p, const void *buf, size_t count); +typedef off_t (*seekl) (void *p, off_t offset, int whence); +typedef void (*closel)(void *p); +typedef void (*destroyl)(void *p); +typedef ssize_t(*sizel) (void *p); extern char *io_type_names[]; -typedef struct _io_blink { +typedef struct io_blink { char buf[BBSIZ]; /* size_t cnt; */ size_t len; /* How large is this buffer = BBZIS for now */ - struct _io_blink *next; - struct _io_blink *prev; + struct io_blink *next; + struct io_blink *prev; } io_blink; @@ -122,6 +124,8 @@ typedef struct { readl readcb; writel writecb; seekl seekcb; + closel closecb; + destroyl destroycb; } io_cb; typedef union { @@ -131,7 +135,7 @@ typedef union { io_cb cb; } io_obj; -typedef struct _io_glue { +typedef struct io_glue { io_obj source; int flags; /* Flags */ void *exdata; /* Pair specific data */ @@ -144,6 +148,7 @@ typedef struct _io_glue { void io_obj_setp_buffer(io_obj *io, char *p, size_t len, closebufp closecb, void *closedata); void io_obj_setp_cb (io_obj *io, void *p, readl readcb, writel writecb, seekl seekcb); +void io_obj_setp_cb2 (io_obj *io, void *p, readl readcb, writel writecb, seekl seekcb, closel closecb, destroyl destroycb); void io_glue_commit_types(io_glue *ig); void io_glue_gettypes (io_glue *ig, int reqmeth); @@ -152,7 +157,8 @@ void io_glue_gettypes (io_glue *ig, int reqmeth); io_glue *io_new_fd(int fd); io_glue *io_new_bufchain(void); io_glue *io_new_buffer(char *data, size_t len, closebufp closecb, void *closedata); +io_glue *io_new_cb(void *p, readl readcb, writel writecb, seekl seekcb, closel closecb, destroyl destroycb); size_t io_slurp(io_glue *ig, unsigned char **c); -void io_glue_DESTROY(io_glue *ig); +void io_glue_DESTROY(io_glue *ig); #endif /* _IOLAYER_H_ */