Close a Dive stream
void uclose(struct URL *url)
url - Dive stream reference.
uclose closes a Dive stream obtained by the mean of uopen or udopen. Once uclose has been closed, the underlying file descriptor is closed and the reference url becomes invalid.
Associate a Dive stream to a file descriptor.
struct URL *udopen(int fdes)
fdes - File descriptor.
udopen assciates a Dive stream with the file descriptor fdes and return a pointer to the corresponding URL structure. Dive streams ressemble streams in ANSI C and offer a similar set of functions, all starting with "u" instead of "f".
Obtaining a file descriptor, ready for reading, can be done using the function dive_readURL_stream.
uopen, uread, ugets, ugetc, uclose, dive_readURL_stream
Return next character from a Dive stream.
int ugetc(struct URL *url)
url - Dive stream reference.
ugetc return the next character (if it exists) from the opened stream referred by url. The character is returned as an unsigned character converted to an integer. The file pointer within the stream is incremented. EOF is returned at the end of file or upon error.
udopen, uopen, uread, ugets, uungetc
Get a string from a Dive stream.
char *ugets(char *s, int maxlen, struct URL *url)
s - Pointer to receiving character array.
maxlen - Maximum number of character to read.
url - Dive stream reference.
ugets reads characters from the Dive stream referenced by url, into the array pointed by s, until maxlen-1 characters are read or a new-line character is read or an end of line condition is encountered. The new-line character is discarded and the string is terminated with a null character.
If an error occured, NULL is returned, otherwise, s is returned.
Open a local or remote URL and return a Dive stream for reading
struct URL *uopen(char *url)
url - URL top open.
uopen opens the Uniform Resource Locator (URL) named url for reading and associates a Dive stream with it. uopen returns a pointer to the URL structure associated with the stream. Dive streams ressemble streams in ANSI C and offer a similar set of functions, all starting with "u" instead of "f".
udopen, uread, ugets, ugetc, uclose
Binary Input on Dive streams
int uread(void *ptr, int size, int nitems,
struct URL *url)
ptr - Pointer to receiving array.
size - Size of each item to be read, in number of bytes.
nitems - Number of items to be read.
url - URL top open.
uread copies, into an array pointed to by ptr, up to nitems of data from the named input Dive stream url, where an item of data is a sequence of bytes (not necessary terminated by a null byte) of length size. uread stops reading if an end of file or an error condition is encountered or if nitems have been read.
udopen, uopen, ugets, ugetc, uclose
Resolve relative URLs
char *url_resolve_relative(char *base_url,
char *embedded_url)
base_url - String containing the model, URL containing
the other one.
embedded_url - String containing the embedded URL to be resolved.
url_resolve_relative resolve relative URLs, according to the algorithm of the RFC 1808, chapter 4. The base URL base_url is the model on which the embedded_url should be resolved. This function returns a mallocated pointer to a string containing the result of resolution, or NULL if an error was encountered.
Insert back a character in a Dive stream
int uungetc(int c, struct URL *url)
c - Character to put back.
url - URL top open.
uungetc inserts the character c into the buffer associated with an input Dive stream url. Pushed-back characters will be returned by subsequent reads on that stream in the reverse order of their pushing. One character pushback is guaranteed, provided something has already been read from the stream.