Skip to content

Commit

Permalink
Update libmseed to v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chad-earthscope committed Jan 24, 2024
1 parent 2a47d5a commit eb45461
Show file tree
Hide file tree
Showing 27 changed files with 519 additions and 470 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024.024: 4.2
- Update libmseed to v3.1.1.

2024.006: 4.1
- Update libmseed to v3.0.18.

Expand Down
24 changes: 24 additions & 0 deletions libmseed/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
2024.024: 3.1.1
- Change library compatibility version in Makefile to MAJOR.1.0, as this is now
incompatible with the x.0.0 releases.

2024.024: 3.1.0
BREAKING CHANGES, data structure and an API changes:
- `MS3Record.encoding` now int16_t instead of int8_t.
- `MS3Record.datalength` now uint32_t instead of uint16_t (change in 3.0.18).
- `MS3Record.datasize` and `MS3TraceSeg.datasize` now uint64_t instead of size_t.
- `ms3_detect()` now returns int64_t instead of int.
- `mstl3_unpack_recordlist()`'s `outputsize` argument is now uint64_t instead of size_t.
- `mseh_get_ptr_r()`'s `maxlength` is now uint32_t instead of size_t.

- Fix to handle full range of allowed encoding values from 0-255.
- Fix to handle detection of huge record lengths beyond MAXRECLEN gracefully.
- Add more checks to avoid writing impossible values to miniSEED v2 blockette fields.
- Fix all compiler warnings at level -Wextra for clang, gcc, and \W3 for MSVC.

2024.015:
- Fix build of DLL target on Windows by defining exports in libmseed.def.

2024.007:
- Improve formatting of gap list produced by mstl3_printgaplist().

