On Thu, Oct 12, 2000 at 11:46:59PM +0100, Nick Ing-Simmons wrote:
> It is late and I will respond again tomorrow but I think 
> we need the table of functions to include:
> 
>     read   - give me N bytes (with a magic "as much as is to hand" value)
>     unread - take these bytes back
>     seek   - move to X (from start, here, end as usual) 
>     flush  - 
> 
> on write side it is simpler 'cos I have not thought about it as much
>     write
>     seek
>     flush  - wait for drain etc.
>     eof    - that's all folks
>   (and maybe "purge" = "forget what I told you we are in trouble").


/* Definitions for file objects and discipline stacks */

#ifndef _SYS_TYPES_H
#include <sys/types.h>
#endif

#define BUFFSIZE 1024

typedef struct _IOLayer IOLayer;

struct {
    IOLayer* next;
    IOLayer* prev; /* Has to be doubly linked. */
    unsigned char id; /* Top two bits are layer, bottom 6 are sequence no. */
    char** buff;
    unsigned int buffsize;

    void* (*Layer_read)();
    void* (*Layer_write)();
    void* (*Layer_lseek)();
    void* (*Layer_tell)();
    off_t Layer_where;
} _IOLayer;

typedef struct {
    int filedes;
    char flags;
    
    /* System IO layer */
    void* (*File_read)();
    void* (*File_write)();
    void* (*File_lseek)();
    void* (*File_tell)();
    off_t File_where;

    char** buff;
    unsigned int buffsize;
    IOLayer* discipline[3]; /* Transformation layers */
} FileObject;


-- 
BEWARE!  People acting under the influence of human nature.

Reply via email to