Slim numerical data compression  1.0
Classes | Typedefs | Enumerations | Functions
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:
sfThe 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. But as of October 2009, writing is NOT YET IMPLEMENTED!

Parameters:
filenameThe file to open.
modesModes codes as in fopen. Only "r" or "w" are used. At present, only "r" is allowed.
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:
filenameThe 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:
ptrBuffer to be filled by data from file.
sizeSize of each data word (in bytes).
nmembNumber of data words to read.
sfOpen 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:
sfThe 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:
sfThe open SLIMFILE.
offsetByte requested, relative to beginning, current point, or end.
whenceMay 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:
sfThe open SLIMFILE.

References slimlib_file_t::bytes_used.