Streaming access for fetching segmented CCNx data. More...
Go to the source code of this file.
Defines | |
#define | CCN_FETCH_READ_ZERO (-3) |
#define | CCN_FETCH_READ_TIMEOUT (-2) |
#define | CCN_FETCH_READ_NONE (-1) |
#define | CCN_FETCH_READ_END (0) |
Enumerations | |
enum | ccn_fetch_flags { ccn_fetch_flags_None = 0, ccn_fetch_flags_NoteGlitch = 1, ccn_fetch_flags_NoteAddRem = 2, ccn_fetch_flags_NoteNeed = 4, ccn_fetch_flags_NoteFill = 8, ccn_fetch_flags_NoteFinal = 16, ccn_fetch_flags_NoteTimeout = 32, ccn_fetch_flags_NoteOpenClose = 64, ccn_fetch_flags_NoteAll = 0xffff } |
Functions | |
struct ccn_fetch * | ccn_fetch_new (struct ccn *h) |
Creates a new ccn_fetch object using the given ccn connection. | |
void | ccn_fetch_set_debug (struct ccn_fetch *f, FILE *debug, ccn_fetch_flags flags) |
Sets the destination for debug output. | |
struct ccn_fetch * | ccn_fetch_destroy (struct ccn_fetch *f) |
Destroys a ccn_fetch object. | |
int | ccn_fetch_poll (struct ccn_fetch *f) |
Polls the underlying streams and attempts to make progress. | |
struct ccn_fetch_stream * | ccn_fetch_next (struct ccn_fetch *f, struct ccn_fetch_stream *fs) |
Provides an iterator through the underlying streams. | |
struct ccn * | ccn_fetch_get_ccn (struct ccn_fetch *f) |
struct ccn_fetch_stream * | ccn_fetch_open (struct ccn_fetch *f, struct ccn_charbuf *name, const char *id, struct ccn_charbuf *interestTemplate, int maxBufs, int resolveVersion, int assumeFixed) |
Creates a stream for a named interest. | |
struct ccn_fetch_stream * | ccn_fetch_close (struct ccn_fetch_stream *fs) |
Closes the stream and reclaims any resources used by the stream. | |
intmax_t | ccn_fetch_avail (struct ccn_fetch_stream *fs) |
Tests for available bytes in the stream. | |
intmax_t | ccn_fetch_read (struct ccn_fetch_stream *fs, void *buf, intmax_t len) |
Reads bytes from a stream. | |
void | ccn_reset_timeout (struct ccn_fetch_stream *fs) |
Resets the timeout indicator, which will cause pending interests to be retried. | |
int | ccn_fetch_seek (struct ccn_fetch_stream *fs, intmax_t pos) |
Seeks to a position in a stream. | |
intmax_t | ccn_fetch_position (struct ccn_fetch_stream *fs) |
Streaming access for fetching segmented CCNx data.
Supports multiple streams from a single connection and seeking to an arbitrary position within the associated file.
Definition in file fetch.h.
#define CCN_FETCH_READ_END (0) |
Definition at line 59 of file fetch.h.
Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().
#define CCN_FETCH_READ_NONE (-1) |
Definition at line 58 of file fetch.h.
Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().
#define CCN_FETCH_READ_TIMEOUT (-2) |
Definition at line 57 of file fetch.h.
Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().
#define CCN_FETCH_READ_ZERO (-3) |
Definition at line 56 of file fetch.h.
Referenced by ccn_fetch_avail(), and ccn_fetch_read().
enum ccn_fetch_flags |
intmax_t ccn_fetch_avail | ( | struct ccn_fetch_stream * | fs | ) |
Tests for available bytes in the stream.
Determines how many bytes can be read on the given stream without waiting (via ccn_fetch_poll).
Definition at line 902 of file ccn_fetch.c.
Referenced by ccn_fetch_poll().
struct ccn_fetch_stream* ccn_fetch_close | ( | struct ccn_fetch_stream * | fs | ) | [read] |
Closes the stream and reclaims any resources used by the stream.
The stream object will be freed, so the client must not access it again.
Definition at line 842 of file ccn_fetch.c.
Referenced by ccn_fetch_destroy(), ElemDone(), and main().
struct ccn_fetch* ccn_fetch_destroy | ( | struct ccn_fetch * | f | ) | [read] |
Destroys a ccn_fetch object.
Only destroys the underlying ccn connection if it was automatically created. Forces all underlying streams to close immediately.
Definition at line 659 of file ccn_fetch.c.
Referenced by main().
struct ccn* ccn_fetch_get_ccn | ( | struct ccn_fetch * | f | ) | [read] |
Definition at line 735 of file ccn_fetch.c.
struct ccn_fetch* ccn_fetch_new | ( | struct ccn * | h | ) | [read] |
Creates a new ccn_fetch object using the given ccn connection.
If h == NULL, attempts to create a new connection automatically.
Definition at line 630 of file ccn_fetch.c.
Referenced by main().
struct ccn_fetch_stream* ccn_fetch_next | ( | struct ccn_fetch * | f, | |
struct ccn_fetch_stream * | fs | |||
) | [read] |
Provides an iterator through the underlying streams.
Use fs == NULL to start the iteration, and an existing stream to continue the iteration.
Definition at line 717 of file ccn_fetch.c.
struct ccn_fetch_stream* ccn_fetch_open | ( | struct ccn_fetch * | f, | |
struct ccn_charbuf * | name, | |||
const char * | id, | |||
struct ccn_charbuf * | interestTemplate, | |||
int | maxBufs, | |||
int | resolveVersion, | |||
int | assumeFixed | |||
) | [read] |
Creates a stream for a named interest.
The name should be a ccnb encoded interest. If resolveVersion, then we assume that the version is unresolved, and an attempt is made to determine the version number using the highest version. If interestTemplate == NULL then a suitable default is used. The max number of buffers (maxBufs) is a hint, and may be clamped to an implementation minimum or maximum. If assumeFixed, then assume that the segment size is given by the first segment fetched, otherwise segments may be of variable size.
The name should be a ccnb encoded interest. If resolveVersion, then we assume that the version is unresolved, and an attempt is made to determine the version number using the highest version. The number of buffers (nBufs) may be silently limited.
Definition at line 750 of file ccn_fetch.c.
int ccn_fetch_poll | ( | struct ccn_fetch * | f | ) |
Polls the underlying streams and attempts to make progress.
Scans the streams for those that have data already present, or are at the end of the stream. If the count is 0, perfoms a ccn_poll on the underlying ccn connection with a 0 timeout.
NOTE: periodic calls to ccn_fetch_poll should be performed to update the contents of the streams UNLESS the client is calling ccn_run for the underlying ccn connection.
Definition at line 693 of file ccn_fetch.c.
Referenced by runTest().
intmax_t ccn_fetch_position | ( | struct ccn_fetch_stream * | fs | ) |
Definition at line 1089 of file ccn_fetch.c.
intmax_t ccn_fetch_read | ( | struct ccn_fetch_stream * | fs, | |
void * | buf, | |||
intmax_t | len | |||
) |
Reads bytes from a stream.
Reads at most len bytes into buf from the given stream. Will not wait for bytes to arrive. Advances the read position on a successful read.
Definition at line 954 of file ccn_fetch.c.
int ccn_fetch_seek | ( | struct ccn_fetch_stream * | fs, | |
intmax_t | pos | |||
) |
Seeks to a position in a stream.
Sets the read position. It is strongly recommended that the seek is only done to a position that is either 0 or has resulted from a successful read. Otherwise end of stream indicators may be returned for a seek beyond the end.
Sets the read position. It is strongly recommended that the seek is only done to a position that is either 0 or has resulted from a successful read. Otherwise end of stream indicators may be returned for a seek beyond the end.
Definition at line 1041 of file ccn_fetch.c.
void ccn_fetch_set_debug | ( | struct ccn_fetch * | f, | |
FILE * | debug, | |||
ccn_fetch_flags | flags | |||
) |
Sets the destination for debug output.
NULL disables debug output.
Definition at line 647 of file ccn_fetch.c.
Referenced by main().
void ccn_reset_timeout | ( | struct ccn_fetch_stream * | fs | ) |
Resets the timeout indicator, which will cause pending interests to be retried.
The client determines conditions for a timeout to be considered an unrecoverable error.
Definition at line 1027 of file ccn_fetch.c.