[libmseed] 01/04: New upstream version 2.19.2

Pierre Duperray zulu-guest at moszumanska.debian.org
Sat Mar 11 13:04:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

zulu-guest pushed a commit to branch master
in repository libmseed.

commit 8970bae2bc869681e1b86863b00ab444a65868e0
Author: Pierre Duperray <pierreduperray at free.fr>
Date:   Sat Mar 11 13:29:56 2017 +0100

    New upstream version 2.19.2
---
 ChangeLog                                     |  24 ++++++
 INSTALL => INSTALL.md                         |  24 +++---
 Makefile                                      | 103 +++++++++++++++-------
 Makefile.wat                                  |   4 +-
 Makefile.win                                  |   8 +-
 README => README.md                           |  36 +++++---
 doc/ms_bigendianhost.3                        |   4 +-
 doc/ms_doy2md.3                               |   4 +-
 doc/ms_find_reclen.3                          |   4 +-
 doc/ms_genfactmult.3                          |   4 +-
 doc/ms_gswap.3                                |   4 +-
 doc/ms_intro.3                                |   4 +-
 doc/ms_log.3                                  |   2 +-
 doc/ms_lookup.3                               |   4 +-
 doc/ms_parse_raw.3                            |   4 +-
 doc/ms_readleapseconds.3                      |   4 +-
 doc/ms_readmsr.3                              |   6 +-
 doc/ms_selection.3                            |  12 +--
 doc/ms_splitsrcname.3                         |   4 +-
 doc/ms_srcname.3                              |   4 +-
 doc/ms_strncpclean.3                          |   4 +-
 doc/ms_time.3                                 |   4 +-
 doc/ms_writemseed.3                           |   4 +-
 doc/msr_addblockette.3                        |   4 +-
 doc/msr_duplicate.3                           |   4 +-
 doc/msr_host_latency.3                        |   4 +-
 doc/msr_init.3                                |   4 +-
 doc/msr_normalize_header.3                    |   4 +-
 doc/msr_pack.3                                |   4 +-
 doc/msr_parse.3                               |   6 +-
 doc/msr_print.3                               |   4 +-
 doc/msr_samprate.3                            |   4 +-
 doc/msr_starttime.3                           |   4 +-
 doc/msr_unpack.3                              |   4 +-
 doc/mst_addmsr.3                              |   4 +-
 doc/mst_convertsamples.3                      |   6 +-
 doc/mst_findmatch.3                           |   4 +-
 doc/mst_groupsort.3                           |   4 +-
 doc/mst_init.3                                |   4 +-
 doc/mst_pack.3                                |   4 +-
 doc/mst_printtracelist.3                      |   4 +-
 doc/mstl_addmsr.3                             |   4 +-
 doc/mstl_init.3                               |   6 +-
 doc/mstl_printtracelist.3                     |   4 +-
 example/Makefile.win                          |   9 +-
 genutils.c                                    |   5 +-
 gswap.c                                       |   2 +-
 libmseed.h                                    | 118 ++++++++++++++++++++++----
 libmseed.map                                  |  11 +++
 lmplatform.c                                  |   2 +-
 lmplatform.h                                  | 115 -------------------------
 mseed.pc.in                                   |  12 +++
 packdata.c                                    |  80 ++++++++---------
 test/pack-Float32-encoded.test                |   2 +
 test/pack-Float64-encoded.test                |   2 +
 test/pack-Int16-encoded.test                  |   2 +
 test/pack-Int32-encoded.test                  |   2 +
 test/pack-Steim1-encoded.test                 |   2 +
 test/pack-Steim2-encoded.test                 |   2 +
 test/pack-text-encoded.test                   |   2 +
 test/read-CDSN-encoded.test                   |   2 +
 test/read-DWWSSN-encoded.test                 |   2 +
 test/read-Float32-encoded.test                |   2 +
 test/read-Float64-encoded.test                |   2 +
 test/read-GEOSCOPE163-encoded.test            |   2 +
 test/read-Int16-encoded.test                  |   2 +
 test/read-Int32-1024byte-encoded.test         |   2 +
 test/read-Int32-128byte-encoded.test          |   2 +
 test/read-Int32-2048byte-encoded.test         |   2 +
 test/read-Int32-256byte-encoded.test          |   2 +
 test/read-Int32-4096byte-encoded.test         |   2 +
 test/read-Int32-512byte-encoded.test          |   2 +
 test/read-Int32-8192byte-encoded.test         |   2 +
 test/read-SRO-encoded.test                    |   2 +
 test/read-Steim1-bigendian.test               |   2 +
 test/read-Steim1-littleendian.test            |   2 +
 test/read-Steim2-bigendian.test               |   2 +
 test/read-Steim2-littleendian.test            |   2 +
 test/read-detection-record.test               |   2 +
 test/read-invalid-blockette-offset.test       |   2 +
 test/read-mixed-order-mixed-length-trace.test |   2 +
 test/read-no-blockette1000.test               |   2 +
 test/read-text-encoded.test                   |   2 +
 test/read-unapplied-timecorrection.test       |   2 +
 unpackdata.c                                  |  52 ++++++------
 85 files changed, 476 insertions(+), 357 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df617b0..4b6e1e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2017.061: 2.19.2
+	- Provide install target in Makefile thanks to by Pierre Duperray.
+	- Deprecate dynamic build target, the shared target will now build
+	shared or dynamic (Darwin) libraries depending on the system.
+	- Limit symbols exported in shared libraries to public interfaces
+	as defined in libmseed.map, thanks again to Pierre Duperray.
+	- Allow tests to work on Darwin with dynamic libraries.
+
+2017.060: 2.19.1
+	- Derive versioning of shared/dynamic library from canonical version
+	defined as LIBMSEED_VERSION in libmseed.h.
+	- Apply updates to more standardized use of NAME and typos in man pages,
+	submitted by Pierre Duperray.
+
+2017.053: 2.19
+	- Incorporate lmplatform.h details into libmseed.h for improved usage.
+	All that is needed is the static/shared/dynamic library and libmseed.h.
+	- Avoid undefined left shifts of signed values that would go out of
+	range and specify the types of some constants.
+
+2016.290:
+	- Remove dependency on ntwin32.mak for Windows nmake makefiles, now
+	building works in plain MSVC development environments.
+
 2016.286: 2.18
 	- Remove limitation on sample rate before calling ms_genfactmult()
 	in the normal path of packing records.  Previously generating the
diff --git a/INSTALL b/INSTALL.md
similarity index 60%
rename from INSTALL
rename to INSTALL.md
index 7211af0..5d1af58 100644
--- a/INSTALL
+++ b/INSTALL.md
@@ -1,32 +1,32 @@
 
 The library requires that C99 integer types are available on the
 target computer.  Specifically the int8_t, int16_t, int32_t, int64_t
-and their unsigned counterpart types.  If these data types are not
-available guesses are made in lmplatform.h.
+and their unsigned counterpart types.
 
--- Unix --
+## Unix, Linux, macOS
 
 A simple 'make' on most Unix-like systems should build the library.
 
 The included Makefile should work for most Unix-like environments and
-most make variants; it is know to work with GNU make.
+most make variants. It is know to work with GNU make, which, if not the
+default, is sometimes installed as gmake.
 
-The CC and CFLAGS environment variables can be set to control the build.
+The CC, CFLAGS, LDFLAGS and CPPFLAGS environment variables can be set
+to control the build.
 
 By default a statically linked version of the library is built: 'libmseed.a'.
 
 With GCC, clang or compatible build tools it is possible to build a shared
 library with 'make shared'.
 
--- macOS --
+A simple install method for the shared library can be invoked with
+'make install'.  By default the installation destination is /usr/local.
+The install destination may be specified using the PREFIX variable, for
+example:
 
-A static library can be compiled using the above Unix instructions,
-just run 'make'.
+make install PREFIX=/path/to/install/
 
-Using GCC, clang or compatible build tools it is possible to build a dynamic
-library with 'make dynamic'.
-
--- Windows (Win32) --
+## Windows (Win32)
 
 On a WIN32 platform the library can be compiled by using the
 Nmake compatible Makefile.win (e.g. 'nmake -f Makefile.win') or Open
diff --git a/Makefile b/Makefile
index 2cb7c9a..2a11fff 100644
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,23 @@
 # environment variables:
 #   CC : Specify the C compiler to use
 #   CFLAGS : Specify compiler options to use
-
-MAJOR_VER = 2
-MINOR_VER = 18
-CURRENT_VER = $(MAJOR_VER).$(MINOR_VER)
-COMPAT_VER = $(MAJOR_VER).$(MINOR_VER)
+#   LDFLAGS : Specify linker options to use
+#   CPPFLAGS : Specify c-preprocessor options to use
+
+# 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
+
+# Default settings for install target
+PREFIX ?= /usr/local
+EXEC_PREFIX ?= $(PREFIX)
+LIBDIR ?= $(EXEC_PREFIX)/lib
+INCLUDEDIR ?= $(PREFIX)/include
+DATAROOTDIR ?= $(PREFIX)/share
+DOCDIR ?= $(DATAROOTDIR)/doc/libmseed
+MANDIR ?= $(DATAROOTDIR)/man
+MAN3DIR ?= $(MANDIR)/man3
 
 LIB_SRCS = fileutils.c genutils.c gswap.c lmplatform.c lookup.c \
            msrutils.c pack.c packdata.c traceutils.c tracelist.c \
@@ -17,60 +29,87 @@ LIB_OBJS = $(LIB_SRCS:.c=.o)
 LIB_DOBJS = $(LIB_SRCS:.c=.lo)
 
 LIB_A = libmseed.a
-LIB_SO_FILENAME = libmseed.so
-LIB_SO_ALIAS = $(LIB_SO_FILENAME).$(MAJOR_VER)
-LIB_SO = $(LIB_SO_FILENAME).$(CURRENT_VER)
-LIB_DYN_ALIAS = libmseed.dylib
-LIB_DYN = libmseed.$(CURRENT_VER).dylib
+LIB_SO_BASE = libmseed.so
+LIB_SO_NAME = $(LIB_SO_BASE).$(MAJOR_VER)
+LIB_SO = $(LIB_SO_BASE).$(FULL_VER)
+LIB_DYN_NAME = libmseed.dylib
+LIB_DYN = libmseed.$(FULL_VER).dylib
+LIB_FILES = Blarg
 
 all: static
 
 static: $(LIB_A)
 