2024.006: 3.0.18
- ms_nslc2sid() requires all codes except location to be set to reduce misuse.
- Fix raw, diagnostic generation of SIDs from miniSEED v2 when full codes are used.
Expand Down
2 changes: 1 addition & 1 deletion libmseed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Extract version from libmseed.h, expected line should include LIBMSEED_VERSION "#.#.#"
MAJOR_VER = $(shell grep LIBMSEED_VERSION libmseed.h | grep -Eo '[0-9]+.[0-9]+.[0-9]+' | cut -d . -f 1)
FULL_VER = $(shell grep LIBMSEED_VERSION libmseed.h | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
COMPAT_VER = $(MAJOR_VER).0.0
COMPAT_VER = $(MAJOR_VER).1.0

# Default settings for install target
PREFIX ?= /usr/local
Expand Down
2 changes: 1 addition & 1 deletion libmseed/Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ lib: $(OBJS)
link.exe /lib /nologo /OUT:$(LM_LIB) $(OBJS)

dll: $(OBJS)
link.exe /dll /nologo /OUT:$(LM_DLL) $(OBJS)
link.exe /dll /nologo /DEF:$(LM_DEF) /OUT:$(LM_DLL) $(OBJS)

.c.obj:
$(CC) /nologo $(CFLAGS) $(INCS) $(OPTS) /c $<
Expand Down
5 changes: 3 additions & 2 deletions libmseed/example/Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OPTS = /O2 /D_CRT_SECURE_NO_WARNINGS
SRCS = lm_pack.c \
lm_pack_rollingbuffer.c \
lm_parse.c \
lm_read_buffer.c \
lm_read_buffer.c \
lm_read_recordlist.c \
lm_read_selection.c \
lm_sids.c \
Expand All @@ -25,4 +25,5 @@ all: $(BINS)

# Clean-up directives
clean:
-del *.obj *.exe *% *~
-del *.obj *.exe *% *~

1 change: 1 addition & 0 deletions libmseed/example/lm_pack_rollingbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
void
record_handler (char *record, int reclen, void *handlerdata)
{
(void)handlerdata;
MS3Record *msr = NULL;

if (!msr3_parse (record, reclen, &msr, 0, 0))
Expand Down
10 changes: 5 additions & 5 deletions libmseed/example/lm_read_recordlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ main (int argc, char **argv)
char fileptrstr[30];
uint32_t flags = 0;
int8_t verbose = 0;
size_t idx;
uint64_t idx;
int rv;

char printdata = 0;
int64_t unpacked;
uint8_t samplesize;
char sampletype;
size_t lineidx;
size_t lines;
uint64_t lineidx;
uint64_t lines;
int col;
void *sptr;

Expand All @@ -62,7 +62,7 @@ main (int argc, char **argv)
mseedfile = argv[1];

/* Simplistic argument parsing */
for (idx = 2; idx < argc; idx++)
for (idx = 2; (int)idx < argc; idx++)
{
if (strncmp (argv[idx], "-v", 2) == 0)
verbose += strspn (&argv[idx][1], "v");
Expand Down Expand Up @@ -166,7 +166,7 @@ main (int argc, char **argv)

for (idx = 0, lineidx = 0; lineidx < lines; lineidx++)
{
for (col = 0; col < 6 && idx < seg->numsamples; col++)
for (col = 0; col < 6 && (int64_t)idx < seg->numsamples; col++)
{
sptr = (char *)seg->datasamples + (idx * samplesize);

Expand Down
2 changes: 1 addition & 1 deletion libmseed/extraheaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ parse_json (char *jsonstring, size_t length, LM_PARSED_JSON *parsed)
***************************************************************************/
int
mseh_get_ptr_r (const MS3Record *msr, const char *ptr,
void *value, char type, size_t maxlength,
void *value, char type, uint32_t maxlength,
LM_PARSED_JSON **parsestate)
{
LM_PARSED_JSON *parsed = (parsestate) ? *parsestate : NULL;
Expand Down
16 changes: 10 additions & 6 deletions libmseed/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ int
ms3_url_useragent (const char *program, const char *version)
{
#if !defined(LIBMSEED_URL)
(void)program; /* Unused */
(void)version; /* Unused */
ms_log (2, "URL support not included in library\n");
return -1;
#else
Expand Down Expand Up @@ -796,6 +798,7 @@ int
ms3_url_userpassword (const char *userpassword)
{
#if !defined(LIBMSEED_URL)
(void) userpassword; /* Unused */
ms_log (2, "URL support not included in library\n");
return -1;
#else
Expand Down Expand Up @@ -824,6 +827,7 @@ int
ms3_url_addheader (const char *header)
{
#if !defined(LIBMSEED_URL)
(void)header; /* Unused */
ms_log (2, "URL support not included in library\n");
return -1;
#else
Expand Down Expand Up @@ -1008,12 +1012,12 @@ mstl3_writemseed (MS3TraceList *mstl, const char *mspath, int8_t overwrite,
char *
parse_pathname_range (const char *string, int64_t *start, int64_t *end)
{
char startstr[21] = {0}; /* Maximum of 20 digit value */
char endstr[21] = {0}; /* Maximum of 20 digit value */
int startdigits = 0;
int enddigits = 0;
char *dash = NULL;
char *at = NULL;
char startstr[21] = {0}; /* Maximum of 20 digit value */
char endstr[21] = {0}; /* Maximum of 20 digit value */
uint8_t startdigits = 0;
uint8_t enddigits = 0;
char *dash = NULL;
char *at = NULL;
char *ptr;

if (!string || (!start || !end))
Expand Down
47 changes: 24 additions & 23 deletions libmseed/genutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static const int monthdays_leap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30,
#define VALIDSEC(sec) (sec >= 0 && sec <= 60)

/* Check that a nanosecond is in a valid range */
#define VALIDNANOSEC(nanosec) (nanosec >= 0 && nanosec <= 999999999)
#define VALIDNANOSEC(nanosec) (nanosec <= 999999999)

/** @endcond */

Expand Down Expand Up @@ -314,6 +314,7 @@ int
ms_nslc2sid (char *sid, int sidlen, uint16_t flags,
const char *net, const char *sta, const char *loc, const char *chan)
{
(void)flags; /* Unused */
char *sptr = sid;
char xchan[6] = {0};
int needed = 0;
Expand Down Expand Up @@ -411,7 +412,7 @@ ms_nslc2sid (char *sid, int sidlen, uint16_t flags,
return -1;
}

return (sptr - sid);
return (int)(sptr - sid);
} /* End of ms_nslc2sid() */

/**********************************************************************/ /**
Expand Down Expand Up @@ -1344,7 +1345,7 @@ ms_timestr2nstime (const char *timestr)
}
}

length = cp - timestr;
length = (int)(cp - timestr);

/* If the time string is all number-like characters assume it is an epoch time.
* Unless it is 4 characters, which could be a year, unless it starts with a sign. */
Expand Down Expand Up @@ -1431,15 +1432,15 @@ nstime_t
ms_mdtimestr2nstime (const char *timestr)
{
int fields;
int year = 0;
int mon = 1;
int mday = 1;
int yday = 1;
int hour = 0;
int min = 0;
int sec = 0;
double fsec = 0.0;
int nsec = 0;
int year = 0;
int mon = 1;
int mday = 1;
int yday = 1;
int hour = 0;
int min = 0;
int sec = 0;
double fsec = 0.0;
uint32_t nsec = 0;

if (!timestr)
{
Expand All @@ -1453,7 +1454,7 @@ ms_mdtimestr2nstime (const char *timestr)
/* Convert fractional seconds to nanoseconds */
if (fsec != 0.0)
{
nsec = (int)(fsec * 1000000000.0 + 0.5);
nsec = (uint32_t)(fsec * 1000000000.0 + 0.5);
}

if (fields < 1)
Expand Down Expand Up @@ -1500,7 +1501,7 @@ ms_mdtimestr2nstime (const char *timestr)

if (!VALIDNANOSEC (nsec))
{
ms_log (2, "fractional second (%d) is out of range\n", nsec);
ms_log (2, "fractional second (%u) is out of range\n", nsec);
return NSTERROR;
}

Expand Down Expand Up @@ -1539,13 +1540,13 @@ nstime_t
ms_seedtimestr2nstime (const char *seedtimestr)
{
int fields;
int year = 0;
int yday = 1;
int hour = 0;
int min = 0;
int sec = 0;
double fsec = 0.0;
int nsec = 0;
int year = 0;
int yday = 1;
int hour = 0;
int min = 0;
int sec = 0;
double fsec = 0.0;
uint32_t nsec = 0;

if (!seedtimestr)
{
Expand All @@ -1559,7 +1560,7 @@ ms_seedtimestr2nstime (const char *seedtimestr)
/* Convert fractional seconds to nanoseconds */
if (fsec != 0.0)
{
nsec = (int)(fsec * 1000000000.0 + 0.5);
nsec = (uint32_t)(fsec * 1000000000.0 + 0.5);
}

if (fields < 1)
Expand Down Expand Up @@ -1600,7 +1601,7 @@ ms_seedtimestr2nstime (const char *seedtimestr)

if (!VALIDNANOSEC (nsec))
{
ms_log (2, "fractional second (%d) is out of range\n", nsec);
ms_log (2, "fractional second (%u) is out of range\n", nsec);
return NSTERROR;
}

Expand Down
5 changes: 2 additions & 3 deletions libmseed/libmseed.def
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ EXPORTS
msr3_writemseed
mstl3_writemseed
libmseed_url_support
ms3_mstl_init_fd
ms_sid2nslc
ms_nslc2sid
ms_seedchan2xchan
Expand All @@ -76,6 +77,7 @@ EXPORTS
mseh_add_recenter_r
mseh_serialize
mseh_free_parsestate
mseh_replace
mseh_print
ms_rlog
ms_rlog_l
Expand All @@ -93,8 +95,5 @@ EXPORTS
ms_dabs
ms_bigendianhost
ms_crc32c
ms_gswap2
ms_gswap4
ms_gswap8
leapsecondlist
libmseed_memory
20 changes: 10 additions & 10 deletions libmseed/libmseed.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#define LIBMSEED_VERSION "3.0.18" //!< Library version
#define LIBMSEED_RELEASE "2024.006" //!< Library release date
#define LIBMSEED_VERSION "3.1.1" //!< Library version
#define LIBMSEED_RELEASE "2024.024" //!< Library release date

/** @defgroup io-functions File and URL I/O */
/** @defgroup miniseed-record Record Handling */
Expand Down Expand Up @@ -365,7 +365,7 @@ typedef struct MS3Record {
uint8_t flags; //!< Record-level bit flags
nstime_t starttime; //!< Record start time (first sample)
double samprate; //!< Nominal sample rate as samples/second (Hz) or period (s)
int8_t encoding; //!< Data encoding format, see @ref encoding-values
int16_t encoding; //!< Data encoding format, see @ref encoding-values
uint8_t pubversion; //!< Publication version
int64_t samplecnt; //!< Number of samples in record
uint32_t crc; //!< CRC of entire record
Expand All @@ -375,7 +375,7 @@ typedef struct MS3Record {

/* Data sample fields */
void *datasamples; //!< Data samples, \a numsamples of type \a sampletype
size_t datasize; //!< Size of datasamples buffer in bytes
uint64_t datasize; //!< Size of datasamples buffer in bytes
int64_t numsamples; //!< Number of data samples in datasamples
char sampletype; //!< Sample type code: t, i, f, d @ref sample-types
} MS3Record;
Expand All @@ -398,8 +398,8 @@ extern int64_t msr3_unpack_data (MS3Record *msr, int8_t verbose);

extern int msr3_data_bounds (const MS3Record *msr, uint32_t *dataoffset, uint32_t *datasize);

extern int64_t ms_decode_data (const void *input, size_t inputsize, uint8_t encoding,
int64_t samplecount, void *output, size_t outputsize,
extern int64_t ms_decode_data (const void *input, uint64_t inputsize, uint8_t encoding,
uint64_t samplecount, void *output, uint64_t outputsize,
char *sampletype, int8_t swapflag, const char *sid, int8_t verbose);

extern MS3Record* msr3_init (MS3Record *msr);
Expand All @@ -411,7 +411,7 @@ extern int msr3_resize_buffer (MS3Record *msr);
extern double msr3_sampratehz (const MS3Record *msr);
extern double msr3_host_latency (const MS3Record *msr);

extern int ms3_detect (const char *record, uint64_t recbuflen, uint8_t *formatversion);
extern int64_t ms3_detect (const char *record, uint64_t recbuflen, uint8_t *formatversion);
extern int ms_parse_raw3 (const char *record, int maxreclen, int8_t details);
extern int ms_parse_raw2 (const char *record, int maxreclen, int8_t details, int8_t swapflag);
/** @} */
Expand Down Expand Up @@ -551,7 +551,7 @@ typedef struct MS3TraceSeg {
double samprate; //!< Nominal sample rate (Hz)
int64_t samplecnt; //!< Number of samples in trace coverage
void *datasamples; //!< Data samples, \a numsamples of type \a sampletype
size_t datasize; //!< Size of datasamples buffer in bytes
uint64_t datasize; //!< Size of datasamples buffer in bytes
int64_t numsamples; //!< Number of data samples in datasamples
char sampletype; //!< Sample type code, see @ref sample-types
void *prvtptr; //!< Private pointer for general use, unused by library
Expand Down Expand Up @@ -639,7 +639,7 @@ extern int64_t mstl3_readbuffer_selection (MS3TraceList **ppmstl, const ch
const MS3Tolerance *tolerance, const MS3Selections *selections,
int8_t verbose);
extern int64_t mstl3_unpack_recordlist (MS3TraceID *id, MS3TraceSeg *seg, void *output,
size_t outputsize, int8_t verbose);
uint64_t outputsize, int8_t verbose);
extern int mstl3_convertsamples (MS3TraceSeg *seg, char type, int8_t truncate);
extern int mstl3_resize_buffers (MS3TraceList *mstl);
extern int64_t mstl3_pack (MS3TraceList *mstl, void (*record_handler) (char *, int, void *),
Expand Down Expand Up @@ -940,7 +940,7 @@ typedef struct LM_PARSED_JSON_s LM_PARSED_JSON;
(!mseh_get_ptr_r (msr, ptr, NULL, 0, 0, NULL))

extern int mseh_get_ptr_r (const MS3Record *msr, const char *ptr,
void *value, char type, size_t maxlength,
void *value, char type, uint32_t maxlength,
LM_PARSED_JSON **parsestate);

/** @def mseh_set
Expand Down
Loading

0 comments on commit eb45461

Please sign in to comment.