Logo Search packages:      
Sourcecode: bar version File versions  Download package


 * I/O and buffering

#ifndef __io_h__
#define __io_h__

#include "headers.h"
#include "types.h"

/** I/O */
00012 struct _io {
      /** Input path, if given on the command line.  This is used when copying a
       * file into a directory, the base filename of the input file is used as the
       * filename in the destination directory, so we need to keep it around. */
00016       char *in_path;
      /** Input file descriptor. */
00018       int in;
      /** Output file descriptor. */
00020       int out;
      /** Flag: Input source is ready to be read. */
00022       int in_ready;
      /** Flag: Output source is ready to be written to. */
00024       int out_ready;
      /** Flag: End of input has been reached. */
00026       int eof_in;
      /** Flag: End of output has been reached. */
00028       int eof_out;
      /** The size of the I/O buffer. */
00030       size_t buffer_size;
      /** A pointer to the I/O buffer. */
00032       char *buffer;
      /** The location of the start of the ring buffer. */
00034       size_t buffer_head;
      /** The length of the ring buffer. */
00036       size_t buffer_used;
      /** The number of bytes read the last time I/O was performed. */
00038       ssize_t last_read;
      /** The number of bytes written the last time I/O was performed. */
00040       ssize_t last_write;
      /** The total number of bytes read. */
00042       uint64 total_read;
      /** The total number of bytes written. */
00044       uint64 total_write;
      /** The total size of the input stream, if known. */
00046       uint64 total_size;
      /** If continuing from a previously interrupted stream, assume that this
       * many bytes have already been read and written. */
00049       uint64 continue_size;
      /** Flag: Whether or not the total size of the input stream is known. */
00051       int total_size_known;
      /** The number of microseconds to wait for a change in I/O state. */
00053       uint32 timeout;
      /** The current time, used for throttling input. */
00055       time_t current_time;
      /** The maximum number of bytes per second that we're allowed to read. */
00057       uint64 throttle;
      /** The number if bytes read so far for this second. */
00059       uint64 throttle_count;
      /** The size of a block in bytes, used for calculating total_size and
       * buffer_size. */
00062       uint64 block_size;

typedef struct _io IO;

extern IO io;

int ioInit(void);
int ioBegin(void);
int ioEnd(void);
void ioCheck(void);
int ioRead(void);
int ioWrite(void);
int ioIsDone(void);


Generated by  Doxygen 1.6.0   Back to index