Xref: utzoo comp.lang.c:31674 alt.lang.cfutures:47 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!midway!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c,alt.lang.cfutures Subject: Re: STDIO (Re: TRUE and FALSE) Message-ID: <26431@mimsy.umd.edu> Date: 7 Sep 90 21:43:28 GMT References: <17632@haddock.ima.isc.com> <38Q5QG2@xds13.ferranti.com> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 35 In article stephen@estragon.uchicago.edu (Stephen P Spackman) writes: >Another thing that is needed is a function > FILE *pseudof > ( int (*producer)(void *handle, char *buf, size_t len) > , int (*consumer)(void *handle, char const *buf, size_t len) > , void *handle > , char const *mode > ); > >that takes USER-DEFINED buffer readers and writers and makes a "FILE" >object. Gee, you mean like this one? :-) FILE *funopen(const void *_cookie, int (*readfn)(void *_cookie, char *_buf, int _n), int (*writefn)(void *_cookie, const char *_buf, int _n), fpos_t (*seekfn)(void *_cookie, fpos_t _off, int _whence), int (*closefn)(void *_cookie)); >That signature needs further thought - maybe it needs a flush/close >function as well, e.g.; but it's not so far away. No flush function is required, but seek and close functions are. No `mode' is required either; this is implicit in the arguments. (At least one of readfn and writefn must be non nil; if both are, the function is a read-and-write. All operations are `binary'; any `text' conversion must be done in the read/write operations.) This is running in the stdio on my 4.3BSD-reno-ish machine. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris