libmseed 3.1.3
The miniSEED data format library
|
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. | |
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.
|
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.
[in] | sid | Source identifier |
[out] | net | Network code |
[out] | sta | Station code |
[out] | loc | Location code |
[out] | chan | Channel code |
0 | on success |
-1 | on error |
MessageOnError - this function logs a message on error
|
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.
[out] | sid | Destination string for source identifier |
sidlen | Maximum length of sid | |
flags | Currently unused, set to 0 | |
[in] | net | Network code |
[in] | sta | Station code |
[in] | loc | Location code |
[in] | chan | Channel code |
-1 | on error |
MessageOnError - this function logs a message on error
|
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.
[out] | xchan | Destination for extended channel string, must be at least 6 bytes |
[in] | seedchan | Source string, must be a 3-character string |
0 | on successful mapping of channel |
-1 | on error |
|
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.
[out] | seedchan | Destination for SEED channel string, must be at least 4 bytes |
[in] | xchan | Source string, must be a 5-character string |
0 | on successful mapping of channel |
-1 | on error |
|
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.
[out] | dest | Destination for terminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |
|
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.
[out] | dest | Destination for terminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |
|
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.
[out] | dest | Destination for unterminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |