#include <stdlib.h>
#include "rdd.h"
#include "reader.h"
Go to the source code of this file.
Functions | |
int | rdd_new_reader (RDD_READER **self, RDD_READ_OPS *ops, unsigned statesize) |
Allocates and partially initializes a reader object. | |
int | rdd_reader_close (RDD_READER *r, int recurse) |
Closes and deallocates the reader object. | |
int | rdd_reader_read (RDD_READER *r, unsigned char *buf, unsigned nbyte, unsigned *nread) |
Generic read routine. | |
int | rdd_reader_seek (RDD_READER *r, rdd_count_t pos) |
Updates the current file position. | |
int | rdd_reader_skip (RDD_READER *r, rdd_count_t skip) |
Moves the file pointer skip bytes forward. | |
int | rdd_reader_tell (RDD_READER *r, rdd_count_t *pos) |
Returns the current file position in bytes. | |
Variables | |
static char | copyright [] |
int rdd_new_reader | ( | RDD_READER ** | r, | |
RDD_READ_OPS * | ops, | |||
unsigned | statesize | |||
) |
Allocates and partially initializes a reader object.
r | output value: a new reader object. | |
ops | pointers to implementation-specific reader functions. | |
statesize | size in bytes of implementation-specific state. |
RDD_OK
on success. Returns RDD_NOMEM
when there is insufficient memory to allocate the reader object or its state buffer.rdd_new_reader
allocates a reader object and initializes its ops
field to argument . The state
field is set to point to a new buffer (allocated with malloc()
) with size statesize
. The state buffer is zeroed.
Definition at line 50 of file reader.c.
References _RDD_READER::ops, RDD_BADARG, RDD_NOMEM, RDD_OK, and _RDD_READER::state.
int rdd_reader_close | ( | RDD_READER * | r, | |
int | recurse | |||
) |
Closes and deallocates the reader object.
r | pointer to the reader object. | |
recurse | recursive-close flag |
recurse
is nonzero.
Definition at line 107 of file reader.c.
References _RDD_READ_OPS::close, _RDD_READER::ops, RDD_OK, and _RDD_READER::state.
int rdd_reader_read | ( | RDD_READER * | r, | |
unsigned char * | buf, | |||
unsigned | nbyte, | |||
unsigned * | nread | |||
) |
Generic read routine.
r | pointer to the reader object. | |
buf | pointer to the target buffer; the size of this buffer must be at least nbyte bytes. | |
nbyte | the number of bytes to read | |
nread | output value: the number of bytes actually read; the value in *read is valid only if RDD_OK is returned. |
*nread
will be equal to nbyte
except when there are fewer than nbyte
bytes left until the end of the file is reached. In that case *nread
will be equal to the number of bytes left. If *nread
equals 0
, then end-of-file has been reached. Definition at line 71 of file reader.c.
References _RDD_READER::ops, and _RDD_READ_OPS::read.
int rdd_reader_seek | ( | RDD_READER * | r, | |
rdd_count_t | pos | |||
) |
Updates the current file position.
r | pointer to the reader object. | |
pos | the new (absolute) file position in bytes. |
seek()
routine.
Definition at line 84 of file reader.c.
References _RDD_READER::ops, and _RDD_READ_OPS::seek.
int rdd_reader_skip | ( | RDD_READER * | r, | |
rdd_count_t | skip | |||
) |
Moves the file pointer skip
bytes forward.
r | pointer to the reader object. | |
skip | the number of bytes to move forward. |
skip()
routine.
Definition at line 90 of file reader.c.
References RDD_OK, rdd_reader_seek(), and rdd_reader_tell().
int rdd_reader_tell | ( | RDD_READER * | r, | |
rdd_count_t * | pos | |||
) |
Returns the current file position in bytes.
r | pointer to the reader object. | |
pos | output value: the current file position in bytes. The value in *pos is valid only if RDD_OK is returned. |
Definition at line 78 of file reader.c.
References _RDD_READER::ops, and _RDD_READ_OPS::tell.
char copyright[] [static] |