-shared: $(LIB_SO)
-
-dynamic: $(LIB_DYN)
+# Build dynamic (.dylib) on macOS/Darwin, otherwise shared (.so)
+shared dynamic:
+ifeq ($(shell uname -s),Darwin)
+	$(MAKE) $(LIB_DYN)
+else
+	$(MAKE) $(LIB_SO)
+endif
 
 # Build static library
 $(LIB_A): $(LIB_OBJS)
-	rm -f $(LIB_A)
-	ar -crs $(LIB_A) $(LIB_OBJS)
+	@echo "Building static library $(LIB_A)"
+	$(RM) -f $(LIB_A)
+	$(AR) -crs $(LIB_A) $(LIB_OBJS)
 
 # Build shared library using GCC-style options
 $(LIB_SO): $(LIB_DOBJS)
-	rm -f $(LIB_SO) $(LIB_SO_FILENAME)
-	$(CC) $(CFLAGS) -shared -Wl,-soname -Wl,$(LIB_SO_ALIAS) -o $(LIB_SO) $(LIB_DOBJS)
-	ln -s $(LIB_SO) $(LIB_SO_ALIAS)
-	ln -s $(LIB_SO) $(LIB_SO_FILENAME)
+	@echo "Building shared library $(LIB_SO)"
+	$(RM) -f $(LIB_SO) $(LIB_SONAME) $(LIB_SO_BASE)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,--version-script=libmseed.map -Wl,-soname,$(LIB_SO_NAME) -o $(LIB_SO) $(LIB_DOBJS)
+	ln -s $(LIB_SO) $(LIB_SO_BASE)
+	ln -s $(LIB_SO) $(LIB_SO_NAME)
 
-# Build dynamic library (usually for Mac OSX)
+# Build dynamic library (usually for macOS)
 $(LIB_DYN): $(LIB_DOBJS)
-	rm -f $(LIB_DYN) $(LIB_DYN_ALIAS)
-	$(CC) $(CFLAGS) -dynamiclib -compatibility_version $(COMPAT_VER) -current_version $(CURRENT_VER) -install_name $(LIB_DYN_ALIAS) -o $(LIB_DYN) $(LIB_DOBJS)
-	ln -sf $(LIB_DYN) $(LIB_DYN_ALIAS)
+	@echo "Building dynamic library $(LIB_DYN)"
+	$(RM) -f $(LIB_DYN) $(LIB_DYN_NAME)
+	$(CC) $(CFLAGS) -dynamiclib -compatibility_version $(COMPAT_VER) -current_version $(FULL_VER) -install_name $(LIB_DYN_NAME) -o $(LIB_DYN) $(LIB_DOBJS)
+	ln -sf $(LIB_DYN) $(LIB_DYN_NAME)
 
-test: static FORCE
+test check: static FORCE
 	@$(MAKE) -C test test
 
 clean:
-	@rm -f $(LIB_OBJS) $(LIB_DOBJS) $(LIB_A) $(LIB_SO_FILENAME) $(LIB_SO) $(LIB_SO_ALIAS) $(LIB_DYN) $(LIB_DYN_ALIAS)
+	@$(RM) -f $(LIB_OBJS) $(LIB_DOBJS) $(LIB_A) $(LIB_SO) $(LIB_SO_NAME) $(LIB_SO_BASE) $(LIB_DYN) $(LIB_DYN_NAME)
 	@$(MAKE) -C test clean
 	@echo "All clean."
 
-install:
-	@echo
-	@echo "No install target, copy the library and header as needed"
-	@echo
-
+install: shared
+	@echo "Installing into $(PREFIX)"
+	@mkdir -p $(DESTDIR)$(PREFIX)/include
+	@cp libmseed.h $(DESTDIR)$(PREFIX)/include
+	@mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
+ifneq ("$(wildcard $(LIB_SO))","")
+	@cp -a $(LIB_SO_BASE) $(LIB_SO_NAME) $(LIB_SO) $(DESTDIR)$(LIBDIR)
+endif
+ifneq ("$(wildcard $(LIB_DYN))","")
+	@cp -a $(LIB_DYN_NAME) $(LIB_DYN) $(DESTDIR)$(LIBDIR)
+endif
+	@sed -e 's|@prefix@|$(PREFIX)|g' \
+	     -e 's|@exec_prefix@|$(EXEC_PREFIX)|g' \
+	     -e 's|@libdir@|$(LIBDIR)|g' \
+	     -e 's|@includedir@|$(PREFIX)/include|g' \
+	     -e 's|@PACKAGE_NAME@|libmseed|g' \
+	     -e 's|@PACKAGE_URL@|http://ds.iris.edu/ds/nodes/dmc/software/downloads/libmseed/|g' \
+	     -e 's|@VERSION@|$(FULL_VER)|g' \
+	     mseed.pc.in > $(DESTDIR)$(LIBDIR)/pkgconfig/mseed.pc
+	@mkdir -p $(DESTDIR)$(DOCDIR)/example
+	@cp -r example $(DESTDIR)$(DOCDIR)/
+	@cp doc/libmseed-UsersGuide $(DESTDIR)$(DOCDIR)/
+	@mkdir -p $(DESTDIR)$(MAN3DIR)
+	@cp -a doc/ms*.3 $(DESTDIR)$(MAN3DIR)/
 
 .SUFFIXES: .c .o .lo
 
 # Standard object building
 .c.o:
-	$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
 
 # Standard object building for dynamic library components using -fPIC
 .c.lo:
-	$(CC) $(CFLAGS) -fPIC -c $< -o $@
+	$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
 
 FORCE:
diff --git a/Makefile.wat b/Makefile.wat
index 1aecfe1..7271dc7 100644
--- a/Makefile.wat
+++ b/Makefile.wat
@@ -48,8 +48,8 @@ dll:	$(OBJS) .SYMBOLIC
 # Source dependencies:
 fileutils.obj:	fileutils.c libmseed.h
 genutils.obj:	genutils.c libmseed.h
-gswap.obj:	gswap.c lmplatform.h
-lmplatform.obj:	lmplatform.c libmseed.h lmplatform.h
+gswap.obj:	gswap.c libmseed.h
+lmplatform.obj:	lmplatform.c libmseed.h
 lookup.obj:	lookup.c libmseed.h
 msrutils.obj:	msrutils.c libmseed.h
 pack.obj:	pack.c libmseed.h packdata.h
diff --git a/Makefile.win b/Makefile.win
index 4c073c9..a7e9409 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -1,12 +1,9 @@
 #
-#
-# Nmake File For libmseed - MS Visual C++ version
+# Nmake file For libmseed - MS Visual C/C++ version
 # Use 'nmake -f Makefile.win'
 
 NODEBUG=1
 
-!include <ntwin32.mak>
-
 INCS = -I.
 OPTS = -D_CRT_SECURE_NO_WARNINGS
 LIB = libmseed.lib
@@ -37,8 +34,7 @@ dll: $(OBJS)
 	link.exe /dll /nologo /out:$(DLL) $(OBJS)
 
 .c.obj:
-	$(cc) /nologo $(cflags) $(cdebug) $(cvarsmt) $(tflags) $(INCS) $(OPTS) $<
-
+	$(CC) /nologo $(CFLAGS) $(INCS) $(OPTS) /c $<
 
 # Clean-up directives
 clean:
diff --git a/README b/README.md
similarity index 58%
rename from README
rename to README.md
index ebaffe3..b424a18 100644
--- a/README
+++ b/README.md
@@ -1,24 +1,36 @@
 
-                   libmseed - The Mini-SEED library
+# libmseed - The Mini-SEED library
 
 The Mini-SEED library provides a framework for manipulation of SEED
 data records including the unpacking and packing of data records.
 Functionality is also included for managing waveform data as
-continuous traces.  All structures of SEED 2.4 data records are
-supported with the following exceptions: Blockette 2000 opaque data
-which has an unknown data structure by definition and Blockette 405
-which depends on full SEED (SEED including full ASCII headers) for a
-full data description.
+continuous traces.
+
+All structures of SEED 2.4 data records are supported with the
+following exceptions: Blockette 2000 opaque data which has an unknown
+data structure by definition and Blockette 405 which depends on full
+SEED (SEED including full ASCII headers) for a full data description.
 
 The library should work in Linux, BSD (and derivatives like macOS),
 Solaris and Win32 environments.
 
