libmseed 3.1.3
The miniSEED data format library
Loading...
Searching...
No Matches
Source Identifiers

Source identifier (SID) and string manipulation functions. More...

Functions

int ms_sid2nslc (const char *sid, char *net, char *sta, char *loc, char *chan)
 Parse network, station, location and channel from an FDSN Source ID.
 
int ms_nslc2sid (char *sid, int sidlen, uint16_t flags, const char *net, const char *sta, const char *loc, const char *chan)
 Convert network, station, location and channel to an FDSN Source ID.
 
int ms_seedchan2xchan (char *xchan, const char *seedchan)
 Convert SEED 2.x channel to extended channel.
 
int ms_xchan2seedchan (char *seedchan, const char *xchan)
 Convert extended channel to SEED 2.x channel.
 
int ms_strncpclean (char *dest, const char *source, int length)
 Copy string, removing spaces, always terminated.
 
int ms_strncpcleantail (char *dest, const char *source, int length)
 Copy string, removing trailing spaces, always terminated.
 
int ms_strncpopen (char *dest, const char *source, int length)
 Copy fixed number of characters into unterminated string.
 

Detailed Description

Source identifier (SID) and string manipulation functions.

A source identifier uniquely identifies the generator of data in a record. This is a small string, usually in the form of a URI. For data identified with FDSN codes, the SID is usally a simple combination of the codes.

Function Documentation

◆ ms_sid2nslc()

int ms_sid2nslc ( const char * sid,
char * net,
char * sta,
char * loc,
char * chan )
extern

Parse network, station, location and channel from an FDSN Source ID.

FDSN Source Identifiers are defined at: https://docs.fdsn.org/projects/source-identifiers/

Parse a source identifier into separate components, expecting: "FDSN:NET_STA_LOC_CHAN", where CHAN="BAND_SOURCE_POSITION"

The CHAN value will be converted to a SEED channel code if possible. Meaning, if the BAND, SOURCE, and POSITION are single characters, the underscore delimiters will not be included in the returned channel.

Identifiers may contain additional namespace identifiers, e.g.: "FDSN:AGENCY:NET_STA_LOC_CHAN"

Such additional namespaces are not part of the Source ID standard as of this writing and support is included for specialized usage or future identifier changes.

Memory for each component must already be allocated. If a specific component is not desired set the appropriate argument to NULL.

Parameters
[in]sidSource identifier
[out]netNetwork code
[out]staStation code
[out]locLocation code
[out]chanChannel code
Return values
0on success
-1on error

MessageOnError - this function logs a message on error

◆ ms_nslc2sid()

int ms_nslc2sid ( char * sid,
int sidlen,
uint16_t flags,
const char * net,
const char * sta,
const char * loc,
const char * chan )
extern

Convert network, station, location and channel to an FDSN Source ID.

FDSN Source Identifiers are defined at: https://docs.fdsn.org/projects/source-identifiers/

Create a source identifier from individual network, station, location and channel codes with the form: FDSN:NET_STA_LOC_CHAN, where CHAN="BAND_SOURCE_POSITION"

Memory for the source identifier must already be allocated.

If the loc value is NULL it will be empty in the resulting Source ID.

The chan value will be converted to extended channel format if it appears to be in SEED channel form. Meaning, if the chan is 3 characters with no delimiters, it will be converted to "BAND_SOURCE_POSITION" form by adding delimiters between the codes.

Parameters
[out]sidDestination string for source identifier
sidlenMaximum length of sid
flagsCurrently unused, set to 0
[in]netNetwork code
[in]staStation code
[in]locLocation code
[in]chanChannel code
Returns
length of source identifier
Return values
-1on error

MessageOnError - this function logs a message on error

◆ ms_seedchan2xchan()

int ms_seedchan2xchan ( char * xchan,
const char * seedchan )
extern

Convert SEED 2.x channel to extended channel.

The SEED 2.x channel at seedchan must be a 3-character string. The xchan buffer must be at least 6 bytes, for the extended channel (band,source,position) and the terminating NULL.

This functionality simply maps patterns, it does not check the validity of any codes.

Parameters
[out]xchanDestination for extended channel string, must be at least 6 bytes
[in]seedchanSource string, must be a 3-character string
Return values
0on successful mapping of channel
-1on error

◆ ms_xchan2seedchan()

int ms_xchan2seedchan ( char * seedchan,
const char * xchan )
extern

Convert extended channel to SEED 2.x channel.

The extended channel at xchan must be a 5-character string.

The seedchan buffer must be at least 4 bytes, for the SEED channel and the terminating NULL. Alternatively, seedchan may be set to NULL in which case this function becomes a test for whether the xchan could be mapped without actually doing the conversion. Finally, seedchan can be the same buffer as xchan for an in-place conversion.

This routine simply maps patterns, it does not check the validity of any specific codes.

Parameters
[out]seedchanDestination for SEED channel string, must be at least 4 bytes
[in]xchanSource string, must be a 5-character string
Return values
0on successful mapping of channel
-1on error

◆ ms_strncpclean()

int ms_strncpclean ( char * dest,
const char * source,
int length )
extern

Copy string, removing spaces, always terminated.

Copy up to length bytes of UTF-8 characters from source to dest while removing all spaces. The result is left justified and always null terminated.

The destination string must have enough room needed for the non-space characters within length and the null terminator, a maximum of length + 1.

Parameters
[out]destDestination for terminated string
[in]sourceSource string
[in]lengthLength of characters for destination string in bytes
Returns
the number of characters (not including the null terminator) in the destination string

◆ ms_strncpcleantail()

int ms_strncpcleantail ( char * dest,
const char * source,
int length )
extern

Copy string, removing trailing spaces, always terminated.

Copy up to length bytes of UTF-8 characters from source to dest without any trailing spaces. The result is left justified and always null terminated.

The destination string must have enough room needed for the characters within length and the null terminator, a maximum of length + 1.

Parameters
[out]destDestination for terminated string
[in]sourceSource string
[in]lengthLength of characters for destination string in bytes
Returns
The number of characters (not including the null terminator) in the destination string

◆ ms_strncpopen()

int ms_strncpopen ( char * dest,
const char * source,
int length )
extern

Copy fixed number of characters into unterminated string.

Copy length bytes of UTF-8 characters from source to dest, padding the right side with spaces and leave open-ended, aka un-terminated. The result is left justified and never null terminated.

The destination string must have enough room for length characters.

Parameters
[out]destDestination for unterminated string
[in]sourceSource string
[in]lengthLength of characters for destination string in bytes
Returns
the number of characters copied from the source string