home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_07 / v7n7084a.txt < prev    next >
Text File  |  1989-09-05  |  3KB  |  58 lines

  1.  
  2. #ifndef BLKIO_H         /* prevent multiple includes */
  3. #define BLKIO_H
  4.  
  5. #include <stddef.h>
  6. #include <stdio.h>
  7.  
  8. /* blkio constants */
  9. #define BOPEN_MAX       FOPEN_MAX       /* max # block files open at once */
  10.  
  11. /* blkio type definitions */
  12. typedef size_t  bpos_t;         /* block file position */
  13.  
  14. typedef struct {                /* block buffer control structure */
  15.         bpos_t bn;              /* block number [1...] */
  16.         int flags;              /* block status flags */
  17.         size_t more;            /* link to more recently used block */
  18.         size_t less;            /* link to less recently used block */
  19. } block_t;
  20.  
  21. typedef struct {                /* block file control structure */
  22.         int fd;                 /* file descriptor */
  23.         int flags;              /* status flags */
  24.         size_t hdrsize;         /* size of file header */
  25.         size_t blksize;         /* size of blocks */
  26.         size_t bufcnt;          /* number blocks to buffer (0 if unbuffered) */
  27.         bpos_t endblk;          /* first block past end of file */
  28.         size_t most;            /* most recently accessed block [1..bufcnt] */
  29.         size_t least;           /* least recently accessed block [1..bufcnt] */
  30.         block_t *block_p;       /* doubly linked list of blocks */
  31.         void *blkbuf;           /* buffer storage for header and blocks */
  32. } BLKFILE;
  33. extern BLKFILE biob[BOPEN_MAX]; /* BLKFILE control struct table declaration */
  34.  
  35. /* block_t flag bits */
  36. #define BLKREAD           (01)  /* block can be read */
  37. #define BLKWRITE          (02)  /* block needs to be written to disk */
  38.  
  39. /* biob flag bits */
  40. #define BIOOPEN           (03)  /* open status bits */
  41. #define BIOREAD           (01)  /* block file is open for reading */
  42. #define BIOWRITE          (02)  /* block file is open for writing */
  43. #define BIOUSRBUF         (04)  /* user supplied buffer */
  44.  
  45. /* block file error codes */
  46. #define BEOS            (0)             /* start of blkio error code domain */
  47. #define BEMFILE         (BEOS - 1)      /* too many block files open */
  48. #define BENOPEN         (BEOS - 2)      /* block file is not open */
  49. #define BENBUF          (BEOS - 3)      /* buffering is off */
  50. #define BEBUF           (BEOS - 4)      /* buffering is on */
  51. #define BEBOUND         (BEOS - 5)      /* block boundary error */
  52. #define BEEOF           (BEOS - 6)      /* past end of file */
  53. #define BENFL           (BEOS - 7)      /* no free list */
  54. #define BEPANIC         (BEOS - 10)     /* internal blkio error */
  55.  
  56. #endif  /* #ifndef BLKIO_H */
  57.  
  58.