-For installation instructions see the INSTALL file.  For further
-information regarding the library interface see the documentation in
-the 'doc' directory.  For example uses of libmseed see the source code
-in the 'examples' directory.
+## Documentation
+
+The [Wiki](https://github.com/iris-edu/libmseed/Wiki) provides an
+overview of using the library. For function level documentation,
+man pages are included in the [doc](doc) directory.
+
+## Downloading and installing
+
+The [releases](https://github.com/iris-edu/libmseed/releases) area
+contains release versions.
+
+For installation instructions see the [INSTALL](INSTALL.md) file.
+For further information regarding the library interface see the
+documentation in the 'doc' directory.  For example uses of libmseed
+see the source code in the 'examples' directory.
 
--- License --
+## License
 
 Copyright (C) 2016 Chad Trabant, IRIS Data Management Center
 
@@ -36,7 +48,7 @@ You should have received a copy of the GNU Lesser General Public
 License along with this software.
 If not, see <https://www.gnu.org/licenses/>.
 
--- Acknowlegements --
+## Acknowlegements
 
 Numerous improvements have been incorporated based on feedback and
 patches submitted by others.  Individual acknowlegements are included
diff --git a/doc/ms_bigendianhost.3 b/doc/ms_bigendianhost.3
index f98ae05..ad35935 100644
--- a/doc/ms_bigendianhost.3
+++ b/doc/ms_bigendianhost.3
@@ -1,6 +1,6 @@
 .TH MS_BIGENDIANHOST 3 2004/11/22 "Libmseed API"
-.SH DESCRIPTION
-Determine host computer byte order
+.SH NAME
+ms_bigendianhost - Determine host computer byte order
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_doy2md.3 b/doc/ms_doy2md.3
index f761464..1c2c50a 100644
--- a/doc/ms_doy2md.3
+++ b/doc/ms_doy2md.3
@@ -1,6 +1,6 @@
 .TH MS_DOY2MD 3 2004/11/22 "Libmseed API"
-.SH DESCRIPTION
-Convert between day of year and month and day of month
+.SH NAME
+ms_doy2md - Convert between day of year and month and day of month
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_find_reclen.3 b/doc/ms_find_reclen.3
index 4824139..19323cb 100644
--- a/doc/ms_find_reclen.3
+++ b/doc/ms_find_reclen.3
@@ -1,6 +1,6 @@
 .TH MS_FIND_RECLEN 3 2006/11/08 "Libmseed API"
-.SH DESCRIPTION
-Determine SEED record data length
+.SH NAME
+ms_find_reclen - Determine SEED record data length
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_genfactmult.3 b/doc/ms_genfactmult.3
index 8923b73..9cd7958 100644
--- a/doc/ms_genfactmult.3
+++ b/doc/ms_genfactmult.3
@@ -1,6 +1,6 @@
 .TH MS_GENFACTMULT 3 2016/10/07 "Libmseed API"
-.SH DESCRIPTION
-Generate SEED sample rate factor and multiplier
+.SH NAME
+ms_genfactmult - Generate SEED sample rate factor and multiplier
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_gswap.3 b/doc/ms_gswap.3
index 6edcd14..cf32912 100644
--- a/doc/ms_gswap.3
+++ b/doc/ms_gswap.3
@@ -1,6 +1,6 @@
 .TH MS_GSWAP 3 2006/12/20 "Libmseed API"
-.SH DESCRIPTION
-Generalized, in-place byte swapping routines
+.SH NAME
+ms_gswap - Generalized, in-place byte swapping routines
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_intro.3 b/doc/ms_intro.3
index c92ce62..21a14f4 100644
--- a/doc/ms_intro.3
+++ b/doc/ms_intro.3
@@ -1,6 +1,6 @@
 .TH MS_INTRO 3 2013/07/17
 .SH NAME
-Introduction to libmseed
+ms_intro - Introduction to libmseed
 
 .SH INTRODUCTION
 
@@ -420,7 +420,7 @@ little endian but that the data section is big endian (as the only
 defined data encodings must be based on the SEED DDL which, in turn,
 must be defined in terms of big endian).  Libmseed will not create
 MiniSEED of this flavor by default but can be configured to do so by
-setting the environment variables described above approriately.
+setting the environment variables described above appropriately.
 
 .SH COMMON USAGE
 
diff --git a/doc/ms_log.3 b/doc/ms_log.3
index f616e1b..cfcceb7 100644
--- a/doc/ms_log.3
+++ b/doc/ms_log.3
@@ -1,6 +1,6 @@
 .TH MS_LOG 3 2014/07/16
 .SH NAME
-ms_log and friends \- Central logging facility for libmseed
+ms_log - Central logging facility for libmseed
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_lookup.3 b/doc/ms_lookup.3
index 857356e..ec6b163 100644
--- a/doc/ms_lookup.3
+++ b/doc/ms_lookup.3
@@ -1,6 +1,6 @@
 .TH MS_LOOKUP 3 2006/12/12 "Libmseed API"
-.SH DESCRIPTION
-Look up libmseed and Mini-SEED related information
+.SH NAME
+ms_lookup - Look up libmseed and Mini-SEED related information
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_parse_raw.3 b/doc/ms_parse_raw.3
index 2ec72c6..e41ca30 100644
--- a/doc/ms_parse_raw.3
+++ b/doc/ms_parse_raw.3
@@ -1,6 +1,6 @@
 .TH MSR_PARSE 3 2010/12/30 "Libmseed API"
-.SH DESCRIPTION
-Parse, validate and print details of a SEED data record
+.SH NAME
+msr_parse - Parse, validate and print details of a SEED data record
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_readleapseconds.3 b/doc/ms_readleapseconds.3
index fa006ea..d4f3c2d 100644
--- a/doc/ms_readleapseconds.3
+++ b/doc/ms_readleapseconds.3
@@ -1,6 +1,6 @@
 .TH MS_READLEAPSECONDS 3 2016/10/01 "Libmseed API"
-.SH DESCRIPTION
-Read a leap second file into a global buffer
+.SH NAME
+ms_readleapseconds - Read a leap second file into a global buffer
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_readmsr.3 b/doc/ms_readmsr.3
index f5eb65a..3835c1d 100644
--- a/doc/ms_readmsr.3
+++ b/doc/ms_readmsr.3
@@ -1,6 +1,6 @@
 .TH MS_READMSR 3 2011/01/06 "Libmseed API"
-.SH DESCRIPTION
-Read Mini-SEED data from files
+.SH NAME
+ms_readmsr - Read Mini-SEED data from files
 
 .SH SYNOPSIS
 .nf
@@ -73,7 +73,7 @@ file position (offset from the beginning in bytes) from where the
 returned record was read.  As a special case, if \fIfpos\fP is not
 NULL and the value it points to is less than zero it will be
 interpreted as the (positive) offset in the file at which to begin
-reading data; this feauture does not work with packed files.
+reading data; this feature does not work with packed files.
 
 If the \fIlast\fP pointer is not NULL the value will be set to 1 when
 the record at the end of the file is being returned, otherwise it will
diff --git a/doc/ms_selection.3 b/doc/ms_selection.3
index 9a2e2aa..625b2cd 100644
--- a/doc/ms_selection.3
+++ b/doc/ms_selection.3
@@ -1,6 +1,6 @@
 .TH MS_SELECTION 3 2012/12/28 "Libmseed API"
-.SH DESCRIPTION
-Routines to manage and use data selection lists.
+.SH NAME
+ms_selection - Routines to manage and use data selection lists.
 
 .SH SYNOPSIS
 .nf
@@ -112,7 +112,7 @@ IU   COLA 00   LHZ   *     2008,100,10,00,00 2008,100,10,30,00
 
 .SH SRCNAME MATCHING
 Entries in a Selections list include a "source name" (srcname) string
-to represent matching paramters for network, station, location,
+to represent matching parameters for network, station, location,
 channel and optionally the quality name components.  Each name
 component may contain globbing characters to match more than one
 unique srcname.
@@ -124,9 +124,9 @@ Valid glob patterns include:
    [set]   matches any character in the set
    [^set]  matches any character NOT in the set
            where a set is a group of characters or ranges. a range
-           is written as two characters seperated with a hyphen:
+           is written as two characters separated with a hyphen:
            a-z denotes all characters between a to z inclusive.
-   [-set]  set matches a literal hypen and any character in the set
+   [-set]  set matches a literal hyphen and any character in the set
    []set]  matches a literal close bracket and any character in the set
 
    char    matches itself except where char is '*' or '?' or '['
@@ -182,7 +182,7 @@ The following two calls are equivalent:
   ms_addselect_comp (&selections, "IU", "ANMO", "00", "LH?", "?", startime, endtime);
 .fi
 
-As a futher convienence usage of \fBms_readselectionsfile()\fP would
+As a further convienence usage of \fBms_readselectionsfile()\fP would
 allow the selections to be specified in a simple ASCII file and avoid
 the need to directly call \fBms_addselect()\fP.
 
diff --git a/doc/ms_splitsrcname.3 b/doc/ms_splitsrcname.3
index 4539137..5b70652 100644
--- a/doc/ms_splitsrcname.3
+++ b/doc/ms_splitsrcname.3
@@ -1,6 +1,6 @@
 .TH MS_SPLITSRCNAME 3 2009/12/19 "Libmseed API"
-.SH DESCRIPTION
-Split source names into the SEED naming nomenclature.
+.SH NAME
+ms_splitsrcname - Split source names into the SEED naming nomenclature.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_srcname.3 b/doc/ms_srcname.3
index 7f939fd..551ce6f 100644
--- a/doc/ms_srcname.3
+++ b/doc/ms_srcname.3
@@ -1,6 +1,6 @@
 .TH MS_SRCNAME 3 2006/11/27 "Libmseed API"
-.SH DESCRIPTION
-Determine source names using the SEED naming nomenclature.
+.SH NAME
+ms_srcname - Determine source names using the SEED naming nomenclature.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_strncpclean.3 b/doc/ms_strncpclean.3
index 8937f21..d2ca3cf 100644
--- a/doc/ms_strncpclean.3
+++ b/doc/ms_strncpclean.3
@@ -1,6 +1,6 @@
 .TH MS_STRNCPCLEAN 3 2004/11/22 "Libmseed API"
-.SH DESCRIPTION
-Non-standard string copying
+.SH NAME
+ms_strncpclean - Non-standard string copying
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_time.3 b/doc/ms_time.3
index 34c6b9a..5c5c367 100644
--- a/doc/ms_time.3
+++ b/doc/ms_time.3
@@ -1,6 +1,6 @@
 .TH MS_TIME 3 2013/02/22 "Libmseed API"
-.SH DESCRIPTION
-Time conversion and string generation
+.SH NAME
+ms_time - Time conversion and string generation
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/ms_writemseed.3 b/doc/ms_writemseed.3
index 6f4c556..ca91d15 100644
--- a/doc/ms_writemseed.3
+++ b/doc/ms_writemseed.3
@@ -1,6 +1,6 @@
 .TH MS_WRITEMSEED 3 2011/01/06 "Libmseed API"
-.SH DESCRIPTION
-Write Mini-SEED records to files.
+.SH NAME
+ms_writemseed - Write Mini-SEED records to files.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_addblockette.3 b/doc/msr_addblockette.3
index f7d3d91..6a5c4e8 100644
--- a/doc/msr_addblockette.3
+++ b/doc/msr_addblockette.3
@@ -1,6 +1,6 @@
 .TH MSR_ADDBLOCKETTE 3 2006/02/27 "Libmseed API"
-.SH DESCRIPTION
-Add a blockette to the blockette chain of an MSRecord structure
+.SH NAME
+msr_addblockette - Add a blockette to the blockette chain of an MSRecord structure
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_duplicate.3 b/doc/msr_duplicate.3
index 0de018a..d97d0b2 100644
--- a/doc/msr_duplicate.3
+++ b/doc/msr_duplicate.3
@@ -1,6 +1,6 @@
 .TH MSR_DUPLICATE 3 2007/04/28 "Libmseed API"
-.SH DESCRIPTION
-Duplicate an MSRecord structure
+.SH NAME
+msr_duplicate - Duplicate an MSRecord structure
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_host_latency.3 b/doc/msr_host_latency.3
index 855b6d3..421e9e8 100644
--- a/doc/msr_host_latency.3
+++ b/doc/msr_host_latency.3
@@ -1,6 +1,6 @@
 .TH MSR_HOST_LATENCY 3 2006/02/27 "Libmseed API"
-.SH DESCRIPTION
-Calculate latency between last sample in a Mini-SEED record and the
+.SH NAME
+msr_host_latency - Calculate latency between last sample in a Mini-SEED record and the
 host computer time.
 
 .SH SYNOPSIS
diff --git a/doc/msr_init.3 b/doc/msr_init.3
index 89b4ad9..c619399 100644
--- a/doc/msr_init.3
+++ b/doc/msr_init.3
@@ -1,6 +1,6 @@
 .TH MSR_INIT 3 2006/02/27 "Libmseed API"
-.SH DESCRIPTION
-Initializing and freeing MSRecord and related structures
+.SH NAME
+msr_init - Initializing and freeing MSRecord and related structures
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_normalize_header.3 b/doc/msr_normalize_header.3
index de35685..52f990b 100644
--- a/doc/msr_normalize_header.3
+++ b/doc/msr_normalize_header.3
@@ -1,6 +1,6 @@
 .TH MSR_NORMALIZE_HEADER 3 2007/04/28 "Libmseed API"
-.SH DESCRIPTION
-Normalize or synchronize the header fields of an MSRecord structure.
+.SH NAME
+msr_normalize_header - Normalize or synchronize the header fields of an MSRecord structure.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_pack.3 b/doc/msr_pack.3
index 5fa8a3b..90d53a4 100644
--- a/doc/msr_pack.3
+++ b/doc/msr_pack.3
@@ -1,6 +1,6 @@
 .TH MSR_PACK 3 2013/05/17 "Libmseed API"
-.SH DESCRIPTION
-Packing of Mini-SEED records.
+.SH NAME
+msr_pack - Packing of Mini-SEED records.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_parse.3 b/doc/msr_parse.3
index 861af7c..7de7376 100644
--- a/doc/msr_parse.3
+++ b/doc/msr_parse.3
@@ -1,6 +1,6 @@
 .TH MSR_PARSE 3 2013/01/07 "Libmseed API"
-.SH DESCRIPTION
-Detect and parse a SEED data record from a memory buffer
+.SH NAME
+msr_parse - Detect and parse a SEED data record from a memory buffer
 
 .SH SYNOPSIS
 .nf
@@ -101,7 +101,7 @@ The following example illustrates the intended usage:
           if ( verbose && offset < recbuflen )
           ms_log (2, "Error parsing record at offset %"PRId64"\n", offset);
         }
