libBigWig
 All Data Structures Files Functions Variables Enumerations Enumerator Pages
Functions
io.c File Reference
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "io.h"

Functions

CURLcode urlFetchData (URL_t *URL)
 
size_t url_fread (void *obuf, size_t obufSize, URL_t *URL)
 
size_t urlRead (URL_t *URL, void *buf, size_t bufSize)
 Reads data into the given buffer. More...
 
CURLcode urlSeek (URL_t *URL, size_t pos)
 Seeks to a given position in a local or remote file. More...
 
URL_turlOpen (char *fname)
 
void urlClose (URL_t *URL)
 
int bwSetPos (bigWigFile_t *fp, size_t pos)
 
size_t bwRead (void *data, size_t sz, size_t nmemb, bigWigFile_t *fp)
 
void bwClose (bigWigFile_t *fp)
 
int bwInit (size_t defaultBufSize, int nFetchIterations, unsigned int nSeconds)
 
void bwCleanup ()
 

Function Documentation

void bwCleanup ( )
void bwClose ( bigWigFile_t fp)
int bwInit ( size_t  defaultBufSize,
int  nFetchIterations,
unsigned int  nSeconds 
)
size_t bwRead ( void *  data,
size_t  sz,
size_t  nmemb,
bigWigFile_t fp 
)
int bwSetPos ( bigWigFile_t fp,
size_t  pos 
)
size_t url_fread ( void *  obuf,
size_t  obufSize,
URL_t URL 
)
void urlClose ( URL_t URL)
CURLcode urlFetchData ( URL_t URL)
URL_t* urlOpen ( char *  fname)
size_t urlRead ( URL_t URL,
void *  buf,
size_t  bufSize 
)

Reads data into the given buffer.

This function will store bufSize data into buf for both local and remote files. For remote files an internal buffer is used to store a (typically larger) segment of the remote file.

Parameters
URLA URL_t * pointing to a valid opened file or remote URL.
bufThe buffer in memory that you would like filled. It must be able to hold bufSize bytes!
bufSizeThe number of bytes to transfer to buf.
Returns
Returns the number of bytes stored in buf, which should be bufSize on success and something else on error.
Warning
Note that on error, URL for remote files is left in an unusable state. You can get around this by running urlSeek() to a position outside of the range held by the internal buffer.
CURLcode urlSeek ( URL_t URL,
size_t  pos 
)

Seeks to a given position in a local or remote file.

For local files, this will set the file position indicator for the file pointer to the desired position. For remote files, it sets the position to start downloading data for the next urlRead(). Note that for remote files that running urlSeek() with a pos within the current buffer will simply modify the internal offset.

Returns
CURLE_OK on success and a different CURLE_XXX on error. For local files, the error return value is always CURLE_FAILED_INIT