home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / win95 / ext2tool.exe / EXT2FS / IO.H < prev    next >
C/C++ Source or Header  |  1995-05-10  |  2KB  |  76 lines

  1. /*
  2.  * io.h --- the I/O manager abstraction
  3.  * 
  4.  * Copyright (C) 1993 Theodore Ts'o.  This file may be redistributed
  5.  * under the terms of the GNU Public License.
  6.  */
  7.  
  8. /*
  9.  * ext2_loff_t is defined here since unix_io.c needs it.
  10.  */
  11. #if defined(__GNUC__) || defined(HAS_LONG_LONG)
  12. typedef long long    ext2_loff_t;
  13. #else
  14. typedef long        ext2_loff_t;
  15. #endif
  16.  
  17. /* llseek.c */
  18. ext2_loff_t ext2_llseek (unsigned int, ext2_loff_t, unsigned int);
  19.  
  20. typedef struct struct_io_manager *io_manager;
  21. typedef struct struct_io_channel *io_channel;
  22.  
  23. struct struct_io_channel {
  24.     int        magic;
  25.     io_manager    manager;
  26.     char        *name;
  27.     int        block_size;
  28.     errcode_t    (*read_error)(io_channel channel,
  29.                       unsigned long block,
  30.                       int count,
  31.                       void *data,
  32.                       size_t size,
  33.                       int actual_bytes_read,
  34.                       errcode_t    error);
  35.     errcode_t    (*write_error)(io_channel channel,
  36.                        unsigned long block,
  37.                        int count,
  38.                        const void *data,
  39.                        size_t size,
  40.                        int actual_bytes_written,
  41.                        errcode_t error);
  42.     int        reserved[16];
  43.     void        *private_data;
  44. };
  45.  
  46. struct struct_io_manager {
  47.     int magic;
  48.     const char *name;
  49.     errcode_t (*open)(const char *name, int flags, io_channel *channel);
  50.     errcode_t (*close)(io_channel channel);
  51.     errcode_t (*set_blksize)(io_channel channel, int blksize);
  52.     errcode_t (*read_blk)(io_channel channel, unsigned long block,
  53.                   int count, void *data);
  54.     errcode_t (*write_blk)(io_channel channel, unsigned long block,
  55.                    int count, const void *data);
  56.     errcode_t (*flush)(io_channel channel);
  57.     int        reserved[16];
  58. };
  59.  
  60. #define IO_FLAG_RW    1
  61.  
  62. /*
  63.  * Convenience functions....
  64.  */
  65. #define io_channel_close(c)         ((c)->manager->close((c)))
  66. #define io_channel_set_blksize(c,s)    ((c)->manager->set_blksize((c),s))
  67. #define io_channel_read_blk(c,b,n,d)    ((c)->manager->read_blk((c),b,n,d))
  68. #define io_channel_write_blk(c,b,n,d)    ((c)->manager->write_blk((c),b,n,d))
  69. #define io_channel_flush(c)         ((c)->manager->flush((c)))
  70.     
  71. extern io_manager unix_io_manager;
  72.  
  73.  
  74.  
  75.  
  76.