-      else /* Succesfully found and parsed record */
+      else /* Successfully found and parsed record */
         {
           /* Do something with the record, for example print the details */
           msr_print (msr, verbose);
diff --git a/doc/msr_print.3 b/doc/msr_print.3
index 81da16a..6fb0ca7 100644
--- a/doc/msr_print.3
+++ b/doc/msr_print.3
@@ -1,6 +1,6 @@
 .TH MSR_PRINT 3 2006/11/27 "Libmseed API"
-.SH DESCRIPTION
-Printing of Mini-SEED record header values.
+.SH NAME
+msr_print - Printing of Mini-SEED record header values.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_samprate.3 b/doc/msr_samprate.3
index 62ad076..e1399fe 100644
--- a/doc/msr_samprate.3
+++ b/doc/msr_samprate.3
@@ -1,6 +1,6 @@
 .TH MSR_SAMPRATE 3 2006/02/27 "Libmseed API"
-.SH DESCRIPTION
-Determine sample rate from an MSRecord structure
+.SH NAME
+msr_samprate - Determine sample rate from an MSRecord structure
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_starttime.3 b/doc/msr_starttime.3
index da4a58a..5a233f3 100644
--- a/doc/msr_starttime.3
+++ b/doc/msr_starttime.3
@@ -1,6 +1,6 @@
 .TH MSR_STARTTIME 3 2015/03/02 "Libmseed API"
-.SH DESCRIPTION
-Start and end time determination for MSRecord structures
+.SH NAME
+msr_starttime - Start and end time determination for MSRecord structures
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/msr_unpack.3 b/doc/msr_unpack.3
index 07e11fc..8a18d71 100644
--- a/doc/msr_unpack.3
+++ b/doc/msr_unpack.3
@@ -1,6 +1,6 @@
 .TH MSR_UNPACK 3 2012/12/22 "Libmseed API"
-.SH DESCRIPTION
-Unpacking of Mini-SEED records.
+.SH NAME
+msr_unpack - Unpacking of Mini-SEED records.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_addmsr.3 b/doc/mst_addmsr.3
index 08f5332..b085f98 100644
--- a/doc/mst_addmsr.3
+++ b/doc/mst_addmsr.3
@@ -1,6 +1,6 @@
 .TH MST_ADDMSR 3 2013/05/17 "Libmseed API"
-.SH DESCRIPTION
-Add time coverage and data samples to MSTrace structures
+.SH NAME
+mst_addmsr - Add time coverage and data samples to MSTrace structures
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_convertsamples.3 b/doc/mst_convertsamples.3
index 2c88e46..1c7758a 100644
--- a/doc/mst_convertsamples.3
+++ b/doc/mst_convertsamples.3
@@ -1,6 +1,6 @@
 .TH MST_CONVERTSAMPLES 3 2013/10/01 "Libmseed API"
-.SH DESCRIPTION
-Convert data samples between numeric types
+.SH NAME
+mst_convertsamples - Convert data samples between numeric types
 
 .SH SYNOPSIS
 .nf
@@ -19,7 +19,7 @@ The routines can convert between 32-bit integers (type \fIi\fP),
 32-bit floats (type \fIf\fP) and 64-bit doubles (type \fId\fP).
 
 When converting float and double sample types to integer type a simple
-rouding is applied by adding 0.5 to the sample value before converting
+rounding is applied by adding 0.5 to the sample value before converting
 (truncating) to integer.  This compensates for common machine
 representations of floating point values (e.g. "40.0" represented by
 "39.99999999").
diff --git a/doc/mst_findmatch.3 b/doc/mst_findmatch.3
index 0bb5b9f..428d457 100644
--- a/doc/mst_findmatch.3
+++ b/doc/mst_findmatch.3
@@ -1,6 +1,6 @@
 .TH MST_FINDMATCH 3 2006/02/27 "Libmseed API"
-.SH DESCRIPTION
-Searching a MSTraceGroup for specific MSTrace structures.
+.SH NAME
+mst_findmatch - Searching a MSTraceGroup for specific MSTrace structures.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_groupsort.3 b/doc/mst_groupsort.3
index 9895507..10f8fac 100644
--- a/doc/mst_groupsort.3
+++ b/doc/mst_groupsort.3
@@ -1,6 +1,6 @@
 .TH MST_GROUPSORT 3 2007/04/12 "Libmseed API"
-.SH DESCRIPTION
-Manipulate MSTrace segments in a MSTraceGroup
+.SH NAME
+mst_groupsort - Manipulate MSTrace segments in a MSTraceGroup
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_init.3 b/doc/mst_init.3
index 25acebc..29a6c04 100644
--- a/doc/mst_init.3
+++ b/doc/mst_init.3
@@ -1,6 +1,6 @@
 .TH MST_INIT 3 2006/10/10 "Libmseed API"
-.SH DESCRIPTION
-Initializing and freeing MSTrace and MSTraceGroup structures
+.SH NAME
+mst_init - Initializing and freeing MSTrace and MSTraceGroup structures
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_pack.3 b/doc/mst_pack.3
index 6a84534..d21a54e 100644
--- a/doc/mst_pack.3
+++ b/doc/mst_pack.3
@@ -1,6 +1,6 @@
 .TH MST_PACK 3 2013/05/17 "Libmseed API"
-.SH DESCRIPTION
-Packing of Mini-SEED records from MSTrace segments.
+.SH NAME
+mst_pack - Packing of Mini-SEED records from MSTrace segments.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mst_printtracelist.3 b/doc/mst_printtracelist.3
index 9170388..ecb8f3f 100644
--- a/doc/mst_printtracelist.3
+++ b/doc/mst_printtracelist.3
@@ -1,6 +1,6 @@
 .TH MST_PRINT 3 2008/11/21 "Libmseed API"
-.SH DESCRIPTION
-Printing of MSTrace information.
+.SH NAME
+mst_print - Printing of MSTrace information.
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mstl_addmsr.3 b/doc/mstl_addmsr.3
index e549d8f..e7956d9 100644
--- a/doc/mstl_addmsr.3
+++ b/doc/mstl_addmsr.3
@@ -1,6 +1,6 @@
 .TH MSTL_INIT 3 2008/11/21 "Libmseed API"
-.SH DESCRIPTION
-Adding MSRecord data coverage to and MSTraceList structure
+.SH NAME
+mstl_init - Adding MSRecord data coverage to and MSTraceList structure
 
 .SH SYNOPSIS
 .nf
diff --git a/doc/mstl_init.3 b/doc/mstl_init.3
index b355322..edd7f61 100644
--- a/doc/mstl_init.3
+++ b/doc/mstl_init.3
@@ -1,6 +1,6 @@
 .TH MSTL_INIT 3 2008/11/21 "Libmseed API"
-.SH DESCRIPTION
-Initializing and freeing MSTraceList structures
+.SH NAME
+mstl_init - Initializing and freeing MSTraceList structures
 
 .SH SYNOPSIS
 .nf
@@ -14,7 +14,7 @@ Initializing and freeing MSTraceList structures
 .SH DESCRIPTION
 \fBmstl_init\fP will initialize a MSTraceList structure.  If the
 \fImstl\fP parameter is not NULL the structure will be cleared before
-being reallocated any memory allocated for assosiated MSTraceID and
+being reallocated any memory allocated for associated MSTraceID and
 relate sub-structures will be freed.
 
 \fBmstl_free\fP will free all memory associated with a MSTraceList
diff --git a/doc/mstl_printtracelist.3 b/doc/mstl_printtracelist.3
index 77ff4db..17033f4 100644
--- a/doc/mstl_printtracelist.3
+++ b/doc/mstl_printtracelist.3
@@ -1,6 +1,6 @@
 .TH MSTL_PRINT 3 2008/11/21 "Libmseed API"
-.SH DESCRIPTION
-Printing of MSTrace information.
+.SH NAME
+mstl_print - Printing of MSTrace information.
 
 .SH SYNOPSIS
 .nf
diff --git a/example/Makefile.win b/example/Makefile.win
index c5b80e9..fe4828f 100644
--- a/example/Makefile.win
+++ b/example/Makefile.win
@@ -1,21 +1,14 @@
 #
 # Nmake file - Windows version
 # Use 'nmake -f Makefile.win'
-#
-# THIS HAS NEVER BEEN TESTED
-# Some modification might be required.
 
 NODEBUG=1
 
-!include <ntwin32.mak>
-
 INCS = /I..
 OPTS = -D_CRT_SECURE_NO_WARNINGS
 LIBS = ../libmseed.lib
 BINS = msrepack.exe msview.exe
 
-cflags = $(cflags) -DWIN32
-
 all: $(BINS)
 
 msrepack.exe: msrepack.obj
@@ -25,7 +18,7 @@ msview.exe: msview.obj
 	link.exe /nologo /out:msview.exe $(LIBS) msview.obj
 
 .c.obj:
-	$(cc) /nologo $(cflags) $(cdebug) $(cvarsmt) $(tflags) $(INCS) $(OPTS) $<
+	$(CC) /nologo $(CFLAGS) $(INCS) $(OPTS) /c $<
 
 # Clean-up directives
 clean:
diff --git a/genutils.c b/genutils.c
index a056a10..602cc44 100644
--- a/genutils.c
+++ b/genutils.c
@@ -7,7 +7,7 @@
  * ORFEUS/EC-Project MEREDIAN
  * IRIS Data Management Center
  *
- * modified: 2016.281
+ * modified: 2017.053
  ***************************************************************************/
 
 #include <errno.h>
@@ -17,7 +17,6 @@
 #include <time.h>
 
 #include "libmseed.h"
-#include "lmplatform.h"
 
 static hptime_t ms_time2hptime_int (int year, int day, int hour,
                                     int min, int sec, int usec);
@@ -1573,7 +1572,7 @@ ms_rsqrt64 (double val)
   x2 = val * 0.5;
   y  = val;
   memcpy (&i, &y, sizeof(i));
-  i  = 0x5fe6eb50c7b537a9 - (i >> 1);
+  i  = 0x5fe6eb50c7b537a9ULL - (i >> 1);
   memcpy (&y, &i, sizeof(y));
   y  = y * (1.5 - (x2 * y * y));
   y  = y * (1.5 - (x2 * y * y));
diff --git a/gswap.c b/gswap.c
index 492509a..5979126 100644
--- a/gswap.c
+++ b/gswap.c
@@ -21,7 +21,7 @@
  * Version: 2010.006
  ***************************************************************************/
 
-#include "lmplatform.h"
+#include "libmseed.h"
 
 /* Swap routines that work on any (aligned or not) quantities */
 
diff --git a/libmseed.h b/libmseed.h
index 06459e4..b578906 100644
--- a/libmseed.h
+++ b/libmseed.h
@@ -1,7 +1,6 @@
-
 /***************************************************************************
  * libmseed.h:
- * 
+ *
  * Interface declarations for the Mini-SEED library (libmseed).
  *
  * This library is free software; you can redistribute it and/or modify
@@ -18,11 +17,10 @@
  * License along with this software.
  * If not, see <https://www.gnu.org/licenses/>.
  *
- * Copyright (C) 2016 Chad Trabant
+ * Copyright (C) 2017 Chad Trabant
  * IRIS Data Management Center
  ***************************************************************************/
 
-
 #ifndef LIBMSEED_H
 #define LIBMSEED_H 1
 
@@ -30,10 +28,95 @@
 extern "C" {
 #endif
 
-#include "lmplatform.h"
+#define LIBMSEED_VERSION "2.19.2"
+#define LIBMSEED_RELEASE "2017.061"
+
+/* C99 standard headers */
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+
+/* This library uses structs that map to SEED header/blockette
+   structures that are required to have a layout exactly as specified,
+   i.e. no padding.
+
+   If "ATTRIBUTE_PACKED" is defined at compile time (e.g. -DATTRIBUTE_PACKED)
+   the preprocessor will use the define below to add the "packed" attribute
+   to effected structs.  This attribute is supported by GCC and increasingly
+   more compilers.
+  */
+#if defined(ATTRIBUTE_PACKED)
+  #define LMP_PACKED __attribute__((packed))
+#else
+  #define LMP_PACKED
+#endif
+
+/* Set platform specific defines */
+#if defined(__linux__) || defined(__linux) || defined(__CYGWIN__)
+  #define LMP_LINUX 1
+  #define LMP_GLIBC2 1 /* Deprecated */
+#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+  #define LMP_BSD 1
+#elif defined(__sun__) || defined(__sun)
+  #define LMP_SOLARIS 1
+#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+  #define LMP_WIN 1
+  #define LMP_WIN32 1 /* Deprecated */
+#endif
 
-#define LIBMSEED_VERSION "2.18"
-#define LIBMSEED_RELEASE "2016.286"
+/* Set platform specific features */
+#if defined(LMP_LINUX) || defined(LMP_BSD) || defined(LMP_SOLARIS)
+  #include <unistd.h>
+  #include <inttypes.h>
+#elif defined(LMP_WIN)
+  #include <windows.h>
+  #include <sys/types.h>
+
+  /* For MSVC 2012 and earlier define standard int types, otherwise use inttypes.h */
+  #if defined(_MSC_VER) && _MSC_VER <= 1700
+    typedef signed char int8_t;
+    typedef unsigned char uint8_t;
+    typedef signed short int int16_t;
+    typedef unsigned short int uint16_t;
+    typedef signed int int32_t;
+    typedef unsigned int uint32_t;
+    typedef signed __int64 int64_t;
+    typedef unsigned __int64 uint64_t;
+  #else
+    #include <inttypes.h>
+  #endif
+
+  /* For MSVC define PRId64 and SCNd64 if needed */
+  #if defined(_MSC_VER)
+    #if !defined(PRId64)
+      #define PRId64 "I64d"
+    #endif
+    #if !defined(SCNd64)
+      #define SCNd64 "I64d"
+    #endif
+
+    #define snprintf _snprintf
+    #define vsnprintf _vsnprintf
+    #define strcasecmp _stricmp
+    #define strncasecmp _strnicmp
+    #define strtoull _strtoui64
+    #define strdup _strdup
+    #define fileno _fileno
+  #endif
+
+  /* Extras needed for MinGW */
+  #if defined(__MINGW32__) || defined(__MINGW64__)
+    #include <fcntl.h>
+
+    #define fstat _fstat
+    #define stat _stat
+  #endif
+#else
+  #include <inttypes.h>
+#endif
 
 #define MINRECLEN   128      /* Minimum Mini-SEED record length, 2^7 bytes */
                              /* Note: the SEED specification minimum is 256 */
@@ -85,7 +168,7 @@ extern "C" {
 
 /* Macro to test for sane year and day values, used primarily to
  * determine if byte order swapping is needed.
- * 
+ *
  * Year : between 1900 and 2100
  * Day  : between 1 and 366
  *
@@ -97,7 +180,7 @@ extern "C" {
 /* Macro to test memory for a SEED data record signature by checking
  * SEED data record header values at known byte offsets to determine
  * if the memory contains a valid record.
- * 
+ *
  * Offset = Value
  * [0-5]  = Digits, spaces or NULL, SEED sequence number
  *     6  = Data record quality indicator
@@ -125,7 +208,7 @@ extern "C" {
 /* Macro to test memory for a blank/noise SEED data record signature
  * by checking for a valid SEED sequence number and padding characters
  * to determine if the memory contains a valid blank/noise record.
- * 
+ *
  * Offset = Value
  * [0-5]  = Digits or NULL, SEED sequence number
  * [6-47] = Space character (ASCII 32), remainder of fixed header
@@ -282,7 +365,7 @@ struct blkt_320_s
   char      rolloff[12];
   char      noise_type[8];
 } LMP_PACKED;
-  
+
 /* Blockette 390, Generic Calibration (without header) */
 struct blkt_390_s
 {
@@ -384,14 +467,14 @@ StreamState;
 typedef struct MSRecord_s {
   char           *record;            /* Mini-SEED record */
   int32_t         reclen;            /* Length of Mini-SEED record in bytes */
-  
+
   /* Pointers to SEED data record structures */
   struct fsdh_s      *fsdh;          /* Fixed Section of Data Header */
   BlktLink           *blkts;         /* Root of blockette chain */
   struct blkt_100_s  *Blkt100;       /* Blockette 100, if present */
   struct blkt_1000_s *Blkt1000;      /* Blockette 1000, if present */
   struct blkt_1001_s *Blkt1001;      /* Blockette 1001, if present */
-  
+
   /* Common header fields in accessible form */
   int32_t         sequence_number;   /* SEED record sequence number */
   char            network[11];       /* Network designation, NULL terminated */
@@ -404,12 +487,12 @@ typedef struct MSRecord_s {
   int64_t         samplecnt;         /* Number of samples in record */
   int8_t          encoding;          /* Data encoding format */
   int8_t          byteorder;         /* Original/Final byte order of record */
-  
+
   /* Data sample fields */
   void           *datasamples;       /* Data samples, 'numsamples' of type 'sampletype'*/
   int64_t         numsamples;        /* Number of data samples in datasamples */
   char            sampletype;        /* Sample type code: a, i, f, d */
-  
+
   /* Stream oriented state information */
   StreamState    *ststate;           /* Stream processing state information */
 }
@@ -421,7 +504,7 @@ typedef struct MSTrace_s {
   char            station[11];       /* Station designation, NULL terminated */
   char            location[11];      /* Location designation, NULL terminated */
   char            channel[11];       /* Channel designation, NULL terminated */
-  char            dataquality;       /* Data quality indicator */ 
+  char            dataquality;       /* Data quality indicator */
   char            type;              /* MSTrace type code */
   hptime_t        starttime;         /* Time of first sample */
   hptime_t        endtime;           /* Time of last sample */
@@ -744,6 +827,9 @@ extern void     ms_gswap8a ( void *data8 );
   ms_gswap2 (x.day);    \
   ms_gswap2 (x.fract);
 
+/* Platform portable functions */
+extern off_t lmp_ftello (FILE *stream);
+extern int lmp_fseeko (FILE *stream, off_t offset, int whence);
 
 #ifdef __cplusplus
 }
diff --git a/libmseed.map b/libmseed.map
new file mode 100644
index 0000000..27c5ab6
--- /dev/null
+++ b/libmseed.map
@@ -0,0 +1,11 @@
+{
+  global:
+      ms_*;
+      msr_*;
+      mst_*;
+      mstl_*;
+      unpackencodingformat;
+
+  local:
+      *;
+};
diff --git a/lmplatform.c b/lmplatform.c
index 2006faf..9023d0b 100644
--- a/lmplatform.c
+++ b/lmplatform.c
@@ -9,7 +9,7 @@
 /* Define _LARGEFILE_SOURCE to get ftello/fseeko on some systems (Linux) */
 #define _LARGEFILE_SOURCE 1
 
-#include "lmplatform.h"
+#include "libmseed.h"
 
 /***************************************************************************
  * lmp_ftello:
diff --git a/lmplatform.h b/lmplatform.h
deleted file mode 100644
index 52e11c2..0000000
--- a/lmplatform.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/***************************************************************************
- * lmplatform.h:
- *
- * Platform specific headers.  This file provides a basic level of platform
- * portability.
- *
- * modified: 2016.275
- ***************************************************************************/
-
-#ifndef LMPLATFORM_H
-#define LMPLATFORM_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-  /* On some platforms (e.g. ARM) structures are aligned on word boundaries
-     by adding padding between the elements.  This library uses structs that
-     map to SEED header/blockette structures that are required to have a
-     layout exactly as specified, i.e. no padding.
-
-     If "ATTRIBUTE_PACKED" is defined at compile time (e.g. -DATTRIBUTE_PACKED)
-     the preprocessor will use the define below to add the "packed" attribute
-     to effected structs.  This attribute is supported by GCC and increasingly
-     more compilers.
-  */
-#if defined(ATTRIBUTE_PACKED)
-  #define LMP_PACKED __attribute__((packed))
-#else
-  #define LMP_PACKED
-#endif
-
-/* C99 standard headers */
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-
-/* Set architecture specific defines and features */
-#if defined(__linux__) || defined(__linux) || defined(__CYGWIN__)
-  #define LMP_LINUX 1
-  #define LMP_GLIBC2 1 /* Deprecated */
-
-  #include <unistd.h>
-  #include <inttypes.h>
-
-#elif defined(__sun__) || defined(__sun)
-  #define LMP_SOLARIS 1
-
-  #include <unistd.h>
-  #include <inttypes.h>
-
-#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
-  #define LMP_BSD 1
-
-  #include <unistd.h>
-  #include <inttypes.h>
-
-#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-  #define LMP_WIN 1
-  #define LMP_WIN32 1 /* Deprecated */
-
-  #include <windows.h>
-  #include <sys/types.h>
-
-  /* For MSVC 2012 and earlier define standard int types, otherwise use inttypes.h */
-  #if defined(_MSC_VER) && _MSC_VER <= 1700
-    typedef signed char int8_t;
-    typedef unsigned char uint8_t;
-    typedef signed short int int16_t;
-    typedef unsigned short int uint16_t;
-    typedef signed int int32_t;
-    typedef unsigned int uint32_t;
-    typedef signed __int64 int64_t;
-    typedef unsigned __int64 uint64_t;
-  #else
-    #include <inttypes.h>
-  #endif
-
-  #if defined(_MSC_VER)
-    #if !defined(PRId64)
-      #define PRId64 "I64d"
-    #endif
-    #if !defined(SCNd64)
-      #define SCNd64 "I64d"
-    #endif
-
-    #define snprintf _snprintf
-    #define vsnprintf _vsnprintf
-    #define strcasecmp _stricmp
-    #define strncasecmp _strnicmp
-    #define strtoull _strtoui64
-    #define strdup _strdup
-    #define fileno _fileno
-  #endif
-
-  #if defined(__MINGW32__) || defined(__MINGW64__)
-    #include <fcntl.h>
-
-    #define fstat _fstat
-    #define stat _stat
-  #endif
-
-#endif
-
-extern off_t lmp_ftello (FILE *stream);
-extern int lmp_fseeko (FILE *stream, off_t offset, int whence);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LMPLATFORM_H */
diff --git a/mseed.pc.in b/mseed.pc.in
new file mode 100644
index 0000000..7fcac74
--- /dev/null
+++ b/mseed.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: @PACKAGE_NAME@
+Description: The Mini-SEED library provides a framework for manipulation of SEED
+ (Standard for the Exchange of Earthquake Data) data records.
+URL: @PACKAGE_URL@
+Version: @VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lmseed
diff --git a/packdata.c b/packdata.c
index 6a1c044..4841723 100644
--- a/packdata.c
+++ b/packdata.c
@@ -2,7 +2,7 @@
  * Routines for packing text/ASCII, INT_16, INT_32, FLOAT_32, FLOAT_64,
  * STEIM1 and STEIM2 data records.
  *
- * modified: 2016.277
+ * modified: 2017.053
  ************************************************************************/
 
 #include <memory.h>
@@ -344,7 +344,7 @@ msr_encode_steim1 (int32_t *input, int samplecount, int32_t *output,
         word->d8[3] = diffs[3];
 
         /* 2-bit nibble is 0b01 (0x1) */
-        frameptr[0] |= 0x1 << (30 - 2 * widx);
+        frameptr[0] |= 0x1ul << (30 - 2 * widx);
 
         packedsamples = 4;
       }
@@ -365,7 +365,7 @@ msr_encode_steim1 (int32_t *input, int samplecount, int32_t *output,
         }
 
         /* 2-bit nibble is 0b10 (0x2) */
-        frameptr[0] |= 0x2 << (30 - 2 * widx);
+        frameptr[0] |= 0x2ul << (30 - 2 * widx);
 
         packedsamples = 2;
       }
@@ -381,7 +381,7 @@ msr_encode_steim1 (int32_t *input, int samplecount, int32_t *output,
           ms_gswap4a (&frameptr[widx]);
 
         /* 2-bit nibble is 0b11 (0x3) */
-        frameptr[0] |= 0x3 << (30 - 2 * widx);
+        frameptr[0] |= 0x3ul << (30 - 2 * widx);
 
         packedsamples = 1;
       }
@@ -533,19 +533,19 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0], diffs[1], diffs[2], diffs[3], diffs[4], diffs[5], diffs[6]);
 
         /* Mask the values, shift to proper location and set in word */
-        frameptr[widx] = ((uint32_t)diffs[6] & 0xF);
-        frameptr[widx] |= ((uint32_t)diffs[5] & 0xF) << 4;
-        frameptr[widx] |= ((uint32_t)diffs[4] & 0xF) << 8;
-        frameptr[widx] |= ((uint32_t)diffs[3] & 0xF) << 12;
-        frameptr[widx] |= ((uint32_t)diffs[2] & 0xF) << 16;
-        frameptr[widx] |= ((uint32_t)diffs[1] & 0xF) << 20;
-        frameptr[widx] |= ((uint32_t)diffs[0] & 0xF) << 24;
+        frameptr[widx] = ((uint32_t)diffs[6] & 0xFul);
+        frameptr[widx] |= ((uint32_t)diffs[5] & 0xFul) << 4;
+        frameptr[widx] |= ((uint32_t)diffs[4] & 0xFul) << 8;
+        frameptr[widx] |= ((uint32_t)diffs[3] & 0xFul) << 12;
+        frameptr[widx] |= ((uint32_t)diffs[2] & 0xFul) << 16;
+        frameptr[widx] |= ((uint32_t)diffs[1] & 0xFul) << 20;
+        frameptr[widx] |= ((uint32_t)diffs[0] & 0xFul) << 24;
 
         /* 2-bit decode nibble is 0b10 (0x2) */
-        frameptr[widx] |= 0x2 << 30;
+        frameptr[widx] |= 0x2ul << 30;
 
         /* 2-bit nibble is 0b11 (0x3) */
-        frameptr[0] |= 0x3 << (30 - 2 * widx);
+        frameptr[0] |= 0x3ul << (30 - 2 * widx);
 
         packedsamples = 7;
       }
@@ -559,18 +559,18 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0], diffs[1], diffs[2], diffs[3], diffs[4], diffs[5]);
 
         /* Mask the values, shift to proper location and set in word */
