slimlib.cpp File Reference

The C-linkable sliblib library that wraps the underlying C++ classes. More...

#include "slimlib.h"
#include "slim.h"
#include <string.h>

Classes

struct  slimlib_file_t
 All important elements of the SLIMFILE. More...

Typedefs

typedef struct slimlib_file_t SLIMFILE
 The external name is SLIMFILE.

Enumerations

enum  slimlib_mode_t { SLIMLIB_READ, SLIMLIB_WRITE }
 Select the read/write mode. More...

Functions

SLIMFILEslimopen (const char *filename, const char *modes)
 The following symbols need to be linkable from C.
int slimclose (SLIMFILE *sf)
 Close an open SLIMFILE.
long slimtell (SLIMFILE *sf)
 Return the current position in the file (bytes from the start).
size_t slimread (void *ptr, size_t size, size_t nmemb, SLIMFILE *sf)
 Read bytes from open SLIMFILE into a buffer.
void slimrewind (SLIMFILE *sf)
 Rewind the current position pointer in the file to the beginning.
int slimseek (SLIMFILE *sf, long offset, int whence)
 Seek to a point in the file (analogue of fseek, which see for meaning of offset and whence).
long slimrawsize (const char *filename)
 Return the raw size of a compressed slim file.


Detailed Description

The C-linkable sliblib library that wraps the underlying C++ classes.


Enumeration Type Documentation

Select the read/write mode.

Enumerator:
SLIMLIB_READ  This SLIMFILE object is for reading slim data.
SLIMLIB_WRITE  This SLIMFILE object is for writing slim data.


Function Documentation

int slimclose ( SLIMFILE sf  ) 

Close an open SLIMFILE.

Parameters:
sf The open SLIMFILE.

References slimlib_file_t::compressor, slimlib_file_t::expander, and slimlib_file_t::filename.

Referenced by slimopen().

SLIMFILE* slimopen ( const char *  filename,
const char *  modes 
)

The following symbols need to be linkable from C.

Open a SLIMFILE for reading or writing. Writing is NOT YET IMPLEMENTED!

Parameters:
filename The file to open.
modes Modes codes as in fopen. Only "r" or "w" are used.
Returns:
The open SLIMFILE, or NULL if opening fails.

References slimlib_file_t::bytes_used, slimlib_file_t::compressor, slimlib_file_t::expander, slimlib_file_t::filename, slimlib_file_t::mode, slimlib_file_t::nchan, slimlib_file_t::nframes, slimclose(), SLIMLIB_READ, SLIMLIB_WRITE, and slimlib_file_t::writing_is_underway.

long slimrawsize ( const char *  filename  ) 

Return the raw size of a compressed slim file.

Must open the file and read its header.

Parameters:
filename The file to test by reading its header.

Referenced by slimseek().

size_t slimread ( void *  ptr,
size_t  size,
size_t  nmemb,
SLIMFILE sf 
)

Read bytes from open SLIMFILE into a buffer.

Parameters:
ptr Buffer to be filled by data from file.
size Size of each data word (in bytes).
nmemb Number of data words to read.
sf Open SLIMFILE to read from.
Returns:
Number of words actually read. This will be 0 if slim raises an error.

References slimlib_file_t::bytes_used, and slimlib_file_t::expander.

void slimrewind ( SLIMFILE sf  ) 

Rewind the current position pointer in the file to the beginning.

Implemented by closing the file and starting again.

Parameters:
sf The open SLIMFILE.

References slimlib_file_t::bytes_used, slimlib_file_t::expander, slimlib_file_t::filename, slimlib_file_t::mode, and SLIMLIB_READ.

Referenced by slimseek().

int slimseek ( SLIMFILE sf,
long  offset,
int  whence 
)

Seek to a point in the file (analogue of fseek, which see for meaning of offset and whence).

Parameters:
sf The open SLIMFILE.
offset Byte requested, relative to beginning, current point, or end.
whence May be SEEK_SET, SEEK_CUR, or SEEK_END.
Returns:
0 on success, -1 on error.

References slimlib_file_t::bytes_used, slimlib_file_t::expander, slimlib_file_t::filename, slimrawsize(), and slimrewind().

long slimtell ( SLIMFILE sf  ) 

Return the current position in the file (bytes from the start).

Parameters:
sf The open SLIMFILE.

References slimlib_file_t::bytes_used.


Generated on Mon Jun 15 14:43:59 2009 for Slim numerical data compression by  doxygen 1.5.8