libmseed 3.1.3
The miniSEED data format library
Loading...
Searching...
No Matches
General Utility Functions

General utilities. More...

Macros

#define ms_dabs(val)   fabs(val)
 

Functions

uint8_t ms_samplesize (char sampletype)
 Determine data sample size for each type.
 
int ms_encoding_sizetype (uint8_t encoding, uint8_t *samplesize, char *sampletype)
 Return sample size and/or type for given encoding value.
 
const char * ms_encodingstr (uint8_t encoding)
 Descriptive string for data encodings.
 
const char * ms_errorstr (int errorcode)
 Descriptive string for library Return codes.
 
nstime_t ms_sampletime (nstime_t time, int64_t offset, double samprate)
 Calculate the time of a sample in an array.
 
int ms_bigendianhost (void)
 Runtime test for host endianess.
 
int64_t lmp_ftell64 (FILE *stream)
 
int lmp_fseek64 (FILE *stream, int64_t offset, int whence)
 
uint64_t lmp_nanosleep (uint64_t nanoseconds)
 
uint32_t ms_crc32c (const uint8_t *input, int length, uint32_t previousCRC32C)
 

Detailed Description

General utilities.

Macro Definition Documentation

◆ ms_dabs

#define ms_dabs ( val)    fabs(val)

DEPRECATED legacy implementation of fabs(), now a macro

Function Documentation

◆ ms_samplesize()

uint8_t ms_samplesize ( char sampletype)
extern

Determine data sample size for each type.

Parameters
[in]sampletypeLibrary sample type code:
  • 't' - Text data type
  • 'i' - 32-bit integer data type
  • 'f' - 32-bit float data type
  • 'd' - 64-bit float (double) data type
Returns
The sample size based on type code or 0 for unknown.

◆ ms_encoding_sizetype()

int ms_encoding_sizetype ( uint8_t encoding,
uint8_t * samplesize,
char * sampletype )
extern

Return sample size and/or type for given encoding value.

Determine the decoded sample size and/or type based on data encoding. The samplesize and sampletype values will only be set if not NULL, allowing lookup of either value or both.

Parameters
[in]encodingData sample encoding code
[out]samplesizeSize of sample, pointer that will be set
[out]sampletypeSample type, pointer to char that will be set
Returns
0 on success, -1 on error

◆ ms_encodingstr()

const char * ms_encodingstr ( uint8_t encoding)
extern

Descriptive string for data encodings.

Parameters
[in]encodingData sample encoding code
Returns
a string describing a data encoding format

◆ ms_errorstr()

const char * ms_errorstr ( int errorcode)
extern

Descriptive string for library Return codes.

Parameters
[in]errorcodeLibrary error code
Returns
a string describing the library error code or NULL if the code is unknown.

◆ ms_sampletime()

nstime_t ms_sampletime ( nstime_t time,
int64_t offset,
double samprate )
extern

Calculate the time of a sample in an array.

Given a time, sample offset and sample rate/period calculate the time of the sample at the offset.

If samprate is negative the negated value is interpreted as a sample period in seconds, otherwise the value is assumed to be a sample rate in Hertz.

If leap seconds have been loaded into the internal library list: when a time span, from start to offset, completely contains a leap second, starts before and ends after, the calculated sample time will be adjusted (reduced) by one second.

Note
On the epoch time scale the value of a leap second is the same as the second following the leap second, without external information the values are ambiguous.
See also
ms_readleapsecondfile()
Parameters
[in]timeTime value for first sample in array
[in]offsetOffset of sample to calculate time of
[in]samprateSample rate (when positive) or period (when negative)
Returns
Time of the sample at specified offset

◆ ms_bigendianhost()

int ms_bigendianhost ( void )
externinline

Runtime test for host endianess.

Returns
0 if the host is little endian, otherwise 1.

◆ lmp_ftell64()

int64_t lmp_ftell64 ( FILE * stream)
extern

Portable version of POSIX ftello() to get file position in large files

◆ lmp_fseek64()

int lmp_fseek64 ( FILE * stream,
int64_t offset,
int whence )
extern

Portable version of POSIX fseeko() to set position in large files

◆ lmp_nanosleep()

uint64_t lmp_nanosleep ( uint64_t nanoseconds)
extern

Portable version of POSIX nanosleep() to sleep for nanoseconds

◆ ms_crc32c()

uint32_t ms_crc32c ( const uint8_t * input,
int length,
uint32_t previousCRC32C )
extern

Return CRC32C value of supplied buffer, with optional starting CRC32C value