-        frameptr[widx] = ((uint32_t)diffs[5] & 0x1F);
-        frameptr[widx] |= ((uint32_t)diffs[4] & 0x1F) << 5;
-        frameptr[widx] |= ((uint32_t)diffs[3] & 0x1F) << 10;
-        frameptr[widx] |= ((uint32_t)diffs[2] & 0x1F) << 15;
-        frameptr[widx] |= ((uint32_t)diffs[1] & 0x1F) << 20;
-        frameptr[widx] |= ((uint32_t)diffs[0] & 0x1F) << 25;
+        frameptr[widx] = ((uint32_t)diffs[5] & 0x1Ful);
+        frameptr[widx] |= ((uint32_t)diffs[4] & 0x1Ful) << 5;
+        frameptr[widx] |= ((uint32_t)diffs[3] & 0x1Ful) << 10;
+        frameptr[widx] |= ((uint32_t)diffs[2] & 0x1Ful) << 15;
+        frameptr[widx] |= ((uint32_t)diffs[1] & 0x1Ful) << 20;
+        frameptr[widx] |= ((uint32_t)diffs[0] & 0x1Ful) << 25;
 
         /* 2-bit decode nibble is 0b01 (0x1) */
-        frameptr[widx] |= 0x1 << 30;
+        frameptr[widx] |= 0x1ul << 30;
 
         /* 2-bit nibble is 0b11 (0x3) */
-        frameptr[0] |= 0x3 << (30 - 2 * widx);
+        frameptr[0] |= 0x3ul << (30 - 2 * widx);
 
         packedsamples = 6;
       }
@@ -584,16 +584,16 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0], diffs[1], diffs[2], diffs[3], diffs[4]);
 
         /* Mask the values, shift to proper location and set in word */
-        frameptr[widx] = ((uint32_t)diffs[4] & 0x3F);
-        frameptr[widx] |= ((uint32_t)diffs[3] & 0x3F) << 6;
-        frameptr[widx] |= ((uint32_t)diffs[2] & 0x3F) << 12;
-        frameptr[widx] |= ((uint32_t)diffs[1] & 0x3F) << 18;
-        frameptr[widx] |= ((uint32_t)diffs[0] & 0x3F) << 24;
+        frameptr[widx] = ((uint32_t)diffs[4] & 0x3Ful);
+        frameptr[widx] |= ((uint32_t)diffs[3] & 0x3Ful) << 6;
+        frameptr[widx] |= ((uint32_t)diffs[2] & 0x3Ful) << 12;
+        frameptr[widx] |= ((uint32_t)diffs[1] & 0x3Ful) << 18;
+        frameptr[widx] |= ((uint32_t)diffs[0] & 0x3Ful) << 24;
 
         /* 2-bit decode nibble is 0b00, nothing to set */
 
         /* 2-bit nibble is 0b11 (0x3) */
-        frameptr[0] |= 0x3 << (30 - 2 * widx);
+        frameptr[0] |= 0x3ul << (30 - 2 * widx);
 
         packedsamples = 5;
       }
@@ -614,7 +614,7 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
         word->d8[3] = diffs[3];
 
         /* 2-bit nibble is 0b01, only need to set 2nd bit */
-        frameptr[0] |= 0x1 << (30 - 2 * widx);
+        frameptr[0] |= 0x1ul << (30 - 2 * widx);
 
         packedsamples = 4;
       }
@@ -627,15 +627,15 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0], diffs[1], diffs[2]);
 
         /* Mask the values, shift to proper location and set in word */
-        frameptr[widx] = ((uint32_t)diffs[2] & 0x3FF);
-        frameptr[widx] |= ((uint32_t)diffs[1] & 0x3FF) << 10;
-        frameptr[widx] |= ((uint32_t)diffs[0] & 0x3FF) << 20;
+        frameptr[widx] = ((uint32_t)diffs[2] & 0x3FFul);
+        frameptr[widx] |= ((uint32_t)diffs[1] & 0x3FFul) << 10;
+        frameptr[widx] |= ((uint32_t)diffs[0] & 0x3FFul) << 20;
 
         /* 2-bit decode nibble is 0b11 (0x3) */
-        frameptr[widx] |= 0x3 << 30;
+        frameptr[widx] |= 0x3ul << 30;
 
         /* 2-bit nibble is 0b10 (0x2) */
-        frameptr[0] |= 0x2 << (30 - 2 * widx);
+        frameptr[0] |= 0x2ul << (30 - 2 * widx);
 
         packedsamples = 3;
       }
@@ -648,14 +648,14 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0], diffs[1]);
 
         /* Mask the values, shift to proper location and set in word */
-        frameptr[widx] = ((uint32_t)diffs[1] & 0x7FFF);
-        frameptr[widx] |= ((uint32_t)diffs[0] & 0x7FFF) << 15;
+        frameptr[widx] = ((uint32_t)diffs[1] & 0x7FFFul);
+        frameptr[widx] |= ((uint32_t)diffs[0] & 0x7FFFul) << 15;
 
         /* 2-bit decode nibble is 0b10 (0x2) */
-        frameptr[widx] |= 0x2 << 30;
+        frameptr[widx] |= 0x2ul << 30;
 
         /* 2-bit nibble is 0b10 (0x2) */
-        frameptr[0] |= 0x2 << (30 - 2 * widx);
+        frameptr[0] |= 0x2ul << (30 - 2 * widx);
 
         packedsamples = 2;
       }
@@ -668,13 +668,13 @@ msr_encode_steim2 (int32_t *input, int samplecount, int32_t *output,
                   widx, diffs[0]);
 
         /* Mask the value and set in word */
-        frameptr[widx] = ((uint32_t)diffs[0] & 0x3FFFFFFF);
+        frameptr[widx] = ((uint32_t)diffs[0] & 0x3FFFFFFFul);
 
         /* 2-bit decode nibble is 0b01 (0x1) */
-        frameptr[widx] |= 0x1 << 30;
+        frameptr[widx] |= 0x1ul << 30;
 
         /* 2-bit nibble is 0b10 (0x2) */
-        frameptr[0] |= 0x2 << (30 - 2 * widx);
+        frameptr[0] |= 0x2ul << (30 - 2 * widx);
 
         packedsamples = 1;
       }
diff --git a/test/pack-Float32-encoded.test b/test/pack-Float32-encoded.test
index 1cefb6c..a73b3b5 100755
--- a/test/pack-Float32-encoded.test
+++ b/test/pack-Float32-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 4 -o -
diff --git a/test/pack-Float64-encoded.test b/test/pack-Float64-encoded.test
index d0addab..2c18270 100755
--- a/test/pack-Float64-encoded.test
+++ b/test/pack-Float64-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 5 -o -
diff --git a/test/pack-Int16-encoded.test b/test/pack-Int16-encoded.test
index 8801c40..1b9d23d 100755
--- a/test/pack-Int16-encoded.test
+++ b/test/pack-Int16-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 1 -o -
diff --git a/test/pack-Int32-encoded.test b/test/pack-Int32-encoded.test
index 86e0a4c..7ad7e4b 100755
--- a/test/pack-Int32-encoded.test
+++ b/test/pack-Int32-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 3 -o -
diff --git a/test/pack-Steim1-encoded.test b/test/pack-Steim1-encoded.test
index e951850..75a4cff 100755
--- a/test/pack-Steim1-encoded.test
+++ b/test/pack-Steim1-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 10 -o -
diff --git a/test/pack-Steim2-encoded.test b/test/pack-Steim2-encoded.test
index 8caf1cd..2ff59cd 100755
--- a/test/pack-Steim2-encoded.test
+++ b/test/pack-Steim2-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 11 -o -
diff --git a/test/pack-text-encoded.test b/test/pack-text-encoded.test
index 62b9cfb..ec96b8b 100755
--- a/test/pack-text-encoded.test
+++ b/test/pack-text-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestpack -e 0 -o -
diff --git a/test/read-CDSN-encoded.test b/test/read-CDSN-encoded.test
index 3289674..3a9f087 100755
--- a/test/read-CDSN-encoded.test
+++ b/test/read-CDSN-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/CDSN-encoded.mseed -D
diff --git a/test/read-DWWSSN-encoded.test b/test/read-DWWSSN-encoded.test
index b75c63f..dd9d8f5 100755
--- a/test/read-DWWSSN-encoded.test
+++ b/test/read-DWWSSN-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/DWWSSN-encoded.mseed -D
diff --git a/test/read-Float32-encoded.test b/test/read-Float32-encoded.test
index 7afce92..68693cf 100755
--- a/test/read-Float32-encoded.test
+++ b/test/read-Float32-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Float32-encoded.mseed -D
diff --git a/test/read-Float64-encoded.test b/test/read-Float64-encoded.test
index c85dea8..d1b7b85 100755
--- a/test/read-Float64-encoded.test
+++ b/test/read-Float64-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Float64-encoded.mseed -D
diff --git a/test/read-GEOSCOPE163-encoded.test b/test/read-GEOSCOPE163-encoded.test
index ac8753e..2f270f1 100755
--- a/test/read-GEOSCOPE163-encoded.test
+++ b/test/read-GEOSCOPE163-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/GEOSCOPE-16bit-3exp-encoded.mseed -D
diff --git a/test/read-Int16-encoded.test b/test/read-Int16-encoded.test
index 51f35e9..95f7af4 100755
--- a/test/read-Int16-encoded.test
+++ b/test/read-Int16-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int16-encoded.mseed -D
diff --git a/test/read-Int32-1024byte-encoded.test b/test/read-Int32-1024byte-encoded.test
index d5c9a21..c4d5d69 100755
--- a/test/read-Int32-1024byte-encoded.test
+++ b/test/read-Int32-1024byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-1024byte.mseed -D
diff --git a/test/read-Int32-128byte-encoded.test b/test/read-Int32-128byte-encoded.test
index 0969d8f..88a75c0 100755
--- a/test/read-Int32-128byte-encoded.test
+++ b/test/read-Int32-128byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-128byte.mseed -D
diff --git a/test/read-Int32-2048byte-encoded.test b/test/read-Int32-2048byte-encoded.test
index ce9f3eb..5768e9a 100755
--- a/test/read-Int32-2048byte-encoded.test
+++ b/test/read-Int32-2048byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-2048byte.mseed -D
diff --git a/test/read-Int32-256byte-encoded.test b/test/read-Int32-256byte-encoded.test
index 5c4c17e..1bc32a7 100755
--- a/test/read-Int32-256byte-encoded.test
+++ b/test/read-Int32-256byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-256byte.mseed -D
diff --git a/test/read-Int32-4096byte-encoded.test b/test/read-Int32-4096byte-encoded.test
index 9a05d9a..0dd031c 100755
--- a/test/read-Int32-4096byte-encoded.test
+++ b/test/read-Int32-4096byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-4096byte.mseed -D
diff --git a/test/read-Int32-512byte-encoded.test b/test/read-Int32-512byte-encoded.test
index e61ce69..efc5f00 100755
--- a/test/read-Int32-512byte-encoded.test
+++ b/test/read-Int32-512byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-512byte.mseed -D
diff --git a/test/read-Int32-8192byte-encoded.test b/test/read-Int32-8192byte-encoded.test
index 9edba1c..419c6f4 100755
--- a/test/read-Int32-8192byte-encoded.test
+++ b/test/read-Int32-8192byte-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-8192byte.mseed -D
diff --git a/test/read-SRO-encoded.test b/test/read-SRO-encoded.test
index 1e6f6ae..78dfb42 100755
--- a/test/read-SRO-encoded.test
+++ b/test/read-SRO-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/SRO-encoded.mseed -D
diff --git a/test/read-Steim1-bigendian.test b/test/read-Steim1-bigendian.test
index dde0a07..e15a1f4 100755
--- a/test/read-Steim1-bigendian.test
+++ b/test/read-Steim1-bigendian.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Steim1-AllDifferences-BE.mseed -D
diff --git a/test/read-Steim1-littleendian.test b/test/read-Steim1-littleendian.test
index 5b14300..da4a1d6 100755
--- a/test/read-Steim1-littleendian.test
+++ b/test/read-Steim1-littleendian.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Steim1-AllDifferences-LE.mseed -D
diff --git a/test/read-Steim2-bigendian.test b/test/read-Steim2-bigendian.test
index 9325e0c..ec97983 100755
--- a/test/read-Steim2-bigendian.test
+++ b/test/read-Steim2-bigendian.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Steim2-AllDifferences-BE.mseed -D
diff --git a/test/read-Steim2-littleendian.test b/test/read-Steim2-littleendian.test
index 070a304..501da7a 100755
--- a/test/read-Steim2-littleendian.test
+++ b/test/read-Steim2-littleendian.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Steim2-AllDifferences-LE.mseed -D
diff --git a/test/read-detection-record.test b/test/read-detection-record.test
index 485f89f..8850216 100755
--- a/test/read-detection-record.test
+++ b/test/read-detection-record.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/detection.record.mseed -pp
diff --git a/test/read-invalid-blockette-offset.test b/test/read-invalid-blockette-offset.test
index 19b897f..3e16982 100755
--- a/test/read-invalid-blockette-offset.test
+++ b/test/read-invalid-blockette-offset.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/invalid-blockette-offset.mseed
diff --git a/test/read-mixed-order-mixed-length-trace.test b/test/read-mixed-order-mixed-length-trace.test
index 2de67bb..3d4e816 100755
--- a/test/read-mixed-order-mixed-length-trace.test
+++ b/test/read-mixed-order-mixed-length-trace.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/Int32-oneseries-mixedlengths-mixedorder.mseed -tg
diff --git a/test/read-no-blockette1000.test b/test/read-no-blockette1000.test
index ca83fed..732185e 100755
--- a/test/read-no-blockette1000.test
+++ b/test/read-no-blockette1000.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/no-blockette1000-steim1.mseed -d -pp
diff --git a/test/read-text-encoded.test b/test/read-text-encoded.test
index 22a5fb2..697283d 100755
--- a/test/read-text-encoded.test
+++ b/test/read-text-encoded.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/text-encoded.mseed -D
diff --git a/test/read-unapplied-timecorrection.test b/test/read-unapplied-timecorrection.test
index caab550..102e03c 100755
--- a/test/read-unapplied-timecorrection.test
+++ b/test/read-unapplied-timecorrection.test
@@ -1,2 +1,4 @@
 #!/bin/sh
+LD_LIBRARY_PATH=.. \
+DYLD_LIBRARY_PATH=.. \
 ./lmtestparse data/unapplied-timecorrection.mseed -pp
diff --git a/unpackdata.c b/unpackdata.c
index c7afa7a..3ef84a2 100644
--- a/unpackdata.c
+++ b/unpackdata.c
@@ -3,7 +3,7 @@
  * STEIM2, GEOSCOPE (24bit and gain ranged), CDSN, SRO and DWWSSN
  * encoded data.
  *
- * modified: 2016.281
+ * modified: 2017.053
  ************************************************************************/
 
 #include <memory.h>
@@ -16,13 +16,13 @@
 /* Control for printing debugging information */
 int decodedebug = 0;
 
-/* Extract bit range and shift to start */
-#define EXTRACTBITRANGE(VALUE, STARTBIT, LENGTH) ((VALUE & (((1 << LENGTH) - 1) << STARTBIT)) >> STARTBIT)
+/* Extract bit range.  Byte order agnostic & defined when used with unsigned values */
+#define EXTRACTBITRANGE(VALUE, STARTBIT, LENGTH) ((VALUE >> STARTBIT) & ((1U << LENGTH) - 1))
 
-#define MAX12 0x7ff    /* maximum 12 bit positive # */
-#define MAX14 0x1fff   /* maximum 14 bit positive # */
-#define MAX16 0x7fff   /* maximum 16 bit positive # */
-#define MAX24 0x7fffff /* maximum 24 bit positive # */
+#define MAX12 0x7FFul    /* maximum 12 bit positive # */
+#define MAX14 0x1FFFul   /* maximum 14 bit positive # */
+#define MAX16 0x7FFFul   /* maximum 16 bit positive # */
+#define MAX24 0x7FFFFFul /* maximum 24 bit positive # */
 
 /************************************************************************
  * msr_decode_int16:
@@ -441,7 +441,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 
         case 1: /* nibble=10, dnib=01: One 30-bit difference */
           diffcount = 1;
-          semask    = 1U << (30 - 1); /* Sign extension from bit 30 */
+          semask    = 1ul << (30 - 1); /* Sign extension from bit 30 */
           diff[0]   = EXTRACTBITRANGE (frame[widx], 0, 30);
           diff[0]   = (diff[0] ^ semask) - semask;
 
@@ -451,7 +451,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 
         case 2: /* nibble=10, dnib=10: Two 15-bit differences */
           diffcount = 2;
-          semask    = 1U << (15 - 1); /* Sign extension from bit 15 */
+          semask    = 1ul << (15 - 1); /* Sign extension from bit 15 */
           for (idx = 0; idx < diffcount; idx++)
           {
             diff[idx] = EXTRACTBITRANGE (frame[widx], (15 - idx * 15), 15);
@@ -464,7 +464,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 
         case 3: /* nibble=10, dnib=11: Three 10-bit differences */
           diffcount = 3;
-          semask    = 1U << (10 - 1); /* Sign extension from bit 10 */
+          semask    = 1ul << (10 - 1); /* Sign extension from bit 10 */
           for (idx = 0; idx < diffcount; idx++)
           {
             diff[idx] = EXTRACTBITRANGE (frame[widx], (20 - idx * 10), 10);
@@ -487,7 +487,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
         {
         case 0: /* nibble=11, dnib=00: Five 6-bit differences */
           diffcount = 5;
-          semask    = 1U << (6 - 1); /* Sign extension from bit 6 */
+          semask    = 1ul << (6 - 1); /* Sign extension from bit 6 */
           for (idx = 0; idx < diffcount; idx++)
           {
             diff[idx] = EXTRACTBITRANGE (frame[widx], (24 - idx * 6), 6);
@@ -501,7 +501,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 
         case 1: /* nibble=11, dnib=01: Six 5-bit differences */
           diffcount = 6;
-          semask    = 1U << (5 - 1); /* Sign extension from bit 5 */
+          semask    = 1ul << (5 - 1); /* Sign extension from bit 5 */
           for (idx = 0; idx < diffcount; idx++)
           {
             diff[idx] = EXTRACTBITRANGE (frame[widx], (25 - idx * 5), 5);
@@ -515,7 +515,7 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 
         case 2: /* nibble=11, dnib=10: Seven 4-bit differences */
           diffcount = 7;
-          semask    = 1U << (4 - 1); /* Sign extension from bit 4 */
+          semask    = 1ul << (4 - 1); /* Sign extension from bit 4 */
           for (idx = 0; idx < diffcount; idx++)
           {
             diff[idx] = EXTRACTBITRANGE (frame[widx], (24 - idx * 4), 4);
@@ -564,10 +564,10 @@ msr_decode_steim2 (int32_t *input, int inputlength, int samplecount,
 } /* End of msr_decode_steim2() */
 
 /* Defines for GEOSCOPE encoding */
-#define GEOSCOPE_MANTISSA_MASK 0x0fff /* mask for mantissa */
-#define GEOSCOPE_GAIN3_MASK 0x7000    /* mask for gainrange factor */
-#define GEOSCOPE_GAIN4_MASK 0xf000    /* mask for gainrange factor */
-#define GEOSCOPE_SHIFT 12             /* # bits in mantissa */
+#define GEOSCOPE_MANTISSA_MASK 0x0FFFul /* mask for mantissa */
+#define GEOSCOPE_GAIN3_MASK 0x7000ul    /* mask for gainrange factor */
+#define GEOSCOPE_GAIN4_MASK 0xf000ul    /* mask for gainrange factor */
+#define GEOSCOPE_SHIFT 12               /* # bits in mantissa */
 
 /************************************************************************
  * msr_decode_geoscope:
@@ -692,9 +692,9 @@ msr_decode_geoscope (char *input, int samplecount, float *output,
 } /* End of msr_decode_geoscope() */
 
 /* Defines for CDSN encoding */
-#define CDSN_MANTISSA_MASK 0x3fff  /* mask for mantissa */
-#define CDSN_GAINRANGE_MASK 0xc000 /* mask for gainrange factor */
-#define CDSN_SHIFT 14              /* # bits in mantissa */
+#define CDSN_MANTISSA_MASK 0x3FFFul  /* mask for mantissa */
+#define CDSN_GAINRANGE_MASK 0xC000ul /* mask for gainrange factor */
+#define CDSN_SHIFT 14                /* # bits in mantissa */
 
 /************************************************************************
  * msr_decode_cdsn:
@@ -758,7 +758,7 @@ msr_decode_cdsn (int16_t *input, int samplecount, int32_t *output,
     gainrange = (sint & CDSN_GAINRANGE_MASK) >> CDSN_SHIFT;
 
     /* Determine multiplier from the gain range factor and format definition
-       * because shift operator is used later, these are powers of two */
+     * because shift operator is used later, these are powers of two */
     if (gainrange == 0)
       mult = 0;
     else if (gainrange == 1)
@@ -772,8 +772,8 @@ msr_decode_cdsn (int16_t *input, int samplecount, int32_t *output,
     mantissa -= MAX14;
 
     /* Calculate sample from mantissa and multiplier using left shift
-       * mantissa << mult is equivalent to mantissa * (2 exp (mult)) */
-    sample = (mantissa << mult);
+     * mantissa << mult is equivalent to mantissa * (2 exp (mult)) */
+    sample = ((uint32_t)mantissa << mult);
 
     /* Save sample in output array */
     output[idx] = sample;
@@ -784,9 +784,9 @@ msr_decode_cdsn (int16_t *input, int samplecount, int32_t *output,
 } /* End of msr_decode_cdsn() */
 
 /* Defines for SRO encoding */
-#define SRO_MANTISSA_MASK 0x0fff  /* mask for mantissa */
-#define SRO_GAINRANGE_MASK 0xf000 /* mask for gainrange factor */
-#define SRO_SHIFT 12              /* # bits in mantissa */
+#define SRO_MANTISSA_MASK 0x0FFFul  /* mask for mantissa */
+#define SRO_GAINRANGE_MASK 0xF000ul /* mask for gainrange factor */
+#define SRO_SHIFT 12                /* # bits in mantissa */
 
 /************************************************************************
  * msr_decode_sro:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libmseed.git



More information about the debian-science-commits mailing list