From 8b2a408e6ff45c60828dbdfdf7b38a9cecdab462 Mon Sep 17 00:00:00 2001 From: Enrico Ellguth Date: Thu, 22 Apr 2021 15:57:00 +0200 Subject: [PATCH] Initial commit based on common repo commit ffeb9c9b --- .gitignore | 13 + CMakeLists.txt | 26 + Modules/FindBoost.cmake | 341 + Modules/FindNumpy.cmake | 23 + Modules/FindOpenSSL.cmake | 74 + README.md | 85 + examples/CMakeLists.txt | 19 + examples/python/raw2caps.py | 114 + examples/raw2caps.cpp | 112 + libs/3rd-party/CMakeLists.txt | 1 + libs/3rd-party/mseed/CMakeLists.txt | 7 + libs/3rd-party/mseed/fileutils.c | 1183 + libs/3rd-party/mseed/genutils.c | 1407 + libs/3rd-party/mseed/gswap.c | 150 + libs/3rd-party/mseed/libmseed.def | 106 + libs/3rd-party/mseed/libmseed.h | 735 + libs/3rd-party/mseed/lmplatform.c | 65 + libs/3rd-party/mseed/lmplatform.h | 166 + libs/3rd-party/mseed/logging.c | 334 + libs/3rd-party/mseed/lookup.c | 235 + libs/3rd-party/mseed/msrutils.c | 1179 + libs/3rd-party/mseed/pack.c | 1065 + libs/3rd-party/mseed/packdata.c | 699 + libs/3rd-party/mseed/packdata.h | 35 + libs/3rd-party/mseed/parseutils.c | 1163 + libs/3rd-party/mseed/selection.c | 680 + libs/3rd-party/mseed/steimdata.h | 51 + libs/3rd-party/mseed/tracelist.c | 1277 + libs/3rd-party/mseed/traceutils.c | 1855 ++ libs/3rd-party/mseed/unpack.c | 1083 + libs/3rd-party/mseed/unpackdata.c | 892 + libs/3rd-party/mseed/unpackdata.h | 40 + libs/CMakeLists.txt | 5 + libs/gempa/CMakeLists.txt | 1 + libs/gempa/caps/CHANGELOG.md | 150 + libs/gempa/caps/CMakeLists.txt | 22 + libs/gempa/caps/anypacket.cpp | 197 + libs/gempa/caps/anypacket.h | 154 + libs/gempa/caps/api.h | 17 + libs/gempa/caps/application.cpp | 141 + libs/gempa/caps/application.h | 106 + libs/gempa/caps/connection.cpp | 621 + libs/gempa/caps/connection.h | 180 + libs/gempa/caps/datetime.cpp | 1063 + libs/gempa/caps/datetime.h | 245 + libs/gempa/caps/encoderfactory.cpp | 246 + libs/gempa/caps/encoderfactory.h | 164 + libs/gempa/caps/endianess.h | 210 + libs/gempa/caps/log.cpp | 31 + libs/gempa/caps/log.h | 61 + libs/gempa/caps/metapacket.cpp | 81 + libs/gempa/caps/metapacket.h | 143 + libs/gempa/caps/mseed/encoder.h | 75 + libs/gempa/caps/mseed/mseed.cpp | 162 + libs/gempa/caps/mseed/mseed.h | 90 + libs/gempa/caps/mseed/packet.h | 44 + libs/gempa/caps/mseed/slink.h | 131 + libs/gempa/caps/mseed/spclock.h | 78 + libs/gempa/caps/mseed/steim1.h | 90 + libs/gempa/caps/mseed/steim1.ipp | 184 + libs/gempa/caps/mseed/steim2.h | 94 + libs/gempa/caps/mseed/steim2.ipp | 241 + libs/gempa/caps/mseed/uncompressed.h | 84 + libs/gempa/caps/mseedpacket.cpp | 491 + libs/gempa/caps/mseedpacket.h | 92 + libs/gempa/caps/packet.cpp | 125 + libs/gempa/caps/packet.h | 420 + libs/gempa/caps/plugin.cpp | 1120 + libs/gempa/caps/plugin.h | 324 + libs/gempa/caps/pluginapplication.cpp | 383 + libs/gempa/caps/pluginapplication.h | 114 + libs/gempa/caps/pluginpacket.h | 69 + libs/gempa/caps/rawpacket.cpp | 418 + libs/gempa/caps/rawpacket.h | 237 + libs/gempa/caps/recordbuilder.h | 137 + libs/gempa/caps/riff.cpp | 398 + libs/gempa/caps/riff.h | 193 + libs/gempa/caps/rtcm2packet.cpp | 174 + libs/gempa/caps/rtcm2packet.h | 109 + libs/gempa/caps/sessiontable.cpp | 404 + libs/gempa/caps/sessiontable.h | 104 + libs/gempa/caps/socket.cpp | 545 + libs/gempa/caps/socket.h | 273 + libs/gempa/caps/strptime.c | 1009 + libs/gempa/caps/strptime.h | 22 + libs/gempa/caps/test/CMakeLists.txt | 23 + .../test/data/AM.RFE4F.00.SHZ.20180912.mseed | Bin 0 -> 512 bytes libs/gempa/caps/test/datetime.cpp | 566 + libs/gempa/caps/test/datetime_time.cpp | 511 + libs/gempa/caps/test/endianess.cpp | 105 + libs/gempa/caps/test/errors_find | 29 + libs/gempa/caps/test/mseedpacket.cpp | 227 + libs/gempa/caps/test/packet.cpp | 97 + libs/gempa/caps/test/rawpacket.cpp | 288 + libs/gempa/caps/test/test_utils.h | 10 + libs/gempa/caps/test/utils.cpp | 289 + libs/gempa/caps/utils.h | 377 + libs/gempa/caps/version.h | 32 + libs/swig/CMakeLists.txt | 1 + libs/swig/gempa/CAPS.i | 125 + libs/swig/gempa/CAPS.py | 1928 ++ libs/swig/gempa/CAPSPYTHON_wrap.cxx | 26030 ++++++++++++++++ libs/swig/gempa/CMakeLists.txt | 79 + libs/swig/gempa/__init__.py | 0 libs/swig/gempa/codegen.sh | 2 + libs/swig/gempa/numpy.i | 3161 ++ py-compile | 175 + 107 files changed, 61542 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Modules/FindBoost.cmake create mode 100644 Modules/FindNumpy.cmake create mode 100644 Modules/FindOpenSSL.cmake create mode 100644 README.md create mode 100644 examples/CMakeLists.txt create mode 100644 examples/python/raw2caps.py create mode 100644 examples/raw2caps.cpp create mode 100644 libs/3rd-party/CMakeLists.txt create mode 100644 libs/3rd-party/mseed/CMakeLists.txt create mode 100644 libs/3rd-party/mseed/fileutils.c create mode 100644 libs/3rd-party/mseed/genutils.c create mode 100644 libs/3rd-party/mseed/gswap.c create mode 100644 libs/3rd-party/mseed/libmseed.def create mode 100644 libs/3rd-party/mseed/libmseed.h create mode 100644 libs/3rd-party/mseed/lmplatform.c create mode 100644 libs/3rd-party/mseed/lmplatform.h create mode 100644 libs/3rd-party/mseed/logging.c create mode 100644 libs/3rd-party/mseed/lookup.c create mode 100644 libs/3rd-party/mseed/msrutils.c create mode 100644 libs/3rd-party/mseed/pack.c create mode 100644 libs/3rd-party/mseed/packdata.c create mode 100644 libs/3rd-party/mseed/packdata.h create mode 100644 libs/3rd-party/mseed/parseutils.c create mode 100644 libs/3rd-party/mseed/selection.c create mode 100644 libs/3rd-party/mseed/steimdata.h create mode 100644 libs/3rd-party/mseed/tracelist.c create mode 100644 libs/3rd-party/mseed/traceutils.c create mode 100644 libs/3rd-party/mseed/unpack.c create mode 100644 libs/3rd-party/mseed/unpackdata.c create mode 100644 libs/3rd-party/mseed/unpackdata.h create mode 100644 libs/CMakeLists.txt create mode 100644 libs/gempa/CMakeLists.txt create mode 100644 libs/gempa/caps/CHANGELOG.md create mode 100644 libs/gempa/caps/CMakeLists.txt create mode 100644 libs/gempa/caps/anypacket.cpp create mode 100644 libs/gempa/caps/anypacket.h create mode 100644 libs/gempa/caps/api.h create mode 100644 libs/gempa/caps/application.cpp create mode 100644 libs/gempa/caps/application.h create mode 100644 libs/gempa/caps/connection.cpp create mode 100644 libs/gempa/caps/connection.h create mode 100644 libs/gempa/caps/datetime.cpp create mode 100644 libs/gempa/caps/datetime.h create mode 100644 libs/gempa/caps/encoderfactory.cpp create mode 100644 libs/gempa/caps/encoderfactory.h create mode 100644 libs/gempa/caps/endianess.h create mode 100644 libs/gempa/caps/log.cpp create mode 100644 libs/gempa/caps/log.h create mode 100644 libs/gempa/caps/metapacket.cpp create mode 100644 libs/gempa/caps/metapacket.h create mode 100644 libs/gempa/caps/mseed/encoder.h create mode 100644 libs/gempa/caps/mseed/mseed.cpp create mode 100644 libs/gempa/caps/mseed/mseed.h create mode 100644 libs/gempa/caps/mseed/packet.h create mode 100644 libs/gempa/caps/mseed/slink.h create mode 100644 libs/gempa/caps/mseed/spclock.h create mode 100644 libs/gempa/caps/mseed/steim1.h create mode 100644 libs/gempa/caps/mseed/steim1.ipp create mode 100644 libs/gempa/caps/mseed/steim2.h create mode 100644 libs/gempa/caps/mseed/steim2.ipp create mode 100644 libs/gempa/caps/mseed/uncompressed.h create mode 100644 libs/gempa/caps/mseedpacket.cpp create mode 100644 libs/gempa/caps/mseedpacket.h create mode 100644 libs/gempa/caps/packet.cpp create mode 100644 libs/gempa/caps/packet.h create mode 100644 libs/gempa/caps/plugin.cpp create mode 100644 libs/gempa/caps/plugin.h create mode 100644 libs/gempa/caps/pluginapplication.cpp create mode 100644 libs/gempa/caps/pluginapplication.h create mode 100644 libs/gempa/caps/pluginpacket.h create mode 100644 libs/gempa/caps/rawpacket.cpp create mode 100644 libs/gempa/caps/rawpacket.h create mode 100644 libs/gempa/caps/recordbuilder.h create mode 100644 libs/gempa/caps/riff.cpp create mode 100644 libs/gempa/caps/riff.h create mode 100644 libs/gempa/caps/rtcm2packet.cpp create mode 100644 libs/gempa/caps/rtcm2packet.h create mode 100644 libs/gempa/caps/sessiontable.cpp create mode 100644 libs/gempa/caps/sessiontable.h create mode 100644 libs/gempa/caps/socket.cpp create mode 100644 libs/gempa/caps/socket.h create mode 100644 libs/gempa/caps/strptime.c create mode 100644 libs/gempa/caps/strptime.h create mode 100644 libs/gempa/caps/test/CMakeLists.txt create mode 100644 libs/gempa/caps/test/data/AM.RFE4F.00.SHZ.20180912.mseed create mode 100644 libs/gempa/caps/test/datetime.cpp create mode 100644 libs/gempa/caps/test/datetime_time.cpp create mode 100644 libs/gempa/caps/test/endianess.cpp create mode 100644 libs/gempa/caps/test/errors_find create mode 100644 libs/gempa/caps/test/mseedpacket.cpp create mode 100644 libs/gempa/caps/test/packet.cpp create mode 100644 libs/gempa/caps/test/rawpacket.cpp create mode 100644 libs/gempa/caps/test/test_utils.h create mode 100644 libs/gempa/caps/test/utils.cpp create mode 100644 libs/gempa/caps/utils.h create mode 100644 libs/gempa/caps/version.h create mode 100644 libs/swig/CMakeLists.txt create mode 100644 libs/swig/gempa/CAPS.i create mode 100644 libs/swig/gempa/CAPS.py create mode 100644 libs/swig/gempa/CAPSPYTHON_wrap.cxx create mode 100644 libs/swig/gempa/CMakeLists.txt create mode 100644 libs/swig/gempa/__init__.py create mode 100755 libs/swig/gempa/codegen.sh create mode 100644 libs/swig/gempa/numpy.i create mode 100755 py-compile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05ecff3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/*.config +/*.creator +/*.files +/*.includes +/*.user +*.pyc +nbproject +.DS_Store +*bower* +CMakeCache.txt +CMakeFiles/ +.idea/ +.sass-cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..287b5b2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +PROJECT(LIBCAPS) +CMAKE_MINIMUM_REQUIRED(VERSION 2.4) + +SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) + +FIND_PACKAGE(Boost REQUIRED) +FIND_PACKAGE(OpenSSL REQUIRED) + +INCLUDE_DIRECTORIES(libs) + +#ADD_DEFINITIONS("-DCAPS_FEATURES_ANY=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_MSEED=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_RAW=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_FIXED_RAW=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_RTCM2=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_BACKFILLING=0") +#ADD_DEFINITIONS("-DCAPS_FEATURES_JOURNAL=0") + +OPTION(LIBCAPS_PYTHON_WRAPPER "Create Python wrappers" ON) +OPTION(LIBCAPS_EXAMPLES "Build and install example applications" OFF) + +SUBDIRS(libs) + +IF(LIBCAPS_EXAMPLES) + SUBDIRS(examples) +ENDIF() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake new file mode 100644 index 0000000..b05238b --- /dev/null +++ b/Modules/FindBoost.cmake @@ -0,0 +1,341 @@ +# - Find the Boost includes and libraries. +# The following variables are set if Boost is found. If Boost is not +# found, Boost_FOUND is set to false. +# Boost_FOUND - True when the Boost include directory is found. +# Boost_INCLUDE_DIRS - the path to where the boost include files are. +# Boost_LIBRARY_DIRS - The path to where the boost library files are. +# Boost_LIB_DIAGNOSTIC_DEFINITIONS - Only set if using Windows. +# Boost__FOUND - True if the Boost is found. +# Boost__INCLUDE_DIRS - The include path for Boost . +# Boost__LIBRARIES - The libraries to link to to use Boost . +# Boost_LIBRARIES - The libraries to link to to use all Boost libraries. +# +# The following variables can be set to configure how Boost is found: +# Boost_LIB_PREFIX - Look for Boost libraries prefixed with this, e.g. "lib" +# Boost_LIB_SUFFIX - Look for Boost libraries ending with this, e.g. "vc80-mt" +# Boost_LIB_SUFFIX_DEBUG - As for Boost_LIB_SUFFIX but for debug builds, e.g. "vs80-mt-gd" + +# ---------------------------------------------------------------------------- +# If you have installed Boost in a non-standard location or you have +# just staged the boost files using bjam then you have three +# options. In the following comments, it is assumed that +# points to the root directory of the include directory of Boost. e.g +# If you have put boost in C:\development\Boost then is +# "C:/development/Boost" and in this directory there will be two +# directories called "include" and "lib". +# 1) After CMake runs, set Boost_INCLUDE_DIR to /include/boost<-version> +# 2) Use CMAKE_INCLUDE_PATH to set a path to /include. This will allow FIND_PATH() +# to locate Boost_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. +# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include") +# 3) Set an environment variable called ${BOOST_ROOT} that points to the root of where you have +# installed Boost, e.g. . It is assumed that there is at least a subdirectory called +# include in this path. +# +# Note: +# 1) If you are just using the boost headers, then you do not need to use +# Boost_LIBRARY_DIRS in your CMakeLists.txt file. +# 2) If Boost has not been installed, then when setting Boost_LIBRARY_DIRS +# the script will look for /lib first and, if this fails, then for /stage/lib. +# +# Usage: +# In your CMakeLists.txt file do something like this: +# ... +# # Boost +# FIND_PACKAGE(Boost) +# ... +# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +# LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) +# +# In Windows, we make the assumption that, if the Boost files are installed, the default directory +# will be C:\boost. + +# +# TODO: +# +# 1) Automatically find the Boost library files and eliminate the need +# to use Link Directories. +# + +IF(WIN32) + # In windows, automatic linking is performed, so you do not have to specify the libraries. + # If you are linking to a dynamic runtime, then you can choose to link to either a static or a + # dynamic Boost library, the default is to do a static link. You can alter this for a specific + # library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to + # be linked dynamically. Alternatively you can force all Boost libraries to dynamic link by + # defining BOOST_ALL_DYN_LINK. + + # This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB, + # or for all of Boost by defining BOOST_ALL_NO_LIB. + + # If you want to observe which libraries are being linked against then defining + # BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time + # a library is selected for linking. + SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") +ENDIF(WIN32) + + +SET(BOOST_INCLUDE_PATH_DESCRIPTION "directory containing the boost include files. E.g /usr/local/include/boost-1_33_1 or c:\\boost\\include\\boost-1_33_1") + +SET(BOOST_DIR_MESSAGE "Set the Boost_INCLUDE_DIR cmake cache entry to the ${BOOST_INCLUDE_PATH_DESCRIPTION}") + +SET(BOOST_DIR_SEARCH $ENV{BOOST_ROOT}) +IF(BOOST_DIR_SEARCH) + FILE(TO_CMAKE_PATH ${BOOST_DIR_SEARCH} BOOST_DIR_SEARCH) + SET(BOOST_DIR_SEARCH ${BOOST_DIR_SEARCH}/include) +ENDIF(BOOST_DIR_SEARCH) + +IF(WIN32) + SET(BOOST_DIR_SEARCH + ${BOOST_DIR_SEARCH} + C:/boost/include + D:/boost/include + ) +ENDIF(WIN32) + +# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out. +SET(SUFFIX_FOR_PATH + boost-1_35_1 + boost-1_35_0 + boost-1_35 + boost-1_34_1 + boost-1_34_0 + boost-1_34 + boost-1_33_1 + boost-1_33_0 +) + +# +# Look for an installation. +# +FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS + + # Look in other places. + ${BOOST_DIR_SEARCH} + + # Help the user find it if we cannot. + DOC "The ${BOOST_INCLUDE_PATH_DESCRIPTION}" +) + +# Assume we didn't find it. +SET(Boost_FOUND 0) + +# Now try to get the include and library path. +IF(Boost_INCLUDE_DIR) + + # Look for the boost library path. + # Note that the user may not have installed any libraries + # so it is quite possible the Boost_LIBRARY_PATH may not exist. + SET(Boost_LIBRARY_DIR ${Boost_INCLUDE_DIR}) + + IF("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+") + GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH) + ENDIF ("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+") + + IF("${Boost_LIBRARY_DIR}" MATCHES "/include$") + # Strip off the trailing "/include" in the path. + GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH) + ENDIF("${Boost_LIBRARY_DIR}" MATCHES "/include$") + + IF(EXISTS "${Boost_LIBRARY_DIR}/lib") + SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/lib) + ELSE(EXISTS "${Boost_LIBRARY_DIR}/lib") + IF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib") + SET(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/stage/lib) + ELSE(EXISTS "${Boost_LIBRARY_DIR}/stage/lib") + SET(Boost_LIBRARY_DIR "") + ENDIF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib") + ENDIF(EXISTS "${Boost_LIBRARY_DIR}/lib") + + IF(EXISTS "${Boost_INCLUDE_DIR}") + SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) + # We have found boost. It is possible that the user has not + # compiled any libraries so we set Boost_FOUND to be true here. + SET(Boost_FOUND 1) + MARK_AS_ADVANCED(Boost_INCLUDE_DIR) + ENDIF(EXISTS "${Boost_INCLUDE_DIR}") + + IF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}") + SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR}) + ENDIF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}") +ENDIF(Boost_INCLUDE_DIR) + +# +# Find boost libraries +# + +# List of library suffixes to search, e.g. libboost_date_time-gcc +SET(BOOST_SUFFIX_SEARCH + gcc + il + mt + s + mt-s + mgw + mgw-mt + mgw-s + mgw-mt-s +) + +# List of all boost libraries +SET(BOOST_ALL_LIBRARIES + date_time + filesystem + graph + iostreams + program_options + python + regex + serialization + signals + system + test + thread + wave +) + + +MACRO(LIST_CONTAINS LIST value var) + SET(${var}) + FOREACH (value2 ${${LIST}}) + IF (${value} STREQUAL ${value2}) + SET(${var} TRUE) + ENDIF (${value} STREQUAL ${value2}) + ENDFOREACH (value2) +ENDMACRO(LIST_CONTAINS) + + +# Macro to find boost library called name +MACRO(BOOST_FIND_LIBRARY name) + + # User can specify a particular build variant via the variables: + # Boost_LIB_PREFIX, Boost_LIB_SUFFIX, Boost_LIB_SUFFIX_DEBUG + # otherwise we'll search the BOOST_SUFFIX_SEARCH list + SET(BOOST_LIB_NAMES ${Boost_LIB_PREFIX}boost_${name}) + IF(NOT Boost_LIB_SUFFIX) + FOREACH(suffix ${BOOST_SUFFIX_SEARCH}) + SET(BOOST_LIB_NAMES ${BOOST_LIB_NAMES} ${Boost_LIB_PREFIX}boost_${name}-${suffix}) + ENDFOREACH(suffix) + ELSE(NOT Boost_LIB_SUFFIX) + SET(BOOST_LIB_NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX}) + ENDIF(NOT Boost_LIB_SUFFIX) + + # Find the library in the Boost_LIBRARY_DIRS. We exclude the default path to + # support cross compilation + FIND_LIBRARY(Boost_${name}_LIBRARY + NAMES ${BOOST_LIB_NAMES} + PATHS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH) + + IF(NOT Boost_${name}_LIBRARY) + # Find the library in the Boost_LIBRARY_DIRS + FIND_LIBRARY(Boost_${name}_LIBRARY + NAMES ${BOOST_LIB_NAMES} + PATHS ${Boost_LIBRARY_DIRS}) + ENDIF(NOT Boost_${name}_LIBRARY) + + + # For MSVC builds find debug library + IF(WIN32 AND MSVC AND Boost_${name}_LIBRARY) + FIND_LIBRARY(Boost_${name}_LIBRARY_DEBUG ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX_DEBUG}) + + IF(MSVC_IDE) + IF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG) + SET(Boost_${name}_LIBRARIES debug ${Boost_${name}_LIBRARY_DEBUG} optimized ${Boost_${name}_LIBRARY}) + ELSE(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG) + MESSAGE(FATAL_ERROR "Could not find the debug and release version of Boost ${name} library.") + ENDIF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG) + ELSE(MSVC_IDE) + STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) + IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY_DEBUG}) + ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY}) + ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + ENDIF(MSVC_IDE) + ELSE(WIN32 AND MSVC AND Boost_${name}_LIBRARY) + SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY}) + ENDIF(WIN32 AND MSVC AND Boost_${name}_LIBRARY) + + # If we've got it setup appropriate variables or issue error message + IF(Boost_${name}_LIBRARY) + SET(Boost_${name}_FOUND 1) + SET(Boost_${name}_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) + MARK_AS_ADVANCED(Boost_${name}_LIBRARY Boost_${name}_LIBRARY_DEBUG) + IF(NOT Boost_FIND_QUIETLY) + MESSAGE(STATUS "Found boost_${name} library.") + ENDIF(NOT Boost_FIND_QUIETLY) + ELSE(Boost_${name}_LIBRARY) + IF(NOT Boost_FIND_QUIETLY) + #MESSAGE(STATUS "Boost ${name} library was not found.") + ELSE(NOT Boost_FIND_QUIETLY) + IF(Boost_FIND_REQUIRED_${name}) + MESSAGE(FATAL_ERROR "Could NOT find required Boost ${name} library.") + ENDIF(Boost_FIND_REQUIRED_${name}) + ENDIF(NOT Boost_FIND_QUIETLY) + ENDIF(Boost_${name}_LIBRARY) +ENDMACRO(BOOST_FIND_LIBRARY) + +IF(Boost_LIBRARY_DIRS) + # If the user specified required components e.g. via + # FIND_PACKAGE(Boost REQUIRED date_time regex) + # find (just) those libraries. Otherwise find all libraries. + IF(Boost_FIND_COMPONENTS) + SET(Boost_FIND_LIBRARIES ${Boost_FIND_COMPONENTS}) + # Boost_filesystem is a special case and needs the additional + # linkage of Boost_system as well on some systems. So we search for + # Boost_system as well and add it later to Boost_filesystem_LIBRARIES. + LIST_CONTAINS(Boost_FIND_LIBRARIES "filesystem" has_fs) + IF(has_fs) + LIST_CONTAINS(Boost_FIND_LIBRARIES "system" has_s) + IF(NOT has_s) + SET(Boost_FIND_LIBRARIES ${Boost_FIND_LIBRARIES} system) + ENDIF(NOT has_s) + ENDIF(has_fs) + ELSE(Boost_FIND_COMPONENTS) + SET(Boost_FIND_LIBRARIES ${BOOST_ALL_LIBRARIES}) + ENDIF(Boost_FIND_COMPONENTS) + + SET(Boost_MISSING_REQUIRED_COMPONENTS) + + SET(Boost_LIBRARIES) + FOREACH(library ${Boost_FIND_LIBRARIES}) + BOOST_FIND_LIBRARY(${library}) + IF(Boost_${library}_FOUND) + SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${library}_LIBRARIES}) + ELSE(Boost_${library}_FOUND) + IF(Boost_FIND_REQUIRED AND Boost_FIND_COMPONENTS) + IF(Boost_FIND_REQUIRED_${library}) + SET(Boost_MISSING_COMPONENTS 1) + SET( + Boost_MISSING_REQUIRED_COMPONENTS + ${Boost_MISSING_REQUIRED_COMPONENTS} + ${library} + ) + ENDIF(Boost_FIND_REQUIRED_${library}) + ENDIF(Boost_FIND_REQUIRED AND Boost_FIND_COMPONENTS) + ENDIF(Boost_${library}_FOUND) + ENDFOREACH(library) +ENDIF(Boost_LIBRARY_DIRS) + +IF(Boost_filesystem_FOUND) + IF(Boost_system_FOUND) + SET(Boost_filesystem_LIBRARIES ${Boost_filesystem_LIBRARIES} ${Boost_system_LIBRARIES}) + ENDIF(Boost_system_FOUND) +ENDIF(Boost_filesystem_FOUND) + +IF(NOT Boost_FOUND) + IF(NOT Boost_FIND_QUIETLY) + MESSAGE(STATUS "Boost was not found. ${BOOST_DIR_MESSAGE}") + ELSE(NOT Boost_FIND_QUIETLY) + IF(Boost_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}") + ENDIF(Boost_FIND_REQUIRED) + ENDIF(NOT Boost_FIND_QUIETLY) +ELSE(NOT Boost_FOUND) + IF(Boost_MISSING_COMPONENTS) + MESSAGE(STATUS "The following required Boost components are missing:") + FOREACH(component ${Boost_MISSING_REQUIRED_COMPONENTS}) + MESSAGE(STATUS " * boost_${component}") + ENDFOREACH(component) + MESSAGE(FATAL_ERROR "The Boost libraries (${Boost_FIND_COMPONENTS}) are required!") + ENDIF(Boost_MISSING_COMPONENTS) +ENDIF(NOT Boost_FOUND) diff --git a/Modules/FindNumpy.cmake b/Modules/FindNumpy.cmake new file mode 100644 index 0000000..6442498 --- /dev/null +++ b/Modules/FindNumpy.cmake @@ -0,0 +1,23 @@ +# Try to find numarray python package +# Once done this will define +# +# PYTHON_NUMPY_FOUND - system has numarray development package and it should be used +# PYTHON_NUMPY_INCLUDE_DIR - directory where the arrayobject.h header file can be found + +IF(PYTHON_EXECUTABLE) + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/det_npp.py "from __future__ import print_function\ntry: import numpy; print(numpy.get_include())\nexcept: pass\n") + EXEC_PROGRAM("${PYTHON_EXECUTABLE}" + ARGS "\"${CMAKE_CURRENT_BINARY_DIR}/det_npp.py\"" + OUTPUT_VARIABLE NUMPY_PATH + ) + FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/det_npp.py) +ENDIF(PYTHON_EXECUTABLE) + +FIND_PATH(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h + "${NUMPY_PATH}/" + DOC "Directory where the numpy/arrayobject.h header file can be found. This file is part of the numpy package" +) + +IF(PYTHON_NUMPY_INCLUDE_DIR) + SET (PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy development package is available") +ENDIF(PYTHON_NUMPY_INCLUDE_DIR) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake new file mode 100644 index 0000000..ac18531 --- /dev/null +++ b/Modules/FindOpenSSL.cmake @@ -0,0 +1,74 @@ +# - Try to find the OpenSSL encryption library +# Once done this will define +# +# OPENSSL_FOUND - system has the OpenSSL library +# OPENSSL_INCLUDE_DIR - the OpenSSL include directory +# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL + +# Copyright (c) 2006, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +IF(OPENSSL_LIBRARIES) + SET(OpenSSL_FIND_QUIETLY TRUE) +ENDIF(OPENSSL_LIBRARIES) + +IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(LIB_FOUND 1) +ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + +FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h ) + +IF(WIN32 AND MSVC) + # /MD and /MDd are the standard values - if somone wants to use + # others, the libnames have to change here too + # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b + + FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32) + FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32) + + IF(MSVC_IDE) + IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}) + ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(OPENSSL_LIBRARIES NOTFOUND) + MESSAGE(STATUS "Could not find the debug and release version of openssl") + ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + ELSE(MSVC_IDE) + STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) + IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG}) + ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE}) + ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + ENDIF(MSVC_IDE) + MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) +ENDIF ( WIN32 AND MSVC ) + +FIND_LIBRARY(SSL NAMES ssl ssleay32 ssleay32MD ) +FIND_LIBRARY(CRYPTO NAMES crypto) +IF ( SSL AND CRYPTO ) + SET(OPENSSL_LIBRARIES ${SSL} ${CRYPTO}) +ENDIF ( SSL AND CRYPTO ) + +IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + SET(OPENSSL_FOUND TRUE) +ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + SET(OPENSSL_FOUND FALSE) +ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + +IF (OPENSSL_FOUND) + IF (NOT OpenSSL_FIND_QUIETLY) + MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}") + ENDIF (NOT OpenSSL_FIND_QUIETLY) +ELSE (OPENSSL_FOUND) + IF (OpenSSL_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could NOT find OpenSSL") + ENDIF (OpenSSL_FIND_REQUIRED) +ENDIF (OPENSSL_FOUND) + +MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8818ad7 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# CAPS client library + +This file describes how to build the CAPS client library from source. + +## Runtime Dependencies + +* Boost + * Program options + * Filesystem + * System +* OpenSSL +* Python* + +### Installation + +#### Ubuntu 14.04 +``` +sudo apt-get install libboost-filesystem1.54.0 libboost-program-options1.54.0 libboost-system1.54.0 libssl0.9.8 +``` + +#### Ubuntu 16.04 +``` +sudo apt-get install libboost-filesystem1.58.0 libboost-program-options1.58.0 libboost-system1.58.0 libssl1.0.0 +``` + +#### Ubuntu 18.04 +``` +sudo apt-get install libboost-filesystem1.65.1 libboost-program-options1.65.1 libboost-system1.65.0 libssl1.1 +``` + +#### Ubuntu 20.04 +``` +sudo apt install libboost-filesystem1.71.0 libboost-program-options1.71.0 libboost-system1.71.0 libssl1.1 +``` + +#### RHEL/CentOS +``` +yum install boost-filesystem boost-program-options boost-system openssl +``` + +## Build Dependencies + +* CMake +* GCC, G++ +* Boost +* OpenSSL +* Swig* + +### Installation + +#### Ubuntu +``` + sudo apt-get install cmake gcc g++ libboost-all-dev cmake-curses-gui make libssl-dev +``` +#### RHEL/CentOS +``` +yum install cmake gcc-c++ openssl-devel boost-devel +``` + +## Build + +1. Extract the package +``` +tar xf libcapsclient-1.0.0.tar.gz +``` +2. Change working directory and create a build directory +``` +cd libcapsclient +mkdir build +cd build +``` +3. Setup build environment +``` +ccmake .. +``` +4. Adjust the CMake settings to your needs + 1. Press 'c' + 2. Change the installation directory + 3. Switch on/off features e.g. examples + 4. ... +5. Press 'c' two time followed by 'g' to generate the build configuration +6. Build and install +``` +make install +``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..a439a0a --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(APP_NAME raw2caps) + +SET(SOURCES + raw2caps.cpp +) + +ADD_EXECUTABLE(${APP_NAME} ${SOURCES}) + +TARGET_LINK_LIBRARIES(${APP_NAME} + capsclient + mseed + ${Boost_program_options_LIBRARY} + ${Boost_filesystem_LIBRARY} + ${Boost_system_LIBRARY} + ${OPENSSL_LIBRARIES} +) + +INSTALL(TARGETS ${APP_NAME} DESTINATION examples) +INSTALL(DIRECTORY python DESTINATION examples) diff --git a/examples/python/raw2caps.py b/examples/python/raw2caps.py new file mode 100644 index 0000000..eab7a7e --- /dev/null +++ b/examples/python/raw2caps.py @@ -0,0 +1,114 @@ +############################################################################ +# Copyright (C) 2021 gempa GmbH # +# # +# All Rights Reserved. # +# # +# NOTICE: All information contained herein is, and remains # +# the property of gempa GmbH and its suppliers, if any. The intellectual # +# and technical concepts contained herein are proprietary to gempa GmbH # +# and its suppliers. # +# Dissemination of this information or reproduction of this material # +# is strictly forbidden unless prior written permission is obtained # +# from gempa GmbH. # +############################################################################ + +#!/usr/bin/env python + +from __future__ import absolute_import, division, print_function + +import getopt +import sys +import signal + +import numpy as np + +from gempa import CAPS + + +usage_info = """ +raw2caps - pushes raw samples into CAPS. + +Usage: capstool [options] + +Options: + -H, --host host to connect to + -h, --help display this help message and exit +""" + + +def usage(exitcode=0): + sys.stderr.write(usage_info) + return exitcode + + +output = CAPS.Plugin("raw2caps") + +def signal_handler(sig, frame): #pylint: disable=W0613 + print('Caught Ctrl+C!') + output.quit() + sys.exit(0) + + +def main(): + try: + opts, _ = getopt.getopt(sys.argv[1:], "hH:d:n:", + ["help", "host=", "directory=", "network="]) + except getopt.GetoptError as err: + # print help information and exit: + print(str(err)) # will print something like "option -a not recognized" + return usage(2) + + addr = None + + signal.signal(signal.SIGINT, signal_handler) + + for o, a in opts: + if o in ["-h", "--help"]: + return usage() + + if o in ["-H", "--host"]: + addr = a + else: + assert False, "unhandled option" + + if addr: + try: + host, port = addr.split(":") + except BaseException: + sys.stderr.write("invalid host address given: %s\n" % addr) + return 1 + else: + host = None + port = None + + if port: + try: + port = int(port) + except BaseException: + sys.stderr.write("invalid port given: %s\n" % port) + return 1 + else: + port = 18003 + + if not host: + host = "localhost" + + output.setHost(host) + output.setPort(port) + output.setBufferSize(1 << 30) + output.enableLogging() + + startTime = CAPS.Time.GMT() + + x = np.array([1, 2], dtype=np.int32) + res = output.push("AB", "HMA", "", "BHZ", startTime, 1, 1, "m", x, + CAPS.DT_INT32) + if res != CAPS.Plugin.Success: + sys.stderr.write("failed to send packet\n") + + output.close() + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/examples/raw2caps.cpp b/examples/raw2caps.cpp new file mode 100644 index 0000000..af6585e --- /dev/null +++ b/examples/raw2caps.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2021 gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#include +#include + +#include +#include +#include +#include + +using namespace std; +using namespace Gempa::CAPS; + + +namespace { + +#define LOG_CHANNEL(out, fmt) \ + va_list ap;\ + va_start(ap, fmt);\ + fprintf(stderr, #out" "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n");\ + va_end(ap) + +void LogError(const char *fmt, ...) { + LOG_CHANNEL(ERROR, fmt); +} + +void LogWarning(const char *fmt, ...) { + LOG_CHANNEL(WARNING, fmt); +} + +void LogNotice(const char *fmt, ...) { + LOG_CHANNEL(NOTICE, fmt); +} + +void LogInfo(const char *fmt, ...) { + LOG_CHANNEL(INFO, fmt); +} + +void LogDebug(const char *fmt, ...) { + LOG_CHANNEL(DEBUG, fmt); +} + +} + +int main(int argc, char **argv) { + if ( argc != 1 ) { + cerr << "Pushes samples to CAPS" << endl << endl; + cerr << "Usage: raw2caps" << endl; + return 1; + } + + // Setup log handlers + + int verbosity = 2; + switch ( verbosity ) { + case 4: Gempa::CAPS::SetLogHandler(LL_DEBUG, LogDebug); + case 3: Gempa::CAPS::SetLogHandler(LL_INFO, LogInfo); + case 2: Gempa::CAPS::SetLogHandler(LL_WARNING, LogWarning); + case 1: Gempa::CAPS::SetLogHandler(LL_ERROR, LogError); + default: Gempa::CAPS::SetLogHandler(LL_NOTICE, LogNotice); + } + + Plugin plugin("raw2caps"); + plugin.setHost("localhost"); + plugin.setPort(18003); + + // Enable on-the-fly MSEED Encoding +// Steim2EncoderFactory *factory = new Steim2EncoderFactory(); +// plugin.setEncoderFactory(factory); + + string networkCode = "AB"; + string stationCode = "TEST"; + string locationCode = ""; + string channelCode = "HHZ"; + + uint16_t numerator = 100; + uint16_t denominator = 1; + + Time startTime = Time::FromString("2021-01-01 00:00:00", "%F %T"); + + int timingQuality = 100; + string uom = "m"; + + vector samples; + + for ( int i = 0; i < 100; ++i ) { + samples.push_back(i); + } + + Plugin::Status ret = + plugin.push(networkCode, stationCode, locationCode, channelCode, startTime, + numerator, denominator, uom, samples.data(), samples.size(), + DT_INT32, timingQuality); + if ( ret != Plugin::Success ) { + cerr << "Failed to send packet to CAPS" << endl; + return 1; + } + + return 0; +} diff --git a/libs/3rd-party/CMakeLists.txt b/libs/3rd-party/CMakeLists.txt new file mode 100644 index 0000000..b353d28 --- /dev/null +++ b/libs/3rd-party/CMakeLists.txt @@ -0,0 +1 @@ +subdirs(mseed) diff --git a/libs/3rd-party/mseed/CMakeLists.txt b/libs/3rd-party/mseed/CMakeLists.txt new file mode 100644 index 0000000..13f03fd --- /dev/null +++ b/libs/3rd-party/mseed/CMakeLists.txt @@ -0,0 +1,7 @@ +SET(LIB_NAME mseed) +FILE(GLOB SOURCES "*.cpp" "*.c" "*.h") + + +ADD_LIBRARY(${LIB_NAME} STATIC ${SOURCES}) +SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES COMPILE_FLAGS -fPIC) + diff --git a/libs/3rd-party/mseed/fileutils.c b/libs/3rd-party/mseed/fileutils.c new file mode 100644 index 0000000..1802c9b --- /dev/null +++ b/libs/3rd-party/mseed/fileutils.c @@ -0,0 +1,1183 @@ +/**************************************************************************** + * + * Routines to manage files of Mini-SEED. + * + * Written by Chad Trabant + * IRIS Data Management Center + * + * modified: 2013.117 + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "libmseed.h" + +static int ms_fread (char *buf, int size, int num, FILE *stream); + +/* Pack type parameters for the 8 defined types: + * [type] : [hdrlen] [sizelen] [chksumlen] + */ +int8_t packtypes[9][3] = { + { 0, 0, 0 }, + { 8, 8, 8 }, + { 11, 8, 8 }, + { 11, 8, 8 }, + { 11, 8, 8 }, + { 11, 8, 8 }, + { 13, 8, 8 }, + { 15, 8, 8 }, + { 22, 15, 10 }}; + +/********************************************************************* + * Notes about packed files as read by ms_readmsr_main() + * + * In general a packed file includes a pack file identifier at the + * very beginning, followed by pack header for a data block, followed + * by the data block, followed by a chksum for the data block. The + * pack header, data block and chksum are then repeated for each data + * block in the file: + * + * ID HDR DATA CHKSUM HDR DATA CHKSUM + * |----|-------|--....--|--------|-------|--....--|--------| ... + * + * |________ repeats ________| + * + * The HDR section contains fixed width ASCII fields identifying the + * data in the next section and it's length in bytes. With this + * information the offset of the next CHKSUM and HDR are completely + * predictable. + * + * packtypes[type][0]: length of pack header length + * packtypes[type][1]: length of size field in pack header + * packtypes[type][2]: chksum length following data blocks, skipped + * + * Notes from seed_pack.h documenting the PQI and PLS pack types: + * + * ___________________________________________________________________ + * There were earlier pack file types numbered 1 through 6. These have been discontinued. + * Current file formats can be described as follows: + * + * Quality-Indexed Pack - Type 7: + * _____10_____2__2___3_____8_______mod 256_______8_____2__2___3_____8_______mod 256_______8____ ... + * |PQI- |q |lc|chn| size | ...data... | chksum |q |lc|chn| size | ...data... | chksum ... + * parsing guide: + * 10 | 15 hdr | xx | 8 | 15 hdr | xx + * |+0|+2|+4 |+7 | + * + * + * Large-Size Pack - Type 8: (for large channel blocks) + * _____10_____2__2___3_____15_______mod 256_______8____2__2__2___3_____15_______mod 256_______8____ ... + * |PLS-------|q |lc|chn| size | ...data... | chksum |--|q |lc|chn| size | ...data... | chksum ... + * uniform parsing guide: + * | 10 | 22 | xx | 10 | 22 | xx | + * |+0|+2|+4 |+7 | + * (note the use of hyphens after the PLS marker and just after the checksum. this will serve as a visual + * aid when scanning between channel blocks and provide consistent 32 byte spacing between data blocks) + * ___________________________________________________________________ + * + *********************************************************************/ + +/* Initialize the global file reading parameters */ +MSFileParam gMSFileParam = {NULL, "", NULL, 0, 0, 0, 0, 0, 0, 0}; + + +/********************************************************************** + * ms_readmsr: + * + * This routine is a simple wrapper for ms_readmsr_main() that uses + * the global file reading parameters. This routine is not thread + * safe and cannot be used to read more than one file at a time. + * + * See the comments with ms_readmsr_main() for return values and + * further description of arguments. + *********************************************************************/ +int +ms_readmsr (MSRecord **ppmsr, const char *msfile, int reclen, off_t *fpos, + int *last, flag skipnotdata, flag dataflag, flag verbose) +{ + MSFileParam *msfp = &gMSFileParam; + + return ms_readmsr_main (&msfp, ppmsr, msfile, reclen, fpos, + last, skipnotdata, dataflag, NULL, verbose); +} /* End of ms_readmsr() */ + + +/********************************************************************** + * ms_readmsr_r: + * + * This routine is a simple wrapper for ms_readmsr_main() that uses + * the re-entrant capabilities. This routine is thread safe and can + * be used to read more than one file at a time as long as separate + * MSFileParam structures are used for each file. + * + * See the comments with ms_readmsr_main() for return values and + * further description of arguments. + *********************************************************************/ +int +ms_readmsr_r (MSFileParam **ppmsfp, MSRecord **ppmsr, const char *msfile, + int reclen, off_t *fpos, int *last, flag skipnotdata, + flag dataflag, flag verbose) +{ + return ms_readmsr_main (ppmsfp, ppmsr, msfile, reclen, fpos, + last, skipnotdata, dataflag, NULL, verbose); +} /* End of ms_readmsr_r() */ + + +/********************************************************************** + * ms_shift_msfp: + * + * A helper routine to shift (remove bytes from the beginning of) the + * file reading buffer for a MSFP. The buffer length, reading offset + * and file position indicators are all updated as necessary. + * + *********************************************************************/ +static void +ms_shift_msfp (MSFileParam *msfp, int shift) +{ + if ( ! msfp ) + return; + + if ( shift <= 0 && shift > msfp->readlen ) + { + ms_log (2, "ms_shift_msfp(): Cannot shift buffer, shift: %d, readlen: %d, readoffset: %d\n", + shift, msfp->readlen, msfp->readoffset); + return; + } + + memmove (msfp->rawrec, msfp->rawrec + shift, msfp->readlen - shift); + msfp->readlen -= shift; + + if ( shift < msfp->readoffset ) + { + msfp->readoffset -= shift; + } + else + { + msfp->filepos += (shift - msfp->readoffset); + msfp->readoffset = 0; + } + + return; +} /* End of ms_shift_msfp() */ + + +/* Macro to calculate length of unprocessed buffer */ +#define MSFPBUFLEN(MSFP) (MSFP->readlen - MSFP->readoffset) + +/* Macro to return current reading position */ +#define MSFPREADPTR(MSFP) (MSFP->rawrec + MSFP->readoffset) + +/********************************************************************** + * ms_readmsr_main: + * + * This routine will open and read, with subsequent calls, all + * Mini-SEED records in specified file. + * + * All static file reading parameters are stored in a MSFileParam + * struct and returned (via a pointer to a pointer) for the calling + * routine to use in subsequent calls. A MSFileParam struct will be + * allocated if necessary. This routine is thread safe and can be + * used to read multiple files in parallel as long as the file reading + * parameters are managed appropriately. + * + * If reclen is 0 or negative the length of every record is + * automatically detected. For auto detection of record length the + * record must include a 1000 blockette or be followed by a valid + * record header or end of file. + * + * If *fpos is not NULL it will be updated to reflect the file + * position (offset from the beginning in bytes) from where the + * returned record was read. As a special case, if *fpos is not NULL + * and the value it points to is less than 0 this will be interpreted + * as a (positive) starting offset from which to begin reading data; + * this feature does not work with packed files. + * + * If *last is not NULL it will be set to 1 when the last record in + * the file is being returned, otherwise it will be 0. + * + * If the skipnotdata flag is true any data chunks read that do not + * have valid data record indicators (D, R, Q, M, etc.) will be skipped. + * + * dataflag will be passed directly to msr_unpack(). + * + * If a Selections list is supplied it will be used to determine when + * a section of data in a packed file may be skipped, packed files are + * internal to the IRIS DMC. + * + * After reading all the records in a file the controlling program + * should call it one last time with msfile set to NULL. This will + * close the file and free allocated memory. + * + * Returns MS_NOERROR and populates an MSRecord struct at *ppmsr on + * successful read, returns MS_ENDOFFILE on EOF, otherwise returns a + * libmseed error code (listed in libmseed.h) and *ppmsr is set to + * NULL. + *********************************************************************/ +int +ms_readmsr_main (MSFileParam **ppmsfp, MSRecord **ppmsr, const char *msfile, + int reclen, off_t *fpos, int *last, flag skipnotdata, + flag dataflag, Selections *selections, flag verbose) +{ + MSFileParam *msfp; + off_t packdatasize = 0; + int packskipsize; + int parseval = 0; + int readsize = 0; + int readcount = 0; + int retcode = MS_NOERROR; + + if ( ! ppmsr ) + return MS_GENERROR; + + if ( ! ppmsfp ) + return MS_GENERROR; + + msfp = *ppmsfp; + + /* Initialize the file read parameters if needed */ + if ( ! msfp ) + { + msfp = (MSFileParam *) malloc (sizeof (MSFileParam)); + + if ( msfp == NULL ) + { + ms_log (2, "ms_readmsr_main(): Cannot allocate memory for MSFP\n"); + return MS_GENERROR; + } + + /* Redirect the supplied pointer to the allocated params */ + *ppmsfp = msfp; + + msfp->fp = NULL; + msfp->filename[0] = '\0'; + msfp->rawrec = NULL; + msfp->readlen = 0; + msfp->readoffset = 0; + msfp->packtype = 0; + msfp->packhdroffset = 0; + msfp->filepos = 0; + msfp->filesize = 0; + msfp->recordcount = 0; + } + + /* When cleanup is requested */ + if ( msfile == NULL ) + { + msr_free (ppmsr); + + if ( msfp->fp != NULL ) + fclose (msfp->fp); + + if ( msfp->rawrec != NULL ) + free (msfp->rawrec); + + /* If the file parameters are the global parameters reset them */ + if ( *ppmsfp == &gMSFileParam ) + { + gMSFileParam.fp = NULL; + gMSFileParam.filename[0] = '\0'; + gMSFileParam.rawrec = NULL; + gMSFileParam.readlen = 0; + gMSFileParam.readoffset = 0; + gMSFileParam.packtype = 0; + gMSFileParam.packhdroffset = 0; + gMSFileParam.filepos = 0; + gMSFileParam.filesize = 0; + gMSFileParam.recordcount = 0; + } + /* Otherwise free the MSFileParam */ + else + { + free (*ppmsfp); + *ppmsfp = NULL; + } + + return MS_NOERROR; + } + + /* Allocate reading buffer */ + if ( msfp->rawrec == NULL ) + { + if ( ! (msfp->rawrec = (char *) malloc (MAXRECLEN)) ) + { + ms_log (2, "ms_readmsr_main(): Cannot allocate memory for read buffer\n"); + return MS_GENERROR; + } + } + + /* Sanity check: track if we are reading the same file */ + if ( msfp->fp && strncmp (msfile, msfp->filename, sizeof(msfp->filename)) ) + { + ms_log (2, "ms_readmsr_main() called with a different file name without being reset\n"); + + /* Close previous file and reset needed variables */ + if ( msfp->fp != NULL ) + fclose (msfp->fp); + + msfp->fp = NULL; + msfp->readlen = 0; + msfp->readoffset = 0; + msfp->packtype = 0; + msfp->packhdroffset = 0; + msfp->filepos = 0; + msfp->filesize = 0; + msfp->recordcount = 0; + } + + /* Open the file if needed, redirect to stdin if file is "-" */ + if ( msfp->fp == NULL ) + { + /* Store the filename for tracking */ + strncpy (msfp->filename, msfile, sizeof(msfp->filename) - 1); + msfp->filename[sizeof(msfp->filename) - 1] = '\0'; + + if ( strcmp (msfile, "-") == 0 ) + { + msfp->fp = stdin; + } + else + { + if ( (msfp->fp = fopen (msfile, "rb")) == NULL ) + { + ms_log (2, "Cannot open file: %s (%s)\n", msfile, strerror (errno)); + msr_free (ppmsr); + + return MS_GENERROR; + } + else + { + /* Determine file size */ + struct stat sbuf; + + if ( fstat (fileno(msfp->fp), &sbuf) ) + { + ms_log (2, "Cannot open file: %s (%s)\n", msfile, strerror (errno)); + msr_free (ppmsr); + + return MS_GENERROR; + } + + msfp->filesize = sbuf.st_size; + } + } + } + + /* Seek to a specified offset if requested */ + if ( fpos != NULL && *fpos < 0 ) + { + /* Only try to seek in real files, not stdin */ + if ( msfp->fp != stdin ) + { + if ( lmp_fseeko (msfp->fp, *fpos * -1, SEEK_SET) ) + { + ms_log (2, "Cannot seek in file: %s (%s)\n", msfile, strerror (errno)); + + return MS_GENERROR; + } + + msfp->filepos = *fpos * -1; + msfp->readlen = 0; + msfp->readoffset = 0; + } + } + + /* Zero the last record indicator */ + if ( last ) + *last = 0; + + /* Read data and search for records */ + for (;;) + { + /* Read more data into buffer if not at EOF and buffer has less than MINRECLEN + * or more data is needed for the current record detected in buffer. */ + if ( ! feof(msfp->fp) && (MSFPBUFLEN(msfp) < MINRECLEN || parseval > 0) ) + { + /* Reset offsets if no unprocessed data in buffer */ + if ( MSFPBUFLEN(msfp) <= 0 ) + { + msfp->readlen = 0; + msfp->readoffset = 0; + } + /* Otherwise shift existing data to beginning of buffer */ + else if ( msfp->readoffset > 0 ) + { + ms_shift_msfp (msfp, msfp->readoffset); + } + + /* Determine read size */ + readsize = (MAXRECLEN - msfp->readlen); + + /* Read data into record buffer */ + readcount = ms_fread (msfp->rawrec + msfp->readlen, 1, readsize, msfp->fp); + + if ( readcount != readsize ) + { + if ( ! feof (msfp->fp) ) + { + ms_log (2, "Short read of %d bytes starting from %lld\n", + readsize, msfp->filepos); + retcode = MS_GENERROR; + break; + } + } + + /* Update read buffer length */ + msfp->readlen += readcount; + + /* File position corresponding to start of buffer; not strictly necessary */ + if ( msfp->fp != stdin ) + msfp->filepos = lmp_ftello (msfp->fp) - msfp->readlen; + } + + /* Test for packed file signature at the beginning of the file */ + if ( msfp->filepos == 0 && *(MSFPREADPTR(msfp)) == 'P' && MSFPBUFLEN(msfp) >= 48 ) + { + msfp->packtype = 0; + + /* Determine pack type, the negative pack type indicates initial header */ + if ( ! memcmp ("PED", MSFPREADPTR(msfp), 3) ) + msfp->packtype = -1; + else if ( ! memcmp ("PSD", MSFPREADPTR(msfp), 3) ) + msfp->packtype = -2; + else if ( ! memcmp ("PLC", MSFPREADPTR(msfp), 3) ) + msfp->packtype = -6; + else if ( ! memcmp ("PQI", MSFPREADPTR(msfp), 3) ) + msfp->packtype = -7; + else if ( ! memcmp ("PLS", MSFPREADPTR(msfp), 3) ) + msfp->packtype = -8; + + if ( verbose > 0 ) + ms_log (1, "Detected packed file (%3.3s: type %d)\n", MSFPREADPTR(msfp), -msfp->packtype); + } + + /* Read pack headers, initial and subsequent headers including (ignored) chksum values */ + if ( msfp->packtype && (msfp->packtype < 0 || msfp->filepos == msfp->packhdroffset) && MSFPBUFLEN(msfp) >= 48 ) + { + char hdrstr[30]; + long long datasize; + + /* Determine bytes to skip before header: either initial ID block or type-specific chksum block */ + packskipsize = ( msfp->packtype < 0 ) ? 10 : packtypes[msfp->packtype][2]; + + if ( msfp->packtype < 0 ) + msfp->packtype = -msfp->packtype; + + /* Read pack length from pack header accounting for bytes that should be skipped */ + memset (hdrstr, 0, sizeof(hdrstr)); + memcpy (hdrstr, MSFPREADPTR(msfp) + (packtypes[msfp->packtype][0] + packskipsize - packtypes[msfp->packtype][1]), + packtypes[msfp->packtype][1]); + sscanf (hdrstr, " %lld", &datasize); + packdatasize = (off_t) datasize; + + /* Next pack header = File position + skipsize + header size + data size + * This offset is actually to the data block chksum which is skipped by the logic above, + * the next pack header should directly follow the chksum. */ + msfp->packhdroffset = msfp->filepos + packskipsize + packtypes[msfp->packtype][0] + packdatasize; + + if ( verbose > 1 ) + ms_log (1, "Read packed file header at offset %lld (%d bytes follow), chksum offset: %lld\n", + (long long int) (msfp->filepos + packskipsize), packdatasize, + (long long int) msfp->packhdroffset); + + /* Shift buffer to new reading offset (aligns records in buffer) */ + ms_shift_msfp (msfp, msfp->readoffset + (packskipsize + packtypes[msfp->packtype][0])); + } /* End of packed header processing */ + + /* Check for match if selections are supplied and pack header was read, */ + /* only when enough data is in buffer and not reading from stdin pipe */ + if ( selections && msfp->packtype && packdatasize && MSFPBUFLEN(msfp) >= 48 && msfp->fp != stdin ) + { + char srcname[100]; + + ms_recsrcname (MSFPREADPTR(msfp), srcname, 1); + + if ( ! ms_matchselect (selections, srcname, HPTERROR, HPTERROR, NULL) ) + { + /* Update read position if next section is in buffer */ + if ( MSFPBUFLEN(msfp) >= (msfp->packhdroffset - msfp->filepos) ) + { + if ( verbose > 1 ) + { + ms_log (1, "Skipping (jump) packed section for %s (%d bytes) starting at offset %lld\n", + srcname, (msfp->packhdroffset - msfp->filepos), (long long int) msfp->filepos); + } + + msfp->readoffset += (msfp->packhdroffset - msfp->filepos); + msfp->filepos = msfp->packhdroffset; + packdatasize = 0; + } + + /* Otherwise seek to next pack header and reset reading position */ + else + { + if ( verbose > 1 ) + { + ms_log (1, "Skipping (seek) packed section for %s (%d bytes) starting at offset %lld\n", + srcname, (msfp->packhdroffset - msfp->filepos), (long long int) msfp->filepos); + } + + if ( lmp_fseeko (msfp->fp, msfp->packhdroffset, SEEK_SET) ) + { + ms_log (2, "Cannot seek in file: %s (%s)\n", msfile, strerror (errno)); + + return MS_GENERROR; + break; + } + + msfp->filepos = msfp->packhdroffset; + msfp->readlen = 0; + msfp->readoffset = 0; + packdatasize = 0; + } + + /* Return to top of loop for proper pack header handling */ + continue; + } + } /* End of selection processing */ + + /* Attempt to parse record from buffer */ + if ( MSFPBUFLEN(msfp) >= MINRECLEN ) + { + int parselen = MSFPBUFLEN(msfp); + + /* Limit the parse length to offset of pack header if present in the buffer */ + if ( msfp->packhdroffset && msfp->packhdroffset < (msfp->filepos + MSFPBUFLEN(msfp)) ) + parselen = msfp->packhdroffset - msfp->filepos; + + parseval = msr_parse (MSFPREADPTR(msfp), parselen, ppmsr, reclen, dataflag, verbose); + + /* Record detected and parsed */ + if ( parseval == 0 ) + { + if ( verbose > 1 ) + ms_log (1, "Read record length of %d bytes\n", (*ppmsr)->reclen); + + /* Test if this is the last record if file size is known (not pipe) */ + if ( last && msfp->filesize ) + if ( (msfp->filesize - (msfp->filepos + (*ppmsr)->reclen)) < MINRECLEN ) + *last = 1; + + /* Return file position for this record */ + if ( fpos ) + *fpos = msfp->filepos; + + /* Update reading offset, file position and record count */ + msfp->readoffset += (*ppmsr)->reclen; + msfp->filepos += (*ppmsr)->reclen; + msfp->recordcount++; + + retcode = MS_NOERROR; + break; + } + else if ( parseval < 0 ) + { + /* Skip non-data if requested */ + if ( skipnotdata ) + { + if ( verbose > 1 ) + { + if ( MS_ISVALIDBLANK((char *)MSFPREADPTR(msfp)) ) + ms_log (1, "Skipped %d bytes of blank/noise record at byte offset %lld\n", + MINRECLEN, (long long) msfp->filepos); + else + ms_log (1, "Skipped %d bytes of non-data record at byte offset %lld\n", + MINRECLEN, (long long) msfp->filepos); + } + + /* Skip MINRECLEN bytes, update reading offset and file position */ + msfp->readoffset += MINRECLEN; + msfp->filepos += MINRECLEN; + } + /* Parsing errors */ + else + { + ms_log (2, "Cannot detect record at byte offset %lld: %s\n", + (long long) msfp->filepos, msfile); + + /* Print common errors and raw details if verbose */ + ms_parse_raw (MSFPREADPTR(msfp), MSFPBUFLEN(msfp), verbose, -1); + + retcode = parseval; + break; + } + } + else /* parseval > 0 (found record but need more data) */ + { + /* Determine implied record length if needed */ + int32_t impreclen = reclen; + + /* Check for parse hints that are larger than MAXRECLEN */ + if ( (MSFPBUFLEN(msfp) + parseval) > MAXRECLEN ) + { + if ( skipnotdata ) + { + /* Skip MINRECLEN bytes, update reading offset and file position */ + msfp->readoffset += MINRECLEN; + msfp->filepos += MINRECLEN; + } + else + { + retcode = MS_OUTOFRANGE; + break; + } + } + + /* Pack header check, if pack header offset is within buffer */ + else if ( impreclen <= 0 && msfp->packhdroffset && + msfp->packhdroffset < (msfp->filepos + MSFPBUFLEN(msfp)) ) + { + impreclen = msfp->packhdroffset - msfp->filepos; + + /* Check that record length is within range and a power of 2. + * Power of two if (X & (X - 1)) == 0 */ + if ( impreclen >= MINRECLEN && impreclen <= MAXRECLEN && + (impreclen & (impreclen - 1)) == 0 ) + { + /* Set the record length implied by the next pack header */ + reclen = impreclen; + } + else + { + ms_log (1, "Implied record length (%d) is invalid\n", impreclen); + + retcode = MS_NOTSEED; + break; + } + } + + /* End of file check */ + else if ( impreclen <= 0 && feof (msfp->fp) ) + { + impreclen = msfp->filesize - msfp->filepos; + + /* Check that record length is within range and a power of 2. + * Power of two if (X & (X - 1)) == 0 */ + if ( impreclen >= MINRECLEN && impreclen <= MAXRECLEN && + (impreclen & (impreclen - 1)) == 0 ) + { + /* Set the record length implied by the end of the file */ + reclen = impreclen; + } + /* Otherwise a trucated record */ + else + { + if ( verbose ) + { + if ( msfp->filesize ) + ms_log (1, "Truncated record at byte offset %lld, filesize %d: %s\n", + (long long) msfp->filepos, msfp->filesize, msfile); + else + ms_log (1, "Truncated record at byte offset %lld\n", + (long long) msfp->filepos); + } + + retcode = MS_ENDOFFILE; + break; + } + } + } + } /* End of record detection */ + + /* Finished when within MINRECLEN from EOF and buffer less than MINRECLEN */ + if ( (msfp->filesize - msfp->filepos) < MINRECLEN && MSFPBUFLEN(msfp) < MINRECLEN ) + { + if ( msfp->recordcount == 0 && msfp->packtype == 0 ) + { + if ( verbose > 0 ) + ms_log (2, "%s: No data records read, not SEED?\n", msfile); + retcode = MS_NOTSEED; + } + else + { + retcode = MS_ENDOFFILE; + } + + break; + } + } /* End of reading, record detection and parsing loop */ + + /* Cleanup target MSRecord if returning an error */ + if ( retcode != MS_NOERROR ) + { + msr_free (ppmsr); + } + + return retcode; +} /* End of ms_readmsr_main() */ + + +/********************************************************************* + * ms_readtraces: + * + * This is a simple wrapper for ms_readtraces_selection() that uses no + * selections. + * + * See the comments with ms_readtraces_selection() for return values + * and further description of arguments. + *********************************************************************/ +int +ms_readtraces (MSTraceGroup **ppmstg, const char *msfile, int reclen, + double timetol, double sampratetol, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + return ms_readtraces_selection (ppmstg, msfile, reclen, + timetol, sampratetol, NULL, + dataquality, skipnotdata, + dataflag, verbose); +} /* End of ms_readtraces() */ + + +/********************************************************************* + * ms_readtraces_timewin: + * + * This is a wrapper for ms_readtraces_selection() that creates a + * simple selection for a specified time window. + * + * See the comments with ms_readtraces_selection() for return values + * and further description of arguments. + *********************************************************************/ +int +ms_readtraces_timewin (MSTraceGroup **ppmstg, const char *msfile, int reclen, + double timetol, double sampratetol, + hptime_t starttime, hptime_t endtime, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + Selections selection; + SelectTime selecttime; + + selection.srcname[0] = '*'; + selection.srcname[1] = '\0'; + selection.timewindows = &selecttime; + selection.next = NULL; + + selecttime.starttime = starttime; + selecttime.endtime = endtime; + selecttime.next = NULL; + + return ms_readtraces_selection (ppmstg, msfile, reclen, + timetol, sampratetol, &selection, + dataquality, skipnotdata, + dataflag, verbose); +} /* End of ms_readtraces_timewin() */ + + +/********************************************************************* + * ms_readtraces_selection: + * + * This routine will open and read all Mini-SEED records in specified + * file and populate a trace group. This routine is thread safe. + * + * If reclen is <= 0 the length of every record is automatically + * detected. + * + * If a Selections list is supplied it will be used to limit which + * records are added to the trace group. + * + * Returns MS_NOERROR and populates an MSTraceGroup struct at *ppmstg + * on successful read, otherwise returns a libmseed error code (listed + * in libmseed.h). + *********************************************************************/ +int +ms_readtraces_selection (MSTraceGroup **ppmstg, const char *msfile, + int reclen, double timetol, double sampratetol, + Selections *selections, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + MSRecord *msr = 0; + MSFileParam *msfp = 0; + int retcode; + + if ( ! ppmstg ) + return MS_GENERROR; + + /* Initialize MSTraceGroup if needed */ + if ( ! *ppmstg ) + { + *ppmstg = mst_initgroup (*ppmstg); + + if ( ! *ppmstg ) + return MS_GENERROR; + } + + /* Loop over the input file */ + while ( (retcode = ms_readmsr_main (&msfp, &msr, msfile, reclen, NULL, NULL, + skipnotdata, dataflag, NULL, verbose)) == MS_NOERROR) + { + /* Test against selections if supplied */ + if ( selections ) + { + char srcname[50]; + hptime_t endtime; + + msr_srcname (msr, srcname, 1); + endtime = msr_endtime (msr); + + if ( ms_matchselect (selections, srcname, msr->starttime, endtime, NULL) == NULL ) + { + continue; + } + } + + /* Add to trace group */ + mst_addmsrtogroup (*ppmstg, msr, dataquality, timetol, sampratetol); + } + + /* Reset return code to MS_NOERROR on successful read by ms_readmsr() */ + if ( retcode == MS_ENDOFFILE ) + retcode = MS_NOERROR; + + ms_readmsr_main (&msfp, &msr, NULL, 0, NULL, NULL, 0, 0, NULL, 0); + + return retcode; +} /* End of ms_readtraces_selection() */ + + +/********************************************************************* + * ms_readtracelist: + * + * This is a simple wrapper for ms_readtracelist_selection() that uses + * no selections. + * + * See the comments with ms_readtracelist_selection() for return + * values and further description of arguments. + *********************************************************************/ +int +ms_readtracelist (MSTraceList **ppmstl, const char *msfile, int reclen, + double timetol, double sampratetol, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + return ms_readtracelist_selection (ppmstl, msfile, reclen, + timetol, sampratetol, NULL, + dataquality, skipnotdata, + dataflag, verbose); +} /* End of ms_readtracelist() */ + + +/********************************************************************* + * ms_readtracelist_timewin: + * + * This is a wrapper for ms_readtraces_selection() that creates a + * simple selection for a specified time window. + * + * See the comments with ms_readtraces_selection() for return values + * and further description of arguments. + *********************************************************************/ +int +ms_readtracelist_timewin (MSTraceList **ppmstl, const char *msfile, + int reclen, double timetol, double sampratetol, + hptime_t starttime, hptime_t endtime, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + Selections selection; + SelectTime selecttime; + + selection.srcname[0] = '*'; + selection.srcname[1] = '\0'; + selection.timewindows = &selecttime; + selection.next = NULL; + + selecttime.starttime = starttime; + selecttime.endtime = endtime; + selecttime.next = NULL; + + return ms_readtracelist_selection (ppmstl, msfile, reclen, + timetol, sampratetol, &selection, + dataquality, skipnotdata, + dataflag, verbose); +} /* End of ms_readtracelist_timewin() */ + + +/********************************************************************* + * ms_readtracelist_selection: + * + * This routine will open and read all Mini-SEED records in specified + * file and populate a trace list. This routine is thread safe. + * + * If reclen is <= 0 the length of every record is automatically + * detected. + * + * If a Selections list is supplied it will be used to limit which + * records are added to the trace list. + * + * Returns MS_NOERROR and populates an MSTraceList struct at *ppmstl + * on successful read, otherwise returns a libmseed error code (listed + * in libmseed.h). + *********************************************************************/ +int +ms_readtracelist_selection (MSTraceList **ppmstl, const char *msfile, + int reclen, double timetol, double sampratetol, + Selections *selections, flag dataquality, + flag skipnotdata, flag dataflag, flag verbose) +{ + MSRecord *msr = 0; + MSFileParam *msfp = 0; + int retcode; + + if ( ! ppmstl ) + return MS_GENERROR; + + /* Initialize MSTraceList if needed */ + if ( ! *ppmstl ) + { + *ppmstl = mstl_init (*ppmstl); + + if ( ! *ppmstl ) + return MS_GENERROR; + } + + /* Loop over the input file */ + while ( (retcode = ms_readmsr_main (&msfp, &msr, msfile, reclen, NULL, NULL, + skipnotdata, dataflag, NULL, verbose)) == MS_NOERROR) + { + /* Test against selections if supplied */ + if ( selections ) + { + char srcname[50]; + hptime_t endtime; + + msr_srcname (msr, srcname, 1); + endtime = msr_endtime (msr); + + if ( ms_matchselect (selections, srcname, msr->starttime, endtime, NULL) == NULL ) + { + continue; + } + } + + /* Add to trace list */ + mstl_addmsr (*ppmstl, msr, dataquality, 1, timetol, sampratetol); + } + + /* Reset return code to MS_NOERROR on successful read by ms_readmsr() */ + if ( retcode == MS_ENDOFFILE ) + retcode = MS_NOERROR; + + ms_readmsr_main (&msfp, &msr, NULL, 0, NULL, NULL, 0, 0, NULL, 0); + + return retcode; +} /* End of ms_readtracelist_selection() */ + + +/********************************************************************* + * ms_fread: + * + * A wrapper for fread that handles EOF and error conditions. + * + * Returns the return value from fread. + *********************************************************************/ +static int +ms_fread (char *buf, int size, int num, FILE *stream) +{ + int read = 0; + + read = fread (buf, size, num, stream); + + if ( read <= 0 && size && num ) + { + if ( ferror (stream) ) + ms_log (2, "ms_fread(): Cannot read input file\n"); + + else if ( ! feof (stream) ) + ms_log (2, "ms_fread(): Unknown return from fread()\n"); + } + + return read; +} /* End of ms_fread() */ + + +/*************************************************************************** + * ms_record_handler_int: + * + * Internal record handler. The handler data should be a pointer to + * an open file descriptor to which records will be written. + * + ***************************************************************************/ +static void +ms_record_handler_int (char *record, int reclen, void *ofp) +{ + if ( fwrite(record, reclen, 1, (FILE *)ofp) != 1 ) + { + ms_log (2, "Error writing to output file\n"); + } +} /* End of ms_record_handler_int() */ + + +/*************************************************************************** + * msr_writemseed: + * + * Pack MSRecord data into Mini-SEED record(s) by calling msr_pack() and + * write to a specified file. + * + * Returns the number of records written on success and -1 on error. + ***************************************************************************/ +int +msr_writemseed ( MSRecord *msr, const char *msfile, flag overwrite, + int reclen, flag encoding, flag byteorder, flag verbose ) +{ + FILE *ofp; + char srcname[50]; + char *perms = (overwrite) ? "wb":"ab"; + int packedrecords = 0; + + if ( ! msr || ! msfile ) + return -1; + + /* Open output file or use stdout */ + if ( strcmp (msfile, "-") == 0 ) + { + ofp = stdout; + } + else if ( (ofp = fopen (msfile, perms)) == NULL ) + { + ms_log (1, "Cannot open output file %s: %s\n", msfile, strerror(errno)); + + return -1; + } + + /* Pack the MSRecord */ + if ( msr->numsamples > 0 ) + { + msr->encoding = encoding; + msr->reclen = reclen; + msr->byteorder = byteorder; + + packedrecords = msr_pack (msr, &ms_record_handler_int, ofp, NULL, 1, verbose-1); + + if ( packedrecords < 0 ) + { + msr_srcname (msr, srcname, 1); + ms_log (1, "Cannot write Mini-SEED for %s\n", srcname); + } + } + + /* Close file and return record count */ + fclose (ofp); + + return (packedrecords >= 0) ? packedrecords : -1; +} /* End of msr_writemseed() */ + + +/*************************************************************************** + * mst_writemseed: + * + * Pack MSTrace data into Mini-SEED records by calling mst_pack() and + * write to a specified file. + * + * Returns the number of records written on success and -1 on error. + ***************************************************************************/ +int +mst_writemseed ( MSTrace *mst, const char *msfile, flag overwrite, + int reclen, flag encoding, flag byteorder, flag verbose ) +{ + FILE *ofp; + char srcname[50]; + char *perms = (overwrite) ? "wb":"ab"; + int packedrecords = 0; + + if ( ! mst || ! msfile ) + return -1; + + /* Open output file or use stdout */ + if ( strcmp (msfile, "-") == 0 ) + { + ofp = stdout; + } + else if ( (ofp = fopen (msfile, perms)) == NULL ) + { + ms_log (1, "Cannot open output file %s: %s\n", msfile, strerror(errno)); + + return -1; + } + + /* Pack the MSTrace */ + if ( mst->numsamples > 0 ) + { + packedrecords = mst_pack (mst, &ms_record_handler_int, ofp, reclen, encoding, + byteorder, NULL, 1, verbose-1, NULL); + + if ( packedrecords < 0 ) + { + mst_srcname (mst, srcname, 1); + ms_log (1, "Cannot write Mini-SEED for %s\n", srcname); + } + } + + /* Close file and return record count */ + fclose (ofp); + + return (packedrecords >= 0) ? packedrecords : -1; +} /* End of mst_writemseed() */ + + +/*************************************************************************** + * mst_writemseedgroup: + * + * Pack MSTraceGroup data into Mini-SEED records by calling mst_pack() + * for each MSTrace in the group and write to a specified file. + * + * Returns the number of records written on success and -1 on error. + ***************************************************************************/ +int +mst_writemseedgroup ( MSTraceGroup *mstg, const char *msfile, flag overwrite, + int reclen, flag encoding, flag byteorder, flag verbose ) +{ + MSTrace *mst; + FILE *ofp; + char srcname[50]; + char *perms = (overwrite) ? "wb":"ab"; + int trpackedrecords; + int packedrecords = 0; + + if ( ! mstg || ! msfile ) + return -1; + + /* Open output file or use stdout */ + if ( strcmp (msfile, "-") == 0 ) + { + ofp = stdout; + } + else if ( (ofp = fopen (msfile, perms)) == NULL ) + { + ms_log (1, "Cannot open output file %s: %s\n", msfile, strerror(errno)); + + return -1; + } + + /* Pack each MSTrace in the group */ + mst = mstg->traces; + while ( mst ) + { + if ( mst->numsamples <= 0 ) + { + mst = mst->next; + continue; + } + + trpackedrecords = mst_pack (mst, &ms_record_handler_int, ofp, reclen, encoding, + byteorder, NULL, 1, verbose-1, NULL); + + if ( trpackedrecords < 0 ) + { + mst_srcname (mst, srcname, 1); + ms_log (1, "Cannot write Mini-SEED for %s\n", srcname); + } + else + { + packedrecords += trpackedrecords; + } + + mst = mst->next; + } + + /* Close file and return record count */ + fclose (ofp); + + return packedrecords; +} /* End of mst_writemseedgroup() */ + diff --git a/libs/3rd-party/mseed/genutils.c b/libs/3rd-party/mseed/genutils.c new file mode 100644 index 0000000..efa6180 --- /dev/null +++ b/libs/3rd-party/mseed/genutils.c @@ -0,0 +1,1407 @@ +/*************************************************************************** + * genutils.c + * + * Generic utility routines + * + * Written by Chad Trabant + * ORFEUS/EC-Project MEREDIAN + * IRIS Data Management Center + * + * modified: 2013.053 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "lmplatform.h" +#include "libmseed.h" + +static hptime_t ms_time2hptime_int (int year, int day, int hour, + int min, int sec, int usec); + +static struct tm *ms_gmtime_r (int64_t *timep, struct tm *result); + + +/*************************************************************************** + * ms_recsrcname: + * + * Generate a source name string for a specified raw data record in + * the format: 'NET_STA_LOC_CHAN' or, if the quality flag is true: + * 'NET_STA_LOC_CHAN_QUAL'. The passed srcname must have enough room + * for the resulting string. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_recsrcname (char *record, char *srcname, flag quality) +{ + struct fsdh_s *fsdh; + char network[6]; + char station[6]; + char location[6]; + char channel[6]; + + if ( ! record ) + return NULL; + + fsdh = (struct fsdh_s *) record; + + ms_strncpclean (network, fsdh->network, 2); + ms_strncpclean (station, fsdh->station, 5); + ms_strncpclean (location, fsdh->location, 2); + ms_strncpclean (channel, fsdh->channel, 3); + + /* Build the source name string including the quality indicator*/ + if ( quality ) + sprintf (srcname, "%s_%s_%s_%s_%c", + network, station, location, channel, fsdh->dataquality); + + /* Build the source name string without the quality indicator*/ + else + sprintf (srcname, "%s_%s_%s_%s", network, station, location, channel); + + return srcname; +} /* End of ms_recsrcname() */ + + +/*************************************************************************** + * ms_splitsrcname: + * + * Split srcname into separate components: "NET_STA_LOC_CHAN[_QUAL]". + * Memory for each component must already be allocated. If a specific + * component is not desired set the appropriate argument to NULL. + * + * Returns 0 on success and -1 on error. + ***************************************************************************/ +int +ms_splitsrcname (char *srcname, char *net, char *sta, char *loc, char *chan, + char *qual) +{ + char *id; + char *ptr, *top, *next; + int sepcnt = 0; + + if ( ! srcname ) + return -1; + + /* Verify number of separating underscore characters */ + id = srcname; + while ( (id = strchr (id, '_')) ) + { + id++; + sepcnt++; + } + + /* Either 3 or 4 separating underscores are required */ + if ( sepcnt != 3 && sepcnt != 4 ) + { + return -1; + } + + /* Duplicate srcname */ + if ( ! (id = strdup(srcname)) ) + { + ms_log (2, "ms_splitsrcname(): Error duplicating srcname string"); + return -1; + } + + /* Network */ + top = id; + if ( (ptr = strchr (top, '_')) ) + { + next = ptr + 1; + *ptr = '\0'; + + if ( net ) + strcpy (net, top); + + top = next; + } + /* Station */ + if ( (ptr = strchr (top, '_')) ) + { + next = ptr + 1; + *ptr = '\0'; + + if ( sta ) + strcpy (sta, top); + + top = next; + } + /* Location */ + if ( (ptr = strchr (top, '_')) ) + { + next = ptr + 1; + *ptr = '\0'; + + if ( loc ) + strcpy (loc, top); + + top = next; + } + /* Channel & optional Quality */ + if ( (ptr = strchr (top, '_')) ) + { + next = ptr + 1; + *ptr = '\0'; + + if ( chan ) + strcpy (chan, top); + + top = next; + + /* Quality */ + if ( *top && qual ) + { + /* Quality is a single character */ + *qual = *top; + } + } + /* Otherwise only Channel */ + else if ( *top && chan ) + { + strcpy (chan, top); + } + + /* Free duplicated stream ID */ + if ( id ) + free (id); + + return 0; +} /* End of ms_splitsrcname() */ + + +/*************************************************************************** + * ms_strncpclean: + * + * Copy up to 'length' 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'. + * + * Returns the number of characters (not including the null terminator) in + * the destination string. + ***************************************************************************/ +int +ms_strncpclean (char *dest, const char *source, int length) +{ + int sidx, didx; + + if ( ! dest ) + return 0; + + if ( ! source ) + { + *dest = '\0'; + return 0; + } + + for ( sidx=0, didx=0; sidx < length ; sidx++ ) + { + if ( *(source+sidx) == '\0' ) + { + break; + } + + if ( *(source+sidx) != ' ' ) + { + *(dest+didx) = *(source+sidx); + didx++; + } + } + + *(dest+didx) = '\0'; + + return didx; +} /* End of ms_strncpclean() */ + + +/*************************************************************************** + * ms_strncpcleantail: + * + * Copy up to 'length' 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'. + * + * Returns the number of characters (not including the null terminator) in + * the destination string. + ***************************************************************************/ +int +ms_strncpcleantail (char *dest, const char *source, int length) +{ + int idx, pretail; + + if ( ! dest ) + return 0; + + if ( ! source ) + { + *dest = '\0'; + return 0; + } + + *(dest+length) = '\0'; + + pretail = 0; + for ( idx=length-1; idx >= 0 ; idx-- ) + { + if ( ! pretail && *(source+idx) == ' ' ) + { + *(dest+idx) = '\0'; + } + else + { + pretail++; + *(dest+idx) = *(source+idx); + } + } + + return pretail; +} /* End of ms_strncpcleantail() */ + + +/*************************************************************************** + * ms_strncpopen: + * + * Copy 'length' characters from 'source' to 'dest', padding the right + * side with spaces and leave open-ended. The result is left + * justified and *never* null terminated (the open-ended part). The + * destination string must have enough room for 'length' characters. + * + * Returns the number of characters copied from the source string. + ***************************************************************************/ +int +ms_strncpopen (char *dest, const char *source, int length) +{ + int didx; + int dcnt = 0; + int term = 0; + + if ( ! dest ) + return 0; + + if ( ! source ) + { + for ( didx=0; didx < length ; didx++ ) + { + *(dest+didx) = ' '; + } + + return 0; + } + + for ( didx=0; didx < length ; didx++ ) + { + if ( !term ) + if ( *(source+didx) == '\0' ) + term = 1; + + if ( !term ) + { + *(dest+didx) = *(source+didx); + dcnt++; + } + else + { + *(dest+didx) = ' '; + } + } + + return dcnt; +} /* End of ms_strncpopen() */ + + +/*************************************************************************** + * ms_doy2md: + * + * Compute the month and day-of-month from a year and day-of-year. + * + * Year is expected to be in the range 1800-5000, jday is expected to + * be in the range 1-366, month will be in the range 1-12 and mday + * will be in the range 1-31. + * + * Returns 0 on success and -1 on error. + ***************************************************************************/ +int +ms_doy2md(int year, int jday, int *month, int *mday) +{ + int idx; + int leap; + int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + /* Sanity check for the supplied year */ + if ( year < 1800 || year > 5000 ) + { + ms_log (2, "ms_doy2md(): year (%d) is out of range\n", year); + return -1; + } + + /* Test for leap year */ + leap = ( ((year%4 == 0) && (year%100 != 0)) || (year%400 == 0) ) ? 1 : 0; + + /* Add a day to February if leap year */ + if ( leap ) + days[1]++; + + if (jday > 365+leap || jday <= 0) + { + ms_log (2, "ms_doy2md(): day-of-year (%d) is out of range\n", jday); + return -1; + } + + for ( idx=0; idx < 12; idx++ ) + { + jday -= days[idx]; + + if ( jday <= 0 ) + { + *month = idx + 1; + *mday = days[idx] + jday; + break; + } + } + + return 0; +} /* End of ms_doy2md() */ + + +/*************************************************************************** + * ms_md2doy: + * + * Compute the day-of-year from a year, month and day-of-month. + * + * Year is expected to be in the range 1800-5000, month is expected to + * be in the range 1-12, mday is expected to be in the range 1-31 and + * jday will be in the range 1-366. + * + * Returns 0 on success and -1 on error. + ***************************************************************************/ +int +ms_md2doy(int year, int month, int mday, int *jday) +{ + int idx; + int leap; + int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + /* Sanity check for the supplied parameters */ + if ( year < 1800 || year > 5000 ) + { + ms_log (2, "ms_md2doy(): year (%d) is out of range\n", year); + return -1; + } + if ( month < 1 || month > 12 ) + { + ms_log (2, "ms_md2doy(): month (%d) is out of range\n", month); + return -1; + } + if ( mday < 1 || mday > 31 ) + { + ms_log (2, "ms_md2doy(): day-of-month (%d) is out of range\n", mday); + return -1; + } + + /* Test for leap year */ + leap = ( ((year%4 == 0) && (year%100 != 0)) || (year%400 == 0) ) ? 1 : 0; + + /* Add a day to February if leap year */ + if ( leap ) + days[1]++; + + /* Check that the day-of-month jives with specified month */ + if ( mday > days[month-1] ) + { + ms_log (2, "ms_md2doy(): day-of-month (%d) is out of range for month %d\n", + mday, month); + return -1; + } + + *jday = 0; + month--; + + for ( idx=0; idx < 12; idx++ ) + { + if ( idx == month ) + { + *jday += mday; + break; + } + + *jday += days[idx]; + } + + return 0; +} /* End of ms_md2doy() */ + + +/*************************************************************************** + * ms_btime2hptime: + * + * Convert a binary SEED time structure to a high precision epoch time + * (1/HPTMODULUS second ticks from the epoch). The algorithm used is + * a specific version of a generalized function in GNU glibc. + * + * Returns a high precision epoch time on success and HPTERROR on + * error. + ***************************************************************************/ +hptime_t +ms_btime2hptime (BTime *btime) +{ + hptime_t hptime; + int shortyear; + int a4, a100, a400; + int intervening_leap_days; + int days; + + if ( ! btime ) + return HPTERROR; + + shortyear = btime->year - 1900; + + a4 = (shortyear >> 2) + 475 - ! (shortyear & 3); + a100 = a4 / 25 - (a4 % 25 < 0); + a400 = a100 >> 2; + intervening_leap_days = (a4 - 492) - (a100 - 19) + (a400 - 4); + + days = (365 * (shortyear - 70) + intervening_leap_days + (btime->day - 1)); + + hptime = (hptime_t ) (60 * (60 * ((hptime_t) 24 * days + btime->hour) + btime->min) + btime->sec) * HPTMODULUS + + (btime->fract * (HPTMODULUS / 10000)); + + return hptime; +} /* End of ms_btime2hptime() */ + + +/*************************************************************************** + * ms_btime2isotimestr: + * + * Build a time string in ISO recommended format from a BTime struct. + * + * The provided isostimestr must have enough room for the resulting time + * string of 25 characters, i.e. '2001-07-29T12:38:00.0000' + NULL. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_btime2isotimestr (BTime *btime, char *isotimestr) +{ + int month = 0; + int mday = 0; + int ret; + + if ( ! isotimestr ) + return NULL; + + if ( ms_doy2md (btime->year, btime->day, &month, &mday) ) + { + ms_log (2, "ms_btime2isotimestr(): Error converting year %d day %d\n", + btime->year, btime->day); + return NULL; + } + + ret = snprintf (isotimestr, 25, "%4d-%02d-%02dT%02d:%02d:%02d.%04d", + btime->year, month, mday, + btime->hour, btime->min, btime->sec, btime->fract); + + if ( ret != 24 ) + return NULL; + else + return isotimestr; +} /* End of ms_btime2isotimestr() */ + + +/*************************************************************************** + * ms_btime2mdtimestr: + * + * Build a time string in month-day format from a BTime struct. + * + * The provided isostimestr must have enough room for the resulting time + * string of 25 characters, i.e. '2001-07-29 12:38:00.0000' + NULL. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_btime2mdtimestr (BTime *btime, char *mdtimestr) +{ + int month = 0; + int mday = 0; + int ret; + + if ( ! mdtimestr ) + return NULL; + + if ( ms_doy2md (btime->year, btime->day, &month, &mday) ) + { + ms_log (2, "ms_btime2mdtimestr(): Error converting year %d day %d\n", + btime->year, btime->day); + return NULL; + } + + ret = snprintf (mdtimestr, 25, "%4d-%02d-%02d %02d:%02d:%02d.%04d", + btime->year, month, mday, + btime->hour, btime->min, btime->sec, btime->fract); + + if ( ret != 24 ) + return NULL; + else + return mdtimestr; +} /* End of ms_btime2mdtimestr() */ + + +/*************************************************************************** + * ms_btime2seedtimestr: + * + * Build a SEED time string from a BTime struct. + * + * The provided seedtimestr must have enough room for the resulting time + * string of 23 characters, i.e. '2001,195,12:38:00.0000' + NULL. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_btime2seedtimestr (BTime *btime, char *seedtimestr) +{ + int ret; + + if ( ! seedtimestr ) + return NULL; + + ret = snprintf (seedtimestr, 23, "%4d,%03d,%02d:%02d:%02d.%04d", + btime->year, btime->day, + btime->hour, btime->min, btime->sec, btime->fract); + + if ( ret != 22 ) + return NULL; + else + return seedtimestr; +} /* End of ms_btime2seedtimestr() */ + + +/*************************************************************************** + * ms_hptime2btime: + * + * Convert a high precision epoch time to a SEED binary time + * structure. The microseconds beyond the 1/10000 second range are + * truncated and *not* rounded, this is intentional and necessary. + * + * Returns 0 on success and -1 on error. + ***************************************************************************/ +int +ms_hptime2btime (hptime_t hptime, BTime *btime) +{ + struct tm tms; + int64_t isec; + int ifract; + int bfract; + + if ( btime == NULL ) + return -1; + + /* Reduce to Unix/POSIX epoch time and fractional seconds */ + isec = MS_HPTIME2EPOCH(hptime); + ifract = (int)(hptime - (isec * HPTMODULUS)); + + /* BTime only has 1/10000 second precision */ + bfract = ifract / (HPTMODULUS / 10000); + + /* Adjust for negative epoch times, round back when needed */ + if ( hptime < 0 && ifract != 0 ) + { + /* Isolate microseconds between 1e-4 and 1e-6 precision and adjust bfract if not zero */ + if ( ifract - bfract * (HPTMODULUS / 10000) ) + bfract -= 1; + + isec -= 1; + bfract = 10000 - (-bfract); + } + + if ( ! (ms_gmtime_r (&isec, &tms)) ) + return -1; + + btime->year = tms.tm_year + 1900; + btime->day = tms.tm_yday + 1; + btime->hour = tms.tm_hour; + btime->min = tms.tm_min; + btime->sec = tms.tm_sec; + btime->unused = 0; + btime->fract = (uint16_t) bfract; + + return 0; +} /* End of ms_hptime2btime() */ + + +/*************************************************************************** + * ms_hptime2isotimestr: + * + * Build a time string in ISO recommended format from a high precision + * epoch time. + * + * The provided isostimestr must have enough room for the resulting time + * string of 27 characters, i.e. '2001-07-29T12:38:00.000000' + NULL. + * + * The 'subseconds' flag controls whenther the sub second portion of the + * time is included or not. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_hptime2isotimestr (hptime_t hptime, char *isotimestr, flag subseconds) +{ + struct tm tms; + int64_t isec; + int ifract; + int ret; + + if ( isotimestr == NULL ) + return NULL; + + /* Reduce to Unix/POSIX epoch time and fractional seconds */ + isec = MS_HPTIME2EPOCH(hptime); + ifract = (int)(hptime - (isec * HPTMODULUS)); + + /* Adjust for negative epoch times */ + if ( hptime < 0 && ifract != 0 ) + { + isec -= 1; + ifract = HPTMODULUS - (-ifract); + } + + if ( ! (ms_gmtime_r (&isec, &tms)) ) + return NULL; + + if ( subseconds ) + /* Assuming ifract has at least microsecond precision */ + ret = snprintf (isotimestr, 27, "%4d-%02d-%02dT%02d:%02d:%02d.%06d", + tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec, ifract); + else + ret = snprintf (isotimestr, 20, "%4d-%02d-%02dT%02d:%02d:%02d", + tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec); + + if ( ret != 26 && ret != 19 ) + return NULL; + else + return isotimestr; +} /* End of ms_hptime2isotimestr() */ + + +/*************************************************************************** + * ms_hptime2mdtimestr: + * + * Build a time string in month-day format from a high precision + * epoch time. + * + * The provided mdtimestr must have enough room for the resulting time + * string of 27 characters, i.e. '2001-07-29 12:38:00.000000' + NULL. + * + * The 'subseconds' flag controls whenther the sub second portion of the + * time is included or not. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_hptime2mdtimestr (hptime_t hptime, char *mdtimestr, flag subseconds) +{ + struct tm tms; + int64_t isec; + int ifract; + int ret; + + if ( mdtimestr == NULL ) + return NULL; + + /* Reduce to Unix/POSIX epoch time and fractional seconds */ + isec = MS_HPTIME2EPOCH(hptime); + ifract = (int)(hptime - (isec * HPTMODULUS)); + + /* Adjust for negative epoch times */ + if ( hptime < 0 && ifract != 0 ) + { + isec -= 1; + ifract = HPTMODULUS - (-ifract); + } + + if ( ! (ms_gmtime_r (&isec, &tms)) ) + return NULL; + + if ( subseconds ) + /* Assuming ifract has at least microsecond precision */ + ret = snprintf (mdtimestr, 27, "%4d-%02d-%02d %02d:%02d:%02d.%06d", + tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec, ifract); + else + ret = snprintf (mdtimestr, 20, "%4d-%02d-%02d %02d:%02d:%02d", + tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec); + + if ( ret != 26 && ret != 19 ) + return NULL; + else + return mdtimestr; +} /* End of ms_hptime2mdtimestr() */ + + +/*************************************************************************** + * ms_hptime2seedtimestr: + * + * Build a SEED time string from a high precision epoch time. + * + * The provided seedtimestr must have enough room for the resulting time + * string of 25 characters, i.e. '2001,195,12:38:00.000000\n'. + * + * The 'subseconds' flag controls whenther the sub second portion of the + * time is included or not. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +ms_hptime2seedtimestr (hptime_t hptime, char *seedtimestr, flag subseconds) +{ + struct tm tms; + int64_t isec; + int ifract; + int ret; + + if ( seedtimestr == NULL ) + return NULL; + + /* Reduce to Unix/POSIX epoch time and fractional seconds */ + isec = MS_HPTIME2EPOCH(hptime); + ifract = (int)(hptime - (isec * HPTMODULUS)); + + /* Adjust for negative epoch times */ + if ( hptime < 0 && ifract != 0 ) + { + isec -= 1; + ifract = HPTMODULUS - (-ifract); + } + + if ( ! (ms_gmtime_r (&isec, &tms)) ) + return NULL; + + if ( subseconds ) + /* Assuming ifract has at least microsecond precision */ + ret = snprintf (seedtimestr, 25, "%4d,%03d,%02d:%02d:%02d.%06d", + tms.tm_year + 1900, tms.tm_yday + 1, + tms.tm_hour, tms.tm_min, tms.tm_sec, ifract); + else + ret = snprintf (seedtimestr, 18, "%4d,%03d,%02d:%02d:%02d", + tms.tm_year + 1900, tms.tm_yday + 1, + tms.tm_hour, tms.tm_min, tms.tm_sec); + + if ( ret != 24 && ret != 17 ) + return NULL; + else + return seedtimestr; +} /* End of ms_hptime2seedtimestr() */ + + +/*************************************************************************** + * ms_time2hptime_int: + * + * Convert specified time values to a high precision epoch time. This + * is an internal version which does no range checking, it is assumed + * that checking the range for each value has already been done. + * + * Returns epoch time on success and HPTERROR on error. + ***************************************************************************/ +static hptime_t +ms_time2hptime_int (int year, int day, int hour, int min, int sec, int usec) +{ + BTime btime; + hptime_t hptime; + + memset (&btime, 0, sizeof(BTime)); + btime.day = 1; + + /* Convert integer seconds using ms_btime2hptime */ + btime.year = (int16_t) year; + btime.day = (int16_t) day; + btime.hour = (uint8_t) hour; + btime.min = (uint8_t) min; + btime.sec = (uint8_t) sec; + btime.fract = 0; + + hptime = ms_btime2hptime (&btime); + + if ( hptime == HPTERROR ) + { + ms_log (2, "ms_time2hptime(): Error converting with ms_btime2hptime()\n"); + return HPTERROR; + } + + /* Add the microseconds */ + hptime += (hptime_t) usec * (1000000 / HPTMODULUS); + + return hptime; +} /* End of ms_time2hptime_int() */ + + +/*************************************************************************** + * ms_time2hptime: + * + * Convert specified time values to a high precision epoch time. This + * is essentially a frontend for ms_time2hptime that does range + * checking for each input value. + * + * Expected ranges: + * year : 1800 - 5000 + * day : 1 - 366 + * hour : 0 - 23 + * min : 0 - 59 + * sec : 0 - 60 + * usec : 0 - 999999 + * + * Returns epoch time on success and HPTERROR on error. + ***************************************************************************/ +hptime_t +ms_time2hptime (int year, int day, int hour, int min, int sec, int usec) +{ + if ( year < 1800 || year > 5000 ) + { + ms_log (2, "ms_time2hptime(): Error with year value: %d\n", year); + return HPTERROR; + } + + if ( day < 1 || day > 366 ) + { + ms_log (2, "ms_time2hptime(): Error with day value: %d\n", day); + return HPTERROR; + } + + if ( hour < 0 || hour > 23 ) + { + ms_log (2, "ms_time2hptime(): Error with hour value: %d\n", hour); + return HPTERROR; + } + + if ( min < 0 || min > 59 ) + { + ms_log (2, "ms_time2hptime(): Error with minute value: %d\n", min); + return HPTERROR; + } + + if ( sec < 0 || sec > 60 ) + { + ms_log (2, "ms_time2hptime(): Error with second value: %d\n", sec); + return HPTERROR; + } + + if ( usec < 0 || usec > 999999 ) + { + ms_log (2, "ms_time2hptime(): Error with microsecond value: %d\n", usec); + return HPTERROR; + } + + return ms_time2hptime_int (year, day, hour, min, sec, usec); +} /* End of ms_time2hptime() */ + + +/*************************************************************************** + * ms_seedtimestr2hptime: + * + * Convert a SEED time string (day-of-year style) to a high precision + * epoch time. The time format expected is + * "YYYY[,DDD,HH,MM,SS.FFFFFF]", the delimiter can be a dash [-], + * comma [,], colon [:] or period [.]. Additionally a [T] or space + * may be used to seprate the day and hour fields. The fractional + * seconds ("FFFFFF") must begin with a period [.] if present. + * + * The time string can be "short" in which case the omitted values are + * assumed to be zero (with the exception of DDD which is assumed to + * be 1): "YYYY,DDD,HH" assumes MM, SS and FFFF are 0. The year is + * required, otherwise there wouldn't be much for a date. + * + * Ranges are checked for each value. + * + * Returns epoch time on success and HPTERROR on error. + ***************************************************************************/ +hptime_t +ms_seedtimestr2hptime (char *seedtimestr) +{ + int fields; + int year = 0; + int day = 1; + int hour = 0; + int min = 0; + int sec = 0; + float fusec = 0.0; + int usec = 0; + + fields = sscanf (seedtimestr, "%d%*[-,:.]%d%*[-,:.Tt ]%d%*[-,:.]%d%*[-,:.]%d%f", + &year, &day, &hour, &min, &sec, &fusec); + + /* Convert fractional seconds to microseconds */ + if ( fusec != 0.0 ) + { + usec = (int) (fusec * 1000000.0 + 0.5); + } + + if ( fields < 1 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error converting time string: %s\n", seedtimestr); + return HPTERROR; + } + + if ( year < 1800 || year > 5000 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with year value: %d\n", year); + return HPTERROR; + } + + if ( day < 1 || day > 366 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with day value: %d\n", day); + return HPTERROR; + } + + if ( hour < 0 || hour > 23 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with hour value: %d\n", hour); + return HPTERROR; + } + + if ( min < 0 || min > 59 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with minute value: %d\n", min); + return HPTERROR; + } + + if ( sec < 0 || sec > 60 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with second value: %d\n", sec); + return HPTERROR; + } + + if ( usec < 0 || usec > 999999 ) + { + ms_log (2, "ms_seedtimestr2hptime(): Error with fractional second value: %d\n", usec); + return HPTERROR; + } + + return ms_time2hptime_int (year, day, hour, min, sec, usec); +} /* End of ms_seedtimestr2hptime() */ + + +/*************************************************************************** + * ms_timestr2hptime: + * + * Convert a generic time string to a high precision epoch time. The + * time format expected is "YYYY[/MM/DD HH:MM:SS.FFFF]", the delimiter + * can be a dash [-], comma[,], slash [/], colon [:], or period [.]. + * Additionally a 'T' or space may be used between the date and time + * fields. The fractional seconds ("FFFFFF") must begin with a period + * [.] if present. + * + * The time string can be "short" in which case the omitted values are + * assumed to be zero (with the exception of month and day which are + * assumed to be 1): "YYYY/MM/DD" assumes HH, MM, SS and FFFF are 0. + * The year is required, otherwise there wouldn't be much for a date. + * + * Ranges are checked for each value. + * + * Returns epoch time on success and HPTERROR on error. + ***************************************************************************/ +hptime_t +ms_timestr2hptime (char *timestr) +{ + int fields; + int year = 0; + int mon = 1; + int mday = 1; + int day = 1; + int hour = 0; + int min = 0; + int sec = 0; + float fusec = 0.0; + int usec = 0; + + fields = sscanf (timestr, "%d%*[-,/:.]%d%*[-,/:.]%d%*[-,/:.Tt ]%d%*[-,/:.]%d%*[-,/:.]%d%f", + &year, &mon, &mday, &hour, &min, &sec, &fusec); + + /* Convert fractional seconds to microseconds */ + if ( fusec != 0.0 ) + { + usec = (int) (fusec * 1000000.0 + 0.5); + } + + if ( fields < 1 ) + { + ms_log (2, "ms_timestr2hptime(): Error converting time string: %s\n", timestr); + return HPTERROR; + } + + if ( year < 1800 || year > 5000 ) + { + ms_log (2, "ms_timestr2hptime(): Error with year value: %d\n", year); + return HPTERROR; + } + + if ( mon < 1 || mon > 12 ) + { + ms_log (2, "ms_timestr2hptime(): Error with month value: %d\n", mon); + return HPTERROR; + } + + if ( mday < 1 || mday > 31 ) + { + ms_log (2, "ms_timestr2hptime(): Error with day value: %d\n", mday); + return HPTERROR; + } + + /* Convert month and day-of-month to day-of-year */ + if ( ms_md2doy (year, mon, mday, &day) ) + { + return HPTERROR; + } + + if ( hour < 0 || hour > 23 ) + { + ms_log (2, "ms_timestr2hptime(): Error with hour value: %d\n", hour); + return HPTERROR; + } + + if ( min < 0 || min > 59 ) + { + ms_log (2, "ms_timestr2hptime(): Error with minute value: %d\n", min); + return HPTERROR; + } + + if ( sec < 0 || sec > 60 ) + { + ms_log (2, "ms_timestr2hptime(): Error with second value: %d\n", sec); + return HPTERROR; + } + + if ( usec < 0 || usec > 999999 ) + { + ms_log (2, "ms_timestr2hptime(): Error with fractional second value: %d\n", usec); + return HPTERROR; + } + + return ms_time2hptime_int (year, day, hour, min, sec, usec); +} /* End of ms_timestr2hptime() */ + + +/*************************************************************************** + * ms_nomsamprate: + * + * Calculate a sample rate from SEED sample rate factor and multiplier + * as stored in the fixed section header of data records. + * + * Returns the positive sample rate. + ***************************************************************************/ +double +ms_nomsamprate (int factor, int multiplier) +{ + double samprate = 0.0; + + if ( factor > 0 ) + samprate = (double) factor; + else if ( factor < 0 ) + samprate = -1.0 / (double) factor; + if ( multiplier > 0 ) + samprate = samprate * (double) multiplier; + else if ( multiplier < 0 ) + samprate = -1.0 * (samprate / (double) multiplier); + + return samprate; +} /* End of ms_nomsamprate() */ + + +/*************************************************************************** + * ms_genfactmult: + * + * Generate an approriate SEED sample rate factor and multiplier from + * a double precision sample rate. + * + * Returns 0 on success and -1 on error. + ***************************************************************************/ +int +ms_genfactmult (double samprate, int16_t *factor, int16_t *multiplier) +{ + int num, den; + + /* This routine does not support very high or negative sample rates, + even though high rates are possible in Mini-SEED */ + if ( samprate > 32767.0 || samprate < 0.0 ) + { + ms_log (2, "ms_genfactmult(): samprate out of range: %g\n", samprate); + return -1; + } + + /* If the sample rate is integer set the factor and multipler in the + obvious way, otherwise derive a (potentially approximate) + numerator and denominator for the given samprate */ + if ( (samprate - (int16_t) samprate) < 0.000001 ) + { + *factor = (int16_t) samprate; + if ( *factor ) + *multiplier = 1; + } + else + { + ms_ratapprox (samprate, &num, &den, 32767, 1e-12); + + /* Negate the multiplier to denote a division factor */ + *factor = (int16_t ) num; + *multiplier = (int16_t) -den; + } + + return 0; +} /* End of ms_genfactmult() */ + + +/*************************************************************************** + * ms_ratapprox: + * + * Find an approximate rational number for a real through continued + * fraction expansion. Given a double precsion 'real' find a + * numerator (num) and denominator (den) whose absolute values are not + * larger than 'maxval' while trying to reach a specified 'precision'. + * + * Returns the number of iterations performed. + ***************************************************************************/ +int +ms_ratapprox (double real, int *num, int *den, int maxval, double precision) +{ + double realj, preal; + char pos; + int pnum, pden; + int iterations = 1; + int Aj1, Aj2, Bj1, Bj2; + int bj = 0; + int Aj = 0; + int Bj = 1; + + if ( real >= 0.0 ) { pos = 1; realj = real; } + else { pos = 0; realj = -real; } + + preal = realj; + + bj = (int) (realj + precision); + realj = 1 / (realj - bj); + Aj = bj; Aj1 = 1; + Bj = 1; Bj1 = 0; + *num = pnum = Aj; + *den = pden = Bj; + if ( !pos ) *num = -*num; + + while ( ms_dabs(preal - (double)Aj/(double)Bj) > precision && + Aj < maxval && Bj < maxval ) + { + Aj2 = Aj1; Aj1 = Aj; + Bj2 = Bj1; Bj1 = Bj; + bj = (int) (realj + precision); + realj = 1 / (realj - bj); + Aj = bj * Aj1 + Aj2; + Bj = bj * Bj1 + Bj2; + *num = pnum; + *den = pden; + if ( !pos ) *num = -*num; + pnum = Aj; + pden = Bj; + + iterations++; + } + + if ( pnum < maxval && pden < maxval ) + { + *num = pnum; + *den = pden; + if ( !pos ) *num = -*num; + } + + return iterations; +} + + +/*************************************************************************** + * ms_bigendianhost: + * + * Determine the byte order of the host machine. Due to the lack of + * portable defines to determine host byte order this run-time test is + * provided. The code below actually tests for little-endianess, the + * only other alternative is assumed to be big endian. + * + * Returns 0 if the host is little endian, otherwise 1. + ***************************************************************************/ +int +ms_bigendianhost (void) +{ + int16_t host = 1; + return !(*((int8_t *)(&host))); +} /* End of ms_bigendianhost() */ + + +/*************************************************************************** + * ms_dabs: + * + * Determine the absolute value of an input double, actually just test + * if the input double is positive multiplying by -1.0 if not and + * return it. + * + * Returns the positive value of input double. + ***************************************************************************/ +double +ms_dabs (double val) +{ + if ( val < 0.0 ) + val *= -1.0; + return val; +} /* End of ms_dabs() */ + + +/*************************************************************************** + * ms_gmtime_r: + * + * An internal version of gmtime_r() that is 64-bit compliant and + * works with years beyond 2038. + * + * The original was called pivotal_gmtime_r() by Paul Sheer, all + * required copyright and other hoohas are below. Modifications were + * made to integrate the original to this code base, avoid name + * collisions and formatting so I could read it. + * + * Returns a pointer to the populated tm struct on success and NULL on error. + ***************************************************************************/ + +/* pivotal_gmtime_r - a replacement for gmtime/localtime/mktime + that works around the 2038 bug on 32-bit + systems. (Version 4) + + Copyright (C) 2009 Paul Sheer + + Redistribution and use in source form, with or without modification, + is permitted provided that the above copyright notice, this list of + conditions, the following disclaimer, and the following char array + are retained. + + Redistribution and use in binary form must reproduce an + acknowledgment: 'With software provided by http://2038bug.com/' in + the documentation and/or other materials provided with the + distribution, and wherever such acknowledgments are usually + accessible in Your program. + + This software is provided "AS IS" and WITHOUT WARRANTY, either + express or implied, including, without limitation, the warranties of + NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THIS SOFTWARE IS WITH + YOU. Under no circumstances and under no legal theory, whether in + tort (including negligence), contract, or otherwise, shall the + copyright owners be liable for any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of the use of this software including, without limitation, + damages for loss of goodwill, work stoppage, computer failure or + malfunction, or any and all other commercial damages or losses. This + limitation of liability shall not apply to liability for death or + personal injury resulting from copyright owners' negligence to the + extent applicable law prohibits such limitation. Some jurisdictions + do not allow the exclusion or limitation of incidental or + consequential damages, so this exclusion and limitation may not apply + to You. + +*/ + +const char pivotal_gmtime_r_stamp_lm[] = + "pivotal_gmtime_r. Copyright (C) 2009 Paul Sheer. Terms and " + "conditions apply. Visit http://2038bug.com/ for more info."; + +static const int tm_days[4][13] = { + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}, +}; + +#define TM_LEAP_CHECK(n) ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) + 1900) % 100))) != 0) +#define TM_WRAP(a,b,m) ((a) = ((a) < 0 ) ? ((b)--, (a) + (m)) : (a)) + +static struct tm * +ms_gmtime_r (int64_t *timep, struct tm *result) +{ + int v_tm_sec, v_tm_min, v_tm_hour, v_tm_mon, v_tm_wday, v_tm_tday; + int leap; + long m; + int64_t tv; + + if ( ! timep || ! result ) + return NULL; + + tv = *timep; + + v_tm_sec = ((int64_t) tv % (int64_t) 60); + tv /= 60; + v_tm_min = ((int64_t) tv % (int64_t) 60); + tv /= 60; + v_tm_hour = ((int64_t) tv % (int64_t) 24); + tv /= 24; + v_tm_tday = (int)tv; + + TM_WRAP (v_tm_sec, v_tm_min, 60); + TM_WRAP (v_tm_min, v_tm_hour, 60); + TM_WRAP (v_tm_hour, v_tm_tday, 24); + + if ( (v_tm_wday = (v_tm_tday + 4) % 7) < 0 ) + v_tm_wday += 7; + + m = (long) v_tm_tday; + + if ( m >= 0 ) + { + result->tm_year = 70; + leap = TM_LEAP_CHECK (result->tm_year); + + while ( m >= (long) tm_days[leap + 2][12] ) + { + m -= (long) tm_days[leap + 2][12]; + result->tm_year++; + leap = TM_LEAP_CHECK (result->tm_year); + } + + v_tm_mon = 0; + + while ( m >= (long) tm_days[leap][v_tm_mon] ) + { + m -= (long) tm_days[leap][v_tm_mon]; + v_tm_mon++; + } + } + else + { + result->tm_year = 69; + leap = TM_LEAP_CHECK (result->tm_year); + + while ( m < (long) -tm_days[leap + 2][12] ) + { + m += (long) tm_days[leap + 2][12]; + result->tm_year--; + leap = TM_LEAP_CHECK (result->tm_year); + } + + v_tm_mon = 11; + + while ( m < (long) -tm_days[leap][v_tm_mon] ) + { + m += (long) tm_days[leap][v_tm_mon]; + v_tm_mon--; + } + + m += (long) tm_days[leap][v_tm_mon]; + } + + result->tm_mday = (int) m + 1; + result->tm_yday = tm_days[leap + 2][v_tm_mon] + m; + result->tm_sec = v_tm_sec; + result->tm_min = v_tm_min; + result->tm_hour = v_tm_hour; + result->tm_mon = v_tm_mon; + result->tm_wday = v_tm_wday; + + return result; +} /* End of ms_gmtime_r() */ diff --git a/libs/3rd-party/mseed/gswap.c b/libs/3rd-party/mseed/gswap.c new file mode 100644 index 0000000..ecb6a3e --- /dev/null +++ b/libs/3rd-party/mseed/gswap.c @@ -0,0 +1,150 @@ +/*************************************************************************** + * gswap.c: + * + * Functions for generalized, in-pace byte swapping between LSBF and + * MSBF byte orders. + * + * Some standard integer types are needed, namely uint8_t and + * uint32_t, (these are normally declared by including inttypes.h or + * stdint.h). Each function expects it's input to be a void pointer + * to a quantity of the appropriate size. + * + * There are two versions of most routines, one that works on + * quantities regardless of alignment (gswapX) and one that works on + * memory aligned quantities (gswapXa). The memory aligned versions + * (gswapXa) are much faster than the other versions (gswapX), but the + * memory *must* be aligned. + * + * Written by Chad Trabant, + * IRIS Data Management Center + * + * Version: 2010.006 + ***************************************************************************/ + +#include "lmplatform.h" + +/* Swap routines that work on any (aligned or not) quantities */ + +void +ms_gswap2 ( void *data2 ) +{ + uint8_t temp; + + union + { + uint8_t c[2]; + } dat; + + memcpy( &dat, data2, 2 ); + temp = dat.c[0]; + dat.c[0] = dat.c[1]; + dat.c[1] = temp; + memcpy( data2, &dat, 2 ); +} + + +void +ms_gswap3 ( void *data3 ) +{ + uint8_t temp; + + union + { + uint8_t c[3]; + } dat; + + memcpy( &dat, data3, 3 ); + temp = dat.c[0]; + dat.c[0] = dat.c[2]; + dat.c[2] = temp; + memcpy( data3, &dat, 3 ); +} + + +void +ms_gswap4 ( void *data4 ) +{ + uint8_t temp; + + union { + uint8_t c[4]; + } dat; + + memcpy( &dat, data4, 4 ); + temp = dat.c[0]; + dat.c[0] = dat.c[3]; + dat.c[3] = temp; + temp = dat.c[1]; + dat.c[1] = dat.c[2]; + dat.c[2] = temp; + memcpy( data4, &dat, 4 ); +} + + +void +ms_gswap8 ( void *data8 ) +{ + uint8_t temp; + + union + { + uint8_t c[8]; + } dat; + + memcpy( &dat, data8, 8 ); + temp = dat.c[0]; + dat.c[0] = dat.c[7]; + dat.c[7] = temp; + + temp = dat.c[1]; + dat.c[1] = dat.c[6]; + dat.c[6] = temp; + + temp = dat.c[2]; + dat.c[2] = dat.c[5]; + dat.c[5] = temp; + + temp = dat.c[3]; + dat.c[3] = dat.c[4]; + dat.c[4] = temp; + memcpy( data8, &dat, 8 ); +} + +/* Swap routines that work on memory aligned quantities */ + +void +ms_gswap2a ( void *data2 ) +{ + uint16_t *data = data2; + + *data=(((*data>>8)&0xff) | ((*data&0xff)<<8)); +} + + +void +ms_gswap4a ( void *data4 ) +{ + uint32_t *data = data4; + + *data=(((*data>>24)&0xff) | ((*data&0xff)<<24) | + ((*data>>8)&0xff00) | ((*data&0xff00)<<8)); +} + + +void +ms_gswap8a ( void *data8 ) +{ + uint32_t *data4 = data8; + uint32_t h0, h1; + + h0 = data4[0]; + h0 = (((h0>>24)&0xff) | ((h0&0xff)<<24) | + ((h0>>8)&0xff00) | ((h0&0xff00)<<8)); + + h1 = data4[1]; + h1 = (((h1>>24)&0xff) | ((h1&0xff)<<24) | + ((h1>>8)&0xff00) | ((h1&0xff00)<<8)); + + data4[0] = h1; + data4[1] = h0; +} diff --git a/libs/3rd-party/mseed/libmseed.def b/libs/3rd-party/mseed/libmseed.def new file mode 100644 index 0000000..c2b3b95 --- /dev/null +++ b/libs/3rd-party/mseed/libmseed.def @@ -0,0 +1,106 @@ +LIBRARY libmseed.dll +EXPORTS + msr_parse + msr_parse_selection + msr_unpack + msr_pack + msr_pack_header + msr_init + msr_free + msr_free_blktchain + msr_addblockette + msr_normalize_header + msr_duplicate + msr_samprate + msr_nomsamprate + msr_starttime + msr_starttime_uc + msr_endtime + msr_srcname + msr_print + msr_host_latency + ms_detect + ms_parse_raw + mst_init + mst_free + mst_initgroup + mst_freegroup + mst_findmatch + mst_findadjacent + mst_addmsr + mst_addspan + mst_addmsrtogroup + mst_addtracetogroup + mst_groupheal + mst_groupsort + mst_srcname + mst_printtracelist + mst_printsynclist + mst_printgaplist + mst_pack + mst_packgroup + mstl_init + mstl_free + mstl_addmsr + mstl_printtracelist + mstl_printsynclist + mstl_printgaplist + ms_readmsr + ms_readmsr_r + ms_readmsr_main + ms_readtraces + ms_readtraces_timewin + ms_readtraces_selection + ms_readtracelist + ms_readtracelist_timewin + ms_readtracelist_selection + msr_writemseed + mst_writemseed + mst_writemseedgroup + ms_recsrcname + ms_splitsrcname + ms_strncpclean + ms_strncpopen + ms_doy2md + ms_md2doy + ms_btime2hptime + ms_btime2isotimestr + ms_btime2mdtimestr + ms_btime2seedtimestr + ms_hptime2btime + ms_hptime2isotimestr + ms_hptime2mdtimestr + ms_hptime2seedtimestr + ms_time2hptime + ms_seedtimestr2hptime + ms_timestr2hptime + ms_nomsamprate + ms_genfactmult + ms_ratapprox + ms_bigendianhost + ms_dabs + ms_samplesize + ms_encodingstr + ms_blktdesc + ms_blktlen + ms_errorstr + ms_log + ms_log_l + ms_loginit + ms_loginit_l + ms_matchselect + msr_matchselect + ms_addselect + ms_addselect_comp + ms_readselectionsfile + ms_freeselections + ms_printselections + ms_gswap2 + ms_gswap3 + ms_gswap4 + ms_gswap8 + ms_gswap2a + ms_gswap4a + ms_gswap8a + msr_unpack_steim2 + msr_unpack_steim1 diff --git a/libs/3rd-party/mseed/libmseed.h b/libs/3rd-party/mseed/libmseed.h new file mode 100644 index 0000000..00ec569 --- /dev/null +++ b/libs/3rd-party/mseed/libmseed.h @@ -0,0 +1,735 @@ + +/*************************************************************************** + * libmseed.h: + * + * Interface declarations for the Mini-SEED library (libmseed). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License (GNU-LGPL) for more details. The + * GNU-LGPL and further information can be found here: + * http://www.gnu.org/ + * + * Written by Chad Trabant + * IRIS Data Management Center + ***************************************************************************/ + + +#ifndef LIBMSEED_H +#define LIBMSEED_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lmplatform.h" + +#define LIBMSEED_VERSION "2.13" +#define LIBMSEED_RELEASE "2014.234" + +#define MINRECLEN 128 /* Minimum Mini-SEED record length, 2^7 bytes */ + /* Note: the SEED specification minimum is 256 */ +#define MAXRECLEN 1048576 /* Maximum Mini-SEED record length, 2^20 bytes */ + +/* SEED data encoding types */ +#define DE_ASCII 0 +#define DE_INT16 1 +#define DE_INT32 3 +#define DE_FLOAT32 4 +#define DE_FLOAT64 5 +#define DE_STEIM1 10 +#define DE_STEIM2 11 +#define DE_GEOSCOPE24 12 +#define DE_GEOSCOPE163 13 +#define DE_GEOSCOPE164 14 +#define DE_CDSN 16 +#define DE_SRO 30 +#define DE_DWWSSN 32 + +/* Library return and error code values, error values should always be negative */ +#define MS_ENDOFFILE 1 /* End of file reached return value */ +#define MS_NOERROR 0 /* No error */ +#define MS_GENERROR -1 /* Generic unspecified error */ +#define MS_NOTSEED -2 /* Data not SEED */ +#define MS_WRONGLENGTH -3 /* Length of data read was not correct */ +#define MS_OUTOFRANGE -4 /* SEED record length out of range */ +#define MS_UNKNOWNFORMAT -5 /* Unknown data encoding format */ +#define MS_STBADCOMPFLAG -6 /* Steim, invalid compression flag(s) */ + +/* Define the high precision time tick interval as 1/modulus seconds */ +/* Default modulus of 1000000 defines tick interval as a microsecond */ +#define HPTMODULUS 1000000 + +/* Error code for routines that normally return a high precision time. + * The time value corresponds to '1902/1/1 00:00:00.000000' with the + * default HPTMODULUS */ +#define HPTERROR -2145916800000000LL + +/* Macros to scale between Unix/POSIX epoch time & high precision time */ +#define MS_EPOCH2HPTIME(X) X * (hptime_t) HPTMODULUS +#define MS_HPTIME2EPOCH(X) X / HPTMODULUS + +/* Macro to test a character for data record indicators */ +#define MS_ISDATAINDICATOR(X) (X=='D' || X=='R' || X=='Q' || X=='M') + +/* Macro to test default sample rate tolerance: abs(1-sr1/sr2) < 0.0001 */ +#define MS_ISRATETOLERABLE(A,B) (ms_dabs (1.0 - (A / B)) < 0.0001) + +/* 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 + * + * This test is non-unique (non-deterministic) for days 1, 256 and 257 + * in the year 2056 because the swapped values are also within range. + */ +#define MS_ISVALIDYEARDAY(Y,D) (Y >= 1900 && Y <= 2100 && D >= 1 && D <= 366) + +/* 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 + * 7 = Space or NULL [not valid SEED] + * 24 = Start hour (0-23) + * 25 = Start minute (0-59) + * 26 = Start second (0-60) + * + * Usage: + * MS_ISVALIDHEADER ((char *)X) X buffer must contain at least 27 bytes + */ +#define MS_ISVALIDHEADER(X) ( \ + (isdigit ((unsigned char) *(X)) || *(X) == ' ' || !*(X) ) && \ + (isdigit ((unsigned char) *(X+1)) || *(X+1) == ' ' || !*(X+1) ) && \ + (isdigit ((unsigned char) *(X+2)) || *(X+2) == ' ' || !*(X+2) ) && \ + (isdigit ((unsigned char) *(X+3)) || *(X+3) == ' ' || !*(X+3) ) && \ + (isdigit ((unsigned char) *(X+4)) || *(X+4) == ' ' || !*(X+4) ) && \ + (isdigit ((unsigned char) *(X+5)) || *(X+5) == ' ' || !*(X+5) ) && \ + MS_ISDATAINDICATOR(*(X+6)) && \ + (*(X+7) == ' ' || *(X+7) == '\0') && \ + (int)(*(X+24)) >= 0 && (int)(*(X+24)) <= 23 && \ + (int)(*(X+25)) >= 0 && (int)(*(X+25)) <= 59 && \ + (int)(*(X+26)) >= 0 && (int)(*(X+26)) <= 60) + +/* 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 + * + * Usage: + * MS_ISVALIDBLANK ((char *)X) X buffer must contain at least 27 bytes + */ +#define MS_ISVALIDBLANK(X) ((isdigit ((unsigned char) *(X)) || !*(X) ) && \ + (isdigit ((unsigned char) *(X+1)) || !*(X+1) ) && \ + (isdigit ((unsigned char) *(X+2)) || !*(X+2) ) && \ + (isdigit ((unsigned char) *(X+3)) || !*(X+3) ) && \ + (isdigit ((unsigned char) *(X+4)) || !*(X+4) ) && \ + (isdigit ((unsigned char) *(X+5)) || !*(X+5) ) && \ + (*(X+6)==' ')&&(*(X+7)==' ')&&(*(X+8)==' ') && \ + (*(X+9)==' ')&&(*(X+10)==' ')&&(*(X+11)==' ') && \ + (*(X+12)==' ')&&(*(X+13)==' ')&&(*(X+14)==' ') && \ + (*(X+15)==' ')&&(*(X+16)==' ')&&(*(X+17)==' ') && \ + (*(X+18)==' ')&&(*(X+19)==' ')&&(*(X+20)==' ') && \ + (*(X+21)==' ')&&(*(X+22)==' ')&&(*(X+23)==' ') && \ + (*(X+24)==' ')&&(*(X+25)==' ')&&(*(X+26)==' ') && \ + (*(X+27)==' ')&&(*(X+28)==' ')&&(*(X+29)==' ') && \ + (*(X+30)==' ')&&(*(X+31)==' ')&&(*(X+32)==' ') && \ + (*(X+33)==' ')&&(*(X+34)==' ')&&(*(X+35)==' ') && \ + (*(X+36)==' ')&&(*(X+37)==' ')&&(*(X+38)==' ') && \ + (*(X+39)==' ')&&(*(X+40)==' ')&&(*(X+41)==' ') && \ + (*(X+42)==' ')&&(*(X+43)==' ')&&(*(X+44)==' ') && \ + (*(X+45)==' ')&&(*(X+46)==' ')&&(*(X+47)==' ') ) + +/* A simple bitwise AND test to return 0 or 1 */ +#define bit(x,y) (x&y)?1:0 + +/* Require a large (>= 64-bit) integer type for hptime_t */ +typedef int64_t hptime_t; + +/* A single byte flag type */ +typedef int8_t flag; + +/* SEED binary time */ +typedef struct btime_s +{ + uint16_t year; + uint16_t day; + uint8_t hour; + uint8_t min; + uint8_t sec; + uint8_t unused; + uint16_t fract; +} LMP_PACKED +BTime; + +/* Fixed section data of header */ +struct fsdh_s +{ + char sequence_number[6]; + char dataquality; + char reserved; + char station[5]; + char location[2]; + char channel[3]; + char network[2]; + BTime start_time; + uint16_t numsamples; + int16_t samprate_fact; + int16_t samprate_mult; + uint8_t act_flags; + uint8_t io_flags; + uint8_t dq_flags; + uint8_t numblockettes; + int32_t time_correct; + uint16_t data_offset; + uint16_t blockette_offset; +} LMP_PACKED; + +/* Blockette 100, Sample Rate (without header) */ +struct blkt_100_s +{ + float samprate; + int8_t flags; + uint8_t reserved[3]; +} LMP_PACKED; + +/* Blockette 200, Generic Event Detection (without header) */ +struct blkt_200_s +{ + float amplitude; + float period; + float background_estimate; + uint8_t flags; + uint8_t reserved; + BTime time; + char detector[24]; +} LMP_PACKED; + +/* Blockette 201, Murdock Event Detection (without header) */ +struct blkt_201_s +{ + float amplitude; + float period; + float background_estimate; + uint8_t flags; + uint8_t reserved; + BTime time; + uint8_t snr_values[6]; + uint8_t loopback; + uint8_t pick_algorithm; + char detector[24]; +} LMP_PACKED; + +/* Blockette 300, Step Calibration (without header) */ +struct blkt_300_s +{ + BTime time; + uint8_t numcalibrations; + uint8_t flags; + uint32_t step_duration; + uint32_t interval_duration; + float amplitude; + char input_channel[3]; + uint8_t reserved; + uint32_t reference_amplitude; + char coupling[12]; + char rolloff[12]; +} LMP_PACKED; + +/* Blockette 310, Sine Calibration (without header) */ +struct blkt_310_s +{ + BTime time; + uint8_t reserved1; + uint8_t flags; + uint32_t duration; + float period; + float amplitude; + char input_channel[3]; + uint8_t reserved2; + uint32_t reference_amplitude; + char coupling[12]; + char rolloff[12]; +} LMP_PACKED; + +/* Blockette 320, Pseudo-random Calibration (without header) */ +struct blkt_320_s +{ + BTime time; + uint8_t reserved1; + uint8_t flags; + uint32_t duration; + float ptp_amplitude; + char input_channel[3]; + uint8_t reserved2; + uint32_t reference_amplitude; + char coupling[12]; + char rolloff[12]; + char noise_type[8]; +} LMP_PACKED; + +/* Blockette 390, Generic Calibration (without header) */ +struct blkt_390_s +{ + BTime time; + uint8_t reserved1; + uint8_t flags; + uint32_t duration; + float amplitude; + char input_channel[3]; + uint8_t reserved2; +} LMP_PACKED; + +/* Blockette 395, Calibration Abort (without header) */ +struct blkt_395_s +{ + BTime time; + uint8_t reserved[2]; +} LMP_PACKED; + +/* Blockette 400, Beam (without header) */ +struct blkt_400_s +{ + float azimuth; + float slowness; + uint16_t configuration; + uint8_t reserved[2]; +} LMP_PACKED; + +/* Blockette 405, Beam Delay (without header) */ +struct blkt_405_s +{ + uint16_t delay_values[1]; +}; + +/* Blockette 500, Timing (without header) */ +struct blkt_500_s +{ + float vco_correction; + BTime time; + int8_t usec; + uint8_t reception_qual; + uint32_t exception_count; + char exception_type[16]; + char clock_model[32]; + char clock_status[128]; +} LMP_PACKED; + +/* Blockette 1000, Data Only SEED (without header) */ +struct blkt_1000_s +{ + uint8_t encoding; + uint8_t byteorder; + uint8_t reclen; + uint8_t reserved; +} LMP_PACKED; + +/* Blockette 1001, Data Extension (without header) */ +struct blkt_1001_s +{ + uint8_t timing_qual; + int8_t usec; + uint8_t reserved; + uint8_t framecnt; +} LMP_PACKED; + +/* Blockette 2000, Opaque Data (without header) */ +struct blkt_2000_s +{ + uint16_t length; + uint16_t data_offset; + uint32_t recnum; + uint8_t byteorder; + uint8_t flags; + uint8_t numheaders; + char payload[1]; +} LMP_PACKED; + +/* Blockette chain link, generic linkable blockette index */ +typedef struct blkt_link_s +{ + uint16_t blktoffset; /* Offset to this blockette */ + uint16_t blkt_type; /* Blockette type */ + uint16_t next_blkt; /* Offset to next blockette */ + void *blktdata; /* Blockette data */ + uint16_t blktdatalen; /* Length of blockette data in bytes */ + struct blkt_link_s *next; +} +BlktLink; + +typedef struct StreamState_s +{ + int64_t packedrecords; /* Count of packed records */ + int64_t packedsamples; /* Count of packed samples */ + int32_t lastintsample; /* Value of last integer sample packed */ + flag comphistory; /* Control use of lastintsample for compression history */ +} +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 */ + 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 */ + hptime_t starttime; /* Record start time, corrected (first sample) */ + double samprate; /* Nominal sample rate (Hz) */ + 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 */ +} +MSRecord; + +/* Container for a continuous trace, linkable */ +typedef struct MSTrace_s { + char network[11]; /* Network designation, NULL terminated */ + 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 type; /* MSTrace type code */ + hptime_t starttime; /* Time of first sample */ + hptime_t endtime; /* Time of last sample */ + double samprate; /* Nominal sample rate (Hz) */ + int64_t samplecnt; /* Number of samples in trace coverage */ + 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 */ + void *prvtptr; /* Private pointer for general use, unused by libmseed */ + StreamState *ststate; /* Stream processing state information */ + struct MSTrace_s *next; /* Pointer to next trace */ +} +MSTrace; + +/* Container for a group (chain) of traces */ +typedef struct MSTraceGroup_s { + int32_t numtraces; /* Number of MSTraces in the trace chain */ + struct MSTrace_s *traces; /* Root of the trace chain */ +} +MSTraceGroup; + +/* Container for a continuous trace segment, linkable */ +typedef struct MSTraceSeg_s { + hptime_t starttime; /* Time of first sample */ + hptime_t endtime; /* Time of last sample */ + double samprate; /* Nominal sample rate (Hz) */ + int64_t samplecnt; /* Number of samples in trace coverage */ + 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 */ + void *prvtptr; /* Private pointer for general use, unused by libmseed */ + struct MSTraceSeg_s *prev; /* Pointer to previous segment */ + struct MSTraceSeg_s *next; /* Pointer to next segment */ +} +MSTraceSeg; + +/* Container for a trace ID, linkable */ +typedef struct MSTraceID_s { + char network[11]; /* Network designation, NULL terminated */ + 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 srcname[45]; /* Source name (Net_Sta_Loc_Chan_Qual), NULL terminated */ + char type; /* Trace type code */ + hptime_t earliest; /* Time of earliest sample */ + hptime_t latest; /* Time of latest sample */ + void *prvtptr; /* Private pointer for general use, unused by libmseed */ + int32_t numsegments; /* Number of segments for this ID */ + struct MSTraceSeg_s *first; /* Pointer to first of list of segments */ + struct MSTraceSeg_s *last; /* Pointer to last of list of segments */ + struct MSTraceID_s *next; /* Pointer to next trace */ +} +MSTraceID; + +/* Container for a continuous trace segment, linkable */ +typedef struct MSTraceList_s { + int32_t numtraces; /* Number of traces in list */ + struct MSTraceID_s *traces; /* Pointer to list of traces */ + struct MSTraceID_s *last; /* Pointer to last used trace in list */ +} +MSTraceList; + +/* Data selection structure time window definition containers */ +typedef struct SelectTime_s { + hptime_t starttime; /* Earliest data for matching channels */ + hptime_t endtime; /* Latest data for matching channels */ + struct SelectTime_s *next; +} SelectTime; + +/* Data selection structure definition containers */ +typedef struct Selections_s { + char srcname[100]; /* Matching (globbing) source name: Net_Sta_Loc_Chan_Qual */ + struct SelectTime_s *timewindows; + struct Selections_s *next; +} Selections; + + +/* Global variables (defined in pack.c) and macros to set/force + * pack byte orders */ +extern flag packheaderbyteorder; +extern flag packdatabyteorder; +#define MS_PACKHEADERBYTEORDER(X) (packheaderbyteorder = X); +#define MS_PACKDATABYTEORDER(X) (packdatabyteorder = X); + +/* Global variables (defined in unpack.c) and macros to set/force + * unpack byte orders */ +extern flag unpackheaderbyteorder; +extern flag unpackdatabyteorder; +#define MS_UNPACKHEADERBYTEORDER(X) (unpackheaderbyteorder = X); +#define MS_UNPACKDATABYTEORDER(X) (unpackdatabyteorder = X); + +/* Global variables (defined in unpack.c) and macros to set/force + * encoding and fallback encoding */ +extern int unpackencodingformat; +extern int unpackencodingfallback; +#define MS_UNPACKENCODINGFORMAT(X) (unpackencodingformat = X); +#define MS_UNPACKENCODINGFALLBACK(X) (unpackencodingfallback = X); + +/* Mini-SEED record related functions */ +extern int msr_parse (char *record, int recbuflen, MSRecord **ppmsr, int reclen, + flag dataflag, flag verbose); + +extern int msr_parse_selection ( char *recbuf, int recbuflen, int64_t *offset, + MSRecord **ppmsr, int reclen, + Selections *selections, flag dataflag, flag verbose ); + +extern int msr_unpack (char *record, int reclen, MSRecord **ppmsr, + flag dataflag, flag verbose); + +extern int msr_pack (MSRecord *msr, void (*record_handler) (char *, int, void *), + void *handlerdata, int64_t *packedsamples, flag flush, flag verbose ); + +extern int msr_pack_header (MSRecord *msr, flag normalize, flag verbose); + +extern int msr_unpack_data (MSRecord *msr, int swapflag, flag verbose); + +extern MSRecord* msr_init (MSRecord *msr); +extern void msr_free (MSRecord **ppmsr); +extern void msr_free_blktchain (MSRecord *msr); +extern BlktLink* msr_addblockette (MSRecord *msr, char *blktdata, int length, + int blkttype, int chainpos); +extern int msr_normalize_header (MSRecord *msr, flag verbose); +extern MSRecord* msr_duplicate (MSRecord *msr, flag datadup); +extern double msr_samprate (MSRecord *msr); +extern double msr_nomsamprate (MSRecord *msr); +extern hptime_t msr_starttime (MSRecord *msr); +extern hptime_t msr_starttime_uc (MSRecord *msr); +extern hptime_t msr_endtime (MSRecord *msr); +extern char* msr_srcname (MSRecord *msr, char *srcname, flag quality); +extern void msr_print (MSRecord *msr, flag details); +extern double msr_host_latency (MSRecord *msr); + +extern int ms_detect (const char *record, int recbuflen); +extern int ms_parse_raw (char *record, int maxreclen, flag details, flag swapflag); + + +/* MSTrace related functions */ +extern MSTrace* mst_init (MSTrace *mst); +extern void mst_free (MSTrace **ppmst); +extern MSTraceGroup* mst_initgroup (MSTraceGroup *mstg); +extern void mst_freegroup (MSTraceGroup **ppmstg); +extern MSTrace* mst_findmatch (MSTrace *startmst, char dataquality, + char *network, char *station, char *location, char *channel); +extern MSTrace* mst_findadjacent (MSTraceGroup *mstg, flag *whence, char dataquality, + char *network, char *station, char *location, char *channel, + double samprate, double sampratetol, + hptime_t starttime, hptime_t endtime, double timetol); +extern int mst_addmsr (MSTrace *mst, MSRecord *msr, flag whence); +extern int mst_addspan (MSTrace *mst, hptime_t starttime, hptime_t endtime, + void *datasamples, int64_t numsamples, + char sampletype, flag whence); +extern MSTrace* mst_addmsrtogroup (MSTraceGroup *mstg, MSRecord *msr, flag dataquality, + double timetol, double sampratetol); +extern MSTrace* mst_addtracetogroup (MSTraceGroup *mstg, MSTrace *mst); +extern int mst_groupheal (MSTraceGroup *mstg, double timetol, double sampratetol); +extern int mst_groupsort (MSTraceGroup *mstg, flag quality); +extern int mst_convertsamples (MSTrace *mst, char type, flag truncate); +extern char * mst_srcname (MSTrace *mst, char *srcname, flag quality); +extern void mst_printtracelist (MSTraceGroup *mstg, flag timeformat, + flag details, flag gaps); +extern void mst_printsynclist ( MSTraceGroup *mstg, char *dccid, flag subsecond ); +extern void mst_printgaplist (MSTraceGroup *mstg, flag timeformat, + double *mingap, double *maxgap); +extern int mst_pack (MSTrace *mst, void (*record_handler) (char *, int, void *), + void *handlerdata, int reclen, flag encoding, flag byteorder, + int64_t *packedsamples, flag flush, flag verbose, + MSRecord *mstemplate); +extern int mst_packgroup (MSTraceGroup *mstg, void (*record_handler) (char *, int, void *), + void *handlerdata, int reclen, flag encoding, flag byteorder, + int64_t *packedsamples, flag flush, flag verbose, + MSRecord *mstemplate); + +/* MSTraceList related functions */ +extern MSTraceList * mstl_init ( MSTraceList *mstl ); +extern void mstl_free ( MSTraceList **ppmstl, flag freeprvtptr ); +extern MSTraceSeg * mstl_addmsr ( MSTraceList *mstl, MSRecord *msr, flag dataquality, + flag autoheal, double timetol, double sampratetol ); +extern int mstl_convertsamples ( MSTraceSeg *seg, char type, flag truncate ); +extern void mstl_printtracelist ( MSTraceList *mstl, flag timeformat, + flag details, flag gaps ); +extern void mstl_printsynclist ( MSTraceList *mstl, char *dccid, flag subsecond ); +extern void mstl_printgaplist (MSTraceList *mstl, flag timeformat, + double *mingap, double *maxgap); + +/* Reading Mini-SEED records from files */ +typedef struct MSFileParam_s +{ + FILE *fp; + char filename[512]; + char *rawrec; + int readlen; + int readoffset; + int packtype; + off_t packhdroffset; + off_t filepos; + off_t filesize; + int recordcount; +} MSFileParam; + +extern int ms_readmsr (MSRecord **ppmsr, const char *msfile, int reclen, off_t *fpos, int *last, + flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readmsr_r (MSFileParam **ppmsfp, MSRecord **ppmsr, const char *msfile, int reclen, + off_t *fpos, int *last, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readmsr_main (MSFileParam **ppmsfp, MSRecord **ppmsr, const char *msfile, int reclen, + off_t *fpos, int *last, flag skipnotdata, flag dataflag, Selections *selections, flag verbose); +extern int ms_readtraces (MSTraceGroup **ppmstg, const char *msfile, int reclen, double timetol, double sampratetol, + flag dataquality, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readtraces_timewin (MSTraceGroup **ppmstg, const char *msfile, int reclen, double timetol, double sampratetol, + hptime_t starttime, hptime_t endtime, flag dataquality, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readtraces_selection (MSTraceGroup **ppmstg, const char *msfile, int reclen, double timetol, double sampratetol, + Selections *selections, flag dataquality, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readtracelist (MSTraceList **ppmstl, const char *msfile, int reclen, double timetol, double sampratetol, + flag dataquality, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readtracelist_timewin (MSTraceList **ppmstl, const char *msfile, int reclen, double timetol, double sampratetol, + hptime_t starttime, hptime_t endtime, flag dataquality, flag skipnotdata, flag dataflag, flag verbose); +extern int ms_readtracelist_selection (MSTraceList **ppmstl, const char *msfile, int reclen, double timetol, double sampratetol, + Selections *selections, flag dataquality, flag skipnotdata, flag dataflag, flag verbose); + +extern int msr_writemseed ( MSRecord *msr, const char *msfile, flag overwrite, int reclen, + flag encoding, flag byteorder, flag verbose ); +extern int mst_writemseed ( MSTrace *mst, const char *msfile, flag overwrite, int reclen, + flag encoding, flag byteorder, flag verbose ); +extern int mst_writemseedgroup ( MSTraceGroup *mstg, const char *msfile, flag overwrite, + int reclen, flag encoding, flag byteorder, flag verbose ); + +/* General use functions */ +extern char* ms_recsrcname (char *record, char *srcname, flag quality); +extern int ms_splitsrcname (char *srcname, char *net, char *sta, char *loc, char *chan, char *qual); +extern int ms_strncpclean (char *dest, const char *source, int length); +extern int ms_strncpcleantail (char *dest, const char *source, int length); +extern int ms_strncpopen (char *dest, const char *source, int length); +extern int ms_doy2md (int year, int jday, int *month, int *mday); +extern int ms_md2doy (int year, int month, int mday, int *jday); +extern hptime_t ms_btime2hptime (BTime *btime); +extern char* ms_btime2isotimestr (BTime *btime, char *isotimestr); +extern char* ms_btime2mdtimestr (BTime *btime, char *mdtimestr); +extern char* ms_btime2seedtimestr (BTime *btime, char *seedtimestr); +extern int ms_hptime2btime (hptime_t hptime, BTime *btime); +extern char* ms_hptime2isotimestr (hptime_t hptime, char *isotimestr, flag subsecond); +extern char* ms_hptime2mdtimestr (hptime_t hptime, char *mdtimestr, flag subsecond); +extern char* ms_hptime2seedtimestr (hptime_t hptime, char *seedtimestr, flag subsecond); +extern hptime_t ms_time2hptime (int year, int day, int hour, int min, int sec, int usec); +extern hptime_t ms_seedtimestr2hptime (char *seedtimestr); +extern hptime_t ms_timestr2hptime (char *timestr); +extern double ms_nomsamprate (int factor, int multiplier); +extern int ms_genfactmult (double samprate, int16_t *factor, int16_t *multiplier); +extern int ms_ratapprox (double real, int *num, int *den, int maxval, double precision); +extern int ms_bigendianhost (void); +extern double ms_dabs (double val); + + +/* Lookup functions */ +extern uint8_t ms_samplesize (const char sampletype); +extern char* ms_encodingstr (const char encoding); +extern char* ms_blktdesc (uint16_t blkttype); +extern uint16_t ms_blktlen (uint16_t blkttype, const char *blktdata, flag swapflag); +extern char * ms_errorstr (int errorcode); + +/* Logging facility */ +#define MAX_LOG_MSG_LENGTH 200 /* Maximum length of log messages */ + +/* Logging parameters */ +typedef struct MSLogParam_s +{ + void (*log_print)(char*); + const char *logprefix; + void (*diag_print)(char*); + const char *errprefix; +} MSLogParam; + +extern int ms_log (int level, ...); +extern int ms_log_l (MSLogParam *logp, int level, ...); +extern void ms_loginit (void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix); +extern MSLogParam *ms_loginit_l (MSLogParam *logp, + void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix); + +/* Selection functions */ +extern Selections *ms_matchselect (Selections *selections, char *srcname, + hptime_t starttime, hptime_t endtime, SelectTime **ppselecttime); +extern Selections *msr_matchselect (Selections *selections, MSRecord *msr, SelectTime **ppselecttime); +extern int ms_addselect (Selections **ppselections, char *srcname, + hptime_t starttime, hptime_t endtime); +extern int ms_addselect_comp (Selections **ppselections, char *net, char* sta, char *loc, + char *chan, char *qual, hptime_t starttime, hptime_t endtime); +extern int ms_readselectionsfile (Selections **ppselections, char *filename); +extern void ms_freeselections (Selections *selections); +extern void ms_printselections (Selections *selections); + +/* Generic byte swapping routines */ +extern void ms_gswap2 ( void *data2 ); +extern void ms_gswap3 ( void *data3 ); +extern void ms_gswap4 ( void *data4 ); +extern void ms_gswap8 ( void *data8 ); + +/* Generic byte swapping routines for memory aligned quantities */ +extern void ms_gswap2a ( void *data2 ); +extern void ms_gswap4a ( void *data4 ); +extern void ms_gswap8a ( void *data8 ); + +/* Byte swap macro for the BTime struct */ +#define MS_SWAPBTIME(x) \ + ms_gswap2 (x.year); \ + ms_gswap2 (x.day); \ + ms_gswap2 (x.fract); + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBMSEED_H */ diff --git a/libs/3rd-party/mseed/lmplatform.c b/libs/3rd-party/mseed/lmplatform.c new file mode 100644 index 0000000..72a7fd9 --- /dev/null +++ b/libs/3rd-party/mseed/lmplatform.c @@ -0,0 +1,65 @@ +/*************************************************************************** + * lmplatform.c: + * + * Platform portability routines. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License (GNU-LGPL) for more details. The + * GNU-LGPL and further information can be found here: + * http://www.gnu.org/ + * + * Written by Chad Trabant, IRIS Data Management Center + * + * modified: 2010.304 + ***************************************************************************/ + +/* Define _LARGEFILE_SOURCE to get ftello/fseeko on some systems (Linux) */ +#define _LARGEFILE_SOURCE 1 + +#include "lmplatform.h" + + +/*************************************************************************** + * lmp_ftello: + * + * Return the current file position for the specified descriptor using + * the system's closest match to the POSIX ftello. + ***************************************************************************/ +off_t +lmp_ftello (FILE *stream) +{ +#if defined(LMP_WIN32) + return (off_t) ftell (stream); + +#else + return (off_t) ftello (stream); + +#endif +} /* End of lmp_ftello() */ + + +/*************************************************************************** + * lmp_fseeko: + * + * Seek to a specific file position for the specified descriptor using + * the system's closest match to the POSIX fseeko. + ***************************************************************************/ +int +lmp_fseeko (FILE *stream, off_t offset, int whence) +{ +#if defined(LMP_WIN32) + return (int) fseek (stream, (long int) offset, whence); + +#else + return (int) fseeko (stream, offset, whence); + +#endif +} /* End of lmp_fseeko() */ + diff --git a/libs/3rd-party/mseed/lmplatform.h b/libs/3rd-party/mseed/lmplatform.h new file mode 100644 index 0000000..fb4d5bc --- /dev/null +++ b/libs/3rd-party/mseed/lmplatform.h @@ -0,0 +1,166 @@ +/*************************************************************************** + * lmplatform.h: + * + * Platform specific headers. This file provides a basic level of platform + * portability. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License (GNU-LGPL) for more details. The + * GNU-LGPL and further information can be found here: + * http://www.gnu.org/ + * + * Written by Chad Trabant, IRIS Data Management Center + * + * modified: 2014.074 + ***************************************************************************/ + +#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 + + /* Make some guesses about the system libraries based + * on the architecture. Currently the assumptions are: + * Linux => glibc2 libraries (LMP_GLIBC2) + * Sun => Solaris libraties (LMP_SOLARIS) + * BSD => BSD libraries, including Apple Mac OS X (LMP_BSD) + * WIN32 => WIN32 and Windows Sockets 2 (LMP_WIN32) + */ + +#if defined(__linux__) || defined(__linux) || defined(__CYGWIN__) + #define LMP_GLIBC2 1 + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + +#elif defined(__sun__) || defined(__sun) + #define LMP_SOLARIS 1 + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + +#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) + #define LMP_BSD 1 + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + +#elif defined(WIN32) || defined(WIN64) + #define LMP_WIN32 1 + + #include + #include + #include + #include + #include + #include + + #if defined(_MSC_VER) + #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__) + #define fstat _fstat + #define stat _stat + #endif + + 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 + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + 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 long long int64_t; + typedef unsigned long long uint64_t; + +#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/libs/3rd-party/mseed/logging.c b/libs/3rd-party/mseed/logging.c new file mode 100644 index 0000000..cfa14fa --- /dev/null +++ b/libs/3rd-party/mseed/logging.c @@ -0,0 +1,334 @@ +/*************************************************************************** + * logging.c + * + * Log handling routines for libmseed + * + * Chad Trabant + * IRIS Data Management Center + * + * modified: 2014.197 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "libmseed.h" + +void ms_loginit_main (MSLogParam *logp, + void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix); + +int ms_log_main (MSLogParam *logp, int level, va_list *varlist); + +/* Initialize the global logging parameters */ +MSLogParam gMSLogParam = {NULL, NULL, NULL, NULL}; + + +/*************************************************************************** + * ms_loginit: + * + * Initialize the global logging parameters. + * + * See ms_loginit_main() description for usage. + ***************************************************************************/ +void +ms_loginit (void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix) +{ + ms_loginit_main(&gMSLogParam, log_print, logprefix, diag_print, errprefix); +} /* End of ms_loginit() */ + + +/*************************************************************************** + * ms_loginit_l: + * + * Initialize MSLogParam specific logging parameters. If the logging parameters + * have not been initialized (log == NULL) new parameter space will + * be allocated. + * + * See ms_loginit_main() description for usage. + * + * Returns a pointer to the created/re-initialized MSLogParam struct + * on success and NULL on error. + ***************************************************************************/ +MSLogParam * +ms_loginit_l (MSLogParam *logp, + void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix) +{ + MSLogParam *llog; + + if ( logp == NULL ) + { + llog = (MSLogParam *) malloc (sizeof(MSLogParam)); + + if ( llog == NULL ) + { + ms_log (2, "ms_loginit_l(): Cannot allocate memory\n"); + return NULL; + } + + llog->log_print = NULL; + llog->logprefix = NULL; + llog->diag_print = NULL; + llog->errprefix = NULL; + } + else + { + llog = logp; + } + + ms_loginit_main (llog, log_print, logprefix, diag_print, errprefix); + + return llog; +} /* End of ms_loginit_l() */ + + +/*************************************************************************** + * ms_loginit_main: + * + * Initialize the logging subsystem. Given values determine how ms_log() + * and ms_log_l() emit messages. + * + * This function modifies the logging parameters in the passed MSLogParam. + * + * Any log/error printing functions indicated must except a single + * argument, namely a string (char *). The ms_log() and + * ms_log_r() functions format each message and then pass the result + * on to the log/error printing functions. + * + * If the log/error prefixes have been set they will be pre-pended to the + * message. + * + * Use NULL for the function pointers or the prefixes if they should not + * be changed from previously set or default values. The default behavior + * of the logging subsystem is given in the example below. + * + * Example: ms_loginit_main (0, (void*)&printf, NULL, (void*)&printf, "error: "); + ***************************************************************************/ +void +ms_loginit_main (MSLogParam *logp, + void (*log_print)(char*), const char *logprefix, + void (*diag_print)(char*), const char *errprefix) +{ + if ( ! logp ) + return; + + if ( log_print ) + logp->log_print = log_print; + + if ( logprefix ) + { + if ( strlen(logprefix) >= MAX_LOG_MSG_LENGTH ) + { + ms_log_l (logp, 2, 0, "log message prefix is too large\n"); + } + else + { + logp->logprefix = logprefix; + } + } + + if ( diag_print ) + logp->diag_print = diag_print; + + if ( errprefix ) + { + if ( strlen(errprefix) >= MAX_LOG_MSG_LENGTH ) + { + ms_log_l (logp, 2, 0, "error message prefix is too large\n"); + } + else + { + logp->errprefix = errprefix; + } + } + + return; +} /* End of ms_loginit_main() */ + + +/*************************************************************************** + * ms_log: + * + * A wrapper to ms_log_main() that uses the global logging parameters. + * + * See ms_log_main() description for return values. + ***************************************************************************/ +int +ms_log (int level, ...) +{ + int retval; + va_list varlist; + + va_start (varlist, level); + + retval = ms_log_main (&gMSLogParam, level, &varlist); + + va_end (varlist); + + return retval; +} /* End of ms_log() */ + + +/*************************************************************************** + * ms_log_l: + * + * A wrapper to ms_log_main() that uses the logging parameters in a + * supplied MSLogParam. If the supplied pointer is NULL the global logging + * parameters will be used. + * + * See ms_log_main() description for return values. + ***************************************************************************/ +int +ms_log_l (MSLogParam *logp, int level, ...) +{ + int retval; + va_list varlist; + MSLogParam *llog; + + if ( ! logp ) + llog = &gMSLogParam; + else + llog = logp; + + va_start (varlist, level); + + retval = ms_log_main (llog, level, &varlist); + + va_end (varlist); + + return retval; +} /* End of ms_log_l() */ + + +/*************************************************************************** + * ms_log_main: + * + * A standard logging/printing routine. + * + * The function uses logging parameters specified in the supplied + * MSLogParam. + * + * This function expects 2+ arguments: message level, fprintf format, + * and fprintf arguments. + * + * Three levels are recognized: + * 0 : Normal log messages, printed using log_print with logprefix + * 1 : Diagnostic messages, printed using diag_print with logprefix + * 2+ : Error messagess, printed using diag_print with errprefix + * + * This function builds the log/error message and passes to it as a + * string (char *) to the functions defined with ms_loginit() or + * ms_loginit_l(). If the log/error printing functions have not been + * defined messages will be printed with fprintf, log messages to + * stdout and error messages to stderr. + * + * If the log/error prefix's have been set with ms_loginit() or + * ms_loginit_l() they will be pre-pended to the message. + * + * All messages will be truncated to the MAX_LOG_MSG_LENGTH, this includes + * any set prefix. + * + * Returns the number of characters formatted on success, and a + * a negative value on error. + ***************************************************************************/ +int +ms_log_main (MSLogParam *logp, int level, va_list *varlist) +{ + static char message[MAX_LOG_MSG_LENGTH]; + int retvalue = 0; + int presize; + const char *format; + + if ( ! logp ) + { + fprintf(stderr, "ms_log_main() called without specifying log parameters"); + return -1; + } + + message[0] = '\0'; + + format = va_arg (*varlist, const char *); + + if ( level >= 2 ) /* Error message */ + { + if ( logp->errprefix != NULL ) + { + strncpy (message, logp->errprefix, MAX_LOG_MSG_LENGTH); + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + } + else + { + strncpy (message, "Error: ", MAX_LOG_MSG_LENGTH); + } + + presize = strlen(message); + retvalue = vsnprintf (&message[presize], + MAX_LOG_MSG_LENGTH - presize, + format, *varlist); + + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + + if ( logp->diag_print != NULL ) + { + logp->diag_print (message); + } + else + { + fprintf(stderr, "%s", message); + } + } + else if ( level == 1 ) /* Diagnostic message */ + { + if ( logp->logprefix != NULL ) + { + strncpy (message, logp->logprefix, MAX_LOG_MSG_LENGTH); + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + } + + presize = strlen(message); + retvalue = vsnprintf (&message[presize], + MAX_LOG_MSG_LENGTH - presize, + format, *varlist); + + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + + if ( logp->diag_print != NULL ) + { + logp->diag_print (message); + } + else + { + fprintf(stderr, "%s", message); + } + } + else if ( level == 0 ) /* Normal log message */ + { + if ( logp->logprefix != NULL ) + { + strncpy (message, logp->logprefix, MAX_LOG_MSG_LENGTH); + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + } + + presize = strlen(message); + retvalue = vsnprintf (&message[presize], + MAX_LOG_MSG_LENGTH - presize, + format, *varlist); + + message[MAX_LOG_MSG_LENGTH - 1] = '\0'; + + if ( logp->log_print != NULL ) + { + logp->log_print (message); + } + else + { + fprintf(stdout, "%s", message); + } + } + + return retvalue; +} /* End of ms_log_main() */ diff --git a/libs/3rd-party/mseed/lookup.c b/libs/3rd-party/mseed/lookup.c new file mode 100644 index 0000000..c66917c --- /dev/null +++ b/libs/3rd-party/mseed/lookup.c @@ -0,0 +1,235 @@ +/*************************************************************************** + * lookup.c: + * + * Generic lookup routines for Mini-SEED information. + * + * Written by Chad Trabant, ORFEUS/EC-Project MEREDIAN + * + * modified: 2006.346 + ***************************************************************************/ + +#include + +#include "libmseed.h" + +/*************************************************************************** + * ms_samplesize(): + * + * Returns the sample size based on type code or 0 for unknown. + ***************************************************************************/ +uint8_t +ms_samplesize (const char sampletype) +{ + switch (sampletype) + { + case 'a': + return 1; + case 'i': + case 'f': + return 4; + case 'd': + return 8; + default: + return 0; + } /* end switch */ + +} /* End of ms_samplesize() */ + + +/*************************************************************************** + * ms_encodingstr(): + * + * Returns a string describing a data encoding format. + ***************************************************************************/ +char * +ms_encodingstr (const char encoding) +{ + switch (encoding) + { + case 0: + return "ASCII text"; + case 1: + return "16 bit integers"; + case 2: + return "24 bit integers"; + case 3: + return "32 bit integers"; + case 4: + return "IEEE floating point"; + case 5: + return "IEEE double precision float"; + case 10: + return "STEIM 1 Compression"; + case 11: + return "STEIM 2 Compression"; + case 12: + return "GEOSCOPE Muxed 24 bit int"; + case 13: + return "GEOSCOPE Muxed 16/3 bit gain/exp"; + case 14: + return "GEOSCOPE Muxed 16/4 bit gain/exp"; + case 15: + return "US National Network compression"; + case 16: + return "CDSN 16 bit gain ranged"; + case 17: + return "Graefenberg 16 bit gain ranged"; + case 18: + return "IPG - Strasbourg 16 bit gain"; + case 19: + return "STEIM 3 Compression"; + case 30: + return "SRO Gain Ranged Format"; + case 31: + return "HGLP Format"; + case 32: + return "DWWSSN Format"; + case 33: + return "RSTN 16 bit gain ranged"; + default: + return "Unknown format code"; + } /* end switch */ + +} /* End of ms_encodingstr() */ + + +/*************************************************************************** + * ms_blktdesc(): + * + * Return a string describing a given blockette type or NULL if the + * type is unknown. + ***************************************************************************/ +char * +ms_blktdesc (uint16_t blkttype) +{ + switch (blkttype) + { + case 100: + return "Sample Rate"; + case 200: + return "Generic Event Detection"; + case 201: + return "Murdock Event Detection"; + case 300: + return "Step Calibration"; + case 310: + return "Sine Calibration"; + case 320: + return "Pseudo-random Calibration"; + case 390: + return "Generic Calibration"; + case 395: + return "Calibration Abort"; + case 400: + return "Beam"; + case 500: + return "Timing"; + case 1000: + return "Data Only SEED"; + case 1001: + return "Data Extension"; + case 2000: + return "Opaque Data"; + } /* end switch */ + + return NULL; + +} /* End of ms_blktdesc() */ + + +/*************************************************************************** + * ms_blktlen(): + * + * Returns the total length of a given blockette type in bytes or 0 if + * type unknown. + ***************************************************************************/ +uint16_t +ms_blktlen (uint16_t blkttype, const char *blkt, flag swapflag) +{ + uint16_t blktlen = 0; + + switch (blkttype) + { + case 100: /* Sample Rate */ + blktlen = 12; + break; + case 200: /* Generic Event Detection */ + blktlen = 28; + break; + case 201: /* Murdock Event Detection */ + blktlen = 36; + break; + case 300: /* Step Calibration */ + blktlen = 32; + break; + case 310: /* Sine Calibration */ + blktlen = 32; + break; + case 320: /* Pseudo-random Calibration */ + blktlen = 28; + break; + case 390: /* Generic Calibration */ + blktlen = 28; + break; + case 395: /* Calibration Abort */ + blktlen = 16; + break; + case 400: /* Beam */ + blktlen = 16; + break; + case 500: /* Timing */ + blktlen = 8; + break; + case 1000: /* Data Only SEED */ + blktlen = 8; + break; + case 1001: /* Data Extension */ + blktlen = 8; + break; + case 2000: /* Opaque Data */ + /* First 2-byte field after the blockette header is the length */ + if ( blkt ) + { + memcpy ((void *) &blktlen, blkt+4, sizeof (int16_t)); + if ( swapflag ) ms_gswap2 (&blktlen); + } + break; + } /* end switch */ + + return blktlen; + +} /* End of ms_blktlen() */ + + +/*************************************************************************** + * ms_errorstr(): + * + * Return a string describing a given libmseed error code or NULL if the + * code is unknown. + ***************************************************************************/ +char * +ms_errorstr (int errorcode) +{ + switch (errorcode) + { + case MS_ENDOFFILE: + return "End of file reached"; + case MS_NOERROR: + return "No error"; + case MS_GENERROR: + return "Generic error"; + case MS_NOTSEED: + return "No SEED data detected"; + case MS_WRONGLENGTH: + return "Length of data read does not match record length"; + case MS_OUTOFRANGE: + return "SEED record length out of range"; + case MS_UNKNOWNFORMAT: + return "Unknown data encoding format"; + case MS_STBADCOMPFLAG: + return "Bad Steim compression flag(s) detected"; + } /* end switch */ + + return NULL; + +} /* End of ms_blktdesc() */ diff --git a/libs/3rd-party/mseed/msrutils.c b/libs/3rd-party/mseed/msrutils.c new file mode 100644 index 0000000..c3fa464 --- /dev/null +++ b/libs/3rd-party/mseed/msrutils.c @@ -0,0 +1,1179 @@ +/*************************************************************************** + * msrutils.c: + * + * Generic routines to operate on Mini-SEED records. + * + * Written by Chad Trabant + * ORFEUS/EC-Project MEREDIAN + * IRIS Data Management Center + * + * modified: 2012.088 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "libmseed.h" + + +/*************************************************************************** + * msr_init: + * + * Initialize and return an MSRecord struct, allocating memory if + * needed. If memory for the fsdh and datasamples fields has been + * allocated the pointers will be retained for reuse. If a blockette + * chain is present all associated memory will be released. + * + * Returns a pointer to a MSRecord struct on success or NULL on error. + ***************************************************************************/ +MSRecord * +msr_init ( MSRecord *msr ) +{ + void *fsdh = 0; + void *datasamples = 0; + + if ( ! msr ) + { + msr = (MSRecord *) malloc (sizeof(MSRecord)); + } + else + { + fsdh = msr->fsdh; + datasamples = msr->datasamples; + + if ( msr->blkts ) + msr_free_blktchain (msr); + + if ( msr->ststate ) + free (msr->ststate); + } + + if ( msr == NULL ) + { + ms_log (2, "msr_init(): Cannot allocate memory\n"); + return NULL; + } + + memset (msr, 0, sizeof (MSRecord)); + + msr->fsdh = fsdh; + msr->datasamples = datasamples; + + msr->reclen = -1; + msr->samplecnt = -1; + msr->byteorder = -1; + msr->encoding = -1; + + return msr; +} /* End of msr_init() */ + + +/*************************************************************************** + * msr_free: + * + * Free all memory associated with a MSRecord struct. + ***************************************************************************/ +void +msr_free ( MSRecord **ppmsr ) +{ + if ( ppmsr != NULL && *ppmsr != 0 ) + { + /* Free fixed section header if populated */ + if ( (*ppmsr)->fsdh ) + free ((*ppmsr)->fsdh); + + /* Free blockette chain if populated */ + if ( (*ppmsr)->blkts ) + msr_free_blktchain (*ppmsr); + + /* Free datasamples if present */ + if ( (*ppmsr)->datasamples ) + free ((*ppmsr)->datasamples); + + /* Free stream processing state if present */ + if ( (*ppmsr)->ststate ) + free ((*ppmsr)->ststate); + + free (*ppmsr); + + *ppmsr = NULL; + } +} /* End of msr_free() */ + + +/*************************************************************************** + * msr_free_blktchain: + * + * Free all memory associated with a blockette chain in a MSRecord + * struct and set MSRecord->blkts to NULL. Also reset the shortcut + * blockette pointers. + ***************************************************************************/ +void +msr_free_blktchain ( MSRecord *msr ) +{ + if ( msr ) + { + if ( msr->blkts ) + { + BlktLink *bc = msr->blkts; + BlktLink *nb = NULL; + + while ( bc ) + { + nb = bc->next; + + if ( bc->blktdata ) + free (bc->blktdata); + + free (bc); + + bc = nb; + } + + msr->blkts = 0; + } + + msr->Blkt100 = 0; + msr->Blkt1000 = 0; + msr->Blkt1001 = 0; + } +} /* End of msr_free_blktchain() */ + + +/*************************************************************************** + * msr_addblockette: + * + * Add a blockette to the blockette chain of an MSRecord. 'blktdata' + * should be the body of the blockette type 'blkttype' of 'length' + * bytes without the blockette header (type and next offsets). The + * 'chainpos' value controls which end of the chain the blockette is + * added to. If 'chainpos' is 0 the blockette will be added to the + * end of the chain (last blockette), other wise it will be added to + * the beginning of the chain (first blockette). + * + * Returns a pointer to the BlktLink added to the chain on success and + * NULL on error. + ***************************************************************************/ +BlktLink * +msr_addblockette (MSRecord *msr, char *blktdata, int length, int blkttype, + int chainpos) +{ + BlktLink *blkt; + + if ( ! msr ) + return NULL; + + blkt = msr->blkts; + + if ( blkt ) + { + if ( chainpos != 0 ) + { + blkt = (BlktLink *) malloc (sizeof(BlktLink)); + + blkt->next = msr->blkts; + msr->blkts = blkt; + } + else + { + /* Find the last blockette */ + while ( blkt && blkt->next ) + { + blkt = blkt->next; + } + + blkt->next = (BlktLink *) malloc (sizeof(BlktLink)); + + blkt = blkt->next; + blkt->next = 0; + } + + if ( blkt == NULL ) + { + ms_log (2, "msr_addblockette(): Cannot allocate memory\n"); + return NULL; + } + } + else + { + msr->blkts = (BlktLink *) malloc (sizeof(BlktLink)); + + if ( msr->blkts == NULL ) + { + ms_log (2, "msr_addblockette(): Cannot allocate memory\n"); + return NULL; + } + + blkt = msr->blkts; + blkt->next = 0; + } + + blkt->blktoffset = 0; + blkt->blkt_type = blkttype; + blkt->next_blkt = 0; + + blkt->blktdata = (char *) malloc (length); + + if ( blkt->blktdata == NULL ) + { + ms_log (2, "msr_addblockette(): Cannot allocate memory\n"); + return NULL; + } + + memcpy (blkt->blktdata, blktdata, length); + blkt->blktdatalen = length; + + /* Setup the shortcut pointer for common blockettes */ + switch ( blkttype ) + { + case 100: + msr->Blkt100 = blkt->blktdata; + break; + case 1000: + msr->Blkt1000 = blkt->blktdata; + break; + case 1001: + msr->Blkt1001 = blkt->blktdata; + break; + } + + return blkt; +} /* End of msr_addblockette() */ + + +/*************************************************************************** + * msr_normalize_header: + * + * Normalize header values between the MSRecord struct and the + * associated fixed-section of the header and blockettes. Essentially + * this updates the SEED structured data in the MSRecord.fsdh struct + * and MSRecord.blkts chain with values stored at the MSRecord level. + * + * Returns the header length in bytes on success or -1 on error. + ***************************************************************************/ +int +msr_normalize_header ( MSRecord *msr, flag verbose ) +{ + struct blkt_link_s *cur_blkt; + char seqnum[7]; + int offset = 0; + int blktcnt = 0; + int reclenexp = 0; + int reclenfind; + + if ( ! msr ) + return -1; + + /* Update values in fixed section of data header */ + if ( msr->fsdh ) + { + if ( verbose > 2 ) + ms_log (1, "Normalizing fixed section of data header\n"); + + /* Roll-over sequence number if necessary */ + if ( msr->sequence_number > 999999 ) + msr->sequence_number = 1; + + /* Update values in the MSRecord.fsdh struct */ + snprintf (seqnum, 7, "%06d", msr->sequence_number); + memcpy (msr->fsdh->sequence_number, seqnum, 6); + msr->fsdh->dataquality = msr->dataquality; + msr->fsdh->reserved = ' '; + ms_strncpopen (msr->fsdh->network, msr->network, 2); + ms_strncpopen (msr->fsdh->station, msr->station, 5); + ms_strncpopen (msr->fsdh->location, msr->location, 2); + ms_strncpopen (msr->fsdh->channel, msr->channel, 3); + ms_hptime2btime (msr->starttime, &(msr->fsdh->start_time)); + + /* When the sampling rate is <= 32767 Hertz determine the factor + * and multipler through rational approximation. For higher rates + * set the factor and multiplier to 0. */ + if ( msr->samprate <= 32767.0 ) + { + ms_genfactmult (msr->samprate, &(msr->fsdh->samprate_fact), &(msr->fsdh->samprate_mult)); + } + else + { + if ( verbose > 1 ) + ms_log (1, "Sampling rate too high to approximate factor & multiplier: %g\n", + msr->samprate); + msr->fsdh->samprate_fact = 0; + msr->fsdh->samprate_mult = 0; + } + + offset += 48; + + if ( msr->blkts ) + msr->fsdh->blockette_offset = offset; + else + msr->fsdh->blockette_offset = 0; + } + + /* Traverse blockette chain and performs necessary updates*/ + cur_blkt = msr->blkts; + + if ( cur_blkt && verbose > 2 ) + ms_log (1, "Normalizing blockette chain\n"); + + while ( cur_blkt ) + { + offset += 4; + + if ( cur_blkt->blkt_type == 100 && msr->Blkt100 ) + { + msr->Blkt100->samprate = (float)msr->samprate; + offset += sizeof (struct blkt_100_s); + } + else if ( cur_blkt->blkt_type == 1000 && msr->Blkt1000 ) + { + msr->Blkt1000->byteorder = msr->byteorder; + msr->Blkt1000->encoding = msr->encoding; + + /* Calculate the record length as an exponent of 2 */ + for (reclenfind=1, reclenexp=1; reclenfind <= MAXRECLEN; reclenexp++) + { + reclenfind *= 2; + if ( reclenfind == msr->reclen ) break; + } + + if ( reclenfind != msr->reclen ) + { + ms_log (2, "msr_normalize_header(): Record length %d is not a power of 2\n", + msr->reclen); + return -1; + } + + msr->Blkt1000->reclen = reclenexp; + + offset += sizeof (struct blkt_1000_s); + } + + else if ( cur_blkt->blkt_type == 1001 ) + { + hptime_t sec, usec; + + /* Insert microseconds offset */ + sec = msr->starttime / (HPTMODULUS / 10000); + usec = msr->starttime - (sec * (HPTMODULUS / 10000)); + usec /= (HPTMODULUS / 1000000); + + msr->Blkt1001->usec = (int8_t) usec; + offset += sizeof (struct blkt_1001_s); + } + + blktcnt++; + cur_blkt = cur_blkt->next; + } + + if ( msr->fsdh ) + msr->fsdh->numblockettes = blktcnt; + + return offset; +} /* End of msr_normalize_header() */ + + +/*************************************************************************** + * msr_duplicate: + * + * Duplicate an MSRecord struct + * including the fixed-section data + * header and blockette chain. If + * the datadup flag is true and the + * source MSRecord has associated + * data samples copy them as well. + * + * Returns a pointer to a new MSRecord on success and NULL on error. + ***************************************************************************/ +MSRecord * +msr_duplicate (MSRecord *msr, flag datadup) +{ + MSRecord *dupmsr = 0; + int samplesize = 0; + + if ( ! msr ) + return NULL; + + /* Allocate target MSRecord structure */ + if ( (dupmsr = msr_init (NULL)) == NULL ) + return NULL; + + /* Copy MSRecord structure */ + memcpy (dupmsr, msr, sizeof(MSRecord)); + + /* Copy fixed-section data header structure */ + if ( msr->fsdh ) + { + /* Allocate memory for new FSDH structure */ + if ( (dupmsr->fsdh = (struct fsdh_s *) malloc (sizeof(struct fsdh_s))) == NULL ) + { + ms_log (2, "msr_duplicate(): Error allocating memory\n"); + free (dupmsr); + return NULL; + } + + /* Copy the contents */ + memcpy (dupmsr->fsdh, msr->fsdh, sizeof(struct fsdh_s)); + } + + /* Copy the blockette chain */ + if ( msr->blkts ) + { + BlktLink *blkt = msr->blkts; + BlktLink *next = NULL; + + dupmsr->blkts = 0; + while ( blkt ) + { + next = blkt->next; + + /* Add blockette to chain of new MSRecord */ + if ( msr_addblockette (dupmsr, blkt->blktdata, blkt->blktdatalen, + blkt->blkt_type, 0) == NULL ) + { + ms_log (2, "msr_duplicate(): Error adding blockettes\n"); + msr_free (&dupmsr); + return NULL; + } + + blkt = next; + } + } + + /* Copy data samples if requested and available */ + if ( datadup && msr->datasamples ) + { + /* Determine size of samples in bytes */ + samplesize = ms_samplesize (msr->sampletype); + + if ( samplesize == 0 ) + { + ms_log (2, "msr_duplicate(): unrecognized sample type: '%c'\n", + msr->sampletype); + free (dupmsr); + return NULL; + } + + /* Allocate memory for new data array */ + if ( (dupmsr->datasamples = (void *) malloc ((size_t)(msr->numsamples * samplesize))) == NULL ) + { + ms_log (2, "msr_duplicate(): Error allocating memory\n"); + free (dupmsr); + return NULL; + } + + /* Copy the data array */ + memcpy (dupmsr->datasamples, msr->datasamples, ((size_t)(msr->numsamples * samplesize))); + } + /* Otherwise make sure the sample array and count are zero */ + else + { + dupmsr->datasamples = 0; + dupmsr->numsamples = 0; + } + + return dupmsr; +} /* End of msr_duplicate() */ + + +/*************************************************************************** + * msr_samprate: + * + * Calculate and return a double precision sample rate for the + * specified MSRecord. If a Blockette 100 was included and parsed, + * the "Actual sample rate" (field 3) will be returned, otherwise a + * nominal sample rate will be calculated from the sample rate factor + * and multiplier in the fixed section data header. + * + * Returns the positive sample rate on success and -1.0 on error. + ***************************************************************************/ +double +msr_samprate (MSRecord *msr) +{ + if ( ! msr ) + return -1.0; + + if ( msr->Blkt100 ) + return (double) msr->Blkt100->samprate; + else + return msr_nomsamprate (msr); +} /* End of msr_samprate() */ + + +/*************************************************************************** + * msr_nomsamprate: + * + * Calculate a double precision nominal sample rate from the sample + * rate factor and multiplier in the FSDH struct of the specified + * MSRecord. + * + * Returns the positive sample rate on success and -1.0 on error. + ***************************************************************************/ +double +msr_nomsamprate (MSRecord *msr) +{ + if ( ! msr ) + return -1.0; + + return ms_nomsamprate (msr->fsdh->samprate_fact, msr->fsdh->samprate_mult); +} /* End of msr_nomsamprate() */ + + +/*************************************************************************** + * msr_starttime: + * + * Convert a btime struct of a FSDH struct of a MSRecord (the record + * start time) into a high precision epoch time and apply time + * corrections if any are specified in the header and bit 1 of the + * activity flags indicates that it has not already been applied. If + * a Blockette 1001 is included and has been parsed the microseconds + * of field 4 are also applied. + * + * Returns a high precision epoch time on success and HPTERROR on + * error. + ***************************************************************************/ +hptime_t +msr_starttime (MSRecord *msr) +{ + hptime_t starttime = msr_starttime_uc (msr); + + if ( ! msr || starttime == HPTERROR ) + return HPTERROR; + + /* Check if a correction is included and if it has been applied, + bit 1 of activity flags indicates if it has been appiled */ + + if ( msr->fsdh->time_correct != 0 && + ! (msr->fsdh->act_flags & 0x02) ) + { + starttime += (hptime_t) msr->fsdh->time_correct * (HPTMODULUS / 10000); + } + + /* Apply microsecond precision in a parsed Blockette 1001 */ + if ( msr->Blkt1001 ) + { + starttime += (hptime_t) msr->Blkt1001->usec * (HPTMODULUS / 1000000); + } + + return starttime; +} /* End of msr_starttime() */ + + +/*************************************************************************** + * msr_starttime_uc: + * + * Convert a btime struct of a FSDH struct of a MSRecord (the record + * start time) into a high precision epoch time. This time has no + * correction(s) applied to it. + * + * Returns a high precision epoch time on success and HPTERROR on + * error. + ***************************************************************************/ +hptime_t +msr_starttime_uc (MSRecord *msr) +{ + if ( ! msr ) + return HPTERROR; + + if ( ! msr->fsdh ) + return HPTERROR; + + return ms_btime2hptime (&msr->fsdh->start_time); +} /* End of msr_starttime_uc() */ + + +/*************************************************************************** + * msr_endtime: + * + * Calculate the time of the last sample in the record; this is the + * actual last sample time and *not* the time "covered" by the last + * sample. + * + * Returns the time of the last sample as a high precision epoch time + * on success and HPTERROR on error. + ***************************************************************************/ +hptime_t +msr_endtime (MSRecord *msr) +{ + hptime_t span = 0; + + if ( ! msr ) + return HPTERROR; + + if ( msr->samprate > 0.0 && msr->samplecnt > 0 ) + span = (hptime_t)(((double) (msr->samplecnt - 1) / msr->samprate * HPTMODULUS) + 0.5); + + /* If a positive leap second occurred during this record as denoted by + * bit 4 of the activity flags being set, reduce the end time to match + * the now shifted UTC time. */ + if ( msr->fsdh ) + if ( msr->fsdh->act_flags & 0x10 ) + span -= HPTMODULUS; + + return (msr->starttime + span); +} /* End of msr_endtime() */ + + +/*************************************************************************** + * msr_srcname: + * + * Generate a source name string for a specified MSRecord in the + * format: 'NET_STA_LOC_CHAN' or, if the quality flag is true: + * 'NET_STA_LOC_CHAN_QUAL'. The passed srcname must have enough room + * for the resulting string. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +msr_srcname (MSRecord *msr, char *srcname, flag quality) +{ + char *src = srcname; + char *cp = srcname; + + if ( ! msr || ! srcname ) + return NULL; + + /* Build the source name string */ + cp = msr->network; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = msr->station; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = msr->location; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = msr->channel; + while ( *cp ) { *src++ = *cp++; } + + if ( quality ) + { + *src++ = '_'; + *src++ = msr->dataquality; + } + + *src = '\0'; + + return srcname; +} /* End of msr_srcname() */ + + +/*************************************************************************** + * msr_print: + * + * Prints header values in an MSRecord struct, if 'details' is greater + * than 0 then detailed information about each blockette is printed. + * If 'details' is greater than 1 very detailed information is + * printed. If no FSDH (msr->fsdh) is present only a single line with + * basic information is printed. + ***************************************************************************/ +void +msr_print (MSRecord *msr, flag details) +{ + double nomsamprate; + char srcname[50]; + char time[25]; + char b; + int idx; + + if ( ! msr ) + return; + + /* Generate a source name string */ + srcname[0] = '\0'; + msr_srcname (msr, srcname, 0); + + /* Generate a start time string */ + ms_hptime2seedtimestr (msr->starttime, time, 1); + + /* Report information in the fixed header */ + if ( details > 0 && msr->fsdh ) + { + nomsamprate = msr_nomsamprate (msr); + + ms_log (0, "%s, %06d, %c\n", srcname, msr->sequence_number, msr->dataquality); + ms_log (0, " start time: %s\n", time); + ms_log (0, " number of samples: %d\n", msr->fsdh->numsamples); + ms_log (0, " sample rate factor: %d (%.10g samples per second)\n", + msr->fsdh->samprate_fact, nomsamprate); + ms_log (0, " sample rate multiplier: %d\n", msr->fsdh->samprate_mult); + + if ( details > 1 ) + { + /* Activity flags */ + b = msr->fsdh->act_flags; + ms_log (0, " activity flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Calibration signals present\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Time correction applied\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Beginning of an event, station trigger\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] End of an event, station detrigger\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] A positive leap second happened in this record\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] A negative leap second happened in this record\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] Event in progress\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Undefined bit set\n"); + + /* I/O and clock flags */ + b = msr->fsdh->io_flags; + ms_log (0, " I/O and clock flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Station volume parity error possibly present\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Long record read (possibly no problem)\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Short record read (record padded)\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Start of time series\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] End of time series\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Clock locked\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] Undefined bit set\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Undefined bit set\n"); + + /* Data quality flags */ + b = msr->fsdh->dq_flags; + ms_log (0, " data quality flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Amplifier saturation detected\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Digitizer clipping detected\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Spikes detected\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Glitches detected\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Missing/padded data present\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Telemetry synchronization error\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] A digital filter may be charging\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Time tag is questionable\n"); + } + + ms_log (0, " number of blockettes: %d\n", msr->fsdh->numblockettes); + ms_log (0, " time correction: %ld\n", (long int) msr->fsdh->time_correct); + ms_log (0, " data offset: %d\n", msr->fsdh->data_offset); + ms_log (0, " first blockette offset: %d\n", msr->fsdh->blockette_offset); + } + else + { + ms_log (0, "%s, %06d, %c, %d, %lld samples, %-.10g Hz, %s\n", + srcname, msr->sequence_number, msr->dataquality, + msr->reclen, (long long int) msr->samplecnt, msr->samprate, time); + } + + /* Report information in the blockette chain */ + if ( details > 0 && msr->blkts ) + { + BlktLink *cur_blkt = msr->blkts; + + while ( cur_blkt ) + { + if ( cur_blkt->blkt_type == 100 ) + { + struct blkt_100_s *blkt_100 = (struct blkt_100_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " actual sample rate: %.10g\n", blkt_100->samprate); + + if ( details > 1 ) + { + b = blkt_100->flags; + ms_log (0, " undefined flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + + ms_log (0, " reserved bytes (3): %u,%u,%u\n", + blkt_100->reserved[0], blkt_100->reserved[1], blkt_100->reserved[2]); + } + } + + else if ( cur_blkt->blkt_type == 200 ) + { + struct blkt_200_s *blkt_200 = (struct blkt_200_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " signal amplitude: %g\n", blkt_200->amplitude); + ms_log (0, " signal period: %g\n", blkt_200->period); + ms_log (0, " background estimate: %g\n", blkt_200->background_estimate); + + if ( details > 1 ) + { + b = blkt_200->flags; + ms_log (0, " event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Dilatation wave\n"); + else ms_log (0, " [Bit 0] 0: Compression wave\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] 1: Units after deconvolution\n"); + else ms_log (0, " [Bit 1] 0: Units are digital counts\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Bit 0 is undetermined\n"); + ms_log (0, " reserved byte: %u\n", blkt_200->reserved); + } + + ms_btime2seedtimestr (&blkt_200->time, time); + ms_log (0, " signal onset time: %s\n", time); + ms_log (0, " detector name: %.24s\n", blkt_200->detector); + } + + else if ( cur_blkt->blkt_type == 201 ) + { + struct blkt_201_s *blkt_201 = (struct blkt_201_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " signal amplitude: %g\n", blkt_201->amplitude); + ms_log (0, " signal period: %g\n", blkt_201->period); + ms_log (0, " background estimate: %g\n", blkt_201->background_estimate); + + b = blkt_201->flags; + ms_log (0, " event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Dilation wave\n"); + else ms_log (0, " [Bit 0] 0: Compression wave\n"); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_201->reserved); + ms_btime2seedtimestr (&blkt_201->time, time); + ms_log (0, " signal onset time: %s\n", time); + ms_log (0, " SNR values: "); + for (idx=0; idx < 6; idx++) ms_log (0, "%u ", blkt_201->snr_values[idx]); + ms_log (0, "\n"); + ms_log (0, " loopback value: %u\n", blkt_201->loopback); + ms_log (0, " pick algorithm: %u\n", blkt_201->pick_algorithm); + ms_log (0, " detector name: %.24s\n", blkt_201->detector); + } + + else if ( cur_blkt->blkt_type == 300 ) + { + struct blkt_300_s *blkt_300 = (struct blkt_300_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_btime2seedtimestr (&blkt_300->time, time); + ms_log (0, " calibration start time: %s\n", time); + ms_log (0, " number of calibrations: %u\n", blkt_300->numcalibrations); + + b = blkt_300->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] First pulse is positive\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Calibration's alternate sign\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + + ms_log (0, " step duration: %u\n", blkt_300->step_duration); + ms_log (0, " interval duration: %u\n", blkt_300->interval_duration); + ms_log (0, " signal amplitude: %g\n", blkt_300->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_300->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_300->reserved); + ms_log (0, " reference amplitude: %u\n", blkt_300->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_300->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_300->rolloff); + } + + else if ( cur_blkt->blkt_type == 310 ) + { + struct blkt_310_s *blkt_310 = (struct blkt_310_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_btime2seedtimestr (&blkt_310->time, time); + ms_log (0, " calibration start time: %s\n", time); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_310->reserved1); + + b = blkt_310->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Peak-to-peak amplitude\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Zero-to-peak amplitude\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] RMS amplitude\n"); + + ms_log (0, " calibration duration: %u\n", blkt_310->duration); + ms_log (0, " signal period: %g\n", blkt_310->period); + ms_log (0, " signal amplitude: %g\n", blkt_310->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_310->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_310->reserved2); + ms_log (0, " reference amplitude: %u\n", blkt_310->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_310->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_310->rolloff); + } + + else if ( cur_blkt->blkt_type == 320 ) + { + struct blkt_320_s *blkt_320 = (struct blkt_320_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_btime2seedtimestr (&blkt_320->time, time); + ms_log (0, " calibration start time: %s\n", time); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_320->reserved1); + + b = blkt_320->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Random amplitudes\n"); + + ms_log (0, " calibration duration: %u\n", blkt_320->duration); + ms_log (0, " peak-to-peak amplitude: %g\n", blkt_320->ptp_amplitude); + ms_log (0, " input signal channel: %.3s", blkt_320->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_320->reserved2); + ms_log (0, " reference amplitude: %u\n", blkt_320->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_320->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_320->rolloff); + ms_log (0, " noise type: %.8s\n", blkt_320->noise_type); + } + + else if ( cur_blkt->blkt_type == 390 ) + { + struct blkt_390_s *blkt_390 = (struct blkt_390_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_btime2seedtimestr (&blkt_390->time, time); + ms_log (0, " calibration start time: %s\n", time); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_390->reserved1); + + b = blkt_390->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + + ms_log (0, " calibration duration: %u\n", blkt_390->duration); + ms_log (0, " signal amplitude: %g\n", blkt_390->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_390->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_390->reserved2); + } + + else if ( cur_blkt->blkt_type == 395 ) + { + struct blkt_395_s *blkt_395 = (struct blkt_395_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_btime2seedtimestr (&blkt_395->time, time); + ms_log (0, " calibration end time: %s\n", time); + if ( details > 1 ) + ms_log (0, " reserved bytes (2): %u,%u\n", + blkt_395->reserved[0], blkt_395->reserved[1]); + } + + else if ( cur_blkt->blkt_type == 400 ) + { + struct blkt_400_s *blkt_400 = (struct blkt_400_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " beam azimuth (degrees): %g\n", blkt_400->azimuth); + ms_log (0, " beam slowness (sec/degree): %g\n", blkt_400->slowness); + ms_log (0, " configuration: %u\n", blkt_400->configuration); + if ( details > 1 ) + ms_log (0, " reserved bytes (2): %u,%u\n", + blkt_400->reserved[0], blkt_400->reserved[1]); + } + + else if ( cur_blkt->blkt_type == 405 ) + { + struct blkt_405_s *blkt_405 = (struct blkt_405_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s, incomplete)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " first delay value: %u\n", blkt_405->delay_values[0]); + } + + else if ( cur_blkt->blkt_type == 500 ) + { + struct blkt_500_s *blkt_500 = (struct blkt_500_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " VCO correction: %g%%\n", blkt_500->vco_correction); + ms_btime2seedtimestr (&blkt_500->time, time); + ms_log (0, " time of exception: %s\n", time); + ms_log (0, " usec: %d\n", blkt_500->usec); + ms_log (0, " reception quality: %u%%\n", blkt_500->reception_qual); + ms_log (0, " exception count: %u\n", blkt_500->exception_count); + ms_log (0, " exception type: %.16s\n", blkt_500->exception_type); + ms_log (0, " clock model: %.32s\n", blkt_500->clock_model); + ms_log (0, " clock status: %.128s\n", blkt_500->clock_status); + } + + else if ( cur_blkt->blkt_type == 1000 ) + { + struct blkt_1000_s *blkt_1000 = (struct blkt_1000_s *) cur_blkt->blktdata; + int recsize; + char order[40]; + + /* Calculate record size in bytes as 2^(blkt_1000->rec_len) */ + recsize = (unsigned int) 1 << blkt_1000->reclen; + + /* Big or little endian? */ + if (blkt_1000->byteorder == 0) + strncpy (order, "Little endian", sizeof(order)-1); + else if (blkt_1000->byteorder == 1) + strncpy (order, "Big endian", sizeof(order)-1); + else + strncpy (order, "Unknown value", sizeof(order)-1); + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " encoding: %s (val:%u)\n", + (char *) ms_encodingstr (blkt_1000->encoding), blkt_1000->encoding); + ms_log (0, " byte order: %s (val:%u)\n", + order, blkt_1000->byteorder); + ms_log (0, " record length: %d (val:%u)\n", + recsize, blkt_1000->reclen); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_1000->reserved); + } + + else if ( cur_blkt->blkt_type == 1001 ) + { + struct blkt_1001_s *blkt_1001 = (struct blkt_1001_s *) cur_blkt->blktdata; + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " timing quality: %u%%\n", blkt_1001->timing_qual); + ms_log (0, " micro second: %d\n", blkt_1001->usec); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_1001->reserved); + + ms_log (0, " frame count: %u\n", blkt_1001->framecnt); + } + + else if ( cur_blkt->blkt_type == 2000 ) + { + struct blkt_2000_s *blkt_2000 = (struct blkt_2000_s *) cur_blkt->blktdata; + char order[40]; + + /* Big or little endian? */ + if (blkt_2000->byteorder == 0) + strncpy (order, "Little endian", sizeof(order)-1); + else if (blkt_2000->byteorder == 1) + strncpy (order, "Big endian", sizeof(order)-1); + else + strncpy (order, "Unknown value", sizeof(order)-1); + + ms_log (0, " BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + ms_log (0, " blockette length: %u\n", blkt_2000->length); + ms_log (0, " data offset: %u\n", blkt_2000->data_offset); + ms_log (0, " record number: %u\n", blkt_2000->recnum); + ms_log (0, " byte order: %s (val:%u)\n", + order, blkt_2000->byteorder); + b = blkt_2000->flags; + ms_log (0, " data flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + + if ( details > 1 ) + { + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Stream oriented\n"); + else ms_log (0, " [Bit 0] 0: Record oriented\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] 1: Blockette 2000s may NOT be packaged\n"); + else ms_log (0, " [Bit 1] 0: Blockette 2000s may be packaged\n"); + if ( ! (b & 0x04) && ! (b & 0x08) ) + ms_log (0, " [Bits 2-3] 00: Complete blockette\n"); + else if ( ! (b & 0x04) && (b & 0x08) ) + ms_log (0, " [Bits 2-3] 01: First blockette in span\n"); + else if ( (b & 0x04) && (b & 0x08) ) + ms_log (0, " [Bits 2-3] 11: Continuation blockette in span\n"); + else if ( (b & 0x04) && ! (b & 0x08) ) + ms_log (0, " [Bits 2-3] 10: Final blockette in span\n"); + if ( ! (b & 0x10) && ! (b & 0x20) ) + ms_log (0, " [Bits 4-5] 00: Not file oriented\n"); + else if ( ! (b & 0x10) && (b & 0x20) ) + ms_log (0, " [Bits 4-5] 01: First blockette of file\n"); + else if ( (b & 0x10) && ! (b & 0x20) ) + ms_log (0, " [Bits 4-5] 10: Continuation of file\n"); + else if ( (b & 0x10) && (b & 0x20) ) + ms_log (0, " [Bits 4-5] 11: Last blockette of file\n"); + } + + ms_log (0, " number of headers: %u\n", blkt_2000->numheaders); + + /* Crude display of the opaque data headers */ + if ( details > 1 ) + ms_log (0, " headers: %.*s\n", + (blkt_2000->data_offset - 15), blkt_2000->payload); + } + + else + { + ms_log (0, " BLOCKETTE %u: (%s, not parsed)\n", cur_blkt->blkt_type, + ms_blktdesc(cur_blkt->blkt_type)); + ms_log (0, " next blockette: %u\n", cur_blkt->next_blkt); + } + + cur_blkt = cur_blkt->next; + } + } +} /* End of msr_print() */ + + +/*************************************************************************** + * msr_host_latency: + * + * Calculate the latency based on the host time in UTC accounting for + * the time covered using the number of samples and sample rate; in + * other words, the difference between the host time and the time of + * the last sample in the specified Mini-SEED record. + * + * Double precision is returned, but the true precision is dependent + * on the accuracy of the host system clock among other things. + * + * Returns seconds of latency or 0.0 on error (indistinguishable from + * 0.0 latency). + ***************************************************************************/ +double +msr_host_latency (MSRecord *msr) +{ + double span = 0.0; /* Time covered by the samples */ + double epoch; /* Current epoch time */ + double latency = 0.0; + time_t tv; + + if ( msr == NULL ) + return 0.0; + + /* Calculate the time covered by the samples */ + if ( msr->samprate > 0.0 && msr->samplecnt > 0 ) + span = (1.0 / msr->samprate) * (msr->samplecnt - 1); + + /* Grab UTC time according to the system clock */ + epoch = (double) time(&tv); + + /* Now calculate the latency */ + latency = epoch - ((double) msr->starttime / HPTMODULUS) - span; + + return latency; +} /* End of msr_host_latency() */ diff --git a/libs/3rd-party/mseed/pack.c b/libs/3rd-party/mseed/pack.c new file mode 100644 index 0000000..ee666d7 --- /dev/null +++ b/libs/3rd-party/mseed/pack.c @@ -0,0 +1,1065 @@ +/*************************************************************************** + * pack.c: + * + * Generic routines to pack Mini-SEED records using an MSrecord as a + * header template and data source. + * + * Written by Chad Trabant, + * IRIS Data Management Center + * + * modified: 2014.197 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "libmseed.h" +#include "packdata.h" + +/* Function(s) internal to this file */ +static int msr_pack_header_raw (MSRecord *msr, char *rawrec, int maxheaderlen, + flag swapflag, flag normalize, + struct blkt_1001_s **blkt1001, flag verbose); +static int msr_update_header (MSRecord * msr, char *rawrec, flag swapflag, + struct blkt_1001_s *blkt1001, flag verbose); +static int msr_pack_data (void *dest, void *src, int maxsamples, int maxdatabytes, + int *packsamples, int32_t *lastintsample, flag comphistory, + char sampletype, flag encoding, flag swapflag, + flag verbose); + +/* Header and data byte order flags controlled by environment variables */ +/* -2 = not checked, -1 = checked but not set, or 0 = LE and 1 = BE */ +flag packheaderbyteorder = -2; +flag packdatabyteorder = -2; + +/* A pointer to the srcname of the record being packed */ +char *PACK_SRCNAME = NULL; + + +/*************************************************************************** + * msr_pack: + * + * Pack data into SEED data records. Using the record header values + * in the MSRecord as a template the common header fields are packed + * into the record header, blockettes in the blockettes chain are + * packed and data samples are packed in the encoding format indicated + * by the MSRecord->encoding field. A Blockette 1000 will be added if + * one is not present. + * + * The MSRecord->datasamples array and MSRecord->numsamples value will + * not be changed by this routine. It is the responsibility of the + * calling routine to adjust the data buffer if desired. + * + * As each record is filled and finished they are passed to + * record_handler which expects 1) a char * to the record, 2) the + * length of the record and 3) a pointer supplied by the original + * caller containing optional private data (handlerdata). It is the + * responsibility of record_handler to process the record, the memory + * will be re-used or freed when record_handler returns. + * + * If the flush flag != 0 all of the data will be packed into data + * records even though the last one will probably not be filled. + * + * Default values are: data record & quality indicator = 'D', record + * length = 4096, encoding = 11 (Steim2) and byteorder = 1 (MSBF). + * The defaults are triggered when the the msr->dataquality is 0 or + * msr->reclen, msr->encoding and msr->byteorder are -1 respectively. + * + * Returns the number of records created on success and -1 on error. + ***************************************************************************/ +int +msr_pack ( MSRecord * msr, void (*record_handler) (char *, int, void *), + void *handlerdata, int64_t *packedsamples, flag flush, flag verbose ) +{ + uint16_t *HPnumsamples; + uint16_t *HPdataoffset; + struct blkt_1001_s *HPblkt1001 = NULL; + + char *rawrec; + char *envvariable; + char srcname[50]; + + flag headerswapflag = 0; + flag dataswapflag = 0; + flag packret; + + int samplesize; + int headerlen; + int dataoffset; + int maxdatabytes; + int maxsamples; + int recordcnt = 0; + int packsamples, packoffset; + int64_t totalpackedsamples; + hptime_t segstarttime; + + if ( ! msr ) + return -1; + + if ( ! record_handler ) + { + ms_log (2, "msr_pack(): record_handler() function pointer not set!\n"); + return -1; + } + + /* Allocate stream processing state space if needed */ + if ( ! msr->ststate ) + { + msr->ststate = (StreamState *) malloc (sizeof(StreamState)); + if ( ! msr->ststate ) + { + ms_log (2, "msr_pack(): Could not allocate memory for StreamState\n"); + return -1; + } + memset (msr->ststate, 0, sizeof(StreamState)); + } + + /* Generate source name for MSRecord */ + if ( msr_srcname (msr, srcname, 1) == NULL ) + { + ms_log (2, "msr_unpack_data(): Cannot generate srcname\n"); + return MS_GENERROR; + } + + /* Set shared srcname pointer to source name */ + PACK_SRCNAME = &srcname[0]; + + /* Track original segment start time for new start time calculation */ + segstarttime = msr->starttime; + + /* Read possible environmental variables that force byteorder */ + if ( packheaderbyteorder == -2 ) + { + if ( (envvariable = getenv("PACK_HEADER_BYTEORDER")) ) + { + if ( *envvariable != '0' && *envvariable != '1' ) + { + ms_log (2, "Environment variable PACK_HEADER_BYTEORDER must be set to '0' or '1'\n"); + return -1; + } + else if ( *envvariable == '0' ) + { + packheaderbyteorder = 0; + if ( verbose > 2 ) + ms_log (1, "PACK_HEADER_BYTEORDER=0, packing little-endian header\n"); + } + else + { + packheaderbyteorder = 1; + if ( verbose > 2 ) + ms_log (1, "PACK_HEADER_BYTEORDER=1, packing big-endian header\n"); + } + } + else + { + packheaderbyteorder = -1; + } + } + if ( packdatabyteorder == -2 ) + { + if ( (envvariable = getenv("PACK_DATA_BYTEORDER")) ) + { + if ( *envvariable != '0' && *envvariable != '1' ) + { + ms_log (2, "Environment variable PACK_DATA_BYTEORDER must be set to '0' or '1'\n"); + return -1; + } + else if ( *envvariable == '0' ) + { + packdatabyteorder = 0; + if ( verbose > 2 ) + ms_log (1, "PACK_DATA_BYTEORDER=0, packing little-endian data samples\n"); + } + else + { + packdatabyteorder = 1; + if ( verbose > 2 ) + ms_log (1, "PACK_DATA_BYTEORDER=1, packing big-endian data samples\n"); + } + } + else + { + packdatabyteorder = -1; + } + } + + /* Set default indicator, record length, byte order and encoding if needed */ + if ( msr->dataquality == 0 ) msr->dataquality = 'D'; + if ( msr->reclen == -1 ) msr->reclen = 4096; + if ( msr->byteorder == -1 ) msr->byteorder = 1; + if ( msr->encoding == -1 ) msr->encoding = DE_STEIM2; + + /* Cleanup/reset sequence number */ + if ( msr->sequence_number <= 0 || msr->sequence_number > 999999) + msr->sequence_number = 1; + + if ( msr->reclen < MINRECLEN || msr->reclen > MAXRECLEN ) + { + ms_log (2, "msr_pack(%s): Record length is out of range: %d\n", + PACK_SRCNAME, msr->reclen); + return -1; + } + + if ( msr->numsamples <= 0 ) + { + ms_log (2, "msr_pack(%s): No samples to pack\n", PACK_SRCNAME); + return -1; + } + + samplesize = ms_samplesize (msr->sampletype); + + if ( ! samplesize ) + { + ms_log (2, "msr_pack(%s): Unknown sample type '%c'\n", + PACK_SRCNAME, msr->sampletype); + return -1; + } + + /* Sanity check for msr/quality indicator */ + if ( ! MS_ISDATAINDICATOR(msr->dataquality) ) + { + ms_log (2, "msr_pack(%s): Record header & quality indicator unrecognized: '%c'\n", + PACK_SRCNAME, msr->dataquality); + ms_log (2, "msr_pack(%s): Packing failed.\n", PACK_SRCNAME); + return -1; + } + + /* Allocate space for data record */ + rawrec = (char *) malloc (msr->reclen); + + if ( rawrec == NULL ) + { + ms_log (2, "msr_pack(%s): Cannot allocate memory\n", PACK_SRCNAME); + return -1; + } + + /* Set header pointers to known offsets into FSDH */ + HPnumsamples = (uint16_t *) (rawrec + 30); + HPdataoffset = (uint16_t *) (rawrec + 44); + + /* Check to see if byte swapping is needed */ + if ( msr->byteorder != ms_bigendianhost() ) + headerswapflag = dataswapflag = 1; + + /* Check if byte order is forced */ + if ( packheaderbyteorder >= 0 ) + { + headerswapflag = ( msr->byteorder != packheaderbyteorder ) ? 1 : 0; + } + + if ( packdatabyteorder >= 0 ) + { + dataswapflag = ( msr->byteorder != packdatabyteorder ) ? 1 : 0; + } + + if ( verbose > 2 ) + { + if ( headerswapflag && dataswapflag ) + ms_log (1, "%s: Byte swapping needed for packing of header and data samples\n", PACK_SRCNAME); + else if ( headerswapflag ) + ms_log (1, "%s: Byte swapping needed for packing of header\n", PACK_SRCNAME); + else if ( dataswapflag ) + ms_log (1, "%s: Byte swapping needed for packing of data samples\n", PACK_SRCNAME); + else + ms_log (1, "%s: Byte swapping NOT needed for packing\n", PACK_SRCNAME); + } + + /* Add a blank 1000 Blockette if one is not present, the blockette values + will be populated in msr_pack_header_raw()/msr_normalize_header() */ + if ( ! msr->Blkt1000 ) + { + struct blkt_1000_s blkt1000; + memset (&blkt1000, 0, sizeof (struct blkt_1000_s)); + + if ( verbose > 2 ) + ms_log (1, "%s: Adding 1000 Blockette\n", PACK_SRCNAME); + + if ( ! msr_addblockette (msr, (char *) &blkt1000, sizeof(struct blkt_1000_s), 1000, 0) ) + { + ms_log (2, "msr_pack(%s): Error adding 1000 Blockette\n", PACK_SRCNAME); + return -1; + } + } + + headerlen = msr_pack_header_raw (msr, rawrec, msr->reclen, headerswapflag, 1, &HPblkt1001, verbose); + + if ( headerlen == -1 ) + { + ms_log (2, "msr_pack(%s): Error packing header\n", PACK_SRCNAME); + return -1; + } + + /* Determine offset to encoded data */ + if ( msr->encoding == DE_STEIM1 || msr->encoding == DE_STEIM2 ) + { + dataoffset = 64; + while ( dataoffset < headerlen ) + dataoffset += 64; + + /* Zero memory between blockettes and data if any */ + memset (rawrec + headerlen, 0, dataoffset - headerlen); + } + else + { + dataoffset = headerlen; + } + + *HPdataoffset = (uint16_t) dataoffset; + if ( headerswapflag ) ms_gswap2 (HPdataoffset); + + /* Determine the max data bytes and sample count */ + maxdatabytes = msr->reclen - dataoffset; + + if ( msr->encoding == DE_STEIM1 ) + { + maxsamples = (int) (maxdatabytes/64) * STEIM1_FRAME_MAX_SAMPLES; + } + else if ( msr->encoding == DE_STEIM2 ) + { + maxsamples = (int) (maxdatabytes/64) * STEIM2_FRAME_MAX_SAMPLES; + } + else + { + maxsamples = maxdatabytes / samplesize; + } + + /* Pack samples into records */ + *HPnumsamples = 0; + totalpackedsamples = 0; + if ( packedsamples ) *packedsamples = 0; + packoffset = 0; + + while ( (msr->numsamples - totalpackedsamples) > maxsamples || flush ) + { + packret = msr_pack_data (rawrec + dataoffset, + (char *) msr->datasamples + packoffset, + (int)(msr->numsamples - totalpackedsamples), maxdatabytes, + &packsamples, &msr->ststate->lastintsample, msr->ststate->comphistory, + msr->sampletype, msr->encoding, dataswapflag, verbose); + + if ( packret ) + { + ms_log (2, "msr_pack(%s): Error packing record\n", PACK_SRCNAME); + return -1; + } + + packoffset += packsamples * samplesize; + + /* Update number of samples */ + *HPnumsamples = (uint16_t) packsamples; + if ( headerswapflag ) ms_gswap2 (HPnumsamples); + + if ( verbose > 0 ) + ms_log (1, "%s: Packed %d samples\n", PACK_SRCNAME, packsamples); + + /* Send record to handler */ + record_handler (rawrec, msr->reclen, handlerdata); + + totalpackedsamples += packsamples; + if ( packedsamples ) *packedsamples = totalpackedsamples; + msr->ststate->packedsamples += packsamples; + + /* Update record header for next record */ + msr->sequence_number = ( msr->sequence_number >= 999999 ) ? 1 : msr->sequence_number + 1; + if ( msr->samprate > 0 ) + msr->starttime = segstarttime + (hptime_t)(totalpackedsamples / msr->samprate * HPTMODULUS + 0.5); + + msr_update_header (msr, rawrec, headerswapflag, HPblkt1001, verbose); + + recordcnt++; + msr->ststate->packedrecords++; + + /* Set compression history flag for subsequent records (Steim encodings) */ + if ( ! msr->ststate->comphistory ) + msr->ststate->comphistory = 1; + + if ( totalpackedsamples >= msr->numsamples ) + break; + } + + if ( verbose > 2 ) + ms_log (1, "%s: Packed %d total samples\n", PACK_SRCNAME, totalpackedsamples); + + free (rawrec); + + return recordcnt; +} /* End of msr_pack() */ + + +/*************************************************************************** + * msr_pack_header: + * + * Pack data header/blockettes into the SEED record at + * MSRecord->record. Unlike msr_pack no default values are applied, + * the header structures are expected to be self describing and no + * Blockette 1000 will be added. This routine is only useful for + * re-packing a record header. + * + * Returns the header length in bytes on success and -1 on error. + ***************************************************************************/ +int +msr_pack_header ( MSRecord *msr, flag normalize, flag verbose ) +{ + char srcname[50]; + char *envvariable; + flag headerswapflag = 0; + int headerlen; + int maxheaderlen; + + if ( ! msr ) + return -1; + + /* Generate source name for MSRecord */ + if ( msr_srcname (msr, srcname, 1) == NULL ) + { + ms_log (2, "msr_unpack_data(): Cannot generate srcname\n"); + return MS_GENERROR; + } + + /* Set shared srcname pointer to source name */ + PACK_SRCNAME = &srcname[0]; + + /* Read possible environmental variables that force byteorder */ + if ( packheaderbyteorder == -2 ) + { + if ( (envvariable = getenv("PACK_HEADER_BYTEORDER")) ) + { + if ( *envvariable != '0' && *envvariable != '1' ) + { + ms_log (2, "Environment variable PACK_HEADER_BYTEORDER must be set to '0' or '1'\n"); + return -1; + } + else if ( *envvariable == '0' ) + { + packheaderbyteorder = 0; + if ( verbose > 2 ) + ms_log (1, "PACK_HEADER_BYTEORDER=0, packing little-endian header\n"); + } + else + { + packheaderbyteorder = 1; + if ( verbose > 2 ) + ms_log (1, "PACK_HEADER_BYTEORDER=1, packing big-endian header\n"); + } + } + else + { + packheaderbyteorder = -1; + } + } + + if ( msr->reclen < MINRECLEN || msr->reclen > MAXRECLEN ) + { + ms_log (2, "msr_pack_header(%s): record length is out of range: %d\n", + PACK_SRCNAME, msr->reclen); + return -1; + } + + if ( msr->byteorder != 0 && msr->byteorder != 1 ) + { + ms_log (2, "msr_pack_header(%s): byte order is not defined correctly: %d\n", + PACK_SRCNAME, msr->byteorder); + return -1; + } + + if ( msr->fsdh ) + { + maxheaderlen = (msr->fsdh->data_offset > 0) ? + msr->fsdh->data_offset : + msr->reclen; + } + else + { + maxheaderlen = msr->reclen; + } + + /* Check to see if byte swapping is needed */ + if ( msr->byteorder != ms_bigendianhost() ) + headerswapflag = 1; + + /* Check if byte order is forced */ + if ( packheaderbyteorder >= 0 ) + { + headerswapflag = ( msr->byteorder != packheaderbyteorder ) ? 1: 0; + } + + if ( verbose > 2 ) + { + if ( headerswapflag ) + ms_log (1, "%s: Byte swapping needed for packing of header\n", PACK_SRCNAME); + else + ms_log (1, "%s: Byte swapping NOT needed for packing of header\n", PACK_SRCNAME); + } + + headerlen = msr_pack_header_raw (msr, msr->record, maxheaderlen, + headerswapflag, normalize, NULL, verbose); + + return headerlen; +} /* End of msr_pack_header() */ + + +/*************************************************************************** + * msr_pack_header_raw: + * + * Pack data header/blockettes into the specified SEED data record. + * + * Returns the header length in bytes on success or -1 on error. + ***************************************************************************/ +static int +msr_pack_header_raw ( MSRecord *msr, char *rawrec, int maxheaderlen, + flag swapflag, flag normalize, + struct blkt_1001_s **blkt1001, flag verbose ) +{ + struct blkt_link_s *cur_blkt; + struct fsdh_s *fsdh; + int16_t offset; + int blktcnt = 0; + int nextoffset; + + if ( ! msr || ! rawrec ) + return -1; + + /* Make sure a fixed section of data header is available */ + if ( ! msr->fsdh ) + { + msr->fsdh = (struct fsdh_s *) calloc (1, sizeof (struct fsdh_s)); + + if ( msr->fsdh == NULL ) + { + ms_log (2, "msr_pack_header_raw(%s): Cannot allocate memory\n", + PACK_SRCNAME); + return -1; + } + } + + /* Update the SEED structures associated with the MSRecord */ + if ( normalize ) + if ( msr_normalize_header (msr, verbose) < 0 ) + { + ms_log (2, "msr_pack_header_raw(%s): error normalizing header values\n", + PACK_SRCNAME); + return -1; + } + + if ( verbose > 2 ) + ms_log (1, "%s: Packing fixed section of data header\n", PACK_SRCNAME); + + if ( maxheaderlen > msr->reclen ) + { + ms_log (2, "msr_pack_header_raw(%s): maxheaderlen of %d is beyond record length of %d\n", + PACK_SRCNAME, maxheaderlen, msr->reclen); + return -1; + } + + if ( maxheaderlen < (int)sizeof(struct fsdh_s) ) + { + ms_log (2, "msr_pack_header_raw(%s): maxheaderlen of %d is too small, must be >= %d\n", + PACK_SRCNAME, maxheaderlen, sizeof(struct fsdh_s)); + return -1; + } + + fsdh = (struct fsdh_s *) rawrec; + offset = 48; + + /* Roll-over sequence number if necessary */ + if ( msr->sequence_number > 999999 ) + msr->sequence_number = 1; + + /* Copy FSDH associated with the MSRecord into the record */ + memcpy (fsdh, msr->fsdh, sizeof(struct fsdh_s)); + + /* Swap byte order? */ + if ( swapflag ) + { + MS_SWAPBTIME (&fsdh->start_time); + ms_gswap2 (&fsdh->numsamples); + ms_gswap2 (&fsdh->samprate_fact); + ms_gswap2 (&fsdh->samprate_mult); + ms_gswap4 (&fsdh->time_correct); + ms_gswap2 (&fsdh->data_offset); + ms_gswap2 (&fsdh->blockette_offset); + } + + /* Traverse blockette chain and pack blockettes at 'offset' */ + cur_blkt = msr->blkts; + + while ( cur_blkt && offset < maxheaderlen ) + { + /* Check that the blockette fits */ + if ( (offset + 4 + cur_blkt->blktdatalen) > maxheaderlen ) + { + ms_log (2, "msr_pack_header_raw(%s): header exceeds maxheaderlen of %d\n", + PACK_SRCNAME, maxheaderlen); + break; + } + + /* Pack blockette type and leave space for next offset */ + memcpy (rawrec + offset, &cur_blkt->blkt_type, 2); + if ( swapflag ) ms_gswap2 (rawrec + offset); + nextoffset = offset + 2; + offset += 4; + + if ( cur_blkt->blkt_type == 100 ) + { + struct blkt_100_s *blkt_100 = (struct blkt_100_s *) (rawrec + offset); + memcpy (blkt_100, cur_blkt->blktdata, sizeof (struct blkt_100_s)); + offset += sizeof (struct blkt_100_s); + + if ( swapflag ) + { + ms_gswap4 (&blkt_100->samprate); + } + } + + else if ( cur_blkt->blkt_type == 200 ) + { + struct blkt_200_s *blkt_200 = (struct blkt_200_s *) (rawrec + offset); + memcpy (blkt_200, cur_blkt->blktdata, sizeof (struct blkt_200_s)); + offset += sizeof (struct blkt_200_s); + + if ( swapflag ) + { + ms_gswap4 (&blkt_200->amplitude); + ms_gswap4 (&blkt_200->period); + ms_gswap4 (&blkt_200->background_estimate); + MS_SWAPBTIME (&blkt_200->time); + } + } + + else if ( cur_blkt->blkt_type == 201 ) + { + struct blkt_201_s *blkt_201 = (struct blkt_201_s *) (rawrec + offset); + memcpy (blkt_201, cur_blkt->blktdata, sizeof (struct blkt_201_s)); + offset += sizeof (struct blkt_201_s); + + if ( swapflag ) + { + ms_gswap4 (&blkt_201->amplitude); + ms_gswap4 (&blkt_201->period); + ms_gswap4 (&blkt_201->background_estimate); + MS_SWAPBTIME (&blkt_201->time); + } + } + + else if ( cur_blkt->blkt_type == 300 ) + { + struct blkt_300_s *blkt_300 = (struct blkt_300_s *) (rawrec + offset); + memcpy (blkt_300, cur_blkt->blktdata, sizeof (struct blkt_300_s)); + offset += sizeof (struct blkt_300_s); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_300->time); + ms_gswap4 (&blkt_300->step_duration); + ms_gswap4 (&blkt_300->interval_duration); + ms_gswap4 (&blkt_300->amplitude); + ms_gswap4 (&blkt_300->reference_amplitude); + } + } + + else if ( cur_blkt->blkt_type == 310 ) + { + struct blkt_310_s *blkt_310 = (struct blkt_310_s *) (rawrec + offset); + memcpy (blkt_310, cur_blkt->blktdata, sizeof (struct blkt_310_s)); + offset += sizeof (struct blkt_310_s); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_310->time); + ms_gswap4 (&blkt_310->duration); + ms_gswap4 (&blkt_310->period); + ms_gswap4 (&blkt_310->amplitude); + ms_gswap4 (&blkt_310->reference_amplitude); + } + } + + else if ( cur_blkt->blkt_type == 320 ) + { + struct blkt_320_s *blkt_320 = (struct blkt_320_s *) (rawrec + offset); + memcpy (blkt_320, cur_blkt->blktdata, sizeof (struct blkt_320_s)); + offset += sizeof (struct blkt_320_s); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_320->time); + ms_gswap4 (&blkt_320->duration); + ms_gswap4 (&blkt_320->ptp_amplitude); + ms_gswap4 (&blkt_320->reference_amplitude); + } + } + + else if ( cur_blkt->blkt_type == 390 ) + { + struct blkt_390_s *blkt_390 = (struct blkt_390_s *) (rawrec + offset); + memcpy (blkt_390, cur_blkt->blktdata, sizeof (struct blkt_390_s)); + offset += sizeof (struct blkt_390_s); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_390->time); + ms_gswap4 (&blkt_390->duration); + ms_gswap4 (&blkt_390->amplitude); + } + } + + else if ( cur_blkt->blkt_type == 395 ) + { + struct blkt_395_s *blkt_395 = (struct blkt_395_s *) (rawrec + offset); + memcpy (blkt_395, cur_blkt->blktdata, sizeof (struct blkt_395_s)); + offset += sizeof (struct blkt_395_s); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_395->time); + } + } + + else if ( cur_blkt->blkt_type == 400 ) + { + struct blkt_400_s *blkt_400 = (struct blkt_400_s *) (rawrec + offset); + memcpy (blkt_400, cur_blkt->blktdata, sizeof (struct blkt_400_s)); + offset += sizeof (struct blkt_400_s); + + if ( swapflag ) + { + ms_gswap4 (&blkt_400->azimuth); + ms_gswap4 (&blkt_400->slowness); + ms_gswap2 (&blkt_400->configuration); + } + } + + else if ( cur_blkt->blkt_type == 405 ) + { + struct blkt_405_s *blkt_405 = (struct blkt_405_s *) (rawrec + offset); + memcpy (blkt_405, cur_blkt->blktdata, sizeof (struct blkt_405_s)); + offset += sizeof (struct blkt_405_s); + + if ( swapflag ) + { + ms_gswap2 (&blkt_405->delay_values); + } + + if ( verbose > 0 ) + { + ms_log (1, "msr_pack_header_raw(%s): WARNING Blockette 405 cannot be fully supported\n", + PACK_SRCNAME); + } + } + + else if ( cur_blkt->blkt_type == 500 ) + { + struct blkt_500_s *blkt_500 = (struct blkt_500_s *) (rawrec + offset); + memcpy (blkt_500, cur_blkt->blktdata, sizeof (struct blkt_500_s)); + offset += sizeof (struct blkt_500_s); + + if ( swapflag ) + { + ms_gswap4 (&blkt_500->vco_correction); + MS_SWAPBTIME (&blkt_500->time); + ms_gswap4 (&blkt_500->exception_count); + } + } + + else if ( cur_blkt->blkt_type == 1000 ) + { + struct blkt_1000_s *blkt_1000 = (struct blkt_1000_s *) (rawrec + offset); + memcpy (blkt_1000, cur_blkt->blktdata, sizeof (struct blkt_1000_s)); + offset += sizeof (struct blkt_1000_s); + + /* This guarantees that the byte order is in sync with msr_pack() */ + if ( packdatabyteorder >= 0 ) + blkt_1000->byteorder = packdatabyteorder; + } + + else if ( cur_blkt->blkt_type == 1001 ) + { + struct blkt_1001_s *blkt_1001 = (struct blkt_1001_s *) (rawrec + offset); + memcpy (blkt_1001, cur_blkt->blktdata, sizeof (struct blkt_1001_s)); + offset += sizeof (struct blkt_1001_s); + + /* Track location of Blockette 1001 if requested */ + if ( blkt1001 ) + *blkt1001 = blkt_1001; + } + + else if ( cur_blkt->blkt_type == 2000 ) + { + struct blkt_2000_s *blkt_2000 = (struct blkt_2000_s *) (rawrec + offset); + memcpy (blkt_2000, cur_blkt->blktdata, cur_blkt->blktdatalen); + offset += cur_blkt->blktdatalen; + + if ( swapflag ) + { + ms_gswap2 (&blkt_2000->length); + ms_gswap2 (&blkt_2000->data_offset); + ms_gswap4 (&blkt_2000->recnum); + } + + /* Nothing done to pack the opaque headers and data, they should already + be packed into the blockette payload */ + } + + else + { + memcpy (rawrec + offset, cur_blkt->blktdata, cur_blkt->blktdatalen); + offset += cur_blkt->blktdatalen; + } + + /* Pack the offset to the next blockette */ + if ( cur_blkt->next ) + { + memcpy (rawrec + nextoffset, &offset, 2); + if ( swapflag ) ms_gswap2 (rawrec + nextoffset); + } + else + { + memset (rawrec + nextoffset, 0, 2); + } + + blktcnt++; + cur_blkt = cur_blkt->next; + } + + fsdh->numblockettes = blktcnt; + + if ( verbose > 2 ) + ms_log (1, "%s: Packed %d blockettes\n", PACK_SRCNAME, blktcnt); + + return offset; +} /* End of msr_pack_header_raw() */ + + +/*************************************************************************** + * msr_update_header: + * + * Update the header values that change between records: start time, + * sequence number, etc. + * + * Returns 0 on success or -1 on error. + ***************************************************************************/ +static int +msr_update_header ( MSRecord *msr, char *rawrec, flag swapflag, + struct blkt_1001_s *blkt1001, flag verbose ) +{ + struct fsdh_s *fsdh; + char seqnum[7]; + + if ( ! msr || ! rawrec ) + return -1; + + if ( verbose > 2 ) + ms_log (1, "%s: Updating fixed section of data header\n", PACK_SRCNAME); + + fsdh = (struct fsdh_s *) rawrec; + + /* Pack values into the fixed section of header */ + snprintf (seqnum, 7, "%06d", msr->sequence_number); + memcpy (fsdh->sequence_number, seqnum, 6); + + /* Update fixed-section start time */ + ms_hptime2btime (msr->starttime, &(fsdh->start_time)); + + /* Swap byte order? */ + if ( swapflag ) + { + MS_SWAPBTIME (&fsdh->start_time); + } + + /* Update microseconds if Blockette 1001 is present */ + if ( msr->Blkt1001 && blkt1001 ) + { + hptime_t sec, usec; + + /* Calculate microseconds offset */ + sec = msr->starttime / (HPTMODULUS / 10000); + usec = msr->starttime - (sec * (HPTMODULUS / 10000)); + usec /= (HPTMODULUS / 1000000); + + /* Update microseconds offset in blockette chain entry */ + msr->Blkt1001->usec = (int8_t) usec; + + /* Update microseconds offset in packed header */ + blkt1001->usec = (int8_t) usec; + } + + return 0; +} /* End of msr_update_header() */ + + +/************************************************************************ + * msr_pack_data: + * + * Pack Mini-SEED data samples. The input data samples specified as + * 'src' will be packed with 'encoding' format and placed in 'dest'. + * + * If a pointer to a 32-bit integer sample is provided in the + * argument 'lastintsample' and 'comphistory' is true the sample + * value will be used to seed the difference buffer for Steim1/2 + * encoding and provide a compression history. It will also be + * updated with the last sample packed in order to be used with a + * subsequent call to this routine. + * + * The number of samples packed will be placed in 'packsamples' and + * the number of bytes packed will be placed in 'packbytes'. + * + * Return 0 on success and a negative number on error. + ************************************************************************/ +static int +msr_pack_data (void *dest, void *src, int maxsamples, int maxdatabytes, + int *packsamples, int32_t *lastintsample, flag comphistory, + char sampletype, flag encoding, flag swapflag, flag verbose) +{ + int retval; + int nframes; + int npacked; + int32_t *intbuff; + int32_t d0; + + /* Decide if this is a format that we can decode */ + switch (encoding) + { + + case DE_ASCII: + if ( sampletype != 'a' ) + { + ms_log (2, "%s: Sample type must be ascii (a) for ASCII encoding not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Packing ASCII data\n", PACK_SRCNAME); + + retval = msr_pack_text (dest, src, maxsamples, maxdatabytes, 1, + &npacked, packsamples); + + break; + + case DE_INT16: + if ( sampletype != 'i' ) + { + ms_log (2, "%s: Sample type must be integer (i) for integer-16 encoding not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Packing INT-16 data samples\n", PACK_SRCNAME); + + retval = msr_pack_int_16 (dest, src, maxsamples, maxdatabytes, 1, + &npacked, packsamples, swapflag); + + break; + + case DE_INT32: + if ( sampletype != 'i' ) + { + ms_log (2, "%s: Sample type must be integer (i) for integer-32 encoding not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Packing INT-32 data samples\n", PACK_SRCNAME); + + retval = msr_pack_int_32 (dest, src, maxsamples, maxdatabytes, 1, + &npacked, packsamples, swapflag); + + break; + + case DE_FLOAT32: + if ( sampletype != 'f' ) + { + ms_log (2, "%s: Sample type must be float (f) for float-32 encoding not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Packing FLOAT-32 data samples\n", PACK_SRCNAME); + + retval = msr_pack_float_32 (dest, src, maxsamples, maxdatabytes, 1, + &npacked, packsamples, swapflag); + + break; + + case DE_FLOAT64: + if ( sampletype != 'd' ) + { + ms_log (2, "%s: Sample type must be double (d) for float-64 encoding not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Packing FLOAT-64 data samples\n", PACK_SRCNAME); + + retval = msr_pack_float_64 (dest, src, maxsamples, maxdatabytes, 1, + &npacked, packsamples, swapflag); + + break; + + case DE_STEIM1: + if ( sampletype != 'i' ) + { + ms_log (2, "%s: Sample type must be integer (i) for Steim-1 compression not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + intbuff = (int32_t *) src; + + /* If a previous sample is supplied use it for compression history otherwise cold-start */ + d0 = ( lastintsample && comphistory ) ? (intbuff[0] - *lastintsample) : 0; + + if ( verbose > 1 ) + ms_log (1, "%s: Packing Steim-1 data frames\n", PACK_SRCNAME); + + nframes = maxdatabytes / 64; + + retval = msr_pack_steim1 (dest, src, d0, maxsamples, nframes, 1, + &npacked, packsamples, swapflag); + + /* If a previous sample is supplied update it with the last sample value */ + if ( lastintsample && retval == 0 ) + *lastintsample = intbuff[*packsamples-1]; + + break; + + case DE_STEIM2: + if ( sampletype != 'i' ) + { + ms_log (2, "%s: Sample type must be integer (i) for Steim-2 compression not '%c'\n", + PACK_SRCNAME, sampletype); + return -1; + } + + intbuff = (int32_t *) src; + + /* If a previous sample is supplied use it for compression history otherwise cold-start */ + d0 = ( lastintsample && comphistory ) ? (intbuff[0] - *lastintsample) : 0; + + if ( verbose > 1 ) + ms_log (1, "%s: Packing Steim-2 data frames\n", PACK_SRCNAME); + + nframes = maxdatabytes / 64; + + retval = msr_pack_steim2 (dest, src, d0, maxsamples, nframes, 1, + &npacked, packsamples, swapflag); + + /* If a previous sample is supplied update it with the last sample value */ + if ( lastintsample && retval == 0 ) + *lastintsample = intbuff[*packsamples-1]; + + break; + + default: + ms_log (2, "%s: Unable to pack format %d\n", PACK_SRCNAME, encoding); + + return -1; + } + + return retval; +} /* End of msr_pack_data() */ diff --git a/libs/3rd-party/mseed/packdata.c b/libs/3rd-party/mseed/packdata.c new file mode 100644 index 0000000..cf0ed08 --- /dev/null +++ b/libs/3rd-party/mseed/packdata.c @@ -0,0 +1,699 @@ +/*********************************************************************** + * Routines for packing INT_32, INT_16, FLOAT_32, FLOAT_64, + * STEIM1 and STEIM2 data records. + * + * Douglas Neuhauser + * Seismological Laboratory + * University of California, Berkeley + * doug@seismo.berkeley.edu + * + * + * modified Aug 2008: + * - Optimize Steim 1 & 2 packing routines using small, re-used buffers. + * + * modified Sep 2004: + * - Reworked and cleaned routines for use within libmseed. + * - Added float32 and float64 packing routines. + * + * Modified by Chad Trabant, IRIS Data Management Center + * + * modified: 2009.111 + ************************************************************************/ + +/* + * Copyright (c) 1996-2004 The Regents of the University of California. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for educational, research and non-profit purposes, + * without fee, and without a written agreement is hereby granted, + * provided that the above copyright notice, this paragraph and the + * following three paragraphs appear in all copies. + * + * Permission to incorporate this software into commercial products may + * be obtained from the Office of Technology Licensing, 2150 Shattuck + * Avenue, Suite 510, Berkeley, CA 94704. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY + * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, + * INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND + * ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE + * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF + * CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, + * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include +#include +#include + +#include "libmseed.h" +#include "packdata.h" + +static int pad_steim_frame (DFRAMES*, int, int, int, int, int); + +#define EMPTY_BLOCK(fn,wn) (fn+wn == 0) + +#define X0 dframes->f[0].w[0].fw +#define XN dframes->f[0].w[1].fw + +#define BIT4PACK(i,points_remaining) \ + (points_remaining >= 7 && \ + (minbits[i] <= 4) && (minbits[i+1] <= 4) && \ + (minbits[i+2] <= 4) && (minbits[i+3] <= 4) && \ + (minbits[i+4] <= 4) && (minbits[i+5] <= 4) && \ + (minbits[i+6] <= 4)) + +#define BIT5PACK(i,points_remaining) \ + (points_remaining >= 6 && \ + (minbits[i] <= 5) && (minbits[i+1] <= 5) && \ + (minbits[i+2] <= 5) && (minbits[i+3] <= 5) && \ + (minbits[i+4] <= 5) && (minbits[i+5] <= 5)) + +#define BIT6PACK(i,points_remaining) \ + (points_remaining >= 5 && \ + (minbits[i] <= 6) && (minbits[i+1] <= 6) && \ + (minbits[i+2] <= 6) && (minbits[i+3] <= 6) && \ + (minbits[i+4] <= 6)) + +#define BYTEPACK(i,points_remaining) \ + (points_remaining >= 4 && \ + (minbits[i] <= 8) && (minbits[i+1] <= 8) && \ + (minbits[i+2] <= 8) && (minbits[i+3] <= 8)) + +#define BIT10PACK(i,points_remaining) \ + (points_remaining >= 3 && \ + (minbits[i] <= 10) && (minbits[i+1] <= 10) && \ + (minbits[i+2] <= 10)) + +#define BIT15PACK(i,points_remaining) \ + (points_remaining >= 2 && \ + (minbits[i] <= 15) && (minbits[i+1] <= 15)) + +#define HALFPACK(i,points_remaining) \ + (points_remaining >= 2 && (minbits[i] <= 16) && (minbits[i+1] <= 16)) + +#define BIT30PACK(i,points_remaining) \ + (points_remaining >= 1 && \ + (minbits[i] <= 30)) + +#define MINBITS(diff,minbits) \ + if (diff >= -8 && diff < 8) minbits = 4; \ + else if (diff >= -16 && diff < 16) minbits = 5; \ + else if (diff >= -32 && diff < 32) minbits = 6; \ + else if (diff >= -128 && diff < 128) minbits = 8; \ + else if (diff >= -512 && diff < 512) minbits = 10; \ + else if (diff >= -16384 && diff < 16384) minbits = 15; \ + else if (diff >= -32768 && diff < 32768) minbits = 16; \ + else if (diff >= -536870912 && diff < 536870912) minbits = 30; \ + else minbits = 32; + +#define PACK(bits,n,m1,m2) { \ + int i = 0; \ + unsigned int val = 0; \ + for (i=0;if[fn].w[wn].fw = val; } + + +/************************************************************************ + * msr_pack_int_16: * + * Pack integer data into INT_16 format. * + * Return: 0 on success, -1 on failure. * + ************************************************************************/ +int msr_pack_int_16 + (int16_t *packed, /* output data array - packed */ + int32_t *data, /* input data array */ + int ns, /* desired number of samples to pack */ + int max_bytes, /* max # of bytes for output buffer */ + int pad, /* flag to specify padding to max_bytes */ + int *pnbytes, /* number of bytes actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; /* number of samples remaining to pack */ + int i = 0; + + while (points_remaining > 0 && max_bytes >= 2) + { /* Pack the next available data into INT_16 format */ + if ( data[i] < -32768 || data[i] > 32767 ) + ms_log (2, "msr_pack_int_16(%s): input sample out of range: %d\n", + PACK_SRCNAME, data[i]); + + *packed = data[i]; + if ( swapflag ) ms_gswap2 (packed); + + packed++; + max_bytes -= 2; + points_remaining--; + i++; + } + + *pnbytes = (ns - points_remaining) * 2; + + /* Pad miniSEED block if necessary */ + if (pad) + { + memset ((void *)packed, 0, max_bytes); + *pnbytes += max_bytes; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * msr_pack_int_32: * + * Pack integer data into INT_32 format. * + * Return: 0 on success, -1 on failure. * + ************************************************************************/ +int msr_pack_int_32 + (int32_t *packed, /* output data array - packed */ + int32_t *data, /* input data array - unpacked */ + int ns, /* desired number of samples to pack */ + int max_bytes, /* max # of bytes for output buffer */ + int pad, /* flag to specify padding to max_bytes */ + int *pnbytes, /* number of bytes actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; /* number of samples remaining to pack */ + int i = 0; + + while (points_remaining > 0 && max_bytes >= 4) + { /* Pack the next available data into INT_32 format */ + *packed = data[i]; + if ( swapflag ) ms_gswap4 (packed); + + packed++; + max_bytes -= 4; + points_remaining--; + i++; + } + + *pnbytes = (ns - points_remaining) * 4; + + /* Pad miniSEED block if necessary */ + if (pad) + { + memset ((void *)packed, 0, max_bytes); + *pnbytes += max_bytes; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * msr_pack_float_32: * + * Pack float data into FLOAT32 format. * + * Return: 0 on success, -1 on error. * + ************************************************************************/ +int msr_pack_float_32 + (float *packed, /* output data array - packed */ + float *data, /* input data array - unpacked */ + int ns, /* desired number of samples to pack */ + int max_bytes, /* max # of bytes for output buffer */ + int pad, /* flag to specify padding to max_bytes */ + int *pnbytes, /* number of bytes actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; /* number of samples remaining to pack */ + int i = 0; + + while (points_remaining > 0 && max_bytes >= 4) + { + *packed = data[i]; + if ( swapflag ) ms_gswap4 (packed); + + packed++; + max_bytes -= 4; + points_remaining--; + i++; + } + + *pnbytes = (ns - points_remaining) * 4; + + /* Pad miniSEED block if necessary */ + if (pad) + { + memset ((void *)packed, 0, max_bytes); + *pnbytes += max_bytes; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * msr_pack_float_64: * + * Pack double data into FLOAT64 format. * + * Return: 0 on success, -1 on error. * + ************************************************************************/ +int msr_pack_float_64 + (double *packed, /* output data array - packed */ + double *data, /* input data array - unpacked */ + int ns, /* desired number of samples to pack */ + int max_bytes, /* max # of bytes for output buffer */ + int pad, /* flag to specify padding to max_bytes */ + int *pnbytes, /* number of bytes actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; /* number of samples remaining to pack */ + int i = 0; + + while (points_remaining > 0 && max_bytes >= 8) + { + *packed = data[i]; + if ( swapflag ) ms_gswap8 (packed); + + packed++; + max_bytes -= 8; + points_remaining--; + i++; + } + + *pnbytes = (ns - points_remaining) * 8; + + /* Pad miniSEED block if necessary */ + if (pad) + { + memset ((void *)packed, 0, max_bytes); + *pnbytes += max_bytes; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * msr_pack_steim1: * + * Pack data into STEIM1 data frames. * + * return: * + * 0 on success. * + * -1 on error. * + ************************************************************************/ +int msr_pack_steim1 + (DFRAMES *dframes, /* ptr to data frames */ + int32_t *data, /* ptr to unpacked data array */ + int32_t d0, /* first difference value */ + int ns, /* number of samples to pack */ + int nf, /* total number of data frames */ + int pad, /* flag to specify padding to nf */ + int *pnframes, /* number of frames actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; + int points_packed = 0; + int32_t diff[4]; /* array of differences */ + uint8_t minbits[4]; /* array of minimum bits for diffs */ + int i, j; + int mask; + int ipt = 0; /* index of initial data to pack. */ + int fn = 0; /* index of initial frame to pack. */ + int wn = 2; /* index of initial word to pack. */ + int32_t itmp; + int16_t stmp; + + /* Calculate initial difference and minbits buffers */ + diff[0] = d0; + MINBITS(diff[0],minbits[0]); + for (i=1; i < 4 && i < ns; i++) + { + diff[i] = data[i] - data[i-1]; + MINBITS(diff[i],minbits[i]); + } + + dframes->f[fn].ctrl = 0; + + /* Set X0 and XN values in first frame */ + X0 = data[0]; + if ( swapflag ) ms_gswap4 (&X0); + dframes->f[0].ctrl = (dframes->f[0].ctrl<<2) | STEIM1_SPECIAL_MASK; + XN = data[ns-1]; + if ( swapflag ) ms_gswap4 (&XN); + dframes->f[0].ctrl = (dframes->f[0].ctrl<<2) | STEIM1_SPECIAL_MASK; + + while (points_remaining > 0) + { + points_packed = 0; + + /* Pack the next available data into the most compact form */ + if (BYTEPACK(0,points_remaining)) + { + mask = STEIM1_BYTE_MASK; + for (j=0; j<4; j++) { dframes->f[fn].w[wn].byte[j] = diff[j]; } + points_packed = 4; + } + else if (HALFPACK(0,points_remaining)) + { + mask = STEIM1_HALFWORD_MASK; + for (j=0; j<2; j++) + { + stmp = diff[j]; + if ( swapflag ) ms_gswap2 (&stmp); + dframes->f[fn].w[wn].hw[j] = stmp; + } + points_packed = 2; + } + else + { + mask = STEIM1_FULLWORD_MASK; + itmp = diff[0]; + if ( swapflag ) ms_gswap4 (&itmp); + dframes->f[fn].w[wn].fw = itmp; + points_packed = 1; + } + + /* Append mask for this word to current mask */ + dframes->f[fn].ctrl = (dframes->f[fn].ctrl<<2) | mask; + + points_remaining -= points_packed; + ipt += points_packed; + + /* Check for full frame or full block */ + if (++wn >= VALS_PER_FRAME) + { + if ( swapflag ) ms_gswap4 (&dframes->f[fn].ctrl); + /* Reset output index to beginning of frame */ + wn = 0; + /* If block is full, output block and reinitialize */ + if (++fn >= nf) break; + dframes->f[fn].ctrl = 0; + } + + /* Shift and re-fill difference and minbits buffers */ + for ( i=points_packed; i < 4; i++ ) + { + /* Shift remaining buffer entries */ + diff[i-points_packed] = diff[i]; + minbits[i-points_packed] = minbits[i]; + } + for ( i=4-points_packed,j=ipt+(4-points_packed); i < 4 && j < ns; i++,j++ ) + { + /* Re-fill entries */ + diff[i] = data[j] - data[j-1]; + MINBITS(diff[i],minbits[i]); + } + } + + /* Update XN value in first frame */ + XN = data[(ns-1)-points_remaining]; + if ( swapflag ) ms_gswap4 (&XN); + + /* End of data. Pad current frame and optionally rest of block */ + /* Do not pad and output a completely empty block */ + if ( ! EMPTY_BLOCK(fn,wn) ) + { + *pnframes = pad_steim_frame (dframes, fn, wn, nf, swapflag, pad); + } + else + { + *pnframes = 0; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * msr_pack_steim2: * + * Pack data into STEIM1 data frames. * + * return: * + * 0 on success. * + * -1 on error. * + ************************************************************************/ +int msr_pack_steim2 + (DFRAMES *dframes, /* ptr to data frames */ + int32_t *data, /* ptr to unpacked data array */ + int32_t d0, /* first difference value */ + int ns, /* number of samples to pack */ + int nf, /* total number of data frames to pack */ + int pad, /* flag to specify padding to nf */ + int *pnframes, /* number of frames actually packed */ + int *pnsamples, /* number of samples actually packed */ + int swapflag) /* if data should be swapped */ +{ + int points_remaining = ns; + int points_packed = 0; + int32_t diff[7]; /* array of differences */ + uint8_t minbits[7]; /* array of minimum bits for diffs */ + int i, j; + int mask; + int ipt = 0; /* index of initial data to pack. */ + int fn = 0; /* index of initial frame to pack. */ + int wn = 2; /* index of initial word to pack. */ + + /* Calculate initial difference and minbits buffers */ + diff[0] = d0; + MINBITS(diff[0],minbits[0]); + for (i=1; i < 7 && i < ns; i++) + { + diff[i] = data[i] - data[i-1]; + MINBITS(diff[i],minbits[i]); + } + + dframes->f[fn].ctrl = 0; + + /* Set X0 and XN values in first frame */ + X0 = data[0]; + if ( swapflag ) ms_gswap4 (&X0); + dframes->f[0].ctrl = (dframes->f[0].ctrl<<2) | STEIM2_SPECIAL_MASK; + XN = data[ns-1]; + if ( swapflag ) ms_gswap4 (&XN); + dframes->f[0].ctrl = (dframes->f[0].ctrl<<2) | STEIM2_SPECIAL_MASK; + + while (points_remaining > 0) + { + points_packed = 0; + + /* Pack the next available datapoints into the most compact form */ + if (BIT4PACK(0,points_remaining)) + { + PACK(4,7,0x0000000f,02) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_567_MASK; + points_packed = 7; + } + else if (BIT5PACK(0,points_remaining)) + { + PACK(5,6,0x0000001f,01) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_567_MASK; + points_packed = 6; + } + else if (BIT6PACK(0,points_remaining)) + { + PACK(6,5,0x0000003f,00) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_567_MASK; + points_packed = 5; + } + else if (BYTEPACK(0,points_remaining)) + { + mask = STEIM2_BYTE_MASK; + for (j=0; j<4; j++) dframes->f[fn].w[wn].byte[j] = diff[j]; + points_packed = 4; + } + else if (BIT10PACK(0,points_remaining)) + { + PACK(10,3,0x000003ff,03) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_123_MASK; + points_packed = 3; + } + else if (BIT15PACK(0,points_remaining)) + { + PACK(15,2,0x00007fff,02) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_123_MASK; + points_packed = 2; + } + else if (BIT30PACK(0,points_remaining)) + { + PACK(30,1,0x3fffffff,01) + if ( swapflag ) ms_gswap4 (&dframes->f[fn].w[wn].fw); + mask = STEIM2_123_MASK; + points_packed = 1; + } + else + { + ms_log (2, "msr_pack_steim2(%s): Unable to represent difference in <= 30 bits\n", + PACK_SRCNAME); + return -1; + } + + /* Append mask for this word to current mask */ + dframes->f[fn].ctrl = (dframes->f[fn].ctrl<<2) | mask; + + points_remaining -= points_packed; + ipt += points_packed; + + /* Check for full frame or full block */ + if (++wn >= VALS_PER_FRAME) + { + if ( swapflag ) ms_gswap4 (&dframes->f[fn].ctrl); + /* Reset output index to beginning of frame */ + wn = 0; + /* If block is full, output block and reinitialize */ + if (++fn >= nf) break; + dframes->f[fn].ctrl = 0; + } + + /* Shift and re-fill difference and minbits buffers */ + for ( i=points_packed; i < 7; i++ ) + { + /* Shift remaining buffer entries */ + diff[i-points_packed] = diff[i]; + minbits[i-points_packed] = minbits[i]; + } + for ( i=7-points_packed,j=ipt+(7-points_packed); i < 7 && j < ns; i++,j++ ) + { + /* Re-fill entries */ + diff[i] = data[j] - data[j-1]; + MINBITS(diff[i],minbits[i]); + } + } + + /* Update XN value in first frame */ + XN = data[(ns-1)-points_remaining]; + if ( swapflag ) ms_gswap4 (&XN); + + /* End of data. Pad current frame and optionally rest of block */ + /* Do not pad and output a completely empty block */ + if ( ! EMPTY_BLOCK(fn,wn) ) + { + *pnframes = pad_steim_frame (dframes, fn, wn, nf, swapflag, pad); + } + else + { + *pnframes = 0; + } + + *pnsamples = ns - points_remaining; + + return 0; +} + + +/************************************************************************ + * pad_steim_frame: * + * Pad the rest of the data record with null values, * + * and optionally the rest of the total number of frames. * + * return: * + * total number of frames in record. * + ************************************************************************/ +static int pad_steim_frame + (DFRAMES *dframes, + int fn, /* current frame number. */ + int wn, /* current work number. */ + int nf, /* total number of data frames. */ + int swapflag, /* flag to swap byte order of data. */ + int pad) /* flag to pad # frames to nf. */ +{ + /* Finish off the current frame */ + if (wn < VALS_PER_FRAME && fn < nf) + { + for (; wn < VALS_PER_FRAME; wn++) + { + dframes->f[fn].w[wn].fw = 0; + dframes->f[fn].ctrl = (dframes->f[fn].ctrl<<2) | STEIM1_SPECIAL_MASK; + } + if ( swapflag ) ms_gswap4 (&dframes->f[fn].ctrl); + fn++; + } + + /* Fill the remaining frames in the block */ + if (pad) + { + for (; fnf[fn].ctrl = STEIM1_SPECIAL_MASK; /* mask for ctrl */ + for (wn=0; wnf[fn].w[wn].fw = 0; + dframes->f[fn].ctrl = (dframes->f[fn].ctrl<<2) | STEIM1_SPECIAL_MASK; + } + + if ( swapflag ) ms_gswap4 (&dframes->f[fn].ctrl); + } + } + + return fn; +} + + +/************************************************************************ + * msr_pack_text: * + * Pack text data into text format. Split input data on line * +* breaks so as to not split lines between records. * +* Return: 0 on success, -1 on error. * + ************************************************************************/ +int msr_pack_text + (char *packed, /* output data array - packed. */ + char *data, /* input data array - unpacked. */ + int ns, /* desired number of samples to pack. */ + int max_bytes, /* max # of bytes for output buffer. */ + int pad, /* flag to specify padding to max_bytes.*/ + int *pnbytes, /* number of bytes actually packed. */ + int *pnsamples) /* number of samples actually packed. */ +{ + int points_remaining = ns; /* number of samples remaining to pack. */ + int last = -1; + int nbytes; + int i; + + /* Split lines only if a single line will not fit in 1 record */ + if (points_remaining > max_bytes) + { + /* Look for the last newline that will fit in output buffer */ + for (i=max_bytes-1; i>=0; i--) + { + if (data[i] == '\n') { + last = i; + break; + } + } + if (last < 0) last = max_bytes - 1; + } + + if (last < 0) last = points_remaining - 1; + nbytes = last + 1; + memcpy (packed, data, nbytes); + packed += nbytes; + max_bytes -= nbytes; + *pnbytes = nbytes; + *pnsamples = nbytes; + points_remaining -= nbytes; + + /* Pad miniSEED block if necessary */ + if (pad) + { + memset ((void *)packed, 0, max_bytes); + *pnbytes += max_bytes; + } + + *pnsamples = ns - points_remaining; + + return 0; +} diff --git a/libs/3rd-party/mseed/packdata.h b/libs/3rd-party/mseed/packdata.h new file mode 100644 index 0000000..3247218 --- /dev/null +++ b/libs/3rd-party/mseed/packdata.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * packdata.h: + * + * Interface declarations for the Mini-SEED packing routines in + * packdata.c + * + * modified: 2008.220 + ***************************************************************************/ + + +#ifndef PACKDATA_H +#define PACKDATA_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "steimdata.h" + +/* Pointer to srcname of record being packed, declared in pack.c */ +extern char *PACK_SRCNAME; + +extern int msr_pack_int_16 (int16_t*, int32_t*, int, int, int, int*, int*, int); +extern int msr_pack_int_32 (int32_t*, int32_t*, int, int, int, int*, int*, int); +extern int msr_pack_float_32 (float*, float*, int, int, int, int*, int*, int); +extern int msr_pack_float_64 (double*, double*, int, int, int, int*, int*, int); +extern int msr_pack_steim1 (DFRAMES*, int32_t*, int32_t, int, int, int, int*, int*, int); +extern int msr_pack_steim2 (DFRAMES*, int32_t*, int32_t, int, int, int, int*, int*, int); +extern int msr_pack_text (char *, char *, int, int, int, int*, int*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/3rd-party/mseed/parseutils.c b/libs/3rd-party/mseed/parseutils.c new file mode 100644 index 0000000..e89f2de --- /dev/null +++ b/libs/3rd-party/mseed/parseutils.c @@ -0,0 +1,1163 @@ +/*************************************************************************** + * + * Routines to parse Mini-SEED. + * + * Written by Chad Trabant + * IRIS Data Management Center + * + * modified: 2013.050 + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include "libmseed.h" + + +/********************************************************************** + * msr_parse: + * + * This routine will attempt to parse (detect and unpack) a Mini-SEED + * record from a specified memory buffer and populate a supplied + * MSRecord structure. + * + * If reclen is less than or equal to 0 the length of record is + * automatically detected otherwise reclen should be the correct + * record length. + * + * For auto detection of record length the record should include a + * 1000 blockette or be followed by another record header in the + * buffer. + * + * dataflag will be passed directly to msr_unpack(). + * + * Return values: + * 0 : Success, populates the supplied MSRecord. + * >0 : Data record detected but not enough data is present, the + * return value is a hint of how many more bytes are needed. + * <0 : libmseed error code (listed in libmseed.h) is returned. + *********************************************************************/ +int +msr_parse ( char *record, int recbuflen, MSRecord **ppmsr, int reclen, + flag dataflag, flag verbose ) +{ + int detlen = 0; + int retcode = 0; + + if ( ! ppmsr ) + return MS_GENERROR; + + if ( ! record ) + return MS_GENERROR; + + /* Sanity check: record length cannot be larger than buffer */ + if ( reclen > 0 && reclen > recbuflen ) + { + ms_log (2, "ms_parse() Record length (%d) cannot be larger than buffer (%d)\n", + reclen, recbuflen); + return MS_GENERROR; + } + + /* Autodetect the record length */ + if ( reclen <= 0 ) + { + detlen = ms_detect (record, recbuflen); + + /* No data record detected */ + if ( detlen < 0 ) + { + return MS_NOTSEED; + } + + /* Found record but could not determine length */ + if ( detlen == 0 ) + { + return MINRECLEN; + } + + if ( verbose > 2 ) + { + ms_log (1, "Detected record length of %d bytes\n", detlen); + } + + reclen = detlen; + } + + /* Check that record length is in supported range */ + if ( reclen < MINRECLEN || reclen > MAXRECLEN ) + { + ms_log (2, "Record length is out of range: %d (allowed: %d to %d)\n", + reclen, MINRECLEN, MAXRECLEN); + + return MS_OUTOFRANGE; + } + + /* Check if more data is required, return hint */ + if ( reclen > recbuflen ) + { + if ( verbose > 2 ) + ms_log (1, "Detected %d byte record, need %d more bytes\n", + reclen, (reclen - recbuflen)); + + return (reclen - recbuflen); + } + + /* Unpack record */ + if ( (retcode = msr_unpack (record, reclen, ppmsr, dataflag, verbose)) != MS_NOERROR ) + { + msr_free (ppmsr); + + return retcode; + } + + return MS_NOERROR; +} /* End of msr_parse() */ + + +/********************************************************************** + * msr_parse_selection: + * + * This routine wraps msr_parse() to parse and return the first record + * from a memory buffer that matches optional Selections. If the + * selections pointer is NULL the effect is to search the buffer for + * the first parsable record. + * + * The offset value specifies the starting offset in the buffer and, + * on success, the offset in the buffer to record parsed. + * + * The caller should manage the value of the offset in two ways: + * + * 1) on subsequent calls after a record has been parsed the caller + * should increment the offset by the record length returned or + * properly manipulate the record buffer pointer, buffer length and + * offset to the same effect. + * + * 2) when the end of the buffer is reached MS_GENERROR (-1) is + * returned, the caller should check the offset value against the + * record buffer length to determine when the entire buffer has been + * searched. + * + * Return values: same as msr_parse() except that MS_GENERROR is + * returned when end-of-buffer is reached. + *********************************************************************/ +int +msr_parse_selection ( char *recbuf, int recbuflen, int64_t *offset, + MSRecord **ppmsr, int reclen, + Selections *selections, flag dataflag, flag verbose ) +{ + int retval = MS_GENERROR; + int unpackretval; + flag dataswapflag = 0; + flag bigendianhost = ms_bigendianhost(); + + if ( ! ppmsr ) + return MS_GENERROR; + + if ( ! recbuf ) + return MS_GENERROR; + + if ( ! offset ) + return MS_GENERROR; + + while ( *offset < recbuflen ) + { + retval = msr_parse (recbuf+*offset, recbuflen-*offset, ppmsr, reclen, 0, verbose); + + if ( retval ) + { + if ( verbose ) + ms_log (2, "Error parsing record at offset %lld\n", *offset); + + *offset += MINRECLEN; + } + else + { + if ( selections && ! msr_matchselect (selections, *ppmsr, NULL) ) + { + *offset += (*ppmsr)->reclen; + retval = MS_GENERROR; + } + else + { + if ( dataflag ) + { + /* If BE host and LE data need swapping */ + if ( bigendianhost && (*ppmsr)->byteorder == 0 ) + dataswapflag = 1; + /* If LE host and BE data (or bad byte order value) need swapping */ + else if ( !bigendianhost && (*ppmsr)->byteorder > 0 ) + dataswapflag = 1; + + unpackretval = msr_unpack_data (*ppmsr, dataswapflag, verbose); + + if ( unpackretval < 0 ) + return unpackretval; + else + (*ppmsr)->numsamples = unpackretval; + } + + break; + } + } + } + + return retval; +} /* End of msr_parse_selection() */ + + +/******************************************************************** + * ms_detect: + * + * Determine SEED data record length with the following steps: + * + * 1) determine that the buffer contains a SEED data record by + * verifying known signatures (fields with known limited values) + * + * 2) search the record up to recbuflen bytes for a 1000 blockette. + * + * 3) If no blockette 1000 is found search at MINRECLEN-byte offsets + * for the fixed section of the next header or blank/noise record, + * thereby implying the record length. + * + * Returns: + * -1 : data record not detected or error + * 0 : data record detected but could not determine length + * >0 : size of the record in bytes + *********************************************************************/ +int +ms_detect ( const char *record, int recbuflen ) +{ + uint16_t blkt_offset; /* Byte offset for next blockette */ + uint8_t swapflag = 0; /* Byte swapping flag */ + uint8_t foundlen = 0; /* Found record length */ + int32_t reclen = -1; /* Size of record in bytes */ + + uint16_t blkt_type; + uint16_t next_blkt; + + struct fsdh_s *fsdh; + struct blkt_1000_s *blkt_1000; + const char *nextfsdh; + + /* Buffer must be at least 48 bytes (the fixed section) */ + if ( recbuflen < 48 ) + return -1; + + /* Check for valid fixed section of header */ + if ( ! MS_ISVALIDHEADER(record) ) + return -1; + + fsdh = (struct fsdh_s *) record; + + /* Check to see if byte swapping is needed by checking for sane year and day */ + if ( ! MS_ISVALIDYEARDAY(fsdh->start_time.year, fsdh->start_time.day) ) + swapflag = 1; + + blkt_offset = fsdh->blockette_offset; + + /* Swap order of blkt_offset if needed */ + if ( swapflag ) ms_gswap2 (&blkt_offset); + + /* Loop through blockettes as long as number is non-zero and viable */ + while ( blkt_offset != 0 && + blkt_offset <= recbuflen ) + { + memcpy (&blkt_type, record + blkt_offset, 2); + memcpy (&next_blkt, record + blkt_offset + 2, 2); + + if ( swapflag ) + { + ms_gswap2 (&blkt_type); + ms_gswap2 (&next_blkt); + } + + /* Found a 1000 blockette, not truncated */ + if ( blkt_type == 1000 && + (int)(blkt_offset + 4 + sizeof(struct blkt_1000_s)) <= recbuflen ) + { + blkt_1000 = (struct blkt_1000_s *) (record + blkt_offset + 4); + + foundlen = 1; + + /* Calculate record size in bytes as 2^(blkt_1000->reclen) */ + reclen = (unsigned int) 1 << blkt_1000->reclen; + + break; + } + + /* Saftey check for invalid offset */ + if ( next_blkt != 0 && next_blkt < blkt_offset ) + { + ms_log (2, "Invalid blockette offset (%d) less than current offset (%d)\n", + next_blkt, blkt_offset); + return -1; + } + + blkt_offset = next_blkt; + } + + /* If record length was not determined by a 1000 blockette scan the buffer + * and search for the next record */ + if ( reclen == -1 ) + { + nextfsdh = record + MINRECLEN; + + /* Check for record header or blank/noise record at MINRECLEN byte offsets */ + while ( ((nextfsdh - record) + 48) < recbuflen ) + { + if ( MS_ISVALIDHEADER(nextfsdh) || MS_ISVALIDBLANK(nextfsdh) ) + { + foundlen = 1; + reclen = nextfsdh - record; + break; + } + + nextfsdh += MINRECLEN; + } + } + + if ( ! foundlen ) + return 0; + else + return reclen; +} /* End of ms_detect() */ + + +/*************************************************************************** + * ms_parse_raw: + * + * Parse and verify a SEED data record header (fixed section and + * blockettes) at the lowest level, printing error messages for + * invalid header values and optionally print raw header values. The + * memory at 'record' is assumed to be a Mini-SEED record. Not every + * possible test is performed, common errors and those causing + * libmseed parsing to fail should be detected. + * + * The 'details' argument is interpreted as follows: + * + * details: + * 0 = only print error messages for invalid header fields + * 1 = print basic fields in addition to invalid field errors + * 2 = print all fields in addition to invalid field errors + * + * The 'swapflag' argument is interpreted as follows: + * + * swapflag: + * 1 = swap multibyte quantities + * 0 = do no swapping + * -1 = autodetect byte order using year test, swap if needed + * + * Any byte swapping performed by this routine is applied directly to + * the memory reference by the record pointer. + * + * This routine is primarily intended to diagnose invalid Mini-SEED headers. + * + * Returns 0 when no errors were detected or a positive count of + * errors detected. + ***************************************************************************/ +int +ms_parse_raw ( char *record, int maxreclen, flag details, flag swapflag ) +{ + struct fsdh_s *fsdh; + double nomsamprate; + char srcname[50]; + char *X; + char b; + int retval = 0; + int b1000encoding = -1; + int b1000reclen = -1; + int endofblockettes = -1; + int idx; + + if ( ! record ) + return 1; + + /* Generate a source name string */ + srcname[0] = '\0'; + ms_recsrcname (record, srcname, 1); + + fsdh = (struct fsdh_s *) record; + + /* Check to see if byte swapping is needed by testing the year and day */ + if ( swapflag == -1 && ! MS_ISVALIDYEARDAY(fsdh->start_time.year, fsdh->start_time.day) ) + swapflag = 1; + else + swapflag = 0; + + if ( details > 1 ) + { + if ( swapflag == 1 ) + ms_log (0, "Swapping multi-byte quantities in header\n"); + else + ms_log (0, "Not swapping multi-byte quantities in header\n"); + } + + /* Swap byte order */ + if ( swapflag ) + { + MS_SWAPBTIME (&fsdh->start_time); + ms_gswap2a (&fsdh->numsamples); + ms_gswap2a (&fsdh->samprate_fact); + ms_gswap2a (&fsdh->samprate_mult); + ms_gswap4a (&fsdh->time_correct); + ms_gswap2a (&fsdh->data_offset); + ms_gswap2a (&fsdh->blockette_offset); + } + + /* Validate fixed section header fields */ + X = record; /* Pointer of convenience */ + + /* Check record sequence number, 6 ASCII digits */ + if ( ! isdigit((unsigned char) *(X)) || ! isdigit ((unsigned char) *(X+1)) || + ! isdigit((unsigned char) *(X+2)) || ! isdigit ((unsigned char) *(X+3)) || + ! isdigit((unsigned char) *(X+4)) || ! isdigit ((unsigned char) *(X+5)) ) + { + ms_log (2, "%s: Invalid sequence number: '%c%c%c%c%c%c'\n", srcname, X, X+1, X+2, X+3, X+4, X+5); + retval++; + } + + /* Check header/quality indicator */ + if ( ! MS_ISDATAINDICATOR(*(X+6)) ) + { + ms_log (2, "%s: Invalid header indicator (DRQM): '%c'\n", srcname, X+6); + retval++; + } + + /* Check reserved byte, space or NULL */ + if ( ! (*(X+7) == ' ' || *(X+7) == '\0') ) + { + ms_log (2, "%s: Invalid fixed section reserved byte (Space): '%c'\n", srcname, X+7); + retval++; + } + + /* Check station code, 5 alphanumerics or spaces */ + if ( ! (isalnum((unsigned char) *(X+8)) || *(X+8) == ' ') || + ! (isalnum((unsigned char) *(X+9)) || *(X+9) == ' ') || + ! (isalnum((unsigned char) *(X+10)) || *(X+10) == ' ') || + ! (isalnum((unsigned char) *(X+11)) || *(X+11) == ' ') || + ! (isalnum((unsigned char) *(X+12)) || *(X+12) == ' ') ) + { + ms_log (2, "%s: Invalid station code: '%c%c%c%c%c'\n", srcname, X+8, X+9, X+10, X+11, X+12); + retval++; + } + + /* Check location ID, 2 alphanumerics or spaces */ + if ( ! (isalnum((unsigned char) *(X+13)) || *(X+13) == ' ') || + ! (isalnum((unsigned char) *(X+14)) || *(X+14) == ' ') ) + { + ms_log (2, "%s: Invalid location ID: '%c%c'\n", srcname, X+13, X+14); + retval++; + } + + /* Check channel codes, 3 alphanumerics or spaces */ + if ( ! (isalnum((unsigned char) *(X+15)) || *(X+15) == ' ') || + ! (isalnum((unsigned char) *(X+16)) || *(X+16) == ' ') || + ! (isalnum((unsigned char) *(X+17)) || *(X+17) == ' ') ) + { + ms_log (2, "%s: Invalid channel codes: '%c%c%c'\n", srcname, X+15, X+16, X+17); + retval++; + } + + /* Check network code, 2 alphanumerics or spaces */ + if ( ! (isalnum((unsigned char) *(X+18)) || *(X+18) == ' ') || + ! (isalnum((unsigned char) *(X+19)) || *(X+19) == ' ') ) + { + ms_log (2, "%s: Invalid network code: '%c%c'\n", srcname, X+18, X+19); + retval++; + } + + /* Check start time fields */ + if ( fsdh->start_time.year < 1900 || fsdh->start_time.year > 2100 ) + { + ms_log (2, "%s: Unlikely start year (1900-2100): '%d'\n", srcname, fsdh->start_time.year); + retval++; + } + if ( fsdh->start_time.day < 1 || fsdh->start_time.day > 366 ) + { + ms_log (2, "%s: Invalid start day (1-366): '%d'\n", srcname, fsdh->start_time.day); + retval++; + } + if ( fsdh->start_time.hour > 23 ) + { + ms_log (2, "%s: Invalid start hour (0-23): '%d'\n", srcname, fsdh->start_time.hour); + retval++; + } + if ( fsdh->start_time.min > 59 ) + { + ms_log (2, "%s: Invalid start minute (0-59): '%d'\n", srcname, fsdh->start_time.min); + retval++; + } + if ( fsdh->start_time.sec > 60 ) + { + ms_log (2, "%s: Invalid start second (0-60): '%d'\n", srcname, fsdh->start_time.sec); + retval++; + } + if ( fsdh->start_time.fract > 9999 ) + { + ms_log (2, "%s: Invalid start fractional seconds (0-9999): '%d'\n", srcname, fsdh->start_time.fract); + retval++; + } + + /* Check number of samples, max samples in 4096-byte Steim-2 encoded record: 6601 */ + if ( fsdh->numsamples > 20000 ) + { + ms_log (2, "%s: Unlikely number of samples (>20000): '%d'\n", srcname, fsdh->numsamples); + retval++; + } + + /* Sanity check that there is space for blockettes when both data and blockettes are present */ + if ( fsdh->numsamples > 0 && fsdh->numblockettes > 0 && fsdh->data_offset <= fsdh->blockette_offset ) + { + ms_log (2, "%s: No space for %d blockettes, data offset: %d, blockette offset: %d\n", srcname, + fsdh->numblockettes, fsdh->data_offset, fsdh->blockette_offset); + retval++; + } + + + /* Print raw header details */ + if ( details >= 1 ) + { + /* Determine nominal sample rate */ + nomsamprate = ms_nomsamprate (fsdh->samprate_fact, fsdh->samprate_mult); + + /* Print header values */ + ms_log (0, "RECORD -- %s\n", srcname); + ms_log (0, " sequence number: '%c%c%c%c%c%c'\n", fsdh->sequence_number[0], fsdh->sequence_number[1], fsdh->sequence_number[2], + fsdh->sequence_number[3], fsdh->sequence_number[4], fsdh->sequence_number[5]); + ms_log (0, " data quality indicator: '%c'\n", fsdh->dataquality); + if ( details > 0 ) + ms_log (0, " reserved: '%c'\n", fsdh->reserved); + ms_log (0, " station code: '%c%c%c%c%c'\n", fsdh->station[0], fsdh->station[1], fsdh->station[2], fsdh->station[3], fsdh->station[4]); + ms_log (0, " location ID: '%c%c'\n", fsdh->location[0], fsdh->location[1]); + ms_log (0, " channel codes: '%c%c%c'\n", fsdh->channel[0], fsdh->channel[1], fsdh->channel[2]); + ms_log (0, " network code: '%c%c'\n", fsdh->network[0], fsdh->network[1]); + ms_log (0, " start time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", fsdh->start_time.year, fsdh->start_time.day, + fsdh->start_time.hour, fsdh->start_time.min, fsdh->start_time.sec, fsdh->start_time.fract, fsdh->start_time.unused); + ms_log (0, " number of samples: %d\n", fsdh->numsamples); + ms_log (0, " sample rate factor: %d (%.10g samples per second)\n", + fsdh->samprate_fact, nomsamprate); + ms_log (0, " sample rate multiplier: %d\n", fsdh->samprate_mult); + + /* Print flag details if requested */ + if ( details > 1 ) + { + /* Activity flags */ + b = fsdh->act_flags; + ms_log (0, " activity flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Calibration signals present\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Time correction applied\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Beginning of an event, station trigger\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] End of an event, station detrigger\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] A positive leap second happened in this record\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] A negative leap second happened in this record\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] Event in progress\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Undefined bit set\n"); + + /* I/O and clock flags */ + b = fsdh->io_flags; + ms_log (0, " I/O and clock flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Station volume parity error possibly present\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Long record read (possibly no problem)\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Short record read (record padded)\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Start of time series\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] End of time series\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Clock locked\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] Undefined bit set\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Undefined bit set\n"); + + /* Data quality flags */ + b = fsdh->dq_flags; + ms_log (0, " data quality flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] Amplifier saturation detected\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Digitizer clipping detected\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Spikes detected\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Glitches detected\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Missing/padded data present\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Telemetry synchronization error\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] A digital filter may be charging\n"); + if ( b & 0x80 ) ms_log (0, " [Bit 7] Time tag is questionable\n"); + } + + ms_log (0, " number of blockettes: %d\n", fsdh->numblockettes); + ms_log (0, " time correction: %ld\n", (long int) fsdh->time_correct); + ms_log (0, " data offset: %d\n", fsdh->data_offset); + ms_log (0, " first blockette offset: %d\n", fsdh->blockette_offset); + } /* Done printing raw header details */ + + + /* Validate and report information in the blockette chain */ + if ( fsdh->blockette_offset > 46 && fsdh->blockette_offset < maxreclen ) + { + int blkt_offset = fsdh->blockette_offset; + int blkt_count = 0; + int blkt_length; + uint16_t blkt_type; + uint16_t next_blkt; + char *blkt_desc; + + /* Traverse blockette chain */ + while ( blkt_offset != 0 && blkt_offset < maxreclen ) + { + /* Every blockette has a similar 4 byte header: type and next */ + memcpy (&blkt_type, record + blkt_offset, 2); + memcpy (&next_blkt, record + blkt_offset+2, 2); + + if ( swapflag ) + { + ms_gswap2 (&blkt_type); + ms_gswap2 (&next_blkt); + } + + /* Print common header fields */ + if ( details >= 1 ) + { + blkt_desc = ms_blktdesc(blkt_type); + ms_log (0, " BLOCKETTE %u: (%s)\n", blkt_type, (blkt_desc) ? blkt_desc : "Unknown"); + ms_log (0, " next blockette: %u\n", next_blkt); + } + + blkt_length = ms_blktlen (blkt_type, record + blkt_offset, swapflag); + if ( blkt_length == 0 ) + { + ms_log (2, "%s: Unknown blockette length for type %d\n", srcname, blkt_type); + retval++; + } + + /* Track end of blockette chain */ + endofblockettes = blkt_offset + blkt_length - 1; + + /* Sanity check that the blockette is contained in the record */ + if ( endofblockettes > maxreclen ) + { + ms_log (2, "%s: Blockette type %d at offset %d with length %d does not fix in record (%d)\n", + srcname, blkt_type, blkt_offset, blkt_length, maxreclen); + retval++; + break; + } + + if ( blkt_type == 100 ) + { + struct blkt_100_s *blkt_100 = (struct blkt_100_s *) (record + blkt_offset + 4); + + if ( swapflag ) + ms_gswap4 (&blkt_100->samprate); + + if ( details >= 1 ) + { + ms_log (0, " actual sample rate: %.10g\n", blkt_100->samprate); + + if ( details > 1 ) + { + b = blkt_100->flags; + ms_log (0, " undefined flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + + ms_log (0, " reserved bytes (3): %u,%u,%u\n", + blkt_100->reserved[0], blkt_100->reserved[1], blkt_100->reserved[2]); + } + } + } + + else if ( blkt_type == 200 ) + { + struct blkt_200_s *blkt_200 = (struct blkt_200_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + ms_gswap4 (&blkt_200->amplitude); + ms_gswap4 (&blkt_200->period); + ms_gswap4 (&blkt_200->background_estimate); + MS_SWAPBTIME (&blkt_200->time); + } + + if ( details >= 1 ) + { + ms_log (0, " signal amplitude: %g\n", blkt_200->amplitude); + ms_log (0, " signal period: %g\n", blkt_200->period); + ms_log (0, " background estimate: %g\n", blkt_200->background_estimate); + + if ( details > 1 ) + { + b = blkt_200->flags; + ms_log (0, " event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Dilatation wave\n"); + else ms_log (0, " [Bit 0] 0: Compression wave\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] 1: Units after deconvolution\n"); + else ms_log (0, " [Bit 1] 0: Units are digital counts\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Bit 0 is undetermined\n"); + ms_log (0, " reserved byte: %u\n", blkt_200->reserved); + } + + ms_log (0, " signal onset time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_200->time.year, blkt_200->time.day, + blkt_200->time.hour, blkt_200->time.min, blkt_200->time.sec, blkt_200->time.fract, blkt_200->time.unused); + ms_log (0, " detector name: %.24s\n", blkt_200->detector); + } + } + + else if ( blkt_type == 201 ) + { + struct blkt_201_s *blkt_201 = (struct blkt_201_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + ms_gswap4 (&blkt_201->amplitude); + ms_gswap4 (&blkt_201->period); + ms_gswap4 (&blkt_201->background_estimate); + MS_SWAPBTIME (&blkt_201->time); + } + + if ( details >= 1 ) + { + ms_log (0, " signal amplitude: %g\n", blkt_201->amplitude); + ms_log (0, " signal period: %g\n", blkt_201->period); + ms_log (0, " background estimate: %g\n", blkt_201->background_estimate); + + b = blkt_201->flags; + ms_log (0, " event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Dilation wave\n"); + else ms_log (0, " [Bit 0] 0: Compression wave\n"); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_201->reserved); + ms_log (0, " signal onset time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_201->time.year, blkt_201->time.day, + blkt_201->time.hour, blkt_201->time.min, blkt_201->time.sec, blkt_201->time.fract, blkt_201->time.unused); + ms_log (0, " SNR values: "); + for (idx=0; idx < 6; idx++) ms_log (0, "%u ", blkt_201->snr_values[idx]); + ms_log (0, "\n"); + ms_log (0, " loopback value: %u\n", blkt_201->loopback); + ms_log (0, " pick algorithm: %u\n", blkt_201->pick_algorithm); + ms_log (0, " detector name: %.24s\n", blkt_201->detector); + } + } + + else if ( blkt_type == 300 ) + { + struct blkt_300_s *blkt_300 = (struct blkt_300_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_300->time); + ms_gswap4 (&blkt_300->step_duration); + ms_gswap4 (&blkt_300->interval_duration); + ms_gswap4 (&blkt_300->amplitude); + ms_gswap4 (&blkt_300->reference_amplitude); + } + + if ( details >= 1 ) + { + ms_log (0, " calibration start time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_300->time.year, blkt_300->time.day, + blkt_300->time.hour, blkt_300->time.min, blkt_300->time.sec, blkt_300->time.fract, blkt_300->time.unused); + ms_log (0, " number of calibrations: %u\n", blkt_300->numcalibrations); + + b = blkt_300->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x01 ) ms_log (0, " [Bit 0] First pulse is positive\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] Calibration's alternate sign\n"); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + + ms_log (0, " step duration: %u\n", blkt_300->step_duration); + ms_log (0, " interval duration: %u\n", blkt_300->interval_duration); + ms_log (0, " signal amplitude: %g\n", blkt_300->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_300->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_300->reserved); + ms_log (0, " reference amplitude: %u\n", blkt_300->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_300->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_300->rolloff); + } + } + + else if ( blkt_type == 310 ) + { + struct blkt_310_s *blkt_310 = (struct blkt_310_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_310->time); + ms_gswap4 (&blkt_310->duration); + ms_gswap4 (&blkt_310->period); + ms_gswap4 (&blkt_310->amplitude); + ms_gswap4 (&blkt_310->reference_amplitude); + } + + if ( details >= 1 ) + { + ms_log (0, " calibration start time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_310->time.year, blkt_310->time.day, + blkt_310->time.hour, blkt_310->time.min, blkt_310->time.sec, blkt_310->time.fract, blkt_310->time.unused); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_310->reserved1); + + b = blkt_310->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Peak-to-peak amplitude\n"); + if ( b & 0x20 ) ms_log (0, " [Bit 5] Zero-to-peak amplitude\n"); + if ( b & 0x40 ) ms_log (0, " [Bit 6] RMS amplitude\n"); + + ms_log (0, " calibration duration: %u\n", blkt_310->duration); + ms_log (0, " signal period: %g\n", blkt_310->period); + ms_log (0, " signal amplitude: %g\n", blkt_310->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_310->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_310->reserved2); + ms_log (0, " reference amplitude: %u\n", blkt_310->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_310->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_310->rolloff); + } + } + + else if ( blkt_type == 320 ) + { + struct blkt_320_s *blkt_320 = (struct blkt_320_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_320->time); + ms_gswap4 (&blkt_320->duration); + ms_gswap4 (&blkt_320->ptp_amplitude); + ms_gswap4 (&blkt_320->reference_amplitude); + } + + if ( details >= 1 ) + { + ms_log (0, " calibration start time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_320->time.year, blkt_320->time.day, + blkt_320->time.hour, blkt_320->time.min, blkt_320->time.sec, blkt_320->time.fract, blkt_320->time.unused); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_320->reserved1); + + b = blkt_320->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + if ( b & 0x10 ) ms_log (0, " [Bit 4] Random amplitudes\n"); + + ms_log (0, " calibration duration: %u\n", blkt_320->duration); + ms_log (0, " peak-to-peak amplitude: %g\n", blkt_320->ptp_amplitude); + ms_log (0, " input signal channel: %.3s", blkt_320->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_320->reserved2); + ms_log (0, " reference amplitude: %u\n", blkt_320->reference_amplitude); + ms_log (0, " coupling: %.12s\n", blkt_320->coupling); + ms_log (0, " rolloff: %.12s\n", blkt_320->rolloff); + ms_log (0, " noise type: %.8s\n", blkt_320->noise_type); + } + } + + else if ( blkt_type == 390 ) + { + struct blkt_390_s *blkt_390 = (struct blkt_390_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + MS_SWAPBTIME (&blkt_390->time); + ms_gswap4 (&blkt_390->duration); + ms_gswap4 (&blkt_390->amplitude); + } + + if ( details >= 1 ) + { + ms_log (0, " calibration start time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_390->time.year, blkt_390->time.day, + blkt_390->time.hour, blkt_390->time.min, blkt_390->time.sec, blkt_390->time.fract, blkt_390->time.unused); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_390->reserved1); + + b = blkt_390->flags; + ms_log (0, " calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + if ( b & 0x04 ) ms_log (0, " [Bit 2] Calibration was automatic\n"); + if ( b & 0x08 ) ms_log (0, " [Bit 3] Calibration continued from previous record(s)\n"); + + ms_log (0, " calibration duration: %u\n", blkt_390->duration); + ms_log (0, " signal amplitude: %g\n", blkt_390->amplitude); + ms_log (0, " input signal channel: %.3s", blkt_390->input_channel); + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_390->reserved2); + } + } + + else if ( blkt_type == 395 ) + { + struct blkt_395_s *blkt_395 = (struct blkt_395_s *) (record + blkt_offset + 4); + + if ( swapflag ) + MS_SWAPBTIME (&blkt_395->time); + + if ( details >= 1 ) + { + ms_log (0, " calibration end time: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_395->time.year, blkt_395->time.day, + blkt_395->time.hour, blkt_395->time.min, blkt_395->time.sec, blkt_395->time.fract, blkt_395->time.unused); + if ( details > 1 ) + ms_log (0, " reserved bytes (2): %u,%u\n", + blkt_395->reserved[0], blkt_395->reserved[1]); + } + } + + else if ( blkt_type == 400 ) + { + struct blkt_400_s *blkt_400 = (struct blkt_400_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + ms_gswap4 (&blkt_400->azimuth); + ms_gswap4 (&blkt_400->slowness); + ms_gswap4 (&blkt_400->configuration); + } + + if ( details >= 1 ) + { + ms_log (0, " beam azimuth (degrees): %g\n", blkt_400->azimuth); + ms_log (0, " beam slowness (sec/degree): %g\n", blkt_400->slowness); + ms_log (0, " configuration: %u\n", blkt_400->configuration); + if ( details > 1 ) + ms_log (0, " reserved bytes (2): %u,%u\n", + blkt_400->reserved[0], blkt_400->reserved[1]); + } + } + + else if ( blkt_type == 405 ) + { + struct blkt_405_s *blkt_405 = (struct blkt_405_s *) (record + blkt_offset + 4); + uint16_t firstvalue = blkt_405->delay_values[0]; /* Work on a private copy */ + + if ( swapflag ) + ms_gswap2 (&firstvalue); + + if ( details >= 1 ) + ms_log (0, " first delay value: %u\n", firstvalue); + } + + else if ( blkt_type == 500 ) + { + struct blkt_500_s *blkt_500 = (struct blkt_500_s *) (record + blkt_offset + 4); + + if ( swapflag ) + { + ms_gswap4 (&blkt_500->vco_correction); + MS_SWAPBTIME (&blkt_500->time); + ms_gswap4 (&blkt_500->exception_count); + } + + if ( details >= 1 ) + { + ms_log (0, " VCO correction: %g%%\n", blkt_500->vco_correction); + ms_log (0, " time of exception: %d,%d,%d:%d:%d.%04d (unused: %d)\n", blkt_500->time.year, blkt_500->time.day, + blkt_500->time.hour, blkt_500->time.min, blkt_500->time.sec, blkt_500->time.fract, blkt_500->time.unused); + ms_log (0, " usec: %d\n", blkt_500->usec); + ms_log (0, " reception quality: %u%%\n", blkt_500->reception_qual); + ms_log (0, " exception count: %u\n", blkt_500->exception_count); + ms_log (0, " exception type: %.16s\n", blkt_500->exception_type); + ms_log (0, " clock model: %.32s\n", blkt_500->clock_model); + ms_log (0, " clock status: %.128s\n", blkt_500->clock_status); + } + } + + else if ( blkt_type == 1000 ) + { + struct blkt_1000_s *blkt_1000 = (struct blkt_1000_s *) (record + blkt_offset + 4); + char order[40]; + + /* Calculate record size in bytes as 2^(blkt_1000->rec_len) */ + b1000reclen = (unsigned int) 1 << blkt_1000->reclen; + + /* Big or little endian? */ + if (blkt_1000->byteorder == 0) + strncpy (order, "Little endian", sizeof(order)-1); + else if (blkt_1000->byteorder == 1) + strncpy (order, "Big endian", sizeof(order)-1); + else + strncpy (order, "Unknown value", sizeof(order)-1); + + if ( details >= 1 ) + { + ms_log (0, " encoding: %s (val:%u)\n", + (char *) ms_encodingstr (blkt_1000->encoding), blkt_1000->encoding); + ms_log (0, " byte order: %s (val:%u)\n", + order, blkt_1000->byteorder); + ms_log (0, " record length: %d (val:%u)\n", + b1000reclen, blkt_1000->reclen); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_1000->reserved); + } + + /* Save encoding format */ + b1000encoding = blkt_1000->encoding; + + /* Sanity check encoding format */ + if ( ! (b1000encoding >= 0 && b1000encoding <= 5) && + ! (b1000encoding >= 10 && b1000encoding <= 19) && + ! (b1000encoding >= 30 && b1000encoding <= 33) ) + { + ms_log (2, "%s: Blockette 1000 encoding format invalid (0-5,10-19,30-33): %d\n", srcname, b1000encoding); + retval++; + } + + /* Sanity check byte order flag */ + if ( blkt_1000->byteorder != 0 && blkt_1000->byteorder != 1 ) + { + ms_log (2, "%s: Blockette 1000 byte order flag invalid (0 or 1): %d\n", srcname, blkt_1000->byteorder); + retval++; + } + } + + else if ( blkt_type == 1001 ) + { + struct blkt_1001_s *blkt_1001 = (struct blkt_1001_s *) (record + blkt_offset + 4); + + if ( details >= 1 ) + { + ms_log (0, " timing quality: %u%%\n", blkt_1001->timing_qual); + ms_log (0, " micro second: %d\n", blkt_1001->usec); + + if ( details > 1 ) + ms_log (0, " reserved byte: %u\n", blkt_1001->reserved); + + ms_log (0, " frame count: %u\n", blkt_1001->framecnt); + } + } + + else if ( blkt_type == 2000 ) + { + struct blkt_2000_s *blkt_2000 = (struct blkt_2000_s *) (record + blkt_offset + 4); + char order[40]; + + if ( swapflag ) + { + ms_gswap2 (&blkt_2000->length); + ms_gswap2 (&blkt_2000->data_offset); + ms_gswap4 (&blkt_2000->recnum); + } + + /* Big or little endian? */ + if (blkt_2000->byteorder == 0) + strncpy (order, "Little endian", sizeof(order)-1); + else if (blkt_2000->byteorder == 1) + strncpy (order, "Big endian", sizeof(order)-1); + else + strncpy (order, "Unknown value", sizeof(order)-1); + + if ( details >= 1 ) + { + ms_log (0, " blockette length: %u\n", blkt_2000->length); + ms_log (0, " data offset: %u\n", blkt_2000->data_offset); + ms_log (0, " record number: %u\n", blkt_2000->recnum); + ms_log (0, " byte order: %s (val:%u)\n", + order, blkt_2000->byteorder); + b = blkt_2000->flags; + ms_log (0, " data flags: [%u%u%u%u%u%u%u%u] 8 bits\n", + bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08), + bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80)); + + if ( details > 1 ) + { + if ( b & 0x01 ) ms_log (0, " [Bit 0] 1: Stream oriented\n"); + else ms_log (0, " [Bit 0] 0: Record oriented\n"); + if ( b & 0x02 ) ms_log (0, " [Bit 1] 1: Blockette 2000s may NOT be packaged\n"); + else ms_log (0, " [Bit 1] 0: Blockette 2000s may be packaged\n"); + if ( ! (b & 0x04) && ! (b & 0x08) ) + ms_log (0, " [Bits 2-3] 00: Complete blockette\n"); + else if ( ! (b & 0x04) && (b & 0x08) ) + ms_log (0, " [Bits 2-3] 01: First blockette in span\n"); + else if ( (b & 0x04) && (b & 0x08) ) + ms_log (0, " [Bits 2-3] 11: Continuation blockette in span\n"); + else if ( (b & 0x04) && ! (b & 0x08) ) + ms_log (0, " [Bits 2-3] 10: Final blockette in span\n"); + if ( ! (b & 0x10) && ! (b & 0x20) ) + ms_log (0, " [Bits 4-5] 00: Not file oriented\n"); + else if ( ! (b & 0x10) && (b & 0x20) ) + ms_log (0, " [Bits 4-5] 01: First blockette of file\n"); + else if ( (b & 0x10) && ! (b & 0x20) ) + ms_log (0, " [Bits 4-5] 10: Continuation of file\n"); + else if ( (b & 0x10) && (b & 0x20) ) + ms_log (0, " [Bits 4-5] 11: Last blockette of file\n"); + } + + ms_log (0, " number of headers: %u\n", blkt_2000->numheaders); + + /* Crude display of the opaque data headers */ + if ( details > 1 ) + ms_log (0, " headers: %.*s\n", + (blkt_2000->data_offset - 15), blkt_2000->payload); + } + } + + else + { + ms_log (2, "%s: Unrecognized blockette type: %d\n", srcname, blkt_type); + retval++; + } + + /* Sanity check the next blockette offset */ + if ( next_blkt && next_blkt <= endofblockettes ) + { + ms_log (2, "%s: Next blockette offset (%d) is within current blockette ending at byte %d\n", + srcname, next_blkt, endofblockettes); + blkt_offset = 0; + } + else + { + blkt_offset = next_blkt; + } + + blkt_count++; + } /* End of looping through blockettes */ + + /* Check that the blockette offset is within the maximum record size */ + if ( blkt_offset > maxreclen ) + { + ms_log (2, "%s: Blockette offset (%d) beyond maximum record length (%d)\n", srcname, blkt_offset, maxreclen); + retval++; + } + + /* Check that the data and blockette offsets are within the record */ + if ( b1000reclen && fsdh->data_offset > b1000reclen ) + { + ms_log (2, "%s: Data offset (%d) beyond record length (%d)\n", srcname, fsdh->data_offset, b1000reclen); + retval++; + } + if ( b1000reclen && fsdh->blockette_offset > b1000reclen ) + { + ms_log (2, "%s: Blockette offset (%d) beyond record length (%d)\n", srcname, fsdh->blockette_offset, b1000reclen); + retval++; + } + + /* Check that the data offset is beyond the end of the blockettes */ + if ( fsdh->numsamples && fsdh->data_offset <= endofblockettes ) + { + ms_log (2, "%s: Data offset (%d) is within blockette chain (end of blockettes: %d)\n", srcname, fsdh->data_offset, endofblockettes); + retval++; + } + + /* Check that the correct number of blockettes were parsed */ + if ( fsdh->numblockettes != blkt_count ) + { + ms_log (2, "%s: Specified number of blockettes (%d) not equal to those parsed (%d)\n", srcname, fsdh->numblockettes, blkt_count); + retval++; + } + } + + return retval; +} /* End of ms_parse_raw() */ diff --git a/libs/3rd-party/mseed/selection.c b/libs/3rd-party/mseed/selection.c new file mode 100644 index 0000000..4f150f1 --- /dev/null +++ b/libs/3rd-party/mseed/selection.c @@ -0,0 +1,680 @@ +/*************************************************************************** + * selection.c: + * + * Generic routines to manage selection lists. + * + * Written by Chad Trabant unless otherwise noted + * IRIS Data Management Center + * + * modified: 2014.197 + ***************************************************************************/ + +#include +#include +#include +#include +#include + +#include "libmseed.h" + +static int ms_globmatch (char *string, char *pattern); + + +/*************************************************************************** + * ms_matchselect: + * + * Test the specified parameters for a matching selection entry. The + * srcname parameter may contain globbing characters. The NULL value + * (matching any times) for the start and end times is HPTERROR. + * + * Return Selections pointer to matching entry on successful match and + * NULL for no match or error. + ***************************************************************************/ +Selections * +ms_matchselect (Selections *selections, char *srcname, hptime_t starttime, + hptime_t endtime, SelectTime **ppselecttime) +{ + Selections *findsl = NULL; + SelectTime *findst = NULL; + SelectTime *matchst = NULL; + + if ( selections ) + { + findsl = selections; + while ( findsl ) + { + if ( ms_globmatch (srcname, findsl->srcname) ) + { + findst = findsl->timewindows; + while ( findst ) + { + if ( starttime != HPTERROR && findst->starttime != HPTERROR && + (starttime < findst->starttime && ! (starttime <= findst->starttime && endtime >= findst->starttime)) ) + { findst = findst->next; continue; } + else if ( endtime != HPTERROR && findst->endtime != HPTERROR && + (endtime > findst->endtime && ! (starttime <= findst->endtime && endtime >= findst->endtime)) ) + { findst = findst->next; continue; } + + matchst = findst; + break; + } + } + + if ( matchst ) + break; + else + findsl = findsl->next; + } + } + + if ( ppselecttime ) + *ppselecttime = matchst; + + return ( matchst ) ? findsl : NULL; +} /* End of ms_matchselect() */ + + +/*************************************************************************** + * msr_matchselect: + * + * A simple wrapper for calling ms_matchselect() using details from a + * MSRecord struct. + * + * Return Selections pointer to matching entry on successful match and + * NULL for no match or error. + ***************************************************************************/ +Selections * +msr_matchselect (Selections *selections, MSRecord *msr, SelectTime **ppselecttime) +{ + char srcname[50]; + hptime_t endtime; + + if ( ! selections || ! msr ) + return NULL; + + msr_srcname (msr, srcname, 1); + endtime = msr_endtime (msr); + + return ms_matchselect (selections, srcname, msr->starttime, endtime, + ppselecttime); +} /* End of msr_matchselect() */ + + +/*************************************************************************** + * ms_addselect: + * + * Add select parameters to a specified selection list. The srcname + * argument may contain globbing parameters. The NULL value (matching + * any value) for the start and end times is HPTERROR. + * + * Return 0 on success and -1 on error. + ***************************************************************************/ +int +ms_addselect (Selections **ppselections, char *srcname, + hptime_t starttime, hptime_t endtime) +{ + Selections *newsl = NULL; + SelectTime *newst = NULL; + + if ( ! ppselections || ! srcname ) + return -1; + + /* Allocate new SelectTime and populate */ + if ( ! (newst = (SelectTime *) calloc (1, sizeof(SelectTime))) ) + { + ms_log (2, "Cannot allocate memory\n"); + return -1; + } + + newst->starttime = starttime; + newst->endtime = endtime; + + /* Add new Selections struct to begining of list */ + if ( ! *ppselections ) + { + /* Allocate new Selections and populate */ + if ( ! (newsl = (Selections *) calloc (1, sizeof(Selections))) ) + { + ms_log (2, "Cannot allocate memory\n"); + return -1; + } + + strncpy (newsl->srcname, srcname, sizeof(newsl->srcname)); + newsl->srcname[sizeof(newsl->srcname) - 1] = '\0'; + + /* Add new Selections struct as first in list */ + *ppselections = newsl; + newsl->timewindows = newst; + } + else + { + Selections *findsl = *ppselections; + Selections *matchsl = 0; + + /* Search for matching Selectlink entry */ + while ( findsl ) + { + if ( ! strcmp (findsl->srcname, srcname) ) + { + matchsl = findsl; + break; + } + + findsl = findsl->next; + } + + if ( matchsl ) + { + /* Add time window selection to beginning of window list */ + newst->next = matchsl->timewindows; + matchsl->timewindows = newst; + } + else + { + /* Allocate new Selections and populate */ + if ( ! (newsl = (Selections *) calloc (1, sizeof(Selections))) ) + { + ms_log (2, "Cannot allocate memory\n"); + return -1; + } + + strncpy (newsl->srcname, srcname, sizeof(newsl->srcname)); + newsl->srcname[sizeof(newsl->srcname) - 1] = '\0'; + + /* Add new Selections to beginning of list */ + newsl->next = *ppselections; + *ppselections = newsl; + newsl->timewindows = newst; + } + } + + return 0; +} /* End of ms_addselect() */ + + +/*************************************************************************** + * ms_addselect_comp: + * + * Add select parameters to a specified selection list based on + * separate name components. The network, station, location, channel + * and quality arguments may contain globbing parameters. The NULL + * value (matching any value) for the start and end times is HPTERROR. + * + * If any of the naming parameters are not supplied (pointer is NULL) + * a wildcard for all matches is substituted. As a special case, if + * the location ID (loc) is set to "--" to match a space-space/blank + * ID it will be translated to an empty string to match libmseed's + * notation. + * + * Return 0 on success and -1 on error. + ***************************************************************************/ +int +ms_addselect_comp (Selections **ppselections, char *net, char* sta, char *loc, + char *chan, char *qual, hptime_t starttime, hptime_t endtime) +{ + char srcname[100]; + char selnet[20]; + char selsta[20]; + char selloc[20]; + char selchan[20]; + char selqual[20]; + + if ( ! ppselections ) + return -1; + + if ( net ) + { + strncpy (selnet, net, sizeof(selnet)); + selnet[sizeof(selnet)-1] = '\0'; + } + else + strcpy (selnet, "*"); + + if ( sta ) + { + strncpy (selsta, sta, sizeof(selsta)); + selsta[sizeof(selsta)-1] = '\0'; + } + else + strcpy (selsta, "*"); + + if ( loc ) + { + /* Test for special case blank location ID */ + if ( ! strcmp (loc, "--") ) + selloc[0] = '\0'; + else + { + strncpy (selloc, loc, sizeof(selloc)); + selloc[sizeof(selloc)-1] = '\0'; + } + } + else + strcpy (selloc, "*"); + + if ( chan ) + { + strncpy (selchan, chan, sizeof(selchan)); + selchan[sizeof(selchan)-1] = '\0'; + } + else + strcpy (selchan, "*"); + + if ( qual ) + { + strncpy (selqual, qual, sizeof(selqual)); + selqual[sizeof(selqual)-1] = '\0'; + } + else + strcpy (selqual, "?"); + + /* Create the srcname globbing match for this entry */ + snprintf (srcname, sizeof(srcname), "%s_%s_%s_%s_%s", + selnet, selsta, selloc, selchan, selqual); + + /* Add selection to list */ + if ( ms_addselect (ppselections, srcname, starttime, endtime) ) + return -1; + + return 0; +} /* End of ms_addselect_comp() */ + + +/*************************************************************************** + * ms_readselectionsfile: + * + * Read a list of data selections from a file and them to the + * specified selections list. On errors this routine will leave + * allocated memory unreachable (leaked), it is expected that this is + * a program failing condition. + * + * As a special case if the filename is "-", selection lines will be + * read from stdin. + * + * Returns count of selections added on success and -1 on error. + ***************************************************************************/ +int +ms_readselectionsfile (Selections **ppselections, char *filename) +{ + FILE *fp; + hptime_t starttime; + hptime_t endtime; + char selectline[200]; + char *selnet; + char *selsta; + char *selloc; + char *selchan; + char *selqual; + char *selstart; + char *selend; + char *cp; + char next; + int selectcount = 0; + int linecount = 0; + + if ( ! ppselections || ! filename ) + return -1; + + if ( strcmp (filename, "-" ) ) + { + if ( ! (fp = fopen(filename, "rb")) ) + { + ms_log (2, "Cannot open file %s: %s\n", filename, strerror(errno)); + return -1; + } + } + else + { + /* Use stdin as special case */ + fp = stdin; + } + + while ( fgets (selectline, sizeof(selectline)-1, fp) ) + { + selnet = 0; + selsta = 0; + selloc = 0; + selchan = 0; + selqual = 0; + selstart = 0; + selend = 0; + + linecount++; + + /* Guarantee termination */ + selectline[sizeof(selectline)-1] = '\0'; + + /* End string at first newline character if any */ + if ( (cp = strchr(selectline, '\n')) ) + *cp = '\0'; + + /* Skip empty lines */ + if ( ! strlen (selectline) ) + continue; + + /* Skip comment lines */ + if ( *selectline == '#' ) + continue; + + /* Parse: identify components of selection and terminate */ + cp = selectline; + next = 1; + while ( *cp ) + { + if ( *cp == ' ' || *cp == '\t' ) { *cp = '\0'; next = 1; } + else if ( *cp == '#' ) { *cp = '\0'; break; } + else if ( next && ! selnet ) { selnet = cp; next = 0; } + else if ( next && ! selsta ) { selsta = cp; next = 0; } + else if ( next && ! selloc ) { selloc = cp; next = 0; } + else if ( next && ! selchan ) { selchan = cp; next = 0; } + else if ( next && ! selqual ) { selqual = cp; next = 0; } + else if ( next && ! selstart ) { selstart = cp; next = 0; } + else if ( next && ! selend ) { selend = cp; next = 0; } + else if ( next ) { *cp = '\0'; break; } + cp++; + } + + /* Skip line if network, station, location and channel are not defined */ + if ( ! selnet || ! selsta || ! selloc || ! selchan ) + { + ms_log (2, "[%s] Skipping data selection line number %d\n", filename, linecount); + continue; + } + + if ( selstart ) + { + starttime = ms_seedtimestr2hptime (selstart); + if ( starttime == HPTERROR ) + { + ms_log (2, "Cannot convert data selection start time (line %d): %s\n", linecount, selstart); + return -1; + } + } + else + { + starttime = HPTERROR; + } + + if ( selend ) + { + endtime = ms_seedtimestr2hptime (selend); + if ( endtime == HPTERROR ) + { + ms_log (2, "Cannot convert data selection end time (line %d): %s\n", linecount, selend); + return -1; + } + } + else + { + endtime = HPTERROR; + } + + /* Add selection to list */ + if ( ms_addselect_comp (ppselections, selnet, selsta, selloc, selchan, selqual, starttime, endtime) ) + { + ms_log (2, "[%s] Error adding selection on line %d\n", filename, linecount); + return -1; + } + + selectcount++; + } + + if ( fp != stdin ) + fclose (fp); + + return selectcount; +} /* End of ms_readselectionsfile() */ + + +/*************************************************************************** + * ms_freeselections: + * + * Free all memory associated with a Selections struct. + ***************************************************************************/ +void +ms_freeselections ( Selections *selections ) +{ + Selections *select; + Selections *selectnext; + SelectTime *selecttime; + SelectTime *selecttimenext; + + if ( selections ) + { + select = selections; + + while ( select ) + { + selectnext = select->next; + + selecttime = select->timewindows; + + while ( selecttime ) + { + selecttimenext = selecttime->next; + + free (selecttime); + + selecttime = selecttimenext; + } + + free (select); + + select = selectnext; + } + } + +} /* End of ms_freeselections() */ + + +/*************************************************************************** + * ms_printselections: + * + * Print the selections list using the ms_log() facility. + ***************************************************************************/ +void +ms_printselections ( Selections *selections ) +{ + Selections *select; + SelectTime *selecttime; + char starttime[50]; + char endtime[50]; + + if ( ! selections ) + return; + + select = selections; + while ( select ) + { + ms_log (0, "Selection: %s\n", select->srcname); + + selecttime = select->timewindows; + while ( selecttime ) + { + if ( selecttime->starttime != HPTERROR ) + ms_hptime2seedtimestr (selecttime->starttime, starttime, 1); + else + strncpy (starttime, "No start time", sizeof(starttime)-1); + + if ( selecttime->endtime != HPTERROR ) + ms_hptime2seedtimestr (selecttime->endtime, endtime, 1); + else + strncpy (endtime, "No end time", sizeof(endtime)-1); + + ms_log (0, " %30s %30s\n", starttime, endtime); + + selecttime = selecttime->next; + } + + select = select->next; + } +} /* End of ms_printselections() */ + + +/*********************************************************************** + * robust glob pattern matcher + * ozan s. yigit/dec 1994 + * public domain + * + * glob patterns: + * * matches zero or more characters + * ? matches any single character + * [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: a-z denotes + * all characters between a to z inclusive. + * [-set] set matches a literal hypen 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 '[' + * \char matches char, including any pattern character + * + * examples: + * a*c ac abc abbc ... + * a?c acc abc aXc ... + * a[a-z]c aac abc acc ... + * a[-a-z]c a-c aac abc ... + * + * Revision 1.4 2004/12/26 12:38:00 ct + * Changed function name (amatch -> globmatch), variables and + * formatting for clarity. Also add matching header globmatch.h. + * + * Revision 1.3 1995/09/14 23:24:23 oz + * removed boring test/main code. + * + * Revision 1.2 94/12/11 10:38:15 oz + * charset code fixed. it is now robust and interprets all + * variations of charset [i think] correctly, including [z-a] etc. + * + * Revision 1.1 94/12/08 12:45:23 oz + * Initial revision + ***********************************************************************/ + +#define GLOBMATCH_TRUE 1 +#define GLOBMATCH_FALSE 0 +#define GLOBMATCH_NEGATE '^' /* std char set negation char */ + +/*********************************************************************** + * ms_globmatch: + * + * Check if a string matches a globbing pattern. + * + * Return 0 if string does not match pattern and non-zero otherwise. + **********************************************************************/ +static int +ms_globmatch (char *string, char *pattern) +{ + int negate; + int match; + int c; + + while ( *pattern ) + { + if ( !*string && *pattern != '*' ) + return GLOBMATCH_FALSE; + + switch ( c = *pattern++ ) + { + + case '*': + while ( *pattern == '*' ) + pattern++; + + if ( !*pattern ) + return GLOBMATCH_TRUE; + + if ( *pattern != '?' && *pattern != '[' && *pattern != '\\' ) + while ( *string && *pattern != *string ) + string++; + + while ( *string ) + { + if ( ms_globmatch(string, pattern) ) + return GLOBMATCH_TRUE; + string++; + } + return GLOBMATCH_FALSE; + + case '?': + if ( *string ) + break; + return GLOBMATCH_FALSE; + + /* set specification is inclusive, that is [a-z] is a, z and + * everything in between. this means [z-a] may be interpreted + * as a set that contains z, a and nothing in between. + */ + case '[': + if ( *pattern != GLOBMATCH_NEGATE ) + negate = GLOBMATCH_FALSE; + else + { + negate = GLOBMATCH_TRUE; + pattern++; + } + + match = GLOBMATCH_FALSE; + + while ( !match && (c = *pattern++) ) + { + if ( !*pattern ) + return GLOBMATCH_FALSE; + + if ( *pattern == '-' ) /* c-c */ + { + if ( !*++pattern ) + return GLOBMATCH_FALSE; + if ( *pattern != ']' ) + { + if ( *string == c || *string == *pattern || + ( *string > c && *string < *pattern ) ) + match = GLOBMATCH_TRUE; + } + else + { /* c-] */ + if ( *string >= c ) + match = GLOBMATCH_TRUE; + break; + } + } + else /* cc or c] */ + { + if ( c == *string ) + match = GLOBMATCH_TRUE; + if ( *pattern != ']' ) + { + if ( *pattern == *string ) + match = GLOBMATCH_TRUE; + } + else + break; + } + } + + if ( negate == match ) + return GLOBMATCH_FALSE; + + /* + * if there is a match, skip past the charset and continue on + */ + while ( *pattern && *pattern != ']' ) + pattern++; + if ( !*pattern++ ) /* oops! */ + return GLOBMATCH_FALSE; + break; + + case '\\': + if ( *pattern ) + c = *pattern++; + default: + if ( c != *string ) + return GLOBMATCH_FALSE; + break; + } + + string++; + } + + return !*string; +} /* End of ms_globmatch() */ diff --git a/libs/3rd-party/mseed/steimdata.h b/libs/3rd-party/mseed/steimdata.h new file mode 100644 index 0000000..15c7e44 --- /dev/null +++ b/libs/3rd-party/mseed/steimdata.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * steimdata.h: + * + * Declarations for Steim compression routines. + * + * modified: 2004.278 + ***************************************************************************/ + +#ifndef STEIMDATA_H +#define STEIMDATA_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#define STEIM1_FRAME_MAX_SAMPLES 60 +#define STEIM2_FRAME_MAX_SAMPLES 105 + +#define VALS_PER_FRAME 15 /* # of ints for data per frame.*/ + +#define STEIM1_SPECIAL_MASK 0 +#define STEIM1_BYTE_MASK 1 +#define STEIM1_HALFWORD_MASK 2 +#define STEIM1_FULLWORD_MASK 3 + +#define STEIM2_SPECIAL_MASK 0 +#define STEIM2_BYTE_MASK 1 +#define STEIM2_123_MASK 2 +#define STEIM2_567_MASK 3 + +typedef union u_diff { /* union for Steim objects. */ + int8_t byte[4]; /* 4 1-byte differences. */ + int16_t hw[2]; /* 2 halfword differences. */ + int32_t fw; /* 1 fullword difference. */ +} U_DIFF; + +typedef struct frame { /* frame in a seed data record. */ + uint32_t ctrl; /* control word for frame. */ + U_DIFF w[15]; /* compressed data. */ +} FRAME; + +typedef struct dframes { /* seed data frames. */ + FRAME f[1]; /* data record header frames. */ +} DFRAMES; + + +#ifdef __cplusplus +} +#endif + +#endif /* STEIMDATA_H */ diff --git a/libs/3rd-party/mseed/tracelist.c b/libs/3rd-party/mseed/tracelist.c new file mode 100644 index 0000000..84f5d11 --- /dev/null +++ b/libs/3rd-party/mseed/tracelist.c @@ -0,0 +1,1277 @@ +/*************************************************************************** + * tracelist.c: + * + * Routines to handle TraceList and related structures. + * + * Written by Chad Trabant, IRIS Data Management Center + * + * modified: 2012.273 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "libmseed.h" + + +MSTraceSeg *mstl_msr2seg (MSRecord *msr, hptime_t endtime); +MSTraceSeg *mstl_addmsrtoseg (MSTraceSeg *seg, MSRecord *msr, hptime_t endtime, flag whence); +MSTraceSeg *mstl_addsegtoseg (MSTraceSeg *seg1, MSTraceSeg *seg2); + + +/*************************************************************************** + * mstl_init: + * + * Initialize and return a MSTraceList struct, allocating memory if + * needed. If the supplied MSTraceList is not NULL any associated + * memory it will be freed including data at prvtptr pointers. + * + * Returns a pointer to a MSTraceList struct on success or NULL on error. + ***************************************************************************/ +MSTraceList * +mstl_init ( MSTraceList *mstl ) +{ + if ( mstl ) + { + mstl_free (&mstl, 1); + } + + mstl = (MSTraceList *) malloc (sizeof(MSTraceList)); + + if ( mstl == NULL ) + { + ms_log (2, "mstl_init(): Cannot allocate memory\n"); + return NULL; + } + + memset (mstl, 0, sizeof (MSTraceList)); + + return mstl; +} /* End of mstl_init() */ + + +/*************************************************************************** + * mstl_free: + * + * Free all memory associated with a MSTraceList struct and set the + * pointer to 0. + * + * If the freeprvtptr flag is true any private pointer data will also + * be freed when present. + ***************************************************************************/ +void +mstl_free ( MSTraceList **ppmstl, flag freeprvtptr ) +{ + MSTraceID *id = 0; + MSTraceID *nextid = 0; + MSTraceSeg *seg = 0; + MSTraceSeg *nextseg = 0; + + if ( ! ppmstl ) + return; + + if ( *ppmstl ) + { + /* Free any associated traces */ + id = (*ppmstl)->traces; + while ( id ) + { + nextid = id->next; + + /* Free any associated trace segments */ + seg = id->first; + while ( seg ) + { + nextseg = seg->next; + + /* Free private pointer data if present and requested*/ + if ( freeprvtptr && seg->prvtptr ) + free (seg->prvtptr); + + /* Free data array if allocated */ + if ( seg->datasamples ) + free (seg->datasamples); + + free (seg); + seg = nextseg; + } + + /* Free private pointer data if present and requested*/ + if ( freeprvtptr && id->prvtptr ) + free (id->prvtptr); + + free (id); + id = nextid; + } + + free (*ppmstl); + + *ppmstl = NULL; + } + + return; +} /* End of mstl_free() */ + + +/*************************************************************************** + * mstl_addmsr: + * + * Add data coverage from an MSRecord to a MSTraceList by searching the + * list for the appropriate MSTraceID and MSTraceSeg and either adding + * data to it or creating a new MStraceID and/or MSTraceSeg if needed. + * + * If the dataquality flag is true the data quality bytes must also + * match otherwise they are ignored. + * + * If the autoheal flag is true extra processing is invoked to conjoin + * trace segments that fit together after the MSRecord coverage is + * added. For segments that are removed, any memory at the prvtptr + * will be freed. + * + * An MSTraceList is always maintained with the MSTraceIDs in + * descending alphanumeric order. MSTraceIDs are always maintained + * with MSTraceSegs in data time time order. + * + * Return a pointer to the MSTraceSeg updated or 0 on error. + ***************************************************************************/ +MSTraceSeg * +mstl_addmsr ( MSTraceList *mstl, MSRecord *msr, flag dataquality, + flag autoheal, double timetol, double sampratetol ) +{ + MSTraceID *id = 0; + MSTraceID *searchid = 0; + MSTraceID *ltid = 0; + + MSTraceSeg *seg = 0; + MSTraceSeg *searchseg = 0; + MSTraceSeg *segbefore = 0; + MSTraceSeg *segafter = 0; + MSTraceSeg *followseg = 0; + + hptime_t endtime; + hptime_t pregap; + hptime_t postgap; + hptime_t lastgap; + hptime_t firstgap; + hptime_t hpdelta; + hptime_t hptimetol = 0; + hptime_t nhptimetol = 0; + + char srcname[45]; + char *s1, *s2; + flag whence; + flag lastratecheck; + flag firstratecheck; + int mag; + int cmp; + int ltmag; + int ltcmp; + + if ( ! mstl || ! msr ) + return 0; + + /* Calculate end time for MSRecord */ + if ( (endtime = msr_endtime (msr)) == HPTERROR ) + { + ms_log (2, "mstl_addmsr(): Error calculating record end time\n"); + return 0; + } + + /* Generate source name string */ + if ( ! msr_srcname (msr, srcname, dataquality) ) + { + ms_log (2, "mstl_addmsr(): Error generating srcname for MSRecord\n"); + return 0; + } + + /* Search for matching trace ID starting with last accessed ID and + then looping through the trace ID list. */ + if ( mstl->last ) + { + s1 = mstl->last->srcname; + s2 = srcname; + while ( *s1 == *s2++ ) + { + if ( *s1++ == '\0' ) + break; + } + cmp = (*s1 - *--s2); + + if ( ! cmp ) + { + id = mstl->last; + } + else + { + /* Loop through trace ID list searching for a match, simultaneously + * track the source name which is closest but less than the MSRecord + * to allow for later insertion with sort order. */ + searchid = mstl->traces; + ltcmp = 0; + ltmag = 0; + while ( searchid ) + { + /* Compare source names */ + s1 = searchid->srcname; + s2 = srcname; + mag = 0; + while ( *s1 == *s2++ ) + { + mag++; + if ( *s1++ == '\0' ) + break; + } + cmp = (*s1 - *--s2); + + /* If source names did not match track closest "less than" value + * and continue searching. */ + if ( cmp != 0 ) + { + if ( cmp < 0 ) + { + if ( (ltcmp == 0 || cmp >= ltcmp) && mag >= ltmag ) + { + ltcmp = cmp; + ltmag = mag; + ltid = searchid; + } + else if ( mag > ltmag ) + { + ltcmp = cmp; + ltmag = mag; + ltid = searchid; + } + } + + searchid = searchid->next; + continue; + } + + /* If we made it this far we found a match */ + id = searchid; + break; + } + } + } /* Done searching for match in trace ID list */ + + /* If no matching ID was found create new MSTraceID and MSTraceSeg entries */ + if ( ! id ) + { + if ( ! (id = (MSTraceID *) calloc (1, sizeof(MSTraceID))) ) + { + ms_log (2, "mstl_addmsr(): Error allocating memory\n"); + return 0; + } + + /* Populate MSTraceID */ + strcpy (id->network, msr->network); + strcpy (id->station, msr->station); + strcpy (id->location, msr->location); + strcpy (id->channel, msr->channel); + id->dataquality = msr->dataquality; + strcpy (id->srcname, srcname); + + id->earliest = msr->starttime; + id->latest = endtime; + id->numsegments = 1; + + if ( ! (seg = mstl_msr2seg (msr, endtime)) ) + { + return 0; + } + id->first = id->last = seg; + + /* Add new MSTraceID to MSTraceList */ + if ( ! mstl->traces || ! ltid ) + { + id->next = mstl->traces; + mstl->traces = id; + } + else + { + id->next = ltid->next; + ltid->next = id; + } + + mstl->numtraces++; + } + /* Add data coverage to the matching MSTraceID */ + else + { + /* Calculate high-precision sample period */ + hpdelta = (hptime_t) (( msr->samprate ) ? (HPTMODULUS / msr->samprate) : 0.0); + + /* Calculate high-precision time tolerance */ + if ( timetol == -1.0 ) + hptimetol = (hptime_t) (0.5 * hpdelta); /* Default time tolerance is 1/2 sample period */ + else if ( timetol >= 0.0 ) + hptimetol = (hptime_t) (timetol * HPTMODULUS); + + nhptimetol = ( hptimetol ) ? -hptimetol : 0; + + /* last/firstgap are negative when the record overlaps the trace + * segment and positive when there is a time gap. */ + + /* Gap relative to the last segment */ + lastgap = msr->starttime - id->last->endtime - hpdelta; + + /* Gap relative to the first segment */ + firstgap = id->first->starttime - endtime - hpdelta; + + /* Sample rate tolerance checks for first and last segments */ + if ( sampratetol == -1.0 ) + { + lastratecheck = MS_ISRATETOLERABLE (msr->samprate, id->last->samprate); + firstratecheck = MS_ISRATETOLERABLE (msr->samprate, id->first->samprate); + } + else + { + lastratecheck = (ms_dabs (msr->samprate - id->last->samprate) > sampratetol) ? 0 : 1; + firstratecheck = (ms_dabs (msr->samprate - id->first->samprate) > sampratetol) ? 0 : 1; + } + + /* Search first for the simple scenarios in order of likelihood: + * - Record fits at end of last segment + * - Record fits after all coverage + * - Record fits before all coverage + * - Record fits at beginning of first segment + * + * If none of those scenarios are true search the complete segment list. + */ + + /* Record coverage fits at end of last segment */ + if ( lastgap <= hptimetol && lastgap >= nhptimetol && lastratecheck ) + { + if ( ! mstl_addmsrtoseg (id->last, msr, endtime, 1) ) + return 0; + + seg = id->last; + + if ( endtime > id->latest ) + id->latest = endtime; + } + /* Record coverage is after all other coverage */ + else if ( (msr->starttime - hpdelta - hptimetol) > id->latest ) + { + if ( ! (seg = mstl_msr2seg (msr, endtime)) ) + return 0; + + /* Add to end of list */ + id->last->next = seg; + seg->prev = id->last; + id->last = seg; + id->numsegments++; + + if ( endtime > id->latest ) + id->latest = endtime; + } + /* Record coverage is before all other coverage */ + else if ( (endtime + hpdelta + hptimetol) < id->earliest ) + { + if ( ! (seg = mstl_msr2seg (msr, endtime)) ) + return 0; + + /* Add to beginning of list */ + id->first->prev = seg; + seg->next = id->first; + id->first = seg; + id->numsegments++; + + if ( msr->starttime < id->earliest ) + id->earliest = msr->starttime; + } + /* Record coverage fits at beginning of first segment */ + else if ( firstgap <= hptimetol && firstgap >= nhptimetol && firstratecheck ) + { + if ( ! mstl_addmsrtoseg (id->first, msr, endtime, 2) ) + return 0; + + seg = id->first; + + if ( msr->starttime < id->earliest ) + id->earliest = msr->starttime; + } + /* Search complete segment list for matches */ + else + { + searchseg = id->first; + segbefore = 0; /* Find segment that record fits before */ + segafter = 0; /* Find segment that record fits after */ + followseg = 0; /* Track segment that record follows in time order */ + while ( searchseg ) + { + if ( msr->starttime > searchseg->starttime ) + followseg = searchseg; + + whence = 0; + + postgap = msr->starttime - searchseg->endtime - hpdelta; + if ( ! segbefore && postgap <= hptimetol && postgap >= nhptimetol ) + whence = 1; + + pregap = searchseg->starttime - endtime - hpdelta; + if ( ! segafter && pregap <= hptimetol && pregap >= nhptimetol ) + whence = 2; + + if ( ! whence ) + { + searchseg = searchseg->next; + continue; + } + + if ( sampratetol == -1.0 ) + { + if ( ! MS_ISRATETOLERABLE (msr->samprate, searchseg->samprate) ) + { + searchseg = searchseg->next; + continue; + } + } + else + { + if ( ms_dabs (msr->samprate - searchseg->samprate) > sampratetol ) + { + searchseg = searchseg->next; + continue; + } + } + + if ( whence == 1 ) + segbefore = searchseg; + else + segafter = searchseg; + + /* Done searching if not autohealing */ + if ( ! autoheal ) + break; + + /* Done searching if both before and after segments are found */ + if ( segbefore && segafter ) + break; + + searchseg = searchseg->next; + } /* Done looping through segments */ + + /* Add MSRecord coverage to end of segment before */ + if ( segbefore ) + { + if ( ! mstl_addmsrtoseg (segbefore, msr, endtime, 1) ) + { + return 0; + } + + /* Merge two segments that now fit if autohealing */ + if ( autoheal && segafter && segbefore != segafter ) + { + /* Add segafter coverage to segbefore */ + if ( ! mstl_addsegtoseg (segbefore, segafter) ) + { + return 0; + } + + /* Shift last segment pointer if it's going to be removed */ + if ( segafter == id->last ) + id->last = id->last->prev; + + /* Remove segafter from list */ + if ( segafter->prev ) + segafter->prev->next = segafter->next; + if ( segafter->next ) + segafter->next->prev = segafter->prev; + + /* Free data samples, private data and segment structure */ + if (segafter->datasamples) + free (segafter->datasamples); + + if (segafter->prvtptr) + free (segafter->prvtptr); + + free (segafter); + } + + seg = segbefore; + } + /* Add MSRecord coverage to beginning of segment after */ + else if ( segafter ) + { + if ( ! mstl_addmsrtoseg (segafter, msr, endtime, 2) ) + { + return 0; + } + + seg = segafter; + } + /* Add MSRecord coverage to new segment */ + else + { + /* Create new segment */ + if ( ! (seg = mstl_msr2seg (msr, endtime)) ) + { + return 0; + } + + /* Add new segment as first in list */ + if ( ! followseg ) + { + seg->next = id->first; + if ( id->first ) + id->first->prev = seg; + + id->first = seg; + } + /* Add new segment after the followseg segment */ + else + { + seg->next = followseg->next; + seg->prev = followseg; + if ( followseg->next ) + followseg->next->prev = seg; + followseg->next = seg; + + if ( followseg == id->last ) + id->last = seg; + } + + id->numsegments++; + } + + /* Track earliest and latest times */ + if ( msr->starttime < id->earliest ) + id->earliest = msr->starttime; + + if ( endtime > id->latest ) + id->latest = endtime; + } /* End of searching segment list */ + } /* End of adding coverage to matching ID */ + + /* Sort modified segment into place, logic above should limit these to few shifts if any */ + while ( seg->next && ( seg->starttime > seg->next->starttime || + (seg->starttime == seg->next->starttime && seg->endtime < seg->next->endtime) ) ) + { + /* Move segment down list, swap seg and seg->next */ + segafter = seg->next; + + if ( seg->prev ) + seg->prev->next = segafter; + + if ( segafter->next ) + segafter->next->prev = seg; + + segafter->prev = seg->prev; + seg->prev = segafter; + seg->next = segafter->next; + segafter->next = seg; + + /* Reset first and last segment pointers if replaced */ + if ( id->first == seg ) + id->first = segafter; + + if ( id->last == segafter ) + id->last = seg; + } + while ( seg->prev && ( seg->starttime < seg->prev->starttime || + (seg->starttime == seg->prev->starttime && seg->endtime > seg->prev->endtime) ) ) + { + /* Move segment up list, swap seg and seg->prev */ + segbefore = seg->prev; + + if ( seg->next ) + seg->next->prev = segbefore; + + if ( segbefore->prev ) + segbefore->prev->next = seg; + + segbefore->next = seg->next; + seg->next = segbefore; + seg->prev = segbefore->prev; + segbefore->prev = seg; + + /* Reset first and last segment pointers if replaced */ + if ( id->first == segbefore ) + id->first = seg; + + if ( id->last == seg ) + id->last = segbefore; + } + + /* Set MSTraceID as last accessed */ + mstl->last = id; + + return seg; +} /* End of mstl_addmsr() */ + + +/*************************************************************************** + * mstl_msr2seg: + * + * Create an MSTraceSeg structure from an MSRecord structure. + * + * Return a pointer to a MSTraceSeg otherwise 0 on error. + ***************************************************************************/ +MSTraceSeg * +mstl_msr2seg (MSRecord *msr, hptime_t endtime) +{ + MSTraceSeg *seg = 0; + int samplesize; + + if ( ! (seg = (MSTraceSeg *) calloc (1, sizeof(MSTraceSeg))) ) + { + ms_log (2, "mstl_addmsr(): Error allocating memory\n"); + return 0; + } + + /* Populate MSTraceSeg */ + seg->starttime = msr->starttime; + seg->endtime = endtime; + seg->samprate = msr->samprate; + seg->samplecnt = msr->samplecnt; + seg->sampletype = msr->sampletype; + seg->numsamples = msr->numsamples; + + /* Allocate space for and copy datasamples */ + if ( msr->datasamples && msr->numsamples ) + { + samplesize = ms_samplesize (msr->sampletype); + + if ( ! (seg->datasamples = malloc ((size_t) (samplesize * msr->numsamples))) ) + { + ms_log (2, "mstl_msr2seg(): Error allocating memory\n"); + return 0; + } + + /* Copy data samples from MSRecord to MSTraceSeg */ + memcpy (seg->datasamples, msr->datasamples, (size_t) (samplesize * msr->numsamples)); + } + + return seg; +} /* End of mstl_msr2seg() */ + + +/*************************************************************************** + * mstl_addmsrtoseg: + * + * Add data coverage from a MSRecord structure to a MSTraceSeg structure. + * + * Data coverage is added to the beginning or end of MSTraceSeg + * according to the whence flag: + * 1 : add coverage to the end + * 2 : add coverage to the beginninig + * + * Return a pointer to a MSTraceSeg otherwise 0 on error. + ***************************************************************************/ +MSTraceSeg * +mstl_addmsrtoseg (MSTraceSeg *seg, MSRecord *msr, hptime_t endtime, flag whence) +{ + int samplesize = 0; + void *newdatasamples; + + if ( ! seg || ! msr ) + return 0; + + /* Allocate more memory for data samples if included */ + if ( msr->datasamples && msr->numsamples > 0 ) + { + if ( msr->sampletype != seg->sampletype ) + { + ms_log (2, "mstl_addmsrtoseg(): MSRecord sample type (%c) does not match segment sample type (%c)\n", + msr->sampletype, seg->sampletype); + return 0; + } + + if ( ! (samplesize = ms_samplesize (msr->sampletype)) ) + { + ms_log (2, "mstl_addmsrtoseg(): Unknown sample size for sample type: %c\n", msr->sampletype); + return 0; + } + + if ( ! (newdatasamples = realloc (seg->datasamples, (size_t)((seg->numsamples + msr->numsamples) * samplesize))) ) + { + ms_log (2, "mstl_addmsrtoseg(): Error allocating memory\n"); + return 0; + } + + seg->datasamples = newdatasamples; + } + + /* Add coverage to end of segment */ + if ( whence == 1 ) + { + seg->endtime = endtime; + seg->samplecnt += msr->samplecnt; + + if ( msr->datasamples && msr->numsamples > 0 ) + { + memcpy ((char *)seg->datasamples + (seg->numsamples * samplesize), + msr->datasamples, + (size_t) (msr->numsamples * samplesize)); + + seg->numsamples += msr->numsamples; + } + } + /* Add coverage to beginning of segment */ + else if ( whence == 2 ) + { + seg->starttime = msr->starttime; + seg->samplecnt += msr->samplecnt; + + if ( msr->datasamples && msr->numsamples > 0 ) + { + memmove ((char *)seg->datasamples + (msr->numsamples * samplesize), + seg->datasamples, + (size_t) (seg->numsamples * samplesize)); + + memcpy (seg->datasamples, + msr->datasamples, + (size_t) (msr->numsamples * samplesize)); + + seg->numsamples += msr->numsamples; + } + } + else + { + ms_log (2, "mstl_addmsrtoseg(): unrecognized whence value: %d\n", whence); + return 0; + } + + return seg; +} /* End of mstl_addmsrtoseg() */ + + +/*************************************************************************** + * mstl_addsegtoseg: + * + * Add data coverage from seg2 to seg1. + * + * Return a pointer to a seg1 otherwise 0 on error. + ***************************************************************************/ +MSTraceSeg * +mstl_addsegtoseg (MSTraceSeg *seg1, MSTraceSeg *seg2) +{ + int samplesize = 0; + void *newdatasamples; + + if ( ! seg1 || ! seg2 ) + return 0; + + /* Allocate more memory for data samples if included */ + if ( seg2->datasamples && seg2->numsamples > 0 ) + { + if ( seg2->sampletype != seg1->sampletype ) + { + ms_log (2, "mstl_addsegtoseg(): MSTraceSeg sample types do not match (%c and %c)\n", + seg1->sampletype, seg2->sampletype); + return 0; + } + + if ( ! (samplesize = ms_samplesize (seg1->sampletype)) ) + { + ms_log (2, "mstl_addsegtoseg(): Unknown sample size for sample type: %c\n", seg1->sampletype); + return 0; + } + + if ( ! (newdatasamples = realloc (seg1->datasamples, (size_t) ((seg1->numsamples + seg2->numsamples) * samplesize))) ) + { + ms_log (2, "mstl_addsegtoseg(): Error allocating memory\n"); + return 0; + } + + seg1->datasamples = newdatasamples; + } + + /* Add seg2 coverage to end of seg1 */ + seg1->endtime = seg2->endtime; + seg1->samplecnt += seg2->samplecnt; + + if ( seg2->datasamples && seg2->numsamples > 0 ) + { + memcpy ((char *)seg1->datasamples + (seg1->numsamples * samplesize), + seg2->datasamples, + (size_t) (seg2->numsamples * samplesize)); + + seg1->numsamples += seg2->numsamples; + } + + return seg1; +} /* End of mstl_addsegtoseg() */ + + +/*************************************************************************** + * mstl_convertsamples: + * + * Convert the data samples associated with an MSTraceSeg to another + * data type. ASCII data samples cannot be converted, if supplied or + * requested an error will be returned. + * + * When converting float & double sample types to integer type a + * simple rounding is applied by adding 0.5 to the sample value before + * converting (truncating) to integer. + * + * If the truncate flag is true data samples will be truncated to + * integers even if loss of sample precision is detected. If the + * truncate flag is false (0) and loss of precision is detected an + * error is returned. + * + * Returns 0 on success, and -1 on failure. + ***************************************************************************/ +int +mstl_convertsamples ( MSTraceSeg *seg, char type, flag truncate ) +{ + int32_t *idata; + float *fdata; + double *ddata; + int64_t idx; + + if ( ! seg ) + return -1; + + /* No conversion necessary, report success */ + if ( seg->sampletype == type ) + return 0; + + if ( seg->sampletype == 'a' || type == 'a' ) + { + ms_log (2, "mstl_convertsamples: cannot convert ASCII samples to/from numeric type\n"); + return -1; + } + + idata = (int32_t *) seg->datasamples; + fdata = (float *) seg->datasamples; + ddata = (double *) seg->datasamples; + + /* Convert to 32-bit integers */ + if ( type == 'i' ) + { + if ( seg->sampletype == 'f' ) /* Convert floats to integers with simple rounding */ + { + for (idx = 0; idx < seg->numsamples; idx++) + { + /* Check for loss of sub-integer */ + if ( ! truncate && (fdata[idx] - (int32_t)fdata[idx]) > 0.000001 ) + { + ms_log (1, "mstl_convertsamples: Warning, loss of precision when converting floats to integers, loss: %g\n", + (fdata[idx] - (int32_t)fdata[idx])); + return -1; + } + + idata[idx] = (int32_t) (fdata[idx] + 0.5); + } + } + else if ( seg->sampletype == 'd' ) /* Convert doubles to integers with simple rounding */ + { + for (idx = 0; idx < seg->numsamples; idx++) + { + /* Check for loss of sub-integer */ + if ( ! truncate && (ddata[idx] - (int32_t)ddata[idx]) > 0.000001 ) + { + ms_log (1, "mstl_convertsamples: Warning, loss of precision when converting doubles to integers, loss: %g\n", + (ddata[idx] - (int32_t)ddata[idx])); + return -1; + } + + idata[idx] = (int32_t) (ddata[idx] + 0.5); + } + + /* Reallocate buffer for reduced size needed */ + if ( ! (seg->datasamples = realloc (seg->datasamples, (seg->numsamples * sizeof(int32_t)))) ) + { + ms_log (2, "mstl_convertsamples: cannot re-allocate buffer for sample conversion\n"); + return -1; + } + } + + seg->sampletype = 'i'; + } /* Done converting to 32-bit integers */ + + /* Convert to 32-bit floats */ + else if ( type == 'f' ) + { + if ( seg->sampletype == 'i' ) /* Convert integers to floats */ + { + for (idx = 0; idx < seg->numsamples; idx++) + fdata[idx] = (float) idata[idx]; + } + else if ( seg->sampletype == 'd' ) /* Convert doubles to floats */ + { + for (idx = 0; idx < seg->numsamples; idx++) + fdata[idx] = (float) ddata[idx]; + + /* Reallocate buffer for reduced size needed */ + if ( ! (seg->datasamples = realloc (seg->datasamples, (seg->numsamples * sizeof(float)))) ) + { + ms_log (2, "mstl_convertsamples: cannot re-allocate buffer after sample conversion\n"); + return -1; + } + } + + seg->sampletype = 'f'; + } /* Done converting to 32-bit floats */ + + /* Convert to 64-bit doubles */ + else if ( type == 'd' ) + { + if ( ! (ddata = (double *) malloc (seg->numsamples * sizeof(double))) ) + { + ms_log (2, "mstl_convertsamples: cannot allocate buffer for sample conversion to doubles\n"); + return -1; + } + + if ( seg->sampletype == 'i' ) /* Convert integers to doubles */ + { + for (idx = 0; idx < seg->numsamples; idx++) + ddata[idx] = (double) idata[idx]; + + free (idata); + } + else if ( seg->sampletype == 'f' ) /* Convert floats to doubles */ + { + for (idx = 0; idx < seg->numsamples; idx++) + ddata[idx] = (double) fdata[idx]; + + free (fdata); + } + + seg->datasamples = ddata; + seg->sampletype = 'd'; + } /* Done converting to 64-bit doubles */ + + return 0; +} /* End of mstl_convertsamples() */ + + +/*************************************************************************** + * mstl_printtracelist: + * + * Print trace list summary information for the specified MSTraceList. + * + * By default only print the srcname, starttime and endtime for each + * trace. If details is greater than 0 include the sample rate, + * number of samples and a total trace count. If gaps is greater than + * 0 and the previous trace matches (srcname & samprate) include the + * gap between the endtime of the last trace and the starttime of the + * current trace. + * + * The timeformat flag can either be: + * 0 : SEED time format (year, day-of-year, hour, min, sec) + * 1 : ISO time format (year, month, day, hour, min, sec) + * 2 : Epoch time, seconds since the epoch + ***************************************************************************/ +void +mstl_printtracelist ( MSTraceList *mstl, flag timeformat, + flag details, flag gaps ) +{ + MSTraceID *id = 0; + MSTraceSeg *seg = 0; + char stime[30]; + char etime[30]; + char gapstr[20]; + flag nogap; + double gap; + double delta; + int tracecnt = 0; + int segcnt = 0; + + if ( ! mstl ) + { + return; + } + + /* Print out the appropriate header */ + if ( details > 0 && gaps > 0 ) + ms_log (0, " Source Start sample End sample Gap Hz Samples\n"); + else if ( details <= 0 && gaps > 0 ) + ms_log (0, " Source Start sample End sample Gap\n"); + else if ( details > 0 && gaps <= 0 ) + ms_log (0, " Source Start sample End sample Hz Samples\n"); + else + ms_log (0, " Source Start sample End sample\n"); + + /* Loop through trace list */ + id = mstl->traces; + while ( id ) + { + /* Loop through segment list */ + seg = id->first; + while ( seg ) + { + /* Create formatted time strings */ + if ( timeformat == 2 ) + { + snprintf (stime, sizeof(stime), "%.6f", (double) MS_HPTIME2EPOCH(seg->starttime) ); + snprintf (etime, sizeof(etime), "%.6f", (double) MS_HPTIME2EPOCH(seg->endtime) ); + } + else if ( timeformat == 1 ) + { + if ( ms_hptime2isotimestr (seg->starttime, stime, 1) == NULL ) + ms_log (2, "Cannot convert trace start time for %s\n", id->srcname); + + if ( ms_hptime2isotimestr (seg->endtime, etime, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", id->srcname); + } + else + { + if ( ms_hptime2seedtimestr (seg->starttime, stime, 1) == NULL ) + ms_log (2, "Cannot convert trace start time for %s\n", id->srcname); + + if ( ms_hptime2seedtimestr (seg->endtime, etime, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", id->srcname); + } + + /* Print segment info at varying levels */ + if ( gaps > 0 ) + { + gap = 0.0; + nogap = 0; + + if ( seg->prev ) + gap = (double) (seg->starttime - seg->prev->endtime) / HPTMODULUS; + else + nogap = 1; + + /* Check that any overlap is not larger than the trace coverage */ + if ( gap < 0.0 ) + { + delta = ( seg->samprate ) ? (1.0 / seg->samprate) : 0.0; + + if ( (gap * -1.0) > (((double)(seg->endtime - seg->starttime)/HPTMODULUS) + delta) ) + gap = -(((double)(seg->endtime - seg->starttime)/HPTMODULUS) + delta); + } + + /* Fix up gap display */ + if ( nogap ) + snprintf (gapstr, sizeof(gapstr), " == "); + else if ( gap >= 86400.0 || gap <= -86400.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fd", (gap / 86400)); + else if ( gap >= 3600.0 || gap <= -3600.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fh", (gap / 3600)); + else if ( gap == 0.0 ) + snprintf (gapstr, sizeof(gapstr), "-0 "); + else + snprintf (gapstr, sizeof(gapstr), "%-4.4g", gap); + + if ( details <= 0 ) + ms_log (0, "%-17s %-24s %-24s %-4s\n", + id->srcname, stime, etime, gapstr); + else + ms_log (0, "%-17s %-24s %-24s %-s %-3.3g %-lld\n", + id->srcname, stime, etime, gapstr, seg->samprate, (long long int)seg->samplecnt); + } + else if ( details > 0 && gaps <= 0 ) + ms_log (0, "%-17s %-24s %-24s %-3.3g %-lld\n", + id->srcname, stime, etime, seg->samprate, (long long int)seg->samplecnt); + else + ms_log (0, "%-17s %-24s %-24s\n", id->srcname, stime, etime); + + segcnt++; + seg = seg->next; + } + + tracecnt++; + id = id->next; + } + + if ( tracecnt != mstl->numtraces ) + ms_log (2, "mstl_printtracelist(): number of traces in trace list is inconsistent\n"); + + if ( details > 0 ) + ms_log (0, "Total: %d trace(s) with %d segment(s)\n", tracecnt, segcnt); + + return; +} /* End of mstl_printtracelist() */ + + +/*************************************************************************** + * mstl_printsynclist: + * + * Print SYNC trace list summary information for the specified MSTraceList. + * + * The SYNC header line will be created using the supplied dccid, if + * the pointer is NULL the string "DCC" will be used instead. + * + * If the subsecond flag is true the segment start and end times will + * include subsecond precision, otherwise they will be truncated to + * integer seconds. + * + ***************************************************************************/ +void +mstl_printsynclist ( MSTraceList *mstl, char *dccid, flag subsecond ) +{ + MSTraceID *id = 0; + MSTraceSeg *seg = 0; + char starttime[30]; + char endtime[30]; + char yearday[10]; + time_t now; + struct tm *nt; + + if ( ! mstl ) + { + return; + } + + /* Generate current time stamp */ + now = time (NULL); + nt = localtime ( &now ); nt->tm_year += 1900; nt->tm_yday += 1; + snprintf ( yearday, sizeof(yearday), "%04d,%03d", nt->tm_year, nt->tm_yday); + + /* Print SYNC header line */ + ms_log (0, "%s|%s\n", (dccid)?dccid:"DCC", yearday); + + /* Loop through trace list */ + id = mstl->traces; + while ( id ) + { + /* Loop through segment list */ + seg = id->first; + while ( seg ) + { + ms_hptime2seedtimestr (seg->starttime, starttime, subsecond); + ms_hptime2seedtimestr (seg->endtime, endtime, subsecond); + + /* Print SYNC line */ + ms_log (0, "%s|%s|%s|%s|%s|%s||%.10g|%lld|||||||%s\n", + id->network, id->station, id->location, id->channel, + starttime, endtime, seg->samprate, (long long int)seg->samplecnt, + yearday); + + seg = seg->next; + } + + id = id->next; + } + + return; +} /* End of mstl_printsynclist() */ + + +/*************************************************************************** + * mstl_printgaplist: + * + * Print gap/overlap list summary information for the specified + * MSTraceList. Overlaps are printed as negative gaps. + * + * If mingap and maxgap are not NULL their values will be enforced and + * only gaps/overlaps matching their implied criteria will be printed. + * + * The timeformat flag can either be: + * 0 : SEED time format (year, day-of-year, hour, min, sec) + * 1 : ISO time format (year, month, day, hour, min, sec) + * 2 : Epoch time, seconds since the epoch + ***************************************************************************/ +void +mstl_printgaplist (MSTraceList *mstl, flag timeformat, + double *mingap, double *maxgap) +{ + MSTraceID *id = 0; + MSTraceSeg *seg = 0; + + char time1[30], time2[30]; + char gapstr[30]; + double gap; + double delta; + double nsamples; + flag printflag; + int gapcnt = 0; + + if ( ! mstl ) + return; + + if ( ! mstl->traces ) + return; + + ms_log (0, " Source Last Sample Next Sample Gap Samples\n"); + + id = mstl->traces; + while ( id ) + { + seg = id->first; + while ( seg->next ) + { + /* Skip segments with 0 sample rate, usually from SOH records */ + if ( seg->samprate == 0.0 ) + { + seg = seg->next; + continue; + } + + gap = (double) (seg->next->starttime - seg->endtime) / HPTMODULUS; + + /* Check that any overlap is not larger than the trace coverage */ + if ( gap < 0.0 ) + { + delta = ( seg->next->samprate ) ? (1.0 / seg->next->samprate) : 0.0; + + if ( (gap * -1.0) > (((double)(seg->next->endtime - seg->next->starttime)/HPTMODULUS) + delta) ) + gap = -(((double)(seg->next->endtime - seg->next->starttime)/HPTMODULUS) + delta); + } + + printflag = 1; + + /* Check gap/overlap criteria */ + if ( mingap ) + if ( gap < *mingap ) + printflag = 0; + + if ( maxgap ) + if ( gap > *maxgap ) + printflag = 0; + + if ( printflag ) + { + nsamples = ms_dabs(gap) * seg->samprate; + + if ( gap > 0.0 ) + nsamples -= 1.0; + else + nsamples += 1.0; + + /* Fix up gap display */ + if ( gap >= 86400.0 || gap <= -86400.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fd", (gap / 86400)); + else if ( gap >= 3600.0 || gap <= -3600.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fh", (gap / 3600)); + else if ( gap == 0.0 ) + snprintf (gapstr, sizeof(gapstr), "-0 "); + else + snprintf (gapstr, sizeof(gapstr), "%-4.4g", gap); + + /* Create formatted time strings */ + if ( timeformat == 2 ) + { + snprintf (time1, sizeof(time1), "%.6f", (double) MS_HPTIME2EPOCH(seg->endtime) ); + snprintf (time2, sizeof(time2), "%.6f", (double) MS_HPTIME2EPOCH(seg->next->starttime) ); + } + else if ( timeformat == 1 ) + { + if ( ms_hptime2isotimestr (seg->endtime, time1, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", id->srcname); + + if ( ms_hptime2isotimestr (seg->next->starttime, time2, 1) == NULL ) + ms_log (2, "Cannot convert next trace start time for %s\n", id->srcname); + } + else + { + if ( ms_hptime2seedtimestr (seg->endtime, time1, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", id->srcname); + + if ( ms_hptime2seedtimestr (seg->next->starttime, time2, 1) == NULL ) + ms_log (2, "Cannot convert next trace start time for %s\n", id->srcname); + } + + ms_log (0, "%-17s %-24s %-24s %-4s %-.8g\n", + id->srcname, time1, time2, gapstr, nsamples); + + gapcnt++; + } + + seg = seg->next; + } + + id = id->next; + } + + ms_log (0, "Total: %d gap(s)\n", gapcnt); + + return; +} /* End of mstl_printgaplist() */ diff --git a/libs/3rd-party/mseed/traceutils.c b/libs/3rd-party/mseed/traceutils.c new file mode 100644 index 0000000..90fd614 --- /dev/null +++ b/libs/3rd-party/mseed/traceutils.c @@ -0,0 +1,1855 @@ +/*************************************************************************** + * traceutils.c: + * + * Generic routines to handle Traces. + * + * Written by Chad Trabant, IRIS Data Management Center + * + * modified: 2013.273 + ***************************************************************************/ + +#include +#include +#include +#include + +#include "libmseed.h" + +static int mst_groupsort_cmp ( MSTrace *mst1, MSTrace *mst2, flag quality ); + + +/*************************************************************************** + * mst_init: + * + * Initialize and return a MSTrace struct, allocating memory if needed. + * If the specified MSTrace includes data samples they will be freed. + * + * Returns a pointer to a MSTrace struct on success or NULL on error. + ***************************************************************************/ +MSTrace * +mst_init ( MSTrace *mst ) +{ + /* Free datasamples, prvtptr and stream state if present */ + if ( mst ) + { + if ( mst->datasamples ) + free (mst->datasamples); + + if ( mst->prvtptr ) + free (mst->prvtptr); + + if ( mst->ststate ) + free (mst->ststate); + } + else + { + mst = (MSTrace *) malloc (sizeof(MSTrace)); + } + + if ( mst == NULL ) + { + ms_log (2, "mst_init(): Cannot allocate memory\n"); + return NULL; + } + + memset (mst, 0, sizeof (MSTrace)); + + return mst; +} /* End of mst_init() */ + + +/*************************************************************************** + * mst_free: + * + * Free all memory associated with a MSTrace struct and set the pointer + * to 0. + ***************************************************************************/ +void +mst_free ( MSTrace **ppmst ) +{ + if ( ppmst && *ppmst ) + { + /* Free datasamples if present */ + if ( (*ppmst)->datasamples ) + free ((*ppmst)->datasamples); + + /* Free private memory if present */ + if ( (*ppmst)->prvtptr ) + free ((*ppmst)->prvtptr); + + /* Free stream processing state if present */ + if ( (*ppmst)->ststate ) + free ((*ppmst)->ststate); + + free (*ppmst); + + *ppmst = 0; + } +} /* End of mst_free() */ + + +/*************************************************************************** + * mst_initgroup: + * + * Initialize and return a MSTraceGroup struct, allocating memory if + * needed. If the supplied MSTraceGroup is not NULL any associated + * memory it will be freed. + * + * Returns a pointer to a MSTraceGroup struct on success or NULL on error. + ***************************************************************************/ +MSTraceGroup * +mst_initgroup ( MSTraceGroup *mstg ) +{ + MSTrace *mst = 0; + MSTrace *next = 0; + + if ( mstg ) + { + mst = mstg->traces; + + while ( mst ) + { + next = mst->next; + mst_free (&mst); + mst = next; + } + } + else + { + mstg = (MSTraceGroup *) malloc (sizeof(MSTraceGroup)); + } + + if ( mstg == NULL ) + { + ms_log (2, "mst_initgroup(): Cannot allocate memory\n"); + return NULL; + } + + memset (mstg, 0, sizeof (MSTraceGroup)); + + return mstg; +} /* End of mst_initgroup() */ + + +/*************************************************************************** + * mst_freegroup: + * + * Free all memory associated with a MSTraceGroup struct and set the + * pointer to 0. + ***************************************************************************/ +void +mst_freegroup ( MSTraceGroup **ppmstg ) +{ + MSTrace *mst = 0; + MSTrace *next = 0; + + if ( *ppmstg ) + { + mst = (*ppmstg)->traces; + + while ( mst ) + { + next = mst->next; + mst_free (&mst); + mst = next; + } + + free (*ppmstg); + + *ppmstg = 0; + } +} /* End of mst_freegroup() */ + + +/*************************************************************************** + * mst_findmatch: + * + * Traverse the MSTrace chain starting at 'startmst' until a MSTrace + * is found that matches the given name identifiers. If the dataquality + * byte is not 0 it must also match. + * + * Return a pointer a matching MSTrace otherwise 0 if no match found. + ***************************************************************************/ +MSTrace * +mst_findmatch ( MSTrace *startmst, char dataquality, + char *network, char *station, char *location, char *channel ) +{ + int idx; + + if ( ! startmst ) + return 0; + + while ( startmst ) + { + if ( dataquality && dataquality != startmst->dataquality ) + { + startmst = startmst->next; + continue; + } + + /* Compare network */ + idx = 0; + while ( network[idx] == startmst->network[idx] ) + { + if ( network[idx] == '\0' ) + break; + idx++; + } + if ( network[idx] != '\0' || startmst->network[idx] != '\0' ) + { + startmst = startmst->next; + continue; + } + /* Compare station */ + idx = 0; + while ( station[idx] == startmst->station[idx] ) + { + if ( station[idx] == '\0' ) + break; + idx++; + } + if ( station[idx] != '\0' || startmst->station[idx] != '\0' ) + { + startmst = startmst->next; + continue; + } + /* Compare location */ + idx = 0; + while ( location[idx] == startmst->location[idx] ) + { + if ( location[idx] == '\0' ) + break; + idx++; + } + if ( location[idx] != '\0' || startmst->location[idx] != '\0' ) + { + startmst = startmst->next; + continue; + } + /* Compare channel */ + idx = 0; + while ( channel[idx] == startmst->channel[idx] ) + { + if ( channel[idx] == '\0' ) + break; + idx++; + } + if ( channel[idx] != '\0' || startmst->channel[idx] != '\0' ) + { + startmst = startmst->next; + continue; + } + + /* A match was found if we made it this far */ + break; + } + + return startmst; +} /* End of mst_findmatch() */ + + +/*************************************************************************** + * mst_findadjacent: + * + * Find a MSTrace in a MSTraceGroup matching the given name + * identifiers, samplerate and is adjacent with a time span. If the + * dataquality byte is not 0 it must also match. + * + * The time tolerance and sample rate tolerance are used to determine + * if traces abut. If timetol is -1.0 the default tolerance of 1/2 + * the sample period will be used. If samprratetol is -1.0 the + * default tolerance check of abs(1-sr1/sr2) < 0.0001 is used (defined + * in libmseed.h). If timetol or sampratetol is -2.0 the respective + * tolerance check will not be performed. + * + * The 'whence' flag will be set, when a matching MSTrace is found, to + * indicate where the indicated time span is adjacent to the MSTrace + * using the following values: + * 1: time span fits at the end of the MSTrace + * 2: time span fits at the beginning of the MSTrace + * + * Return a pointer a matching MSTrace and set the 'whence' flag + * otherwise 0 if no match found. + ***************************************************************************/ +MSTrace * +mst_findadjacent ( MSTraceGroup *mstg, flag *whence, char dataquality, + char *network, char *station, char *location, char *channel, + double samprate, double sampratetol, + hptime_t starttime, hptime_t endtime, double timetol ) +{ + MSTrace *mst = 0; + hptime_t pregap; + hptime_t postgap; + hptime_t hpdelta; + hptime_t hptimetol = 0; + hptime_t nhptimetol = 0; + int idx; + + if ( ! mstg ) + return 0; + + *whence = 0; + + /* Calculate high-precision sample period */ + hpdelta = (hptime_t)(( samprate ) ? (HPTMODULUS / samprate) : 0.0); + + /* Calculate high-precision time tolerance */ + if ( timetol == -1.0 ) + hptimetol = (hptime_t) (0.5 * hpdelta); /* Default time tolerance is 1/2 sample period */ + else if ( timetol >= 0.0 ) + hptimetol = (hptime_t) (timetol * HPTMODULUS); + + nhptimetol = ( hptimetol ) ? -hptimetol : 0; + + mst = mstg->traces; + + while ( mst ) + { + /* post/pregap are negative when the record overlaps the trace + * segment and positive when there is a time gap. */ + postgap = starttime - mst->endtime - hpdelta; + + pregap = mst->starttime - endtime - hpdelta; + + /* If not checking the time tolerance decide if beginning or end is a better fit */ + if ( timetol == -2.0 ) + { + if ( ms_dabs((double)postgap) < ms_dabs((double)pregap) ) + *whence = 1; + else + *whence = 2; + } + else + { + if ( postgap <= hptimetol && postgap >= nhptimetol ) + { + /* Span fits right at the end of the trace */ + *whence = 1; + } + else if ( pregap <= hptimetol && pregap >= nhptimetol ) + { + /* Span fits right at the beginning of the trace */ + *whence = 2; + } + else + { + /* Span does not fit with this Trace */ + mst = mst->next; + continue; + } + } + + /* Perform samprate tolerance check if requested */ + if ( sampratetol != -2.0 ) + { + /* Perform default samprate tolerance check if requested */ + if ( sampratetol == -1.0 ) + { + if ( ! MS_ISRATETOLERABLE (samprate, mst->samprate) ) + { + mst = mst->next; + continue; + } + } + /* Otherwise check against the specified sample rate tolerance */ + else if ( ms_dabs(samprate - mst->samprate) > sampratetol ) + { + mst = mst->next; + continue; + } + } + + /* Compare data qualities */ + if ( dataquality && dataquality != mst->dataquality ) + { + mst = mst->next; + continue; + } + + /* Compare network */ + idx = 0; + while ( network[idx] == mst->network[idx] ) + { + if ( network[idx] == '\0' ) + break; + idx++; + } + if ( network[idx] != '\0' || mst->network[idx] != '\0' ) + { + mst = mst->next; + continue; + } + /* Compare station */ + idx = 0; + while ( station[idx] == mst->station[idx] ) + { + if ( station[idx] == '\0' ) + break; + idx++; + } + if ( station[idx] != '\0' || mst->station[idx] != '\0' ) + { + mst = mst->next; + continue; + } + /* Compare location */ + idx = 0; + while ( location[idx] == mst->location[idx] ) + { + if ( location[idx] == '\0' ) + break; + idx++; + } + if ( location[idx] != '\0' || mst->location[idx] != '\0' ) + { + mst = mst->next; + continue; + } + /* Compare channel */ + idx = 0; + while ( channel[idx] == mst->channel[idx] ) + { + if ( channel[idx] == '\0' ) + break; + idx++; + } + if ( channel[idx] != '\0' || mst->channel[idx] != '\0' ) + { + mst = mst->next; + continue; + } + + /* A match was found if we made it this far */ + break; + } + + return mst; +} /* End of mst_findadjacent() */ + + +/*************************************************************************** + * mst_addmsr: + * + * Add MSRecord time coverage to a MSTrace. The start or end time will + * be updated and samples will be copied if they exist. No checking + * is done to verify that the record matches the trace in any way. + * + * If whence is 1 the coverage will be added at the end of the trace, + * whereas if whence is 2 the coverage will be added at the beginning + * of the trace. + * + * Return 0 on success and -1 on error. + ***************************************************************************/ +int +mst_addmsr ( MSTrace *mst, MSRecord *msr, flag whence ) +{ + int samplesize = 0; + + if ( ! mst || ! msr ) + return -1; + + /* Reallocate data sample buffer if samples are present */ + if ( msr->datasamples && msr->numsamples >= 0 ) + { + /* Check that the entire record was decompressed */ + if ( msr->samplecnt != msr->numsamples ) + { + ms_log (2, "mst_addmsr(): Sample counts do not match, record not fully decompressed?\n"); + ms_log (2, " The sample buffer will likely contain a discontinuity.\n"); + } + + if ( (samplesize = ms_samplesize(msr->sampletype)) == 0 ) + { + ms_log (2, "mst_addmsr(): Unrecognized sample type: '%c'\n", + msr->sampletype); + return -1; + } + + if ( msr->sampletype != mst->sampletype ) + { + ms_log (2, "mst_addmsr(): Mismatched sample type, '%c' and '%c'\n", + msr->sampletype, mst->sampletype); + return -1; + } + + mst->datasamples = realloc (mst->datasamples, + (size_t) (mst->numsamples * samplesize + msr->numsamples * samplesize) ); + + if ( mst->datasamples == NULL ) + { + ms_log (2, "mst_addmsr(): Cannot allocate memory\n"); + return -1; + } + } + + /* Add samples at end of trace */ + if ( whence == 1 ) + { + if ( msr->datasamples && msr->numsamples >= 0 ) + { + memcpy ((char *)mst->datasamples + (mst->numsamples * samplesize), + msr->datasamples, + (size_t) (msr->numsamples * samplesize)); + + mst->numsamples += msr->numsamples; + } + + mst->endtime = msr_endtime (msr); + + if ( mst->endtime == HPTERROR ) + { + ms_log (2, "mst_addmsr(): Error calculating record end time\n"); + return -1; + } + } + + /* Add samples at the beginning of trace */ + else if ( whence == 2 ) + { + if ( msr->datasamples && msr->numsamples >= 0 ) + { + /* Move any samples to end of buffer */ + if ( mst->numsamples > 0 ) + { + memmove ((char *)mst->datasamples + (msr->numsamples * samplesize), + mst->datasamples, + (size_t) (mst->numsamples * samplesize)); + } + + memcpy (mst->datasamples, + msr->datasamples, + (size_t) (msr->numsamples * samplesize)); + + mst->numsamples += msr->numsamples; + } + + mst->starttime = msr->starttime; + } + + /* If two different data qualities reset the MSTrace.dataquality to 0 */ + if ( mst->dataquality && msr->dataquality && mst->dataquality != msr->dataquality ) + mst->dataquality = 0; + + /* Update MSTrace sample count */ + mst->samplecnt += msr->samplecnt; + + return 0; +} /* End of mst_addmsr() */ + + +/*************************************************************************** + * mst_addspan: + * + * Add a time span to a MSTrace. The start or end time will be updated + * and samples will be copied if they are provided. No checking is done to + * verify that the record matches the trace in any way. + * + * If whence is 1 the coverage will be added at the end of the trace, + * whereas if whence is 2 the coverage will be added at the beginning + * of the trace. + * + * Return 0 on success and -1 on error. + ***************************************************************************/ +int +mst_addspan ( MSTrace *mst, hptime_t starttime, hptime_t endtime, + void *datasamples, int64_t numsamples, char sampletype, + flag whence ) +{ + int samplesize = 0; + + if ( ! mst ) + return -1; + + if ( datasamples && numsamples > 0 ) + { + if ( (samplesize = ms_samplesize(sampletype)) == 0 ) + { + ms_log (2, "mst_addspan(): Unrecognized sample type: '%c'\n", + sampletype); + return -1; + } + + if ( sampletype != mst->sampletype ) + { + ms_log (2, "mst_addspan(): Mismatched sample type, '%c' and '%c'\n", + sampletype, mst->sampletype); + return -1; + } + + mst->datasamples = realloc (mst->datasamples, + (size_t) (mst->numsamples * samplesize + numsamples * samplesize)); + + if ( mst->datasamples == NULL ) + { + ms_log (2, "mst_addspan(): Cannot allocate memory\n"); + return -1; + } + } + + /* Add samples at end of trace */ + if ( whence == 1 ) + { + if ( datasamples && numsamples > 0 ) + { + memcpy ((char *)mst->datasamples + (mst->numsamples * samplesize), + datasamples, + (size_t) (numsamples * samplesize)); + + mst->numsamples += numsamples; + } + + mst->endtime = endtime; + } + + /* Add samples at the beginning of trace */ + else if ( whence == 2 ) + { + if ( datasamples && numsamples > 0 ) + { + /* Move any samples to end of buffer */ + if ( mst->numsamples > 0 ) + { + memmove ((char *)mst->datasamples + (numsamples * samplesize), + mst->datasamples, + (size_t) (mst->numsamples * samplesize)); + } + + memcpy (mst->datasamples, + datasamples, + (size_t) (numsamples * samplesize)); + + mst->numsamples += numsamples; + } + + mst->starttime = starttime; + } + + /* Update MSTrace sample count */ + if ( numsamples > 0 ) + mst->samplecnt += numsamples; + + return 0; +} /* End of mst_addspan() */ + + +/*************************************************************************** + * mst_addmsrtogroup: + * + * Add data samples from a MSRecord to a MSTrace in a MSTraceGroup by + * searching the group for the approriate MSTrace and either adding data + * to it or creating a new MSTrace if no match found. + * + * Matching traces are found using the mst_findadjacent() routine. If + * the dataquality flag is true the data quality bytes must also match + * otherwise they are ignored. + * + * Return a pointer to the MSTrace updated or 0 on error. + ***************************************************************************/ +MSTrace * +mst_addmsrtogroup ( MSTraceGroup *mstg, MSRecord *msr, flag dataquality, + double timetol, double sampratetol ) +{ + MSTrace *mst = 0; + hptime_t endtime; + flag whence; + char dq; + + if ( ! mstg || ! msr ) + return 0; + + dq = ( dataquality ) ? msr->dataquality : 0; + + endtime = msr_endtime (msr); + + if ( endtime == HPTERROR ) + { + ms_log (2, "mst_addmsrtogroup(): Error calculating record end time\n"); + return 0; + } + + /* Find matching, time adjacent MSTrace */ + mst = mst_findadjacent (mstg, &whence, dq, + msr->network, msr->station, msr->location, msr->channel, + msr->samprate, sampratetol, + msr->starttime, endtime, timetol); + + /* If a match was found update it otherwise create a new MSTrace and + add to end of MSTrace chain */ + if ( mst ) + { + /* Records with no time coverage do not contribute to a trace */ + if ( msr->samplecnt <= 0 || msr->samprate <= 0.0 ) + return mst; + + if ( mst_addmsr (mst, msr, whence) ) + { + return 0; + } + } + else + { + mst = mst_init (NULL); + + mst->dataquality = dq; + + strncpy (mst->network, msr->network, sizeof(mst->network)); + strncpy (mst->station, msr->station, sizeof(mst->station)); + strncpy (mst->location, msr->location, sizeof(mst->location)); + strncpy (mst->channel, msr->channel, sizeof(mst->channel)); + + mst->starttime = msr->starttime; + mst->samprate = msr->samprate; + mst->sampletype = msr->sampletype; + + if ( mst_addmsr (mst, msr, 1) ) + { + mst_free (&mst); + return 0; + } + + /* Link new MSTrace into the end of the chain */ + if ( ! mstg->traces ) + { + mstg->traces = mst; + } + else + { + MSTrace *lasttrace = mstg->traces; + + while ( lasttrace->next ) + lasttrace = lasttrace->next; + + lasttrace->next = mst; + } + + mstg->numtraces++; + } + + return mst; +} /* End of mst_addmsrtogroup() */ + + +/*************************************************************************** + * mst_addtracetogroup: + * + * Add a MSTrace to a MSTraceGroup at the end of the MSTrace chain. + * + * Return a pointer to the MSTrace added or 0 on error. + ***************************************************************************/ +MSTrace * +mst_addtracetogroup ( MSTraceGroup *mstg, MSTrace *mst ) +{ + MSTrace *lasttrace; + + if ( ! mstg || ! mst ) + return 0; + + if ( ! mstg->traces ) + { + mstg->traces = mst; + } + else + { + lasttrace = mstg->traces; + + while ( lasttrace->next ) + lasttrace = lasttrace->next; + + lasttrace->next = mst; + } + + mst->next = 0; + + mstg->numtraces++; + + return mst; +} /* End of mst_addtracetogroup() */ + + +/*************************************************************************** + * mst_groupheal: + * + * Check if traces in MSTraceGroup can be healed, if contiguous segments + * belong together they will be merged. This routine is only useful + * if the trace group was assembled from segments out of time order + * (e.g. a file of Mini-SEED records not in time order) but forming + * contiguous time coverage. The MSTraceGroup will be sorted using + * mst_groupsort() before healing. + * + * The time tolerance and sample rate tolerance are used to determine + * if the traces are indeed the same. If timetol is -1.0 the default + * tolerance of 1/2 the sample period will be used. If samprratetol + * is -1.0 the default tolerance check of abs(1-sr1/sr2) < 0.0001 is + * used (defined in libmseed.h). + * + * Return number of trace mergings on success otherwise -1 on error. + ***************************************************************************/ +int +mst_groupheal ( MSTraceGroup *mstg, double timetol, double sampratetol ) +{ + int mergings = 0; + MSTrace *curtrace = 0; + MSTrace *nexttrace = 0; + MSTrace *searchtrace = 0; + MSTrace *prevtrace = 0; + int8_t merged = 0; + double postgap, pregap, delta; + + if ( ! mstg ) + return -1; + + /* Sort MSTraceGroup before any healing */ + if ( mst_groupsort (mstg, 1) ) + return -1; + + curtrace = mstg->traces; + + while ( curtrace ) + { + nexttrace = mstg->traces; + prevtrace = mstg->traces; + + while ( nexttrace ) + { + searchtrace = nexttrace; + nexttrace = searchtrace->next; + + /* Do not process the same MSTrace we are trying to match */ + if ( searchtrace == curtrace ) + { + prevtrace = searchtrace; + continue; + } + + /* Check if this trace matches the curtrace */ + if ( strcmp (searchtrace->network, curtrace->network) || + strcmp (searchtrace->station, curtrace->station) || + strcmp (searchtrace->location, curtrace->location) || + strcmp (searchtrace->channel, curtrace->channel) ) + { + prevtrace = searchtrace; + continue; + } + + /* Perform default samprate tolerance check if requested */ + if ( sampratetol == -1.0 ) + { + if ( ! MS_ISRATETOLERABLE (searchtrace->samprate, curtrace->samprate) ) + { + prevtrace = searchtrace; + continue; + } + } + /* Otherwise check against the specified sample rates tolerance */ + else if ( ms_dabs(searchtrace->samprate - curtrace->samprate) > sampratetol ) + { + prevtrace = searchtrace; + continue; + } + + merged = 0; + + /* post/pregap are negative when searchtrace overlaps curtrace + * segment and positive when there is a time gap. + */ + delta = ( curtrace->samprate ) ? (1.0 / curtrace->samprate) : 0.0; + + postgap = ((double)(searchtrace->starttime - curtrace->endtime)/HPTMODULUS) - delta; + + pregap = ((double)(curtrace->starttime - searchtrace->endtime)/HPTMODULUS) - delta; + + /* Calculate default time tolerance (1/2 sample period) if needed */ + if ( timetol == -1.0 ) + timetol = 0.5 * delta; + + /* Fits right at the end of curtrace */ + if ( ms_dabs(postgap) <= timetol ) + { + /* Merge searchtrace with curtrace */ + mst_addspan (curtrace, searchtrace->starttime, searchtrace->endtime, + searchtrace->datasamples, searchtrace->numsamples, + searchtrace->sampletype, 1); + + /* If no data is present, make sure sample count is updated */ + if ( searchtrace->numsamples <= 0 ) + curtrace->samplecnt += searchtrace->samplecnt; + + /* If qualities do not match reset the indicator */ + if (curtrace->dataquality != searchtrace->dataquality) + curtrace->dataquality = 0; + + merged = 1; + } + + /* Fits right at the beginning of curtrace */ + else if ( ms_dabs(pregap) <= timetol ) + { + /* Merge searchtrace with curtrace */ + mst_addspan (curtrace, searchtrace->starttime, searchtrace->endtime, + searchtrace->datasamples, searchtrace->numsamples, + searchtrace->sampletype, 2); + + /* If no data is present, make sure sample count is updated */ + if ( searchtrace->numsamples <= 0 ) + curtrace->samplecnt += searchtrace->samplecnt; + + /* If qualities do not match reset the indicator */ + if (curtrace->dataquality != searchtrace->dataquality) + curtrace->dataquality = 0; + + merged = 1; + } + + /* If searchtrace was merged with curtrace remove it from the chain */ + if ( merged ) + { + /* Re-link trace chain and free searchtrace */ + if ( searchtrace == mstg->traces ) + mstg->traces = nexttrace; + else + prevtrace->next = nexttrace; + + mst_free (&searchtrace); + + mstg->numtraces--; + mergings++; + } + else + { + prevtrace = searchtrace; + } + } + + curtrace = curtrace->next; + } + + return mergings; +} /* End of mst_groupheal() */ + + +/*************************************************************************** + * mst_groupsort: + * + * Sort a MSTraceGroup using a mergesort algorithm. MSTrace entries + * are compared using the mst_groupsort_cmp() function. + * + * The mergesort implementation was inspired by the listsort function + * published and copyright 2001 by Simon Tatham. + * + * Return 0 on success and -1 on error. + ***************************************************************************/ +int +mst_groupsort ( MSTraceGroup *mstg, flag quality ) +{ + MSTrace *p, *q, *e, *top, *tail; + int nmerges; + int insize, psize, qsize, i; + + if ( ! mstg ) + return -1; + + if ( ! mstg->traces ) + return 0; + + top = mstg->traces; + insize = 1; + + for (;;) + { + p = top; + top = NULL; + tail = NULL; + + nmerges = 0; /* count number of merges we do in this pass */ + + while ( p ) + { + nmerges++; /* there exists a merge to be done */ + + /* step `insize' places along from p */ + q = p; + psize = 0; + for (i = 0; i < insize; i++) + { + psize++; + q = q->next; + if ( ! q ) + break; + } + + /* if q hasn't fallen off end, we have two lists to merge */ + qsize = insize; + + /* now we have two lists; merge them */ + while ( psize > 0 || (qsize > 0 && q) ) + { + /* decide whether next element of merge comes from p or q */ + if ( psize == 0 ) + { /* p is empty; e must come from q. */ + e = q; q = q->next; qsize--; + } + else if ( qsize == 0 || ! q ) + { /* q is empty; e must come from p. */ + e = p; p = p->next; psize--; + } + else if ( mst_groupsort_cmp (p, q, quality) <= 0 ) + { /* First element of p is lower (or same), e must come from p. */ + e = p; p = p->next; psize--; + } + else + { /* First element of q is lower; e must come from q. */ + e = q; q = q->next; qsize--; + } + + /* add the next element to the merged list */ + if ( tail ) + tail->next = e; + else + top = e; + + tail = e; + } + + /* now p has stepped `insize' places along, and q has too */ + p = q; + } + + tail->next = NULL; + + /* If we have done only one merge, we're finished. */ + if ( nmerges <= 1 ) /* allow for nmerges==0, the empty list case */ + { + mstg->traces = top; + + return 0; + } + + /* Otherwise repeat, merging lists twice the size */ + insize *= 2; + } +} /* End of mst_groupsort() */ + + +/*************************************************************************** + * mst_groupsort_cmp: + * + * Compare two MSTrace entities for the purposes of sorting a + * MSTraceGroup. Criteria for MSTrace comparison are (in order of + * testing): source name, start time, descending endtime (longest + * trace first) and sample rate. + * + * Return 1 if mst1 is "greater" than mst2, otherwise return 0. + ***************************************************************************/ +static int +mst_groupsort_cmp ( MSTrace *mst1, MSTrace *mst2, flag quality ) +{ + char src1[50], src2[50]; + int strcmpval; + + if ( ! mst1 || ! mst2 ) + return -1; + + mst_srcname (mst1, src1, quality); + mst_srcname (mst2, src2, quality); + + strcmpval = strcmp (src1, src2); + + /* If the source names do not match make sure the "greater" string is 2nd, + * otherwise, if source names do match, make sure the later start time is 2nd + * otherwise, if start times match, make sure the earlier end time is 2nd + * otherwise, if end times match, make sure the highest sample rate is 2nd + */ + if ( strcmpval > 0 ) + { + return 1; + } + else if ( strcmpval == 0 ) + { + if ( mst1->starttime > mst2->starttime ) + { + return 1; + } + else if ( mst1->starttime == mst2->starttime ) + { + if ( mst1->endtime < mst2->endtime ) + { + return 1; + } + else if ( mst1->endtime == mst2->endtime ) + { + if ( ! MS_ISRATETOLERABLE (mst1->samprate, mst2->samprate) && + mst1->samprate > mst2->samprate ) + { + return 1; + } + } + } + } + + return 0; +} /* End of mst_groupsort_cmp() */ + + +/*************************************************************************** + * mst_convertsamples: + * + * Convert the data samples associated with an MSTrace to another data + * type. ASCII data samples cannot be converted, if supplied or + * requested an error will be returned. + * + * When converting float & double sample types to integer type a + * simple rounding is applied by adding 0.5 to the sample value before + * converting (truncating) to integer. + * + * If the truncate flag is true data samples will be truncated to + * integers even if loss of sample precision is detected. If the + * truncate flag is false (0) and loss of precision is detected an + * error is returned. + * + * Returns 0 on success, and -1 on failure. + ***************************************************************************/ +int +mst_convertsamples ( MSTrace *mst, char type, flag truncate ) +{ + int32_t *idata; + float *fdata; + double *ddata; + int64_t idx; + + if ( ! mst ) + return -1; + + /* No conversion necessary, report success */ + if ( mst->sampletype == type ) + return 0; + + if ( mst->sampletype == 'a' || type == 'a' ) + { + ms_log (2, "mst_convertsamples: cannot convert ASCII samples to/from numeric type\n"); + return -1; + } + + idata = (int32_t *) mst->datasamples; + fdata = (float *) mst->datasamples; + ddata = (double *) mst->datasamples; + + /* Convert to 32-bit integers */ + if ( type == 'i' ) + { + if ( mst->sampletype == 'f' ) /* Convert floats to integers with simple rounding */ + { + for (idx = 0; idx < mst->numsamples; idx++) + { + /* Check for loss of sub-integer */ + if ( ! truncate && (fdata[idx] - (int32_t)fdata[idx]) > 0.000001 ) + { + ms_log (1, "mst_convertsamples: Warning, loss of precision when converting floats to integers, loss: %g\n", + (fdata[idx] - (int32_t)fdata[idx])); + return -1; + } + + idata[idx] = (int32_t) (fdata[idx] + 0.5); + } + } + else if ( mst->sampletype == 'd' ) /* Convert doubles to integers with simple rounding */ + { + for (idx = 0; idx < mst->numsamples; idx++) + { + /* Check for loss of sub-integer */ + if ( ! truncate && (ddata[idx] - (int32_t)ddata[idx]) > 0.000001 ) + { + ms_log (1, "mst_convertsamples: Warning, loss of precision when converting doubles to integers, loss: %g\n", + (ddata[idx] - (int32_t)ddata[idx])); + return -1; + } + + idata[idx] = (int32_t) (ddata[idx] + 0.5); + } + + /* Reallocate buffer for reduced size needed */ + if ( ! (mst->datasamples = realloc (mst->datasamples, (mst->numsamples * sizeof(int32_t)))) ) + { + ms_log (2, "mst_convertsamples: cannot re-allocate buffer for sample conversion\n"); + return -1; + } + } + + mst->sampletype = 'i'; + } /* Done converting to 32-bit integers */ + + /* Convert to 32-bit floats */ + else if ( type == 'f' ) + { + if ( mst->sampletype == 'i' ) /* Convert integers to floats */ + { + for (idx = 0; idx < mst->numsamples; idx++) + fdata[idx] = (float) idata[idx]; + } + else if ( mst->sampletype == 'd' ) /* Convert doubles to floats */ + { + for (idx = 0; idx < mst->numsamples; idx++) + fdata[idx] = (float) ddata[idx]; + + /* Reallocate buffer for reduced size needed */ + if ( ! (mst->datasamples = realloc (mst->datasamples, (mst->numsamples * sizeof(float)))) ) + { + ms_log (2, "mst_convertsamples: cannot re-allocate buffer after sample conversion\n"); + return -1; + } + } + + mst->sampletype = 'f'; + } /* Done converting to 32-bit floats */ + + /* Convert to 64-bit doubles */ + else if ( type == 'd' ) + { + if ( ! (ddata = (double *) malloc (mst->numsamples * sizeof(double))) ) + { + ms_log (2, "mst_convertsamples: cannot allocate buffer for sample conversion to doubles\n"); + return -1; + } + + if ( mst->sampletype == 'i' ) /* Convert integers to doubles */ + { + for (idx = 0; idx < mst->numsamples; idx++) + ddata[idx] = (double) idata[idx]; + + free (idata); + } + else if ( mst->sampletype == 'f' ) /* Convert floats to doubles */ + { + for (idx = 0; idx < mst->numsamples; idx++) + ddata[idx] = (double) fdata[idx]; + + free (fdata); + } + + mst->datasamples = ddata; + mst->sampletype = 'd'; + } /* Done converting to 64-bit doubles */ + + return 0; +} /* End of mst_convertsamples() */ + + +/*************************************************************************** + * mst_srcname: + * + * Generate a source name string for a specified MSTrace in the + * format: 'NET_STA_LOC_CHAN[_QUAL]'. The quality is added to the + * srcname if the quality flag argument is 1 and mst->dataquality is + * not zero. The passed srcname must have enough room for the + * resulting string. + * + * Returns a pointer to the resulting string or NULL on error. + ***************************************************************************/ +char * +mst_srcname (MSTrace *mst, char *srcname, flag quality) +{ + char *src = srcname; + char *cp = srcname; + + if ( ! mst || ! srcname ) + return NULL; + + /* Build the source name string */ + cp = mst->network; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = mst->station; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = mst->location; + while ( *cp ) { *src++ = *cp++; } + *src++ = '_'; + cp = mst->channel; + while ( *cp ) { *src++ = *cp++; } + + if ( quality && mst->dataquality ) + { + *src++ = '_'; + *src++ = mst->dataquality; + } + + *src = '\0'; + + return srcname; +} /* End of mst_srcname() */ + + +/*************************************************************************** + * mst_printtracelist: + * + * Print trace list summary information for the specified MSTraceGroup. + * + * By default only print the srcname, starttime and endtime for each + * trace. If details is greater than 0 include the sample rate, + * number of samples and a total trace count. If gaps is greater than + * 0 and the previous trace matches (srcname & samprate) include the + * gap between the endtime of the last trace and the starttime of the + * current trace. + * + * The timeformat flag can either be: + * 0 : SEED time format (year, day-of-year, hour, min, sec) + * 1 : ISO time format (year, month, day, hour, min, sec) + * 2 : Epoch time, seconds since the epoch + ***************************************************************************/ +void +mst_printtracelist ( MSTraceGroup *mstg, flag timeformat, + flag details, flag gaps ) +{ + MSTrace *mst = 0; + char srcname[50]; + char prevsrcname[50]; + char stime[30]; + char etime[30]; + char gapstr[20]; + flag nogap; + double gap; + double delta; + double prevsamprate; + hptime_t prevendtime; + int tracecnt = 0; + + if ( ! mstg ) + { + return; + } + + mst = mstg->traces; + + /* Print out the appropriate header */ + if ( details > 0 && gaps > 0 ) + ms_log (0, " Source Start sample End sample Gap Hz Samples\n"); + else if ( details <= 0 && gaps > 0 ) + ms_log (0, " Source Start sample End sample Gap\n"); + else if ( details > 0 && gaps <= 0 ) + ms_log (0, " Source Start sample End sample Hz Samples\n"); + else + ms_log (0, " Source Start sample End sample\n"); + + prevsrcname[0] = '\0'; + prevsamprate = -1.0; + prevendtime = 0; + + while ( mst ) + { + mst_srcname (mst, srcname, 1); + + /* Create formatted time strings */ + if ( timeformat == 2 ) + { + snprintf (stime, sizeof(stime), "%.6f", (double) MS_HPTIME2EPOCH(mst->starttime) ); + snprintf (etime, sizeof(etime), "%.6f", (double) MS_HPTIME2EPOCH(mst->endtime) ); + } + else if ( timeformat == 1 ) + { + if ( ms_hptime2isotimestr (mst->starttime, stime, 1) == NULL ) + ms_log (2, "Cannot convert trace start time for %s\n", srcname); + + if ( ms_hptime2isotimestr (mst->endtime, etime, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", srcname); + } + else + { + if ( ms_hptime2seedtimestr (mst->starttime, stime, 1) == NULL ) + ms_log (2, "Cannot convert trace start time for %s\n", srcname); + + if ( ms_hptime2seedtimestr (mst->endtime, etime, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", srcname); + } + + /* Print trace info at varying levels */ + if ( gaps > 0 ) + { + gap = 0.0; + nogap = 0; + + if ( ! strcmp (prevsrcname, srcname) && prevsamprate != -1.0 && + MS_ISRATETOLERABLE (prevsamprate, mst->samprate) ) + gap = (double) (mst->starttime - prevendtime) / HPTMODULUS; + else + nogap = 1; + + /* Check that any overlap is not larger than the trace coverage */ + if ( gap < 0.0 ) + { + delta = ( mst->samprate ) ? (1.0 / mst->samprate) : 0.0; + + if ( (gap * -1.0) > (((double)(mst->endtime - mst->starttime)/HPTMODULUS) + delta) ) + gap = -(((double)(mst->endtime - mst->starttime)/HPTMODULUS) + delta); + } + + /* Fix up gap display */ + if ( nogap ) + snprintf (gapstr, sizeof(gapstr), " == "); + else if ( gap >= 86400.0 || gap <= -86400.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fd", (gap / 86400)); + else if ( gap >= 3600.0 || gap <= -3600.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fh", (gap / 3600)); + else if ( gap == 0.0 ) + snprintf (gapstr, sizeof(gapstr), "-0 "); + else + snprintf (gapstr, sizeof(gapstr), "%-4.4g", gap); + + if ( details <= 0 ) + ms_log (0, "%-17s %-24s %-24s %-4s\n", + srcname, stime, etime, gapstr); + else + ms_log (0, "%-17s %-24s %-24s %-s %-3.3g %-lld\n", + srcname, stime, etime, gapstr, mst->samprate, (long long int)mst->samplecnt); + } + else if ( details > 0 && gaps <= 0 ) + ms_log (0, "%-17s %-24s %-24s %-3.3g %-lld\n", + srcname, stime, etime, mst->samprate, (long long int)mst->samplecnt); + else + ms_log (0, "%-17s %-24s %-24s\n", srcname, stime, etime); + + if ( gaps > 0 ) + { + strcpy (prevsrcname, srcname); + prevsamprate = mst->samprate; + prevendtime = mst->endtime; + } + + tracecnt++; + mst = mst->next; + } + + if ( tracecnt != mstg->numtraces ) + ms_log (2, "mst_printtracelist(): number of traces in trace group is inconsistent\n"); + + if ( details > 0 ) + ms_log (0, "Total: %d trace segment(s)\n", tracecnt); + +} /* End of mst_printtracelist() */ + + +/*************************************************************************** + * mst_printsynclist: + * + * Print SYNC trace list summary information for the specified MSTraceGroup. + * + * The SYNC header line will be created using the supplied dccid, if + * the pointer is NULL the string "DCC" will be used instead. + * + * If the subsecond flag is true the segment start and end times will + * include subsecond precision, otherwise they will be truncated to + * integer seconds. + * + ***************************************************************************/ +void +mst_printsynclist ( MSTraceGroup *mstg, char *dccid, flag subsecond ) +{ + MSTrace *mst = 0; + char stime[30]; + char etime[30]; + char yearday[10]; + time_t now; + struct tm *nt; + + if ( ! mstg ) + { + return; + } + + /* Generate current time stamp */ + now = time (NULL); + nt = localtime ( &now ); nt->tm_year += 1900; nt->tm_yday += 1; + snprintf ( yearday, sizeof(yearday), "%04d,%03d", nt->tm_year, nt->tm_yday); + + /* Print SYNC header line */ + ms_log (0, "%s|%s\n", (dccid)?dccid:"DCC", yearday); + + /* Loope through trace list */ + mst = mstg->traces; + while ( mst ) + { + ms_hptime2seedtimestr (mst->starttime, stime, subsecond); + ms_hptime2seedtimestr (mst->endtime, etime, subsecond); + + /* Print SYNC line */ + ms_log (0, "%s|%s|%s|%s|%s|%s||%.10g|%lld|||||||%s\n", + mst->network, mst->station, mst->location, mst->channel, + stime, etime, mst->samprate, (long long int)mst->samplecnt, + yearday); + + mst = mst->next; + } +} /* End of mst_printsynclist() */ + + +/*************************************************************************** + * mst_printgaplist: + * + * Print gap/overlap list summary information for the specified + * MSTraceGroup. Overlaps are printed as negative gaps. The trace + * summary information in the MSTraceGroup is logically inverted so gaps + * for like channels are identified. + * + * If mingap and maxgap are not NULL their values will be enforced and + * only gaps/overlaps matching their implied criteria will be printed. + * + * The timeformat flag can either be: + * 0 : SEED time format (year, day-of-year, hour, min, sec) + * 1 : ISO time format (year, month, day, hour, min, sec) + * 2 : Epoch time, seconds since the epoch + ***************************************************************************/ +void +mst_printgaplist (MSTraceGroup *mstg, flag timeformat, + double *mingap, double *maxgap) +{ + MSTrace *mst; + char src1[50], src2[50]; + char time1[30], time2[30]; + char gapstr[30]; + double gap; + double delta; + double nsamples; + flag printflag; + int gapcnt = 0; + + if ( ! mstg ) + return; + + if ( ! mstg->traces ) + return; + + mst = mstg->traces; + + ms_log (0, " Source Last Sample Next Sample Gap Samples\n"); + + while ( mst->next ) + { + mst_srcname (mst, src1, 1); + mst_srcname (mst->next, src2, 1); + + if ( ! strcmp (src1, src2) ) + { + /* Skip MSTraces with 0 sample rate, usually from SOH records */ + if ( mst->samprate == 0.0 ) + { + mst = mst->next; + continue; + } + + /* Check that sample rates match using default tolerance */ + if ( ! MS_ISRATETOLERABLE (mst->samprate, mst->next->samprate) ) + { + ms_log (2, "%s Sample rate changed! %.10g -> %.10g\n", + src1, mst->samprate, mst->next->samprate ); + } + + gap = (double) (mst->next->starttime - mst->endtime) / HPTMODULUS; + + /* Check that any overlap is not larger than the trace coverage */ + if ( gap < 0.0 ) + { + delta = ( mst->next->samprate ) ? (1.0 / mst->next->samprate) : 0.0; + + if ( (gap * -1.0) > (((double)(mst->next->endtime - mst->next->starttime)/HPTMODULUS) + delta) ) + gap = -(((double)(mst->next->endtime - mst->next->starttime)/HPTMODULUS) + delta); + } + + printflag = 1; + + /* Check gap/overlap criteria */ + if ( mingap ) + if ( gap < *mingap ) + printflag = 0; + + if ( maxgap ) + if ( gap > *maxgap ) + printflag = 0; + + if ( printflag ) + { + nsamples = ms_dabs(gap) * mst->samprate; + + if ( gap > 0.0 ) + nsamples -= 1.0; + else + nsamples += 1.0; + + /* Fix up gap display */ + if ( gap >= 86400.0 || gap <= -86400.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fd", (gap / 86400)); + else if ( gap >= 3600.0 || gap <= -3600.0 ) + snprintf (gapstr, sizeof(gapstr), "%-3.1fh", (gap / 3600)); + else if ( gap == 0.0 ) + snprintf (gapstr, sizeof(gapstr), "-0 "); + else + snprintf (gapstr, sizeof(gapstr), "%-4.4g", gap); + + /* Create formatted time strings */ + if ( timeformat == 2 ) + { + snprintf (time1, sizeof(time1), "%.6f", (double) MS_HPTIME2EPOCH(mst->endtime) ); + snprintf (time2, sizeof(time2), "%.6f", (double) MS_HPTIME2EPOCH(mst->next->starttime) ); + } + else if ( timeformat == 1 ) + { + if ( ms_hptime2isotimestr (mst->endtime, time1, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", src1); + + if ( ms_hptime2isotimestr (mst->next->starttime, time2, 1) == NULL ) + ms_log (2, "Cannot convert next trace start time for %s\n", src1); + } + else + { + if ( ms_hptime2seedtimestr (mst->endtime, time1, 1) == NULL ) + ms_log (2, "Cannot convert trace end time for %s\n", src1); + + if ( ms_hptime2seedtimestr (mst->next->starttime, time2, 1) == NULL ) + ms_log (2, "Cannot convert next trace start time for %s\n", src1); + } + + ms_log (0, "%-17s %-24s %-24s %-4s %-.8g\n", + src1, time1, time2, gapstr, nsamples); + + gapcnt++; + } + } + + mst = mst->next; + } + + ms_log (0, "Total: %d gap(s)\n", gapcnt); + +} /* End of mst_printgaplist() */ + + +/*************************************************************************** + * mst_pack: + * + * Pack MSTrace data into Mini-SEED records using the specified record + * length, encoding format and byte order. The datasamples array and + * numsamples field will be adjusted (reduced) based on how many + * samples were packed. + * + * As each record is filled and finished they are passed to + * record_handler which expects 1) a char * to the record, 2) the + * length of the record and 3) a pointer supplied by the original + * caller containing optional private data (handlerdata). It is the + * responsibility of record_handler to process the record, the memory + * will be re-used or freed when record_handler returns. + * + * If the flush flag is > 0 all of the data will be packed into data + * records even though the last one will probably not be filled. + * + * If the mstemplate argument is not NULL it will be used as the + * template for the packed Mini-SEED records. Otherwise a new + * MSRecord will be initialized and populated from values in the + * MSTrace. The reclen, encoding and byteorder arguments take + * precedence over those in the template. The start time, sample + * rate, datasamples, numsamples and sampletype values from the + * template will be preserved. + * + * Returns the number of records created on success and -1 on error. + ***************************************************************************/ +int +mst_pack ( MSTrace *mst, void (*record_handler) (char *, int, void *), + void *handlerdata, int reclen, flag encoding, flag byteorder, + int64_t *packedsamples, flag flush, flag verbose, + MSRecord *mstemplate ) +{ + MSRecord *msr; + char srcname[50]; + int trpackedrecords = 0; + int64_t trpackedsamples = 0; + int samplesize; + int64_t bufsize; + + hptime_t preservestarttime = 0; + double preservesamprate = 0.0; + void *preservedatasamples = 0; + int64_t preservenumsamples = 0; + char preservesampletype = 0; + StreamState *preserveststate = 0; + + if ( packedsamples ) + *packedsamples = 0; + + /* Allocate stream processing state space if needed */ + if ( ! mst->ststate ) + { + mst->ststate = (StreamState *) malloc (sizeof(StreamState)); + if ( ! mst->ststate ) + { + ms_log (2, "mst_pack(): Could not allocate memory for StreamState\n"); + return -1; + } + memset (mst->ststate, 0, sizeof(StreamState)); + } + + if ( mstemplate ) + { + msr = mstemplate; + + preservestarttime = msr->starttime; + preservesamprate = msr->samprate; + preservedatasamples = msr->datasamples; + preservenumsamples = msr->numsamples; + preservesampletype = msr->sampletype; + preserveststate = msr->ststate; + } + else + { + msr = msr_init (NULL); + + if ( msr == NULL ) + { + ms_log (2, "mst_pack(): Error initializing msr\n"); + return -1; + } + + msr->dataquality = 'D'; + strcpy (msr->network, mst->network); + strcpy (msr->station, mst->station); + strcpy (msr->location, mst->location); + strcpy (msr->channel, mst->channel); + } + + /* Setup MSRecord template for packing */ + msr->reclen = reclen; + msr->encoding = encoding; + msr->byteorder = byteorder; + + msr->starttime = mst->starttime; + msr->samprate = mst->samprate; + msr->datasamples = mst->datasamples; + msr->numsamples = mst->numsamples; + msr->sampletype = mst->sampletype; + msr->ststate = mst->ststate; + + /* Sample count sanity check */ + if ( mst->samplecnt != mst->numsamples ) + { + ms_log (2, "mst_pack(): Sample counts do not match, abort\n"); + return -1; + } + + /* Pack data */ + trpackedrecords = msr_pack (msr, record_handler, handlerdata, &trpackedsamples, flush, verbose); + + if ( verbose > 1 ) + { + ms_log (1, "Packed %d records for %s trace\n", trpackedrecords, mst_srcname (mst, srcname, 1)); + } + + /* Adjust MSTrace start time, data array and sample count */ + if ( trpackedsamples > 0 ) + { + /* The new start time was calculated my msr_pack */ + mst->starttime = msr->starttime; + + samplesize = ms_samplesize (mst->sampletype); + bufsize = (mst->numsamples - trpackedsamples) * samplesize; + + if ( bufsize ) + { + memmove (mst->datasamples, + (char *) mst->datasamples + (trpackedsamples * samplesize), + (size_t) bufsize); + + mst->datasamples = realloc (mst->datasamples, (size_t) bufsize); + + if ( mst->datasamples == NULL ) + { + ms_log (2, "mst_pack(): Cannot (re)allocate datasamples buffer\n"); + return -1; + } + } + else + { + if ( mst->datasamples ) + free (mst->datasamples); + mst->datasamples = 0; + } + + mst->samplecnt -= trpackedsamples; + mst->numsamples -= trpackedsamples; + } + + /* Reinstate preserved values if a template was used */ + if ( mstemplate ) + { + msr->starttime = preservestarttime; + msr->samprate = preservesamprate; + msr->datasamples = preservedatasamples; + msr->numsamples = preservenumsamples; + msr->sampletype = preservesampletype; + msr->ststate = preserveststate; + } + else + { + msr->datasamples = 0; + msr->ststate = 0; + msr_free (&msr); + } + + if ( packedsamples ) + *packedsamples = trpackedsamples; + + return trpackedrecords; +} /* End of mst_pack() */ + + +/*************************************************************************** + * mst_packgroup: + * + * Pack MSTraceGroup data into Mini-SEED records by calling mst_pack() + * for each MSTrace in the group. + * + * Returns the number of records created on success and -1 on error. + ***************************************************************************/ +int +mst_packgroup ( MSTraceGroup *mstg, void (*record_handler) (char *, int, void *), + void *handlerdata, int reclen, flag encoding, flag byteorder, + int64_t *packedsamples, flag flush, flag verbose, + MSRecord *mstemplate ) +{ + MSTrace *mst; + int trpackedrecords = 0; + int64_t trpackedsamples = 0; + char srcname[50]; + + if ( ! mstg ) + { + return -1; + } + + if ( packedsamples ) + *packedsamples = 0; + + mst = mstg->traces; + + while ( mst ) + { + if ( mst->numsamples <= 0 ) + { + if ( verbose > 1 ) + { + mst_srcname (mst, srcname, 1); + ms_log (1, "No data samples for %s, skipping\n", srcname); + } + } + else + { + trpackedrecords += mst_pack (mst, record_handler, handlerdata, reclen, + encoding, byteorder, &trpackedsamples, flush, + verbose, mstemplate); + + if ( trpackedrecords == -1 ) + break; + + if ( packedsamples ) + *packedsamples += trpackedsamples; + } + + mst = mst->next; + } + + return trpackedrecords; +} /* End of mst_packgroup() */ diff --git a/libs/3rd-party/mseed/unpack.c b/libs/3rd-party/mseed/unpack.c new file mode 100644 index 0000000..9ac4ebe --- /dev/null +++ b/libs/3rd-party/mseed/unpack.c @@ -0,0 +1,1083 @@ +/*************************************************************************** + * unpack.c: + * + * Generic routines to unpack Mini-SEED records. + * + * Appropriate values from the record header will be byte-swapped to + * the host order. The purpose of this code is to provide a portable + * way of accessing common SEED data record header information. All + * data structures in SEED 2.4 data records are supported. The data + * samples are optionally decompressed/unpacked. + * + * Written by Chad Trabant, + * ORFEUS/EC-Project MEREDIAN + * IRIS Data Management Center + * + * modified: 2014.197 + ***************************************************************************/ +#include +#include +#include +#include +#include + +#include "libmseed.h" +#include "unpackdata.h" + +/* Function(s) internal to this file */ +static int check_environment (int verbose); + +/* Header and data byte order flags controlled by environment variables */ +/* -2 = not checked, -1 = checked but not set, or 0 = LE and 1 = BE */ +flag unpackheaderbyteorder = -2; +flag unpackdatabyteorder = -2; + +/* Data encoding format/fallback controlled by environment variable */ +/* -2 = not checked, -1 = checked but not set, or = encoding */ +int unpackencodingformat = -2; +int unpackencodingfallback = -2; + +/* A pointer to the srcname of the record being unpacked */ +char *UNPACK_SRCNAME = NULL; + + +/*************************************************************************** + * msr_unpack: + * + * Unpack a SEED data record header/blockettes and populate a MSRecord + * struct. All approriate fields are byteswapped, if needed, and + * pointers to structured data are setup in addition to setting the + * common header fields. + * + * If 'dataflag' is true the data samples are unpacked/decompressed + * and the MSRecord->datasamples pointer is set appropriately. The + * data samples will be either 32-bit integers, 32-bit floats or + * 64-bit floats (doubles) with the same byte order as the host + * machine. The MSRecord->numsamples will be set to the actual number + * of samples unpacked/decompressed and MSRecord->sampletype will + * indicated the sample type. + * + * All appropriate values will be byte-swapped to the host order, + * including the data samples. + * + * All header values, blockette values and data samples will be + * overwritten by subsequent calls to this function. + * + * If the msr struct is NULL it will be allocated. + * + * Returns MS_NOERROR and populates the MSRecord struct at *ppmsr on + * success, otherwise returns a libmseed error code (listed in + * libmseed.h). + ***************************************************************************/ +int +msr_unpack ( char *record, int reclen, MSRecord **ppmsr, + flag dataflag, flag verbose ) +{ + flag headerswapflag = 0; + flag dataswapflag = 0; + int retval; + + MSRecord *msr = NULL; + char sequence_number[7]; + char srcname[50]; + + /* For blockette parsing */ + BlktLink *blkt_link = 0; + uint16_t blkt_type; + uint16_t next_blkt; + uint32_t blkt_offset; + uint32_t blkt_length; + int blkt_count = 0; + + if ( ! ppmsr ) + { + ms_log (2, "msr_unpack(): ppmsr argument cannot be NULL\n"); + return MS_GENERROR; + } + + /* Verify that record includes a valid header */ + if ( ! MS_ISVALIDHEADER(record) ) + { + ms_recsrcname (record, srcname, 1); + ms_log (2, "msr_unpack(%s) Record header & quality indicator unrecognized: '%c'\n", srcname); + ms_log (2, "msr_unpack(%s) This is not a valid Mini-SEED record\n", srcname); + + return MS_NOTSEED; + } + + /* Verify that passed record length is within supported range */ + if ( reclen < MINRECLEN || reclen > MAXRECLEN ) + { + ms_recsrcname (record, srcname, 1); + ms_log (2, "msr_unpack(%s): Record length is out of range: %d\n", srcname, reclen); + return MS_OUTOFRANGE; + } + + /* Initialize the MSRecord */ + if ( ! (*ppmsr = msr_init (*ppmsr)) ) + return MS_GENERROR; + + /* Shortcut pointer, historical and help readability */ + msr = *ppmsr; + + /* Set raw record pointer and record length */ + msr->record = record; + msr->reclen = reclen; + + /* Check environment variables if necessary */ + if ( unpackheaderbyteorder == -2 || + unpackdatabyteorder == -2 || + unpackencodingformat == -2 || + unpackencodingfallback == -2 ) + if ( check_environment(verbose) ) + return MS_GENERROR; + + /* Allocate and copy fixed section of data header */ + msr->fsdh = realloc (msr->fsdh, sizeof (struct fsdh_s)); + + if ( msr->fsdh == NULL ) + { + ms_log (2, "msr_unpack(): Cannot allocate memory\n"); + return MS_GENERROR; + } + + memcpy (msr->fsdh, record, sizeof (struct fsdh_s)); + + /* Check to see if byte swapping is needed by testing the year and day */ + if ( ! MS_ISVALIDYEARDAY (msr->fsdh->start_time.year, msr->fsdh->start_time.day) ) + headerswapflag = dataswapflag = 1; + + /* Check if byte order is forced */ + if ( unpackheaderbyteorder >= 0 ) + { + headerswapflag = ( ms_bigendianhost() != unpackheaderbyteorder ) ? 1 : 0; + } + + if ( unpackdatabyteorder >= 0 ) + { + dataswapflag = ( ms_bigendianhost() != unpackdatabyteorder ) ? 1 : 0; + } + + /* Swap byte order? */ + if ( headerswapflag ) + { + MS_SWAPBTIME (&msr->fsdh->start_time); + ms_gswap2a (&msr->fsdh->numsamples); + ms_gswap2a (&msr->fsdh->samprate_fact); + ms_gswap2a (&msr->fsdh->samprate_mult); + ms_gswap4a (&msr->fsdh->time_correct); + ms_gswap2a (&msr->fsdh->data_offset); + ms_gswap2a (&msr->fsdh->blockette_offset); + } + + /* Populate some of the common header fields */ + strncpy (sequence_number, msr->fsdh->sequence_number, 6); + sequence_number[6] = '\0'; + msr->sequence_number = (int32_t) strtol (sequence_number, NULL, 10); + msr->dataquality = msr->fsdh->dataquality; + ms_strncpcleantail (msr->network, msr->fsdh->network, 2); + ms_strncpcleantail (msr->station, msr->fsdh->station, 5); + ms_strncpcleantail (msr->location, msr->fsdh->location, 2); + ms_strncpcleantail (msr->channel, msr->fsdh->channel, 3); + msr->samplecnt = msr->fsdh->numsamples; + + /* Generate source name for MSRecord */ + if ( msr_srcname (msr, srcname, 1) == NULL ) + { + ms_log (2, "msr_unpack(): Cannot generate srcname\n"); + return MS_GENERROR; + } + + /* Set shared srcname pointer to source name */ + UNPACK_SRCNAME = &srcname[0]; + + /* Report byte swapping status */ + if ( verbose > 2 ) + { + if ( headerswapflag ) + ms_log (1, "%s: Byte swapping needed for unpacking of header\n", + UNPACK_SRCNAME); + else + ms_log (1, "%s: Byte swapping NOT needed for unpacking of header\n", + UNPACK_SRCNAME); + } + + /* Traverse the blockettes */ + blkt_offset = msr->fsdh->blockette_offset; + + while ((blkt_offset != 0) && + ((int)blkt_offset < reclen) && + (blkt_offset < MAXRECLEN)) + { + /* Every blockette has a similar 4 byte header: type and next */ + memcpy (&blkt_type, record + blkt_offset, 2); + blkt_offset += 2; + memcpy (&next_blkt, record + blkt_offset, 2); + blkt_offset += 2; + + if ( headerswapflag ) + { + ms_gswap2 (&blkt_type); + ms_gswap2 (&next_blkt); + } + + /* Get blockette length */ + blkt_length = ms_blktlen (blkt_type, + record + blkt_offset - 4, + headerswapflag); + + if ( blkt_length == 0 ) + { + ms_log (2, "msr_unpack(%s): Unknown blockette length for type %d\n", + UNPACK_SRCNAME, blkt_type); + break; + } + + /* Make sure blockette is contained within the msrecord buffer */ + if ( (int)(blkt_offset - 4 + blkt_length) > reclen ) + { + ms_log (2, "msr_unpack(%s): Blockette %d extends beyond record size, truncated?\n", + UNPACK_SRCNAME, blkt_type); + break; + } + + if ( blkt_type == 100 ) + { /* Found a Blockette 100 */ + struct blkt_100_s *blkt_100; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_100_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_100 = (struct blkt_100_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap4 (&blkt_100->samprate); + } + + msr->samprate = msr->Blkt100->samprate; + } + + else if ( blkt_type == 200 ) + { /* Found a Blockette 200 */ + struct blkt_200_s *blkt_200; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_200_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_200 = (struct blkt_200_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap4 (&blkt_200->amplitude); + ms_gswap4 (&blkt_200->period); + ms_gswap4 (&blkt_200->background_estimate); + MS_SWAPBTIME (&blkt_200->time); + } + } + + else if ( blkt_type == 201 ) + { /* Found a Blockette 201 */ + struct blkt_201_s *blkt_201; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_201_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_201 = (struct blkt_201_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap4 (&blkt_201->amplitude); + ms_gswap4 (&blkt_201->period); + ms_gswap4 (&blkt_201->background_estimate); + MS_SWAPBTIME (&blkt_201->time); + } + } + + else if ( blkt_type == 300 ) + { /* Found a Blockette 300 */ + struct blkt_300_s *blkt_300; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_300_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_300 = (struct blkt_300_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + MS_SWAPBTIME (&blkt_300->time); + ms_gswap4 (&blkt_300->step_duration); + ms_gswap4 (&blkt_300->interval_duration); + ms_gswap4 (&blkt_300->amplitude); + ms_gswap4 (&blkt_300->reference_amplitude); + } + } + + else if ( blkt_type == 310 ) + { /* Found a Blockette 310 */ + struct blkt_310_s *blkt_310; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_310_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_310 = (struct blkt_310_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + MS_SWAPBTIME (&blkt_310->time); + ms_gswap4 (&blkt_310->duration); + ms_gswap4 (&blkt_310->period); + ms_gswap4 (&blkt_310->amplitude); + ms_gswap4 (&blkt_310->reference_amplitude); + } + } + + else if ( blkt_type == 320 ) + { /* Found a Blockette 320 */ + struct blkt_320_s *blkt_320; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_320_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_320 = (struct blkt_320_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + MS_SWAPBTIME (&blkt_320->time); + ms_gswap4 (&blkt_320->duration); + ms_gswap4 (&blkt_320->ptp_amplitude); + ms_gswap4 (&blkt_320->reference_amplitude); + } + } + + else if ( blkt_type == 390 ) + { /* Found a Blockette 390 */ + struct blkt_390_s *blkt_390; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_390_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_390 = (struct blkt_390_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + MS_SWAPBTIME (&blkt_390->time); + ms_gswap4 (&blkt_390->duration); + ms_gswap4 (&blkt_390->amplitude); + } + } + + else if ( blkt_type == 395 ) + { /* Found a Blockette 395 */ + struct blkt_395_s *blkt_395; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_395_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_395 = (struct blkt_395_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + MS_SWAPBTIME (&blkt_395->time); + } + } + + else if ( blkt_type == 400 ) + { /* Found a Blockette 400 */ + struct blkt_400_s *blkt_400; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_400_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_400 = (struct blkt_400_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap4 (&blkt_400->azimuth); + ms_gswap4 (&blkt_400->slowness); + ms_gswap2 (&blkt_400->configuration); + } + } + + else if ( blkt_type == 405 ) + { /* Found a Blockette 405 */ + struct blkt_405_s *blkt_405; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_405_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_405 = (struct blkt_405_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap2 (&blkt_405->delay_values); + } + + if ( verbose > 0 ) + { + ms_log (1, "msr_unpack(%s): WARNING Blockette 405 cannot be fully supported\n", + UNPACK_SRCNAME); + } + } + + else if ( blkt_type == 500 ) + { /* Found a Blockette 500 */ + struct blkt_500_s *blkt_500; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_500_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_500 = (struct blkt_500_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap4 (&blkt_500->vco_correction); + MS_SWAPBTIME (&blkt_500->time); + ms_gswap4 (&blkt_500->exception_count); + } + } + + else if ( blkt_type == 1000 ) + { /* Found a Blockette 1000 */ + struct blkt_1000_s *blkt_1000; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_1000_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_1000 = (struct blkt_1000_s *) blkt_link->blktdata; + + /* Calculate record length in bytes as 2^(blkt_1000->reclen) */ + msr->reclen = (uint32_t) 1 << blkt_1000->reclen; + + /* Compare against the specified length */ + if ( msr->reclen != reclen && verbose ) + { + ms_log (2, "msr_unpack(%s): Record length in Blockette 1000 (%d) != specified length (%d)\n", + UNPACK_SRCNAME, msr->reclen, reclen); + } + + msr->encoding = blkt_1000->encoding; + msr->byteorder = blkt_1000->byteorder; + } + + else if ( blkt_type == 1001 ) + { /* Found a Blockette 1001 */ + blkt_link = msr_addblockette (msr, record + blkt_offset, + sizeof (struct blkt_1001_s), + blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + } + + else if ( blkt_type == 2000 ) + { /* Found a Blockette 2000 */ + struct blkt_2000_s *blkt_2000; + uint16_t b2klen; + + /* Read the blockette length from blockette */ + memcpy (&b2klen, record + blkt_offset, 2); + if ( headerswapflag ) ms_gswap2 (&b2klen); + + /* Minus four bytes for the blockette type and next fields */ + b2klen -= 4; + + blkt_link = msr_addblockette (msr, record + blkt_offset, + b2klen, blkt_type, 0); + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + + blkt_2000 = (struct blkt_2000_s *) blkt_link->blktdata; + + if ( headerswapflag ) + { + ms_gswap2 (&blkt_2000->length); + ms_gswap2 (&blkt_2000->data_offset); + ms_gswap4 (&blkt_2000->recnum); + } + } + + else + { /* Unknown blockette type */ + if ( blkt_length >= 4 ) + { + blkt_link = msr_addblockette (msr, record + blkt_offset, + blkt_length - 4, + blkt_type, 0); + + if ( ! blkt_link ) + break; + + blkt_link->blktoffset = blkt_offset - 4; + blkt_link->next_blkt = next_blkt; + } + } + + /* Check that the next blockette offset is beyond the current blockette */ + if ( next_blkt && next_blkt < (blkt_offset + blkt_length - 4) ) + { + ms_log (2, "msr_unpack(%s): Offset to next blockette (%d) is within current blockette ending at byte %d\n", + UNPACK_SRCNAME, next_blkt, (blkt_offset + blkt_length - 4)); + + blkt_offset = 0; + } + /* Check that the offset is within record length */ + else if ( next_blkt && next_blkt > reclen ) + { + ms_log (2, "msr_unpack(%s): Offset to next blockette (%d) from type %d is beyond record length\n", + UNPACK_SRCNAME, next_blkt, blkt_type); + + blkt_offset = 0; + } + else + { + blkt_offset = next_blkt; + } + + blkt_count++; + } /* End of while looping through blockettes */ + + /* Check for a Blockette 1000 */ + if ( msr->Blkt1000 == 0 ) + { + if ( verbose > 1 ) + { + ms_log (1, "%s: Warning: No Blockette 1000 found\n", UNPACK_SRCNAME); + } + } + + /* Check that the data offset is after the blockette chain */ + if ( blkt_link && msr->fsdh->numsamples && msr->fsdh->data_offset < (blkt_link->blktoffset + blkt_link->blktdatalen + 4) ) + { + ms_log (1, "%s: Warning: Data offset in fixed header (%d) is within the blockette chain ending at %d\n", + UNPACK_SRCNAME, msr->fsdh->data_offset, (blkt_link->blktoffset + blkt_link->blktdatalen + 4)); + } + + /* Check that the blockette count matches the number parsed */ + if ( msr->fsdh->numblockettes != blkt_count ) + { + ms_log (1, "%s: Warning: Number of blockettes in fixed header (%d) does not match the number parsed (%d)\n", + UNPACK_SRCNAME, msr->fsdh->numblockettes, blkt_count); + } + + /* Populate remaining common header fields */ + msr->starttime = msr_starttime (msr); + msr->samprate = msr_samprate (msr); + + /* Set MSRecord->byteorder if data byte order is forced */ + if ( unpackdatabyteorder >= 0 ) + { + msr->byteorder = unpackdatabyteorder; + } + + /* Check if encoding format is forced */ + if ( unpackencodingformat >= 0 ) + { + msr->encoding = unpackencodingformat; + } + + /* Use encoding format fallback if defined and no encoding is set, + * also make sure the byteorder is set by default to big endian */ + if ( unpackencodingfallback >= 0 && msr->encoding == -1 ) + { + msr->encoding = unpackencodingfallback; + + if ( msr->byteorder == -1 ) + { + msr->byteorder = 1; + } + } + + /* Unpack the data samples if requested */ + if ( dataflag && msr->samplecnt > 0 ) + { + flag dswapflag = headerswapflag; + flag bigendianhost = ms_bigendianhost(); + + /* Determine byte order of the data and set the dswapflag as + needed; if no Blkt1000 or UNPACK_DATA_BYTEORDER environment + variable setting assume the order is the same as the header */ + if ( msr->Blkt1000 != 0 && unpackdatabyteorder < 0 ) + { + dswapflag = 0; + + /* If BE host and LE data need swapping */ + if ( bigendianhost && msr->byteorder == 0 ) + dswapflag = 1; + /* If LE host and BE data (or bad byte order value) need swapping */ + else if ( !bigendianhost && msr->byteorder > 0 ) + dswapflag = 1; + } + else if ( unpackdatabyteorder >= 0 ) + { + dswapflag = dataswapflag; + } + + if ( verbose > 2 && dswapflag ) + ms_log (1, "%s: Byte swapping needed for unpacking of data samples\n", + UNPACK_SRCNAME); + else if ( verbose > 2 ) + ms_log (1, "%s: Byte swapping NOT needed for unpacking of data samples \n", + UNPACK_SRCNAME); + + retval = msr_unpack_data (msr, dswapflag, verbose); + + if ( retval < 0 ) + return retval; + else + msr->numsamples = retval; + } + else + { + if ( msr->datasamples ) + free (msr->datasamples); + + msr->datasamples = 0; + msr->numsamples = 0; + } + + /* Unset shared pointer to source name */ + UNPACK_SRCNAME = NULL; + + return MS_NOERROR; +} /* End of msr_unpack() */ + + +/************************************************************************ + * msr_unpack_data: + * + * Unpack Mini-SEED data samples for a given MSRecord. The packed + * data is accessed in the record indicated by MSRecord->record and + * the unpacked samples are placed in MSRecord->datasamples. The + * resulting data samples are either 32-bit integers, 32-bit floats + * or 64-bit floats in host byte order. + * + * Return number of samples unpacked or negative libmseed error code. + ************************************************************************/ +int +msr_unpack_data ( MSRecord *msr, int swapflag, flag verbose ) +{ + int datasize; /* byte size of data samples in record */ + int nsamples; /* number of samples unpacked */ + int unpacksize; /* byte size of unpacked samples */ + int samplesize = 0; /* size of the data samples in bytes */ + const char *dbuf; + int32_t *diffbuff; + int32_t x0, xn; + + /* Sanity record length */ + if ( msr->reclen == -1 ) + { + ms_log (2, "msr_unpack_data(%s): Record size unknown\n", + UNPACK_SRCNAME); + return MS_NOTSEED; + } + else if ( msr->reclen < MINRECLEN || msr->reclen > MAXRECLEN ) + { + ms_log (2, "msr_unpack_data(%s): Unsupported record length: %d\n", + UNPACK_SRCNAME, msr->reclen); + return MS_OUTOFRANGE; + } + + /* Sanity check data offset before creating a pointer based on the value */ + if ( msr->fsdh->data_offset < 48 || msr->fsdh->data_offset >= msr->reclen ) + { + ms_log (2, "msr_unpack_data(%s): data offset value is not valid: %d\n", + UNPACK_SRCNAME, msr->fsdh->data_offset); + return MS_GENERROR; + } + + datasize = msr->reclen - msr->fsdh->data_offset; + dbuf = msr->record + msr->fsdh->data_offset; + + switch (msr->encoding) + { + case DE_ASCII: + samplesize = 1; break; + case DE_INT16: + case DE_INT32: + case DE_FLOAT32: + case DE_STEIM1: + case DE_STEIM2: + case DE_GEOSCOPE24: + case DE_GEOSCOPE163: + case DE_GEOSCOPE164: + case DE_CDSN: + case DE_SRO: + case DE_DWWSSN: + samplesize = 4; break; + case DE_FLOAT64: + samplesize = 8; break; + default: + samplesize = 0; break; + } + + /* Calculate buffer size needed for unpacked samples */ + unpacksize = (int) msr->samplecnt * samplesize; + + /* (Re)Allocate space for the unpacked data */ + if ( unpacksize > 0 ) + { + msr->datasamples = realloc (msr->datasamples, unpacksize); + + if ( msr->datasamples == NULL ) + { + ms_log (2, "msr_unpack_data(%s): Cannot (re)allocate memory\n", + UNPACK_SRCNAME); + return MS_GENERROR; + } + } + else + { + if ( msr->datasamples ) + free (msr->datasamples); + msr->datasamples = 0; + msr->numsamples = 0; + } + + if ( verbose > 2 ) + ms_log (1, "%s: Unpacking %lld samples\n", + UNPACK_SRCNAME, (long long int)msr->samplecnt); + + /* Decide if this is a encoding that we can decode */ + switch (msr->encoding) + { + + case DE_ASCII: + if ( verbose > 1 ) + ms_log (1, "%s: Found ASCII data\n", UNPACK_SRCNAME); + + nsamples = (int)msr->samplecnt; + memcpy (msr->datasamples, dbuf, nsamples); + msr->sampletype = 'a'; + break; + + case DE_INT16: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking INT-16 data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_int_16 ((int16_t *)dbuf, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, + swapflag); + msr->sampletype = 'i'; + break; + + case DE_INT32: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking INT-32 data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_int_32 ((int32_t *)dbuf, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, + swapflag); + msr->sampletype = 'i'; + break; + + case DE_FLOAT32: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking FLOAT-32 data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_float_32 ((float *)dbuf, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, + swapflag); + msr->sampletype = 'f'; + break; + + case DE_FLOAT64: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking FLOAT-64 data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_float_64 ((double *)dbuf, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, + swapflag); + msr->sampletype = 'd'; + break; + + case DE_STEIM1: + diffbuff = (int32_t *) malloc(unpacksize); + if ( diffbuff == NULL ) + { + ms_log (2, "msr_unpack_data(%s): Cannot allocate diff buffer\n", + UNPACK_SRCNAME); + return MS_GENERROR; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking Steim-1 data frames\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_steim1 ((FRAME *)dbuf, datasize, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, diffbuff, + &x0, &xn, swapflag, verbose); + msr->sampletype = 'i'; + free (diffbuff); + break; + + case DE_STEIM2: + diffbuff = (int32_t *) malloc(unpacksize); + if ( diffbuff == NULL ) + { + ms_log (2, "msr_unpack_data(%s): Cannot allocate diff buffer\n", + UNPACK_SRCNAME); + return MS_GENERROR; + } + + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking Steim-2 data frames\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_steim2 ((FRAME *)dbuf, datasize, (int)msr->samplecnt, + (int)msr->samplecnt, msr->datasamples, diffbuff, + &x0, &xn, swapflag, verbose); + msr->sampletype = 'i'; + free (diffbuff); + break; + + case DE_GEOSCOPE24: + case DE_GEOSCOPE163: + case DE_GEOSCOPE164: + if ( verbose > 1 ) + { + if ( msr->encoding == DE_GEOSCOPE24 ) + ms_log (1, "%s: Unpacking GEOSCOPE 24bit integer data samples\n", + UNPACK_SRCNAME); + if ( msr->encoding == DE_GEOSCOPE163 ) + ms_log (1, "%s: Unpacking GEOSCOPE 16bit gain ranged/3bit exponent data samples\n", + UNPACK_SRCNAME); + if ( msr->encoding == DE_GEOSCOPE164 ) + ms_log (1, "%s: Unpacking GEOSCOPE 16bit gain ranged/4bit exponent data samples\n", + UNPACK_SRCNAME); + } + + nsamples = msr_unpack_geoscope (dbuf, (int)msr->samplecnt, (int)msr->samplecnt, + msr->datasamples, msr->encoding, swapflag); + msr->sampletype = 'f'; + break; + + case DE_CDSN: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking CDSN encoded data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_cdsn ((int16_t *)dbuf, (int)msr->samplecnt, (int)msr->samplecnt, + msr->datasamples, swapflag); + msr->sampletype = 'i'; + break; + + case DE_SRO: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking SRO encoded data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_sro ((int16_t *)dbuf, (int)msr->samplecnt, (int)msr->samplecnt, + msr->datasamples, swapflag); + msr->sampletype = 'i'; + break; + + case DE_DWWSSN: + if ( verbose > 1 ) + ms_log (1, "%s: Unpacking DWWSSN encoded data samples\n", UNPACK_SRCNAME); + + nsamples = msr_unpack_dwwssn ((int16_t *)dbuf, (int)msr->samplecnt, (int)msr->samplecnt, + msr->datasamples, swapflag); + msr->sampletype = 'i'; + break; + + default: + ms_log (2, "%s: Unsupported encoding format %d (%s)\n", + UNPACK_SRCNAME, msr->encoding, (char *) ms_encodingstr(msr->encoding)); + + return MS_UNKNOWNFORMAT; + } + + return nsamples; +} /* End of msr_unpack_data() */ + + +/************************************************************************ + * check_environment: + * + * Check environment variables and set global variables appropriately. + * + * Return 0 on success and -1 on error. + ************************************************************************/ +static int +check_environment (int verbose) +{ + char *envvariable; + + /* Read possible environmental variables that force byteorder */ + if ( unpackheaderbyteorder == -2 ) + { + if ( (envvariable = getenv("UNPACK_HEADER_BYTEORDER")) ) + { + if ( *envvariable != '0' && *envvariable != '1' ) + { + ms_log (2, "Environment variable UNPACK_HEADER_BYTEORDER must be set to '0' or '1'\n"); + return -1; + } + else if ( *envvariable == '0' ) + { + unpackheaderbyteorder = 0; + if ( verbose > 2 ) + ms_log (1, "UNPACK_HEADER_BYTEORDER=0, unpacking little-endian header\n"); + } + else + { + unpackheaderbyteorder = 1; + if ( verbose > 2 ) + ms_log (1, "UNPACK_HEADER_BYTEORDER=1, unpacking big-endian header\n"); + } + } + else + { + unpackheaderbyteorder = -1; + } + } + + if ( unpackdatabyteorder == -2 ) + { + if ( (envvariable = getenv("UNPACK_DATA_BYTEORDER")) ) + { + if ( *envvariable != '0' && *envvariable != '1' ) + { + ms_log (2, "Environment variable UNPACK_DATA_BYTEORDER must be set to '0' or '1'\n"); + return -1; + } + else if ( *envvariable == '0' ) + { + unpackdatabyteorder = 0; + if ( verbose > 2 ) + ms_log (1, "UNPACK_DATA_BYTEORDER=0, unpacking little-endian data samples\n"); + } + else + { + unpackdatabyteorder = 1; + if ( verbose > 2 ) + ms_log (1, "UNPACK_DATA_BYTEORDER=1, unpacking big-endian data samples\n"); + } + } + else + { + unpackdatabyteorder = -1; + } + } + + /* Read possible environmental variable that forces encoding format */ + if ( unpackencodingformat == -2 ) + { + if ( (envvariable = getenv("UNPACK_DATA_FORMAT")) ) + { + unpackencodingformat = (int) strtol (envvariable, NULL, 10); + + if ( unpackencodingformat < 0 || unpackencodingformat > 33 ) + { + ms_log (2, "Environment variable UNPACK_DATA_FORMAT set to invalid value: '%d'\n", unpackencodingformat); + return -1; + } + else if ( verbose > 2 ) + ms_log (1, "UNPACK_DATA_FORMAT, unpacking data in encoding format %d\n", unpackencodingformat); + } + else + { + unpackencodingformat = -1; + } + } + + /* Read possible environmental variable to be used as a fallback encoding format */ + if ( unpackencodingfallback == -2 ) + { + if ( (envvariable = getenv("UNPACK_DATA_FORMAT_FALLBACK")) ) + { + unpackencodingfallback = (int) strtol (envvariable, NULL, 10); + + if ( unpackencodingfallback < 0 || unpackencodingfallback > 33 ) + { + ms_log (2, "Environment variable UNPACK_DATA_FORMAT_FALLBACK set to invalid value: '%d'\n", + unpackencodingfallback); + return -1; + } + else if ( verbose > 2 ) + ms_log (1, "UNPACK_DATA_FORMAT_FALLBACK, fallback data unpacking encoding format %d\n", + unpackencodingfallback); + } + else + { + unpackencodingfallback = 10; /* Default fallback is Steim-1 encoding */ + } + } + + return 0; +} /* End of check_environment() */ diff --git a/libs/3rd-party/mseed/unpackdata.c b/libs/3rd-party/mseed/unpackdata.c new file mode 100644 index 0000000..b478950 --- /dev/null +++ b/libs/3rd-party/mseed/unpackdata.c @@ -0,0 +1,892 @@ +/************************************************************************ + * Routines for unpacking INT_16, INT_32, FLOAT_32, FLOAT_64, + * STEIM1, STEIM2, GEOSCOPE (24bit and gain ranged), CDSN, SRO + * and DWWSSN encoded data records. + * + * Some routines originated and were borrowed from qlib2 by: + * + * Douglas Neuhauser + * Seismographic Station + * University of California, Berkeley + * doug@seismo.berkeley.edu + * + * Modified by Chad Trabant, + * (previously) ORFEUS/EC-Project MEREDIAN + * (currently) IRIS Data Management Center + * + * modified: 2012.357 + ************************************************************************/ + +/* + * Copyright (c) 1996 The Regents of the University of California. + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for educational, research and non-profit purposes, + * without fee, and without a written agreement is hereby granted, + * provided that the above copyright notice, this paragraph and the + * following three paragraphs appear in all copies. + * + * Permission to incorporate this software into commercial products may + * be obtained from the Office of Technology Licensing, 2150 Shattuck + * Avenue, Suite 510, Berkeley, CA 94704. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY + * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, + * INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND + * ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE + * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF + * CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, + * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#include +#include +#include + +#include "libmseed.h" +#include "unpackdata.h" + +#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 # */ + +/* For Steim encodings */ +#define X0 pf->w[0].fw +#define XN pf->w[1].fw + + + +/************************************************************************ + * msr_unpack_int_16: * + * * + * Unpack int_16 miniSEED data and place in supplied buffer. * + * * + * Return: # of samples returned. * + ************************************************************************/ +int msr_unpack_int_16 + (int16_t *ibuf, /* ptr to input data. */ + int num_samples, /* number of data samples in total. */ + int req_samples, /* number of data desired by caller. */ + int32_t *databuff, /* ptr to unpacked data array. */ + int swapflag) /* if data should be swapped. */ +{ + int nd = 0; /* # of data points in packet. */ + int16_t stmp; + + if (num_samples < 0) return 0; + if (req_samples < 0) return 0; + + for (nd=0; nd 2 ) + ms_log (1, "%s: forward/reverse integration constants:\nX0: %d XN: %d\n", + UNPACK_SRCNAME, *px0, *pxn); + + /* Decode compressed data in each frame */ + for (fn = 0; fn < num_data_frames; fn++) + { + + ctrl = pf->ctrl; + if ( swapflag ) ms_gswap4a (&ctrl); + + for (wn = 0; wn < VALS_PER_FRAME; wn++) + { + if (nd >= num_samples) break; + + compflag = (ctrl >> ((VALS_PER_FRAME-wn-1)*2)) & 0x3; + + switch (compflag) + { + + case STEIM1_SPECIAL_MASK: + /* Headers info -- skip it */ + break; + + case STEIM1_BYTE_MASK: + /* Next 4 bytes are 4 1-byte differences */ + for (i=0; i < 4 && nd < num_samples; i++, nd++) + *diff++ = pf->w[wn].byte[i]; + break; + + case STEIM1_HALFWORD_MASK: + /* Next 4 bytes are 2 2-byte differences */ + for (i=0; i < 2 && nd < num_samples; i++, nd++) + { + if ( swapflag ) + { + stmp = pf->w[wn].hw[i]; + ms_gswap2a (&stmp); + *diff++ = stmp; + } + else *diff++ = pf->w[wn].hw[i]; + } + break; + + case STEIM1_FULLWORD_MASK: + /* Next 4 bytes are 1 4-byte difference */ + if ( swapflag ) + { + itmp = pf->w[wn].fw; + ms_gswap4a (&itmp); + *diff++ = itmp; + } + else *diff++ = pf->w[wn].fw; + nd++; + break; + + default: + /* Should NEVER get here */ + ms_log (2, "msr_unpack_steim1(%s): invalid compression flag = %d\n", + UNPACK_SRCNAME, compflag); + return MS_STBADCOMPFLAG; + } + } + ++pf; + } + + /* Test if the number of samples implied by the data frames is the + * same number indicated in the header. + */ + if ( nd != num_samples ) + { + ms_log (1, "Warning: msr_unpack_steim1(%s): number of samples indicated in header (%d) does not equal data (%d)\n", + UNPACK_SRCNAME, num_samples, nd); + } + + /* For now, assume sample count in header to be correct. */ + /* One way of "trimming" data from a block is simply to reduce */ + /* the sample count. It is not clear from the documentation */ + /* whether this is a valid or not, but it appears to be done */ + /* by other program, so we should not complain about its effect. */ + + nr = req_samples; + + /* Compute first value based on last_value from previous buffer. */ + /* The two should correspond in all cases EXCEPT for the first */ + /* record for each component (because we don't have a valid xn from */ + /* a previous record). Although the Steim compression algorithm */ + /* defines x(-1) as 0 for the first record, this only works for the */ + /* first record created since coldstart of the datalogger, NOT the */ + /* first record of an arbitrary starting record. */ + + /* In all cases, assume x0 is correct, since we don't have x(-1). */ + data = databuff; + diff = diffbuff; + last_data = *px0; + if (nr > 0) + *data = *px0; + + /* Compute all but first values based on previous value */ + prev = data - 1; + while (--nr > 0 && --nd > 0) + last_data = *++data = *++diff + *++prev; + + /* If a short count was requested compute the last sample in order */ + /* to perform the integrity check comparison */ + while (--nd > 0) + last_data = *++diff + last_data; + + /* Verify that the last value is identical to xn = rev. int. constant */ + if (last_data != *pxn) + { + ms_log (1, "%s: Warning: Data integrity check for Steim-1 failed, last_data=%d, xn=%d\n", + UNPACK_SRCNAME, last_data, *pxn); + } + + return ((req_samples < num_samples) ? req_samples : num_samples); +} /* End of msr_unpack_steim1() */ + + +/************************************************************************ + * msr_unpack_steim2: * + * * + * Unpack STEIM2 data frames and place in supplied buffer. * + * See the SEED format manual for Steim-2 encoding details. * + * * + * Return: # of samples returned or negative error code. * + ************************************************************************/ +int msr_unpack_steim2 + (FRAME *pf, /* ptr to Steim2 data frames. */ + int nbytes, /* number of bytes in all data frames. */ + int num_samples, /* number of data samples in all frames.*/ + int req_samples, /* number of data desired by caller. */ + int32_t *databuff, /* ptr to unpacked data array. */ + int32_t *diffbuff, /* ptr to unpacked diff array. */ + int32_t *px0, /* return X0, first sample in frame. */ + int32_t *pxn, /* return XN, last sample in frame. */ + int swapflag, /* if data should be swapped. */ + int verbose) +{ + int32_t *diff = diffbuff; + int32_t *data = databuff; + int32_t *prev; + int num_data_frames = nbytes / sizeof(FRAME); + int nd = 0; /* # of data points in packet. */ + int fn; /* current frame number. */ + int wn; /* current work number in the frame. */ + int compflag; /* current compression flag. */ + int nr, i; + int n, bits, m1, m2; + int32_t last_data; + int32_t val; + int8_t dnib; + uint32_t ctrl; + + if (num_samples < 0) return 0; + if (num_samples == 0) return 0; + if (req_samples < 0) return 0; + + /* Extract forward and reverse integration constants in first frame.*/ + *px0 = X0; + *pxn = XN; + + if ( swapflag ) + { + ms_gswap4a (px0); + ms_gswap4a (pxn); + } + + if ( verbose > 2 ) + ms_log (1, "%s: forward/reverse integration constants: X0: %d XN: %d\n", + UNPACK_SRCNAME, *px0, *pxn); + + /* Decode compressed data in each frame */ + for (fn = 0; fn < num_data_frames; fn++) + { + + ctrl = pf->ctrl; + if ( swapflag ) ms_gswap4a (&ctrl); + + for (wn = 0; wn < VALS_PER_FRAME; wn++) + { + if (nd >= num_samples) break; + + compflag = (ctrl >> ((VALS_PER_FRAME-wn-1)*2)) & 0x3; + + switch (compflag) + { + case STEIM2_SPECIAL_MASK: + /* Headers info -- skip it */ + break; + + case STEIM2_BYTE_MASK: + /* Next 4 bytes are 4 1-byte differences */ + for (i=0; i < 4 && nd < num_samples; i++, nd++) + *diff++ = pf->w[wn].byte[i]; + break; + + case STEIM2_123_MASK: + val = pf->w[wn].fw; + if ( swapflag ) ms_gswap4a (&val); + dnib = val >> 30 & 0x3; + switch (dnib) + { + case 1: /* 1 30-bit difference */ + bits = 30; n = 1; m1 = 0x3fffffff; m2 = 0x20000000; break; + case 2: /* 2 15-bit differences */ + bits = 15; n = 2; m1 = 0x00007fff; m2 = 0x00004000; break; + case 3: /* 3 10-bit differences */ + bits = 10; n = 3; m1 = 0x000003ff; m2 = 0x00000200; break; + default: /* should NEVER get here */ + ms_log (2, "msr_unpack_steim2(%s): invalid compflag, dnib, fn, wn = %d, %d, %d, %d\n", + UNPACK_SRCNAME, compflag, dnib, fn, wn); + return MS_STBADCOMPFLAG; + } + /* Uncompress the differences */ + for (i=(n-1)*bits; i >= 0 && nd < num_samples; i-=bits, nd++) + { + *diff = (val >> i) & m1; + *diff = (*diff & m2) ? *diff | ~m1 : *diff; + diff++; + } + break; + + case STEIM2_567_MASK: + val = pf->w[wn].fw; + if ( swapflag ) ms_gswap4a (&val); + dnib = val >> 30 & 0x3; + switch (dnib) + { + case 0: /* 5 6-bit differences */ + bits = 6; n = 5; m1 = 0x0000003f; m2 = 0x00000020; break; + case 1: /* 6 5-bit differences */ + bits = 5; n = 6; m1 = 0x0000001f; m2 = 0x00000010; break; + case 2: /* 7 4-bit differences */ + bits = 4; n = 7; m1 = 0x0000000f; m2 = 0x00000008; break; + default: + ms_log (2, "msr_unpack_steim2(%s): invalid compflag, dnib, fn, wn = %d, %d, %d, %d\n", + UNPACK_SRCNAME, compflag, dnib, fn, wn); + return MS_STBADCOMPFLAG; + } + /* Uncompress the differences */ + for (i=(n-1)*bits; i >= 0 && nd < num_samples; i-=bits, nd++) + { + *diff = (val >> i) & m1; + *diff = (*diff & m2) ? *diff | ~m1 : *diff; + diff++; + } + break; + + default: + /* Should NEVER get here */ + ms_log (2, "msr_unpack_steim2(%s): invalid compflag, fn, wn = %d, %d, %d - nsamp: %d\n", + UNPACK_SRCNAME, compflag, fn, wn, nd); + return MS_STBADCOMPFLAG; + } + } + ++pf; + } + + /* Test if the number of samples implied by the data frames is the + * same number indicated in the header. + */ + if ( nd != num_samples ) + { + ms_log (1, "Warning: msr_unpack_steim2(%s): number of samples indicated in header (%d) does not equal data (%d)\n", + UNPACK_SRCNAME, num_samples, nd); + } + + /* For now, assume sample count in header to be correct. */ + /* One way of "trimming" data from a block is simply to reduce */ + /* the sample count. It is not clear from the documentation */ + /* whether this is a valid or not, but it appears to be done */ + /* by other program, so we should not complain about its effect. */ + + nr = req_samples; + + /* Compute first value based on last_value from previous buffer. */ + /* The two should correspond in all cases EXCEPT for the first */ + /* record for each component (because we don't have a valid xn from */ + /* a previous record). Although the Steim compression algorithm */ + /* defines x(-1) as 0 for the first record, this only works for the */ + /* first record created since coldstart of the datalogger, NOT the */ + /* first record of an arbitrary starting record. */ + + /* In all cases, assume x0 is correct, since we don't have x(-1). */ + data = databuff; + diff = diffbuff; + last_data = *px0; + if (nr > 0) + *data = *px0; + + /* Compute all but first values based on previous value */ + prev = data - 1; + while (--nr > 0 && --nd > 0) + last_data = *++data = *++diff + *++prev; + + /* If a short count was requested compute the last sample in order */ + /* to perform the integrity check comparison */ + while (--nd > 0) + last_data = *++diff + last_data; + + /* Verify that the last value is identical to xn = rev. int. constant */ + if (last_data != *pxn) + { + ms_log (1, "%s: Warning: Data integrity check for Steim-2 failed, last_data=%d, xn=%d\n", + UNPACK_SRCNAME, last_data, *pxn); + } + + return ((req_samples < num_samples) ? req_samples : num_samples); +} /* End of msr_unpack_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 */ + +/************************************************************************ + * msr_unpack_geoscope: * + * * + * Unpack GEOSCOPE gain ranged data (demultiplexed only) encoded * + * miniSEED data and place in supplied buffer. * + * * + * Return: # of samples returned. * + ************************************************************************/ +int msr_unpack_geoscope + (const char *edata, /* ptr to encoded data. */ + int num_samples, /* number of data samples in total. */ + int req_samples, /* number of data desired by caller. */ + float *databuff, /* ptr to unpacked data array. */ + int encoding, /* specific GEOSCOPE encoding type */ + int swapflag) /* if data should be swapped. */ +{ + int nd = 0; /* # of data points in packet. */ + int mantissa; /* mantissa from SEED data */ + int gainrange; /* gain range factor */ + int exponent; /* total exponent */ + int k; + uint64_t exp2val; + int16_t sint; + double dsample = 0.0; + + union { + uint8_t b[4]; + uint32_t i; + } sample32; + + if (num_samples < 0) return 0; + if (req_samples < 0) return 0; + + /* Make sure we recognize this as a GEOSCOPE encoding format */ + if ( encoding != DE_GEOSCOPE24 && + encoding != DE_GEOSCOPE163 && + encoding != DE_GEOSCOPE164 ) + { + ms_log (2, "msr_unpack_geoscope(%s): unrecognized GEOSCOPE encoding: %d\n", + UNPACK_SRCNAME, encoding); + return -1; + } + + for (nd=0; nd MAX24) + mantissa -= 2 * (MAX24 + 1); + + /* Store */ + dsample = (double) mantissa; + + break; + case DE_GEOSCOPE163: + memcpy (&sint, edata, sizeof(int16_t)); + if ( swapflag ) ms_gswap2a(&sint); + + /* Recover mantissa and gain range factor */ + mantissa = (sint & GEOSCOPE_MANTISSA_MASK); + gainrange = (sint & GEOSCOPE_GAIN3_MASK) >> GEOSCOPE_SHIFT; + + /* Exponent is just gainrange for GEOSCOPE */ + exponent = gainrange; + + /* Calculate sample as mantissa / 2^exponent */ + exp2val = (uint64_t) 1 << exponent; + dsample = ((double) (mantissa-2048)) / exp2val; + + break; + case DE_GEOSCOPE164: + memcpy (&sint, edata, sizeof(int16_t)); + if ( swapflag ) ms_gswap2a(&sint); + + /* Recover mantissa and gain range factor */ + mantissa = (sint & GEOSCOPE_MANTISSA_MASK); + gainrange = (sint & GEOSCOPE_GAIN4_MASK) >> GEOSCOPE_SHIFT; + + /* Exponent is just gainrange for GEOSCOPE */ + exponent = gainrange; + + /* Calculate sample as mantissa / 2^exponent */ + exp2val = (uint64_t) 1 << exponent; + dsample = ((double) (mantissa-2048)) / exp2val; + + break; + } + + /* Save sample in output array */ + databuff[nd] = (float) dsample; + + /* Increment edata pointer depending on size */ + switch (encoding) + { + case DE_GEOSCOPE24: + edata += 3; + break; + case DE_GEOSCOPE163: + case DE_GEOSCOPE164: + edata += 2; + break; + } + } + + return nd; +} /* End of msr_unpack_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 */ + +/************************************************************************ + * msr_unpack_cdsn: * + * * + * Unpack CDSN gain ranged data encoded miniSEED data and place in * + * supplied buffer. * + * * + * Notes from original rdseed routine: * + * CDSN data are compressed according to the formula * + * * + * sample = M * (2 exp G) * + * * + * where * + * sample = seismic data sample * + * M = mantissa; biased mantissa B is written to tape * + * G = exponent of multiplier (i.e. gain range factor); * + * key K is written to tape * + * exp = exponentiation operation * + * B = M + 8191, biased mantissa, written to tape * + * K = key to multiplier exponent, written to tape * + * K may have any of the values 0 - 3, as follows: * + * 0 => G = 0, multiplier = 2 exp 0 = 1 * + * 1 => G = 2, multiplier = 2 exp 2 = 4 * + * 2 => G = 4, multiplier = 2 exp 4 = 16 * + * 3 => G = 7, multiplier = 2 exp 7 = 128 * + * Data are stored on tape in two bytes as follows: * + * fedc ba98 7654 3210 = bit number, power of two * + * KKBB BBBB BBBB BBBB = form of SEED data * + * where K = key to multiplier exponent and B = biased mantissa * + * * + * Masks to recover key to multiplier exponent and biased mantissa * + * from tape are: * + * fedc ba98 7654 3210 = bit number = power of two * + * 0011 1111 1111 1111 = 0x3fff = mask for biased mantissa * + * 1100 0000 0000 0000 = 0xc000 = mask for gain range key * + * * + * Return: # of samples returned. * + ************************************************************************/ +int msr_unpack_cdsn + (int16_t *edata, /* ptr to encoded data. */ + int num_samples, /* number of data samples in total. */ + int req_samples, /* number of data desired by caller. */ + int32_t *databuff, /* ptr to unpacked data array. */ + int swapflag) /* if data should be swapped. */ +{ + int32_t nd = 0; /* sample count */ + int32_t mantissa; /* mantissa */ + int32_t gainrange; /* gain range factor */ + int32_t mult = -1; /* multiplier for gain range */ + uint16_t sint; + int32_t sample; + + if (num_samples < 0) return 0; + if (req_samples < 0) return 0; + + for (nd=0; nd> CDSN_SHIFT; + + /* Determine multiplier from the gain range factor and format definition + * because shift operator is used later, these are powers of two */ + if ( gainrange == 0 ) mult = 0; + else if ( gainrange == 1 ) mult = 2; + else if ( gainrange == 2 ) mult = 4; + else if ( gainrange == 3 ) mult = 7; + + /* Unbias the mantissa */ + mantissa -= MAX14; + + /* Calculate sample from mantissa and multiplier using left shift + * mantissa << mult is equivalent to mantissa * (2 exp (mult)) */ + sample = (mantissa << mult); + + /* Save sample in output array */ + databuff[nd] = sample; + } + + return nd; +} /* End of msr_unpack_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 */ + +/************************************************************************ + * msr_unpack_sro: * + * * + * Unpack SRO gain ranged data encoded miniSEED data and place in * + * supplied buffer. * + * * + * Notes from original rdseed routine: * + * SRO data are represented according to the formula * + * * + * sample = M * (b exp {[m * (G + agr)] + ar}) * + * * + * where * + * sample = seismic data sample * + * M = mantissa * + * G = gain range factor * + * b = base to be exponentiated = 2 for SRO * + * m = multiplier = -1 for SRO * + * agr = term to be added to gain range factor = 0 for SRO * + * ar = term to be added to [m * (gr + agr)] = 10 for SRO * + * exp = exponentiation operation * + * Data are stored in two bytes as follows: * + * fedc ba98 7654 3210 = bit number, power of two * + * GGGG MMMM MMMM MMMM = form of SEED data * + * where G = gain range factor and M = mantissa * + * Masks to recover gain range and mantissa: * + * fedc ba98 7654 3210 = bit number = power of two * + * 0000 1111 1111 1111 = 0x0fff = mask for mantissa * + * 1111 0000 0000 0000 = 0xf000 = mask for gain range * + * * + * Return: # of samples returned. * + ************************************************************************/ +int msr_unpack_sro + (int16_t *edata, /* ptr to encoded data. */ + int num_samples, /* number of data samples in total. */ + int req_samples, /* number of data desired by caller. */ + int32_t *databuff, /* ptr to unpacked data array. */ + int swapflag) /* if data should be swapped. */ +{ + int32_t nd = 0; /* sample count */ + int32_t mantissa; /* mantissa */ + int32_t gainrange; /* gain range factor */ + int32_t add2gr; /* added to gainrage factor */ + int32_t mult; /* multiplier for gain range */ + int32_t add2result; /* added to multiplied gain rage */ + int32_t exponent; /* total exponent */ + uint16_t sint; + int32_t sample; + + if (num_samples < 0) return 0; + if (req_samples < 0) return 0; + + add2gr = 0; + mult = -1; + add2result = 10; + + for (nd=0; nd> SRO_SHIFT; + + /* Take 2's complement for mantissa */ + if ( mantissa > MAX12 ) + mantissa -= 2 * (MAX12 + 1); + + /* Calculate exponent, SRO exponent = 0..10 */ + exponent = (mult * (gainrange + add2gr)) + add2result; + + if ( exponent < 0 || exponent > 10 ) + { + ms_log (2, "msr_unpack_sro(%s): SRO gain ranging exponent out of range: %d\n", + UNPACK_SRCNAME, exponent); + return MS_GENERROR; + } + + /* Calculate sample as mantissa * 2^exponent */ + sample = mantissa * ( (uint64_t) 1 << exponent ); + + /* Save sample in output array */ + databuff[nd] = sample; + } + + return nd; +} /* End of msr_unpack_sro() */ + + +/************************************************************************ + * msr_unpack_dwwssn: * + * * + * Unpack DWWSSN encoded miniSEED data and place in supplied buffer. * + * * + * Return: # of samples returned. * + ************************************************************************/ +int msr_unpack_dwwssn + (int16_t *edata, /* ptr to encoded data. */ + int num_samples, /* number of data samples in total. */ + int req_samples, /* number of data desired by caller. */ + int32_t *databuff, /* ptr to unpacked data array. */ + int swapflag) /* if data should be swapped. */ +{ + int32_t nd = 0; /* sample count */ + int32_t sample; + uint16_t sint; + + if (num_samples < 0) return 0; + if (req_samples < 0) return 0; + + for (nd=0; nd MAX16 ) + sample -= 2 * (MAX16 + 1); + + /* Save sample in output array */ + databuff[nd] = sample; + } + + return nd; +} /* End of msr_unpack_dwwssn() */ diff --git a/libs/3rd-party/mseed/unpackdata.h b/libs/3rd-party/mseed/unpackdata.h new file mode 100644 index 0000000..dfff81f --- /dev/null +++ b/libs/3rd-party/mseed/unpackdata.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * unpack.h: + * + * Interface declarations for the Mini-SEED unpacking routines in + * unpackdata.c + * + * modified: 2009.111 + ***************************************************************************/ + + +#ifndef UNPACKDATA_H +#define UNPACKDATA_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#include "steimdata.h" + +/* Pointer to srcname of record being unpacked, declared in unpack.c */ +extern char *UNPACK_SRCNAME; + +extern int msr_unpack_int_16 (int16_t*, int, int, int32_t*, int); +extern int msr_unpack_int_32 (int32_t*, int, int, int32_t*, int); +extern int msr_unpack_float_32 (float*, int, int, float*, int); +extern int msr_unpack_float_64 (double*, int, int, double*, int); +extern int msr_unpack_steim1 (FRAME*, int, int, int, int32_t*, int32_t*, + int32_t*, int32_t*, int, int); +extern int msr_unpack_steim2 (FRAME*, int, int, int, int32_t*, int32_t*, + int32_t*, int32_t*, int, int); +extern int msr_unpack_geoscope (const char*, int, int, float*, int, int); +extern int msr_unpack_cdsn (int16_t*, int, int, int32_t*, int); +extern int msr_unpack_sro (int16_t*, int, int, int32_t*, int); +extern int msr_unpack_dwwssn (int16_t*, int, int, int32_t*, int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt new file mode 100644 index 0000000..fbdcd6f --- /dev/null +++ b/libs/CMakeLists.txt @@ -0,0 +1,5 @@ +SUBDIRS(3rd-party gempa) + +IF(LIBCAPS_PYTHON_WRAPPER) + SUBDIRS(swig) +ENDIF() diff --git a/libs/gempa/CMakeLists.txt b/libs/gempa/CMakeLists.txt new file mode 100644 index 0000000..2fd6cb7 --- /dev/null +++ b/libs/gempa/CMakeLists.txt @@ -0,0 +1 @@ +subdirs(caps) diff --git a/libs/gempa/caps/CHANGELOG.md b/libs/gempa/caps/CHANGELOG.md new file mode 100644 index 0000000..14d034f --- /dev/null +++ b/libs/gempa/caps/CHANGELOG.md @@ -0,0 +1,150 @@ +# Change Log + +All notable changes to the CAPS client library will be documented in this file. + +## 2021-04-21 1.0.0 +### Changed +- Set library version to 1.0.0 + +## 2021-02-16 +### Added +- Allow to set maximum allowed future end time via plugin API. In additon + add commandline and config support to the plugin application class e.g. + ``` + output.maxFutureEndTime = 120 + ``` + By default the option is set to 120 seconds. + +## 2020-12-14 +### Added +- Support to set miniSEED record length via API + +## 2020-09-22 +### Changed +- Use last sample time as reference time for maximum future time check. Before + we used the packet end time as reference time but this makes no sense in case + of low sampled data. +- So far we used the current time as start time if journal entries exceeded the + maximum allowed future time. With this release we use the journal time no + matter what its value but display a warning when the journal time is more than + one day in the future. + +## 2020-06-22 +### Added +- Python3 byte array support to any record push + +## 2020-02-21 +### Changed +- Increase default timeout for acknowledgement messages from 5s to 60s + +## 2019-09-24 +### Fixed +- Fix high load if packets could not be sent to CAPS. In that case the plugin + automatically reconnects after some amount of time. If triggered under certain + circumstances this delay was not in effect and caused unnecessarily high + amount of connection attempts. Under some circumstances the plugin could have + crashed due to a stack overflow. +- The quit method has now the semantics to continue pushing packets as long + as the connection is established and only abort in case of an error without + attempting a reconnect. + +## 2019-09-20 +### Fixed +- Fix error string if not all data could be sent to the server + +## 2019-08-19 +### Changed +- Discard packets whose end time is more than 120 seconds before the system time. + +## 2019-08-06 +### Added +- new config option ``output.addr`` + +### Fixed +- ambiguous command line option ``-h``. With this version of the library the +host and port can be set via the command line option ``--addr``. +- wrong config option parsing + +## 2019-08-05 +### Fixed +- seg fault in date time parser + +## 2019-08-02 +### Fixed +- Hanging TCP connections. In case of the remote side does not shutdown cleanly +the plugin did not notice that the connection is no longer available. With this +version the plugin reconnects to the server when the TCP send buffer is full and +tries to send all not acknowledged packets again. +- Do not discard packets if the packet buffer is full. Instead we block until +the server acknowledges some packets. + +### Changed +- The plugin application class checks whether the configured buffer size is +below the minimum. + +## 2019-07-05 +### Changed +- Ignore journal entries where the timestamp is more than 10 seconds + before the system time. + +## 2018-12-19 +### Fixed +- Read journal from file in plugin application. + +## 2018-12-18 +### Fixed +- Do not reconnect if the plugin buffer is full. Instead of we try to read +acknowledgements from the CAPS server until the plugin buffer is below the +threshold. + +## 2018-12-17 +### Added +- Support to retrieve status information e.g. the number of buffered bytes from + plugin. + +## 2018-09-06 +### Changed +- Enable more verbose logging for MSEED packets + +## 2018-07-25 +### Fixed +- unset variable of the raw data record +- trim function will return false in case of an unknown datatype + +## 2018-05-30 +### Fixed +- Fixed unexpected closed SSL connections + +## 2018-06-05 +### Fixed +- Fix RawDataRecord::setHeader + +## 2018-05-16 +### Fixed +- RAW data end time calculation + +## 2018-03-19 +### Added +- SSL support + +## 2017-11-20 +### Added +- float and double support for Steim encoders. All values will be converted implicitly +to int 32 values + +## 2017-11-08 +### Added +- timing quality parameter to push call. By default the timing quality is set to -1. + +## 2017-11-07 +### Fixed +- do not flush encoders after reconnect + +## 2017-10-26 +### Added +- SSL support + + +## 2017-10-24 +### Fixed +- packet synchronization error after reconnect diff --git a/libs/gempa/caps/CMakeLists.txt b/libs/gempa/caps/CMakeLists.txt new file mode 100644 index 0000000..8729952 --- /dev/null +++ b/libs/gempa/caps/CMakeLists.txt @@ -0,0 +1,22 @@ +SET(PACKAGE_NAME LIB_CAPS) +SET(LIB_NAME capsclient) + +FILE(GLOB ${PACKAGE_NAME}_SOURCES + "*.cpp" + "mseed/*.cpp" +) + +LIST(FILTER ${PACKAGE_NAME}_SOURCES EXCLUDE REGEX pluginapplication.cpp) + +IF(WIN32) + SET(${PACKAGE_NAME}_SOURCES ${${PACKAGE_NAME}_SOURCES} strptime.c) +ENDIF(WIN32) + +INCLUDE_DIRECTORIES(../../3rd-party/mseed) + +ADD_LIBRARY(${LIB_NAME} SHARED ${${PACKAGE_NAME}_SOURCES}) +SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES COMPILE_FLAGS -fPIC) +SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION 1.0.0 SOVERSION 1) +TARGET_LINK_LIBRARIES(${LIB_NAME} mseed) + +INSTALL(TARGETS ${LIB_NAME} DESTINATION lib) diff --git a/libs/gempa/caps/anypacket.cpp b/libs/gempa/caps/anypacket.cpp new file mode 100644 index 0000000..aabf1b8 --- /dev/null +++ b/libs/gempa/caps/anypacket.cpp @@ -0,0 +1,197 @@ +/*************************************************************************** + * Copyright (C) 2012 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include + +#include +#include +#include + + +namespace Gempa { +namespace CAPS { + +bool AnyDataRecord::AnyHeader::put(std::streambuf &buf) const { + Endianess::Writer put(buf); + put(type, sizeof(type)-1); + dataHeader.put(buf); + + put(endTime.year); + put(endTime.yday); + put(endTime.hour); + put(endTime.minute); + put(endTime.second); + put(endTime.usec); + + return put.good; +} + + +AnyDataRecord::AnyDataRecord() { + strncpy(_header.type, "ANY", sizeof(_header.type)); + _header.dataHeader.samplingFrequencyDenominator = 0; + _header.dataHeader.samplingFrequencyNumerator = 0; + // Just a bunch of bytes + _header.dataHeader.dataType = DT_INT8; +} + +bool AnyDataRecord::setType(const char *type) { + strncpy(_header.type, type, sizeof(_header.type)); + + // Input clipped? + if ( _header.type[sizeof(_header.type)-1] != '\0' ) { + _header.type[sizeof(_header.type)-1] = '\0'; + return false; + } + + return true; +} + + +const char *AnyDataRecord::type() const { + return _header.type; +} + +void AnyDataRecord::setStartTime(const Time &time) { + timeToTimestamp(_header.dataHeader.samplingTime, time); + _startTime = time; +} + + +void AnyDataRecord::setEndTime(const Time &time) { + timeToTimestamp(_header.endTime, time); + _endTime = time; +} + + +void AnyDataRecord::setSamplingFrequency(uint16_t numerator, uint16_t denominator) { + _header.dataHeader.samplingFrequencyNumerator = numerator; + _header.dataHeader.samplingFrequencyDenominator = denominator; +} + + +const char *AnyDataRecord::formatName() const { + return "ANY"; +} + + +bool AnyDataRecord::readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, Time &endTime) { + // Read record type + buf.sgetn(_header.type, 4); + _header.type[sizeof(_header.type)-1] = '\0'; + + size -= sizeof(_header.type)-1; + + if ( !header.get(buf) ) return false; + + TimeStamp tmp; + Endianess::Reader get(buf); + + get(tmp.year); + get(tmp.yday); + get(tmp.hour); + get(tmp.minute); + get(tmp.second); + get(tmp.usec); + + startTime = timestampToTime(header.samplingTime); + endTime = timestampToTime(tmp); + + return true; +} + + +const DataRecord::Header *AnyDataRecord::header() const { + return &_header.dataHeader; +} + + +Time AnyDataRecord::startTime() const { + return _startTime; +} + + +Time AnyDataRecord::endTime() const { + return _endTime; +} + + +bool AnyDataRecord::canTrim() const { + return false; +} + + +bool AnyDataRecord::canMerge() const { + return false; +} + + +bool AnyDataRecord::trim(const Time &start, + const Time &end) const { + return false; +} + + +size_t AnyDataRecord::dataSize(bool withHeader) const { + if ( withHeader ) + return _data.size() + _header.dataSize(); + else + return _data.size(); +} + + +DataRecord::ReadStatus AnyDataRecord::get(std::streambuf &buf, int size, + const Time &start, const Time &end, + int) { + _data.clear(); + size -= _header.dataSize(); + if ( size < 0 ) return RS_Error; + if ( !_header.get(buf) ) return RS_Error; + + _startTime = timestampToTime(_header.dataHeader.samplingTime); + _endTime = timestampToTime(_header.endTime); + + if ( start.valid() ) { + if ( _endTime < start || (_startTime < start && _endTime == start) ) + return RS_BeforeTimeWindow; + } + + if ( end.valid() ) { + if ( _startTime >= end ) return RS_AfterTimeWindow; + } + + RIFF::VectorChunk<1,false> dataChunk(_data, 0, size); + if ( !dataChunk.get(buf, size) ) return RS_Error; + + return RS_Complete; +} + + +bool AnyDataRecord::put(std::streambuf &buf, bool withHeader) const { + if ( withHeader && !_header.put(buf) ) return false; + return (int)buf.sputn(_data.data(), _data.size()) == (int)_data.size(); +} + +void AnyDataRecord::setData(char *data, size_t size) { + _data.resize(size); + memcpy(_data.data(), data, size); +} + +} +} diff --git a/libs/gempa/caps/anypacket.h b/libs/gempa/caps/anypacket.h new file mode 100644 index 0000000..cbe180a --- /dev/null +++ b/libs/gempa/caps/anypacket.h @@ -0,0 +1,154 @@ +/*************************************************************************** + * Copyright (C) 2012 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_CUSTOMPACKET_H +#define GEMPA_CAPS_CUSTOMPACKET_H + + +#include +#include + +#include + +namespace Gempa { +namespace CAPS { + +class AnyDataRecord : public DataRecord { + public: + typedef std::vector Buffer; + + struct AnyHeader { + char type[5]; + Header dataHeader; + TimeStamp endTime; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + get(type, sizeof(type)-1); + type[sizeof(type)-1] = '\0'; + dataHeader.get(buf); + + get(endTime.year); + get(endTime.yday); + get(endTime.hour); + get(endTime.minute); + get(endTime.second); + get(endTime.usec); + + return get.good; + } + + bool put(std::streambuf &buf) const; + + // 4 additional bytes (type) with respect to the original + // data header + int dataSize() const { + return sizeof(type)-1 + + dataHeader.dataSize() + + sizeof(endTime.year) + + sizeof(endTime.yday) + + sizeof(endTime.hour) + + sizeof(endTime.minute) + + sizeof(endTime.second) + + sizeof(endTime.usec); + } + }; + + AnyDataRecord(); + + //! Sets the format of the any record. The format can be + //! anything that fits into 4 characters. If more than + //! 4 characters are given, false is returned. + bool setType(const char *type); + const char *type() const; + + virtual const char *formatName() const; + + virtual bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, + Time &endTime); + + virtual const Header *header() const; + virtual Time startTime() const; + virtual Time endTime() const; + + virtual bool canTrim() const; + virtual bool canMerge() const; + + virtual bool trim(const Time &start, + const Time &end) const; + + virtual size_t dataSize(bool withHeader) const; + + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &start = Time(), + const Time &end = Time(), + int maxSize = -1); + + virtual bool put(std::streambuf &buf, bool withHeader) const; + + /** + * @brief Returns the packet type + * @return The packet type + */ + PacketType packetType() const { return ANYPacket; } + + /** + * @brief Sets the start time of the record + * @param The start time + */ + void setStartTime(const Time &time); + + /** + * @brief Sets the end time of the record + * @param The end time + */ + void setEndTime(const Time &time); + + /** + * @brief Sets the sampling frequency of the record + * @param numerator The numerator + * @param denominator The denomintor + */ + void setSamplingFrequency(uint16_t numerator, uint16_t denominator); + + /** + * @brief Returns the data vector to be filled by the caller + * @return The pointer to the internal buffer + */ + Buffer *data() { return &_data; } + + /** + * @brief Initializes the internal data vector from the given buffer + * @param The buffer to read the data from + * @param The buffer size + */ + virtual void setData(char *data, size_t size); + + protected: + AnyHeader _header; + Buffer _data; + + Time _startTime; + Time _endTime; +}; + + +} +} + + +#endif diff --git a/libs/gempa/caps/api.h b/libs/gempa/caps/api.h new file mode 100644 index 0000000..67dfa25 --- /dev/null +++ b/libs/gempa/caps/api.h @@ -0,0 +1,17 @@ +#ifndef SC_GEMPA_CAPS_API_H +#define SC_GEMPA_CAPS_API_H + +#if defined(WIN32) && (defined(SC_GEMPA_CAPS_SHARED) || defined(SC_ALL_SHARED)) +# if defined(SC_GEMPA_CAPS_EXPORTS) +# define SC_GEMPA_CAPS_API __declspec(dllexport) +# define SC_GEMPA_CAPS_TEMPLATE_EXPORT +# else +# define SC_GEMPA_CAPS_API __declspec(dllimport) +# define SC_GEMPA_CAPS_TEMPLATE_EXPORT extern +# endif +#else +# define SC_GEMPA_CAPS_API +# define SC_GEMPA_CAPS_TEMPLATE_EXPORT +#endif + +#endif diff --git a/libs/gempa/caps/application.cpp b/libs/gempa/caps/application.cpp new file mode 100644 index 0000000..a484c3e --- /dev/null +++ b/libs/gempa/caps/application.cpp @@ -0,0 +1,141 @@ +/*************************************************************************** + * Copyright (C) 2015 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include + +#include +#include + +namespace { + +void signalHandler(int signal) { + Gempa::CAPS::Application::Interrupt(signal); +} + + +void registerSignalHandler() { + CAPS_DEBUG("Registering signal handler"); + + signal(SIGTERM, signalHandler); + signal(SIGINT, signalHandler); + signal(SIGHUP, SIG_IGN); + signal(SIGPIPE, SIG_IGN); +} + +} + +namespace Gempa { +namespace CAPS { + +Application* Application::_app = NULL; + +Application::Application(int argc, char **argv) { + _exitRequested = false; + _argc = argc; + _argv = argv; + + _app = this; + + registerSignalHandler(); +} + +void Application::done() { + _exitRequested = true; + CAPS_DEBUG("leaving ::done"); +} + +int Application::exec() { + _returnCode = 1; + if ( init() ) { + _returnCode = 0; + + if ( !run() && _returnCode == 0 ) + _returnCode = 1; + + done(); + } + else + done(); + + return _returnCode; +} + +void Application::exit(int returnCode) { + _returnCode = returnCode; + _exitRequested = true; +} + +void Application::handleInterrupt(int signal) { + switch ( signal ) { + case SIGABRT: + exit(-1); + + case SIGSEGV: + exit(-1); + + default: + this->exit(_returnCode); + } +} + +void Application::Interrupt(int signal) { + if ( _app ) _app->handleInterrupt(signal); +} + +bool Application::init() { + setlocale(LC_ALL, "C"); + + if ( !initCommandLine() ) { + exit(1); + return false; + } + + if ( !initConfiguration() ) { + exit(1); + return false; + } + + if ( !initCommandLine() ) { + exit(1); + return false; + } + + if ( !validateParameters() ) { + exit(1); + return false; + } + + return true; +} + +bool Application::initCommandLine() { + return true; +} + +bool Application::initConfiguration() { + return true; +} + +bool Application::run() { + return true; +} + +bool Application::validateParameters() { + return true; +} + +} +} diff --git a/libs/gempa/caps/application.h b/libs/gempa/caps/application.h new file mode 100644 index 0000000..c8d64bf --- /dev/null +++ b/libs/gempa/caps/application.h @@ -0,0 +1,106 @@ +/*************************************************************************** + * Copyright (C) 2015 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_APPLICATION_H +#define GEMPA_CAPS_APPLICATION_H + +#include + +namespace Gempa { +namespace CAPS { + +class SC_GEMPA_CAPS_API Application { + public: + Application(int argc, char **argv); + virtual ~Application() {} + + /** + * Exit the application and set the returnCode. + * @param returnCode The value returned from exec() + */ + virtual void exit(int returnCode); + + /** + * @brief Conventient function to simplify usage + * @return The value returned from exec() + */ + int operator()() { return exec(); } + + /** + * @brief In case of an interrupt this method can be used to + * forward the signal to the internal signal handling. + * @param signal + */ + static void Interrupt(int signal); + + protected: + /** + * @brief Cleanup method called before exec() returns. + */ + virtual void done(); + + /** + * Execs the mainloop and waits until exit() is called + * or a appropriate signal has been fired (e.g. SIGTERM). + * @return The value that was set with to exit() + */ + int exec(); + /** + * @brief This method can be used to implement custom + * signal handling. + * @param signal The emitted signal + */ + virtual void handleInterrupt(int signal); + + /** + * @brief Initialization method. This method calls the initCommandLine + * initConfiguration and validateParameters function + */ + virtual bool init(); + /** + * @brief Handles commandline arguments + */ + virtual bool initCommandLine(); + /** + * @brief Handles configuration files + */ + virtual bool initConfiguration(); + + /** + * @brief This method must be implemented in the inherited class to + * execute the plugin specific code. + */ + virtual bool run(); + /** + * @brief This method can be used to verify custom configuration or + commandline parameters + */ + virtual bool validateParameters(); + + protected: + bool _exitRequested; + int _argc; + char **_argv; + + private: + int _returnCode; + static Application *_app; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/connection.cpp b/libs/gempa/caps/connection.cpp new file mode 100644 index 0000000..30fe706 --- /dev/null +++ b/libs/gempa/caps/connection.cpp @@ -0,0 +1,621 @@ +/*************************************************************************** + * Copyright (C) 2014 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +using namespace std; + +namespace Gempa { +namespace CAPS { + +namespace { + +const Time InvalidTime = Time(); + +template +bool fromString(T &value, const string &str); + +template<> inline bool fromString(int &value, const string &str) { + stringstream ss(str); + ss >> value; + return !ss.bad(); +} + +} + +Connection::Connection() { + _port = 18002; + _server = "localhost"; + + _metaMode = false; + _realtime = true; + _ssl = false; + + _sessionTable = SessionTablePtr(new SessionTable()); + _sessionTable->setItemAboutToBeRemovedFunc( + bind(&Connection::onItemAboutToBeRemoved, this, placeholders::_1) + ); + + reset(); +} + +Connection::~Connection() { + close(); +} + +bool Connection::setServer(const string &server) { + close(); + reset(); + + size_t pos = server.rfind(':'); + string addr = server; + int timeout = 300; + + if ( pos == string::npos ) + _server = addr; + else { + _server = addr.substr(0, pos); + if ( !fromString(_port, addr.substr(pos+1)) ) { + CAPS_ERROR("invalid source address: %s", addr.c_str()); + return false; + } + } + + if ( timeout > 0 ) { + CAPS_DEBUG("setting socket timeout to %ds", timeout); + //_socket->setSocketTimeout(timeout,0); + } + + return true; +} + +void Connection::setCredentials(const std::string &user, + const std::string &password) { + if ( user.empty() || password.empty() ) { + _auth.clear(); + CAPS_DEBUG("authentication deactivated"); + } + else { + _auth = "AUTH " + user + " " + password; + CAPS_DEBUG("credentials set: %s:***", user.c_str()); + } +} + +Socket* Connection::createSocket() const { +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + return _ssl? new SSLSocket() : new Socket(); +#else + return new Socket(); +#endif +} + +void Connection::disconnect() { + if ( _socket == NULL ) return; + + CAPS_DEBUG("disconnecting"); + if ( _state != Aborted ) + _state = Error; + + _socket->shutdown(); + _socket->close(); + _sessionTable->reset(); + _currentID = - 1; + _currentItem = NULL; +} + +void Connection::close() { + boost::mutex::scoped_lock l(_mutex); +// _state = Aborted; + disconnect(); + _state = Aborted; +} + +void Connection::abort() { + boost::mutex::scoped_lock l(_mutex); + if ( _state == Aborted ) { + CAPS_WARNING("abort already requested"); + return; + } + + if ( _socket->isValid() && _state == Active ) { + static string line("ABORT\n"); + if ( _socket->write(line.c_str(), line.size()) != (int) line.size() ) { + CAPS_ERROR("could not send abort request"); + disconnect(); + } + else { + CAPS_DEBUG("abort command sent"); + } + } + _state = Aborted; +} + +bool Connection::setTimeout(int /*seconds*/) { + return false; +} + +bool Connection::addStream(const string &net, const string &sta, + const string &loc, const string &cha) { + return addRequest(net, sta, loc, cha, _startTime, _endTime, false); +} + +bool Connection::addStream(const string &net, const string &sta, + const string &loc, const string &cha, + const Time &stime, + const Time &etime) { + return addRequest(net, sta, loc, cha, stime, etime, false); +} + +bool Connection::addRequest(const string &net, const string &sta, + const string &loc, const string &cha, + const Time &stime, + const Time &etime, + bool receivedData) { + boost::mutex::scoped_lock l(_mutex); + if ( _state != EOD ) { + if ( _state == Active ) + CAPS_WARNING("cannot add streams to an active session, invoke " + "abort() or close() first"); + else + CAPS_WARNING("cannot add streams to an erroneous or aborted " + "session, invoke reset() first"); + return false; + } + string streamID = net + "." + sta + "." + loc + "." + cha; + Request &req = _requests[streamID]; + req.net = net; + req.sta = sta; + req.loc = loc; + req.cha = cha; + req.start = stime; + req.end = etime; + req.receivedData = receivedData; + return true; +} + +DataRecord* Connection::next() { + if ( !handshake() ) return NULL; + + while ( true ) { + { + boost::mutex::scoped_lock l(_mutex); + // skip unread bytes of previous iteration and check connection state + if ( !seekToReadLimit() || _state == Error || _state == EOD ) + return NULL; + } + + ResponseHeader responseHeader; + if ( !responseHeader.get(_socketBuf) ) { + boost::mutex::scoped_lock l(_mutex); + if ( _state != Aborted) + CAPS_ERROR("could not read header"); + disconnect(); + return NULL; + } + + CAPS_DEBUG("read header (id/size): %i/%lu", responseHeader.id, + (unsigned long)responseHeader.size); + _socketBuf.set_read_limit(responseHeader.size); + +// if ( _abortRequested ) break; + + // State or session table update + if ( responseHeader.id == 0 ) { + while ( responseHeader.size > 0 /*&& _state == Active*/) { + istream is(&_socketBuf); + if ( is.getline(_lineBuf, 200).fail() ) { + boost::mutex::scoped_lock l(_mutex); + CAPS_ERROR("header line exceeds maximum of 200 characters"); + disconnect(); + return NULL; + } + responseHeader.size -= is.gcount(); + + SessionTable::Status status = + _sessionTable->handleResponse(_lineBuf, is.gcount()); + if ( status == SessionTable::Error ) { + boost::mutex::scoped_lock l(_mutex); + disconnect(); + return NULL; + } + + if ( status == SessionTable::EOD ) { + _state = EOD; + break; + } + } + + continue; + } + + CAPS_DEBUG("reading data record"); + // data + if ( _currentID != responseHeader.id ) { + _currentItem = _sessionTable->getItem(responseHeader.id); + _currentID = responseHeader.id; + + if ( _currentItem == NULL ) { + CAPS_WARNING("unknown data request ID %d", responseHeader.id); + continue; + } + } + + int size = responseHeader.size; + + // To improve performance CAPS uses an optimized protocol + // to deliver RAW packets. The RAW packet class can't be used + // to read the header from socket. + DataRecord *dataRecord = NULL; + if ( _currentItem->type == RawDataPacket ) { + // Read optimized header + RawResponseHeader rawResponseHeader; + if ( !rawResponseHeader.get(_socketBuf) ) { + boost::mutex::scoped_lock l(_mutex); + CAPS_ERROR("failed to extract raw response header %s", + _currentItem->streamID.c_str()); + disconnect(); + return NULL; + } + + Time time(rawResponseHeader.timeSeconds, rawResponseHeader.timeMicroSeconds); + size -= rawResponseHeader.dataSize(); + + // Create raw record, set header and read payload + RawDataRecord *record = new RawDataRecord; + record->setStartTime(time); + record->setSamplingFrequency(_currentItem->samplingFrequency, + _currentItem->samplingFrequencyDivider); + record->setDataType(_currentItem->dataType); + record->getData(_socketBuf, size); + + dataRecord = record; + } + else if ( _currentItem->type == ANYPacket ) { + AnyDataRecord *record = new AnyDataRecord; + record->get(_socketBuf, size, InvalidTime, InvalidTime, size); + dataRecord = record; + } + else if ( _currentItem->type == MSEEDPacket ) { + MSEEDDataRecord *record = new MSEEDDataRecord; + record->get(_socketBuf, size, InvalidTime, InvalidTime, size); + dataRecord = record; + } + else if ( _currentItem->type == MetaDataPacket ) { + // Read start time from optimized header + MetaResponseHeader metaResponseHeader; + if ( !metaResponseHeader.get(_socketBuf) ) { + boost::mutex::scoped_lock l(_mutex); + CAPS_ERROR("failed to extract meta information from stream %s", + _currentItem->streamID.c_str()); + disconnect(); + return NULL; + } + + Time stime(metaResponseHeader.startTime.seconds, + metaResponseHeader.endTime.microSeconds), + etime(metaResponseHeader.endTime.seconds, + metaResponseHeader.endTime.microSeconds); + + size -= metaResponseHeader.dataSize(); + + MetaDataRecord::MetaHeader recHeader; + recHeader.dataHeader.setSamplingTime(stime); + recHeader.setEndTime(etime); + recHeader.dataHeader.samplingFrequencyNumerator = _currentItem->samplingFrequency; + recHeader.dataHeader.samplingFrequencyDenominator = _currentItem->samplingFrequencyDivider; + recHeader.dataHeader.dataType = _currentItem->dataType; + + MetaDataRecord *record = new MetaDataRecord; + record->setHeader(recHeader); + dataRecord = record; + } + else { + CAPS_ERROR("received unknown packet type %d in stream %s", + _currentItem->type, _currentItem->streamID.c_str()); + } + + if ( dataRecord == NULL ) { + boost::mutex::scoped_lock l(_mutex); + disconnect(); + return NULL; + } + + CAPS_DEBUG("data record read"); + + RequestList::iterator it = _requests.find(_currentItem->streamID); + if ( it == _requests.end() ) { + // TODO: Search request map for wildcard match. Add entry with + // streamID -> (record->endTime, wildcardItem->endTime) to + // restrict data query in case of reconnect + +// CAPS_WARNING("received unrequested record: %s: %s - %s", +// _currentItem->streamID.c_str(), +// dataRecord->startTime().iso().c_str(), +// dataRecord->endTime().iso().c_str()); + } + // Update request map to reflect current stream state + else if ( dataRecord->endTime() > it->second.start ) { + it->second.start = dataRecord->endTime(); + it->second.receivedData = true; + } + + return dataRecord; + } + + return NULL; +} + +bool Connection::handshake() { + { + boost::mutex::scoped_lock l(_mutex); + if ( _state == Error || _state == Aborted) { + CAPS_ERROR("cannot read from an erroneous or aborted session, invoke " + "reset() first"); + return false; + } + else if ( _state == Active ) + return true; + // _state is set to EOD + else if ( _requests.empty() ) { + CAPS_WARNING("no stream requested, invoke addStream() first"); + return false; + } + } + + if ( _socket == NULL ) { + _socket = SocketPtr(createSocket()); + if ( _socket == NULL ) return false; + } + + // Connect to server if necessary + while ( !_socket->isValid() && _state == EOD ) { + if ( _socket->connect(_server, _port) == Socket::Success ) { + _socketBuf.setsocket(_socket.get()); + CAPS_DEBUG("connection to %s:%d established", _server.c_str(), _port); +// _state = ios_base::eofbit; + break; + } + + CAPS_WARNING("unable to connect to %s:%d, retrying in 5 seconds", + _server.c_str(), _port); + + // Wait 5 seconds and keep response latency low + for ( int i = 0; (i < 10) && _state == EOD; ++i ) + usleep(500000); + } + + + if ( _state != EOD ) return false; + +// if ( _socket->isValid() ) { +// // Read all data from session +// if ( !seekToReadLimit() ) return false; +//// fd_set set; +//// FD_ZERO(&set); +//// FD_SET(_socket->fd(), &set); +//// timeval t = (struct timeval) {0}; + +//// /* select returns 0 on timeout, 1 if input/output is available, -1 on error. */ +//// int retn = TEMP_FAILURE_RETRY(select(_socket->fd()+1, &set, NULL, NULL, &t)); +//// if ( retn != 0 ) CAPS_ERROR("UUPS"); +// } + +// if ( _state == Aborted ) return false; + + // Request streams + stringstream req; + + if ( !_auth.empty() ) + req << _auth << endl; + + req << "BEGIN REQUEST" << endl + << "META " << (_metaMode ? "ON" : "OFF") << endl + << "REALTIME " << ( _realtime ? "ON" : "OFF") << endl; + + // First pass: continue all previous streams + for ( RequestList::const_iterator it = _requests.begin(); + it != _requests.end() && _state == EOD; ++it ) { + if ( it->second.receivedData ) + formatRequest(req, it); + } + + // Second pass: subscribe to remaining streams + for ( RequestList::iterator it = _requests.begin(); + it != _requests.end() && _state == EOD; ++it ) { + if ( !it->second.receivedData ) + formatRequest(req, it); + } + + req << "END" << endl; + + return sendRequest(req.str()); +} + +bool Connection::sendRequest(const string &req) { + boost::mutex::scoped_lock l(_mutex); + + if ( _state != EOD ) return false; + + CAPS_DEBUG("%s", req.c_str()); + if ( _socket->write(req.c_str(), req.size()) != (int) req.size() ) { + CAPS_ERROR("could not send data request"); + disconnect(); + return false; + } + + Gempa::CAPS::ResponseHeader header; + if ( !header.get(_socketBuf) ) { + // Case to retry, connection closed by peer + CAPS_ERROR("could not read data request response header"); + disconnect(); + return false; + } + + _socketBuf.set_read_limit(header.size); + if ( header.id != 0 ) { + CAPS_ERROR("invalid data request response header id, expected 0, got %d", header.id); + disconnect(); + return false; + } + CAPS_DEBUG("data request response size: %lu", (unsigned long) header.size); + + istream is(&_socketBuf); + // check line length + if ( is.getline(_lineBuf, 200).fail() ) + CAPS_ERROR("data request response line exceeds maximum of 200 characters"); + // skip remaining header data + else if ( !seekToReadLimit(false) ) { + CAPS_ERROR("could not seek to data request response header end"); + return false; + } + + if ( strncasecmp(_lineBuf, "ERROR:", 6) == 0 ) + CAPS_ERROR("server responded to data request with: %s", _lineBuf); + else if ( strncasecmp(_lineBuf, "STATUS OK", 9) != 0 ) + CAPS_ERROR("invalid data request response: %s", _lineBuf); + else { + CAPS_DEBUG("handshake complete"); + _state = Active; + return true; + } + + disconnect(); + return false; +} + + +bool Connection::seekToReadLimit(bool log) { + if ( !_socket->isValid() ) { + disconnect(); + return false; + } + + // Skip unread bytes from previous record + int skippies = _socketBuf.read_limit(); + if ( skippies > 0 ) { + if ( log ) + CAPS_WARNING("no seemless reading, skipping %d bytes", skippies); + if ( _socketBuf.pubseekoff(skippies, ios_base::cur, ios_base::in) < 0 ) { + CAPS_ERROR("could not seek to next header"); + disconnect(); + return false; + } + } + _socketBuf.set_read_limit(-1); + return true; +} + +void Connection::formatRequest(stringstream& req, RequestList::const_iterator it) { + req << "STREAM ADD " << it->first << endl; + req << "TIME "; + + int year, mon, day, hour, minute, second; + + if ( it->second.start.valid() ) { + it->second.start.get(&year, &mon, &day, &hour, &minute, &second); + req << year << "," << mon << "," << day << "," + << hour << "," << minute << "," << second; + if ( it->second.start.microseconds() > 0 ) { + req << "," << setfill('0') << setw(6) + << it->second.start.microseconds() << setw(0); + } + } + + req << ":"; + + if ( it->second.end.valid() ) { + it->second.end.get(&year, &mon, &day, &hour, &minute, &second); + req << year << "," << mon << "," << day << "," + << hour << "," << minute << "," << second; + if ( it->second.end.microseconds() > 0 ) { + req << "," << setfill('0') << setw(6) + << it->second.end.microseconds() << setw(0); + } + } + + req << endl; +} + +void Connection::onItemAboutToBeRemoved(const SessionTableItem *item) { + if ( _currentItem == item) { + _currentID = -1; + _currentItem = NULL; + } + + // remove request since all data has been received + if ( item != NULL ) _requests.erase(item->streamID); +} + +void Connection::reset(bool clearStreams) { + boost::mutex::scoped_lock l(_mutex); + CAPS_DEBUG("resetting connection"); + if ( _state == Active ) { + CAPS_WARNING("cannot reset an active connection, invoking close()"); + close(); + } +// else if ( _state == Aborted ) { +// fd_set set; +// FD_ZERO(&set); +// FD_SET(_socket->fd(), &set); +// timeval t = (struct timeval) {0}; + +// /* select returns 0 on timeout, 1 if input/output is available, -1 on error. */ +// while ( _socket->isValid() ) { +// int retn = TEMP_FAILURE_RETRY(select(_socket->fd()+1, &set, NULL, NULL, &t)); +// if ( retn == 0 ) break; + +// if ( retn != 0 ) CAPS_ERROR("UUPS"); + +// } + + _state = EOD; + if ( clearStreams ) + _requests.clear(); +} + +void Connection::setStartTime(const Time &stime) { + _startTime = stime; + CAPS_DEBUG("set global start time to %s", _startTime.toString("%F %T.%f").c_str()); +} + +void Connection::setEndTime(const Time &etime) { + _endTime = etime; + CAPS_DEBUG("set global end time to %s", _endTime.toString("%F %T.%f").c_str()); +} + +void Connection::setTimeWindow(const Time &stime, const Time &etime) { + _startTime = stime; + _endTime = etime; + CAPS_DEBUG("set global timewindow to %s~%s", _startTime.toString("%F %T.%f").c_str(), + _endTime.toString("%F %T.%f").c_str()); +} + + +} +} diff --git a/libs/gempa/caps/connection.h b/libs/gempa/caps/connection.h new file mode 100644 index 0000000..e7dcf6f --- /dev/null +++ b/libs/gempa/caps/connection.h @@ -0,0 +1,180 @@ +/*************************************************************************** + * Copyright (C) 2014 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_CONNECTION_H +#define GEMPA_CAPS_CONNECTION_H + +#include +#include +#include + +#include +#include +#include + +//#include +#include + +namespace Gempa { +namespace CAPS { + +class SessionTableItem; +class Time; + +class Connection { + public: + //! ConnectionStates: + //! EOD -> connection not yet established or all streams finished (or aborted) + //! Active -> connection was successfully established, data request was sent + //! Error -> connection aborted due to server error + //! Aborted -> connection aborted by user + enum State { EOD, Active, Error, Aborted }; + + //! Constructor + Connection(); + + //! Destructor + virtual ~Connection(); + + //! Sets server parameter + bool setServer(const std::string &server); + + //! Enables SSL feature + void enableSSL(bool enable) { _ssl = enable; } + + //! Sets user name and password + void setCredentials(const std::string &user, const std::string &password); + + //! Sets meta mode. If enabled only the packet header information is + //! transmitted. + void setMetaMode(bool enable) { _metaMode = enable; } + + //! Sets realtime mode. + void setRealtime(bool enable) { _realtime = enable; } + + //! Disconnect from server, connection unuseable until reset() is + //! called. Thread safe. + void close(); + + //! Send abort command to server, keep socket open, requires reset. + //! Thread safe. + void abort(); + + //! Adds a stream request + bool addStream(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha); + + //! Adds a seismic stream requests + bool addStream(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, + const Time &etime); + + //! Resets connection state to eof + void reset(bool clearStreams = false); + + //! Sets the given start time + void setStartTime(const Time &stime); + + //! Sets the given end time + void setEndTime(const Time &etime); + + //! Sets the given time window + void setTimeWindow(const Time &stime, const Time &etime); + + //! Sets timeout + bool setTimeout(int seconds); + + //! Returns the next record. If the record is NULL the caller has + //! to check the state of the connection. Automatically creates a new + //! connection if required, sends data requests and evaluates updates + //! of session table. If the connection state is neither 'good' nor + //!'eof' the connection has to be resetted before invoking this method. + DataRecord* next(); + + + State state() { return _state; } + + + // ---------------------------------------------------------------------- + // protected methods + // ---------------------------------------------------------------------- + protected: + virtual Socket* createSocket() const; + + private: + typedef boost::shared_ptr SessionTablePtr; + + struct Request { + std::string net; + std::string sta; + std::string loc; + std::string cha; + Time start; + Time end; + bool receivedData; + }; + typedef std::map RequestList; + + // ---------------------------------------------------------------------- + // private methods + // ---------------------------------------------------------------------- + private: + bool addRequest(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, + const Time &etime, + bool receivedData); + void onItemAboutToBeRemoved(const SessionTableItem *item); + + void disconnect(); + bool handshake(); + bool sendRequest(const std::string &req); + + bool seekToReadLimit(bool log = true); + void formatRequest(std::stringstream& req, RequestList::const_iterator it); + + + // ---------------------------------------------------------------------- + // private data members + // ---------------------------------------------------------------------- + protected: + SessionTablePtr _sessionTable; + RequestList _requests; + SocketPtr _socket; + socketbuf _socketBuf; + char _lineBuf[201]; + volatile State _state; + SessionTableItem *_currentItem; + uint16_t _currentID; + boost::mutex _mutex; + + std::string _server; + int _port; + std::string _auth; + Time _startTime; + Time _endTime; + bool _realtime; + bool _metaMode; + bool _ssl; +}; + +typedef boost::shared_ptr ConnectionPtr; + + +} +} + +#endif diff --git a/libs/gempa/caps/datetime.cpp b/libs/gempa/caps/datetime.cpp new file mode 100644 index 0000000..bf84c5a --- /dev/null +++ b/libs/gempa/caps/datetime.cpp @@ -0,0 +1,1063 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include + +#include +#include +#include +#include +#include +#include + +#ifdef WIN32 +#include +#endif + + +using namespace std; +using namespace Gempa::CAPS; + + +/* We are linking against the multithreaded versions + of the Microsoft runtimes - this makes gmtime + equiv to gmtime_r in that Windows gmtime is threadsafe +*/ +#if defined (WIN32) +static struct tm* gmtime_r(const time_t *timep, struct tm* result) +{ + struct tm *local; + + local = gmtime(timep); + memcpy(result,local,sizeof(struct tm)); + return result; +} +#endif + + +#if defined(WIN32) + +#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 +#else + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +#endif + + +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + unsigned __int64 tmpres = 0; + static int tzflag; + + if (NULL != tv) + { + GetSystemTimeAsFileTime(&ft); + + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + /*converting file time to unix epoch*/ + tmpres /= 10; /*convert into microseconds*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + + if (NULL != tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} +#endif + + +#if defined(WIN32) +extern "C" { +#include "strptime.h" +} +#endif +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +#define MICROS 1000000 + +namespace { + + +#ifdef __sun__ +#define NO_COMPACT_DATE +#endif + + +#if defined(__SUNPRO_CC) || defined(__sun__) || defined(WIN32) +time_t timegm(struct tm *t) { + time_t tl, tb; + struct tm tg; + + t->tm_isdst = 0; + + tl = mktime (t); + if (tl == -1) { + t->tm_hour--; + tl = mktime (t); + if (tl == -1) + return -1; /* can't deal with output from strptime */ + tl += 3600; + } + + gmtime_r(&tl, &tg); + tg.tm_isdst = 0; + tb = mktime(&tg); + if (tb == -1) { + --tg.tm_hour; + tb = mktime(&tg); + if (tb == -1) + return -1; /* can't deal with output from gmtime */ + tb += 3600; + } + + return (tl - (tb - tl)); +} +#endif + + +template +inline void normalize(T &sec, U &usec) { + if ( usec < 0 ) { + if ( sec > 0 || usec <= -MICROS ) { + usec += MICROS; + sec -= 1; + } + } + else if ( usec > 0 ) { + if ( sec < 0 || usec >= MICROS ) { + usec -= MICROS; + sec += 1; + } + } +} + +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan() { + _timeval.tv_sec = 0; + _timeval.tv_usec = 0; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan(struct timeval* t) { + if ( t != NULL ) { + _timeval.tv_sec = t->tv_sec; + _timeval.tv_usec = t->tv_usec; + } + else { + _timeval.tv_sec = 0; + _timeval.tv_usec = 0; + } +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan(const struct timeval& t) { + _timeval.tv_sec = t.tv_sec; + _timeval.tv_usec = t.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan(double t) { + *this = t; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan(long secs, long usecs) { + _timeval.tv_sec = secs + (usecs / MICROS); + _timeval.tv_usec = usecs % MICROS; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::TimeSpan(const TimeSpan& ts) { + _timeval.tv_sec = ts._timeval.tv_sec; + _timeval.tv_usec = ts._timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator==(const TimeSpan& t) const { + return _timeval.tv_sec == t._timeval.tv_sec && + _timeval.tv_usec == t._timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator!=(const TimeSpan& t) const { + return !(*this == t); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator< (const TimeSpan& t) const { + if ( _timeval.tv_sec > t._timeval.tv_sec ) + return false; + if ( _timeval.tv_sec < t._timeval.tv_sec ) + return true; + return _timeval.tv_usec < t._timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator<=(const TimeSpan& t) const { + if ( _timeval.tv_sec > t._timeval.tv_sec ) + return false; + if ( _timeval.tv_sec < t._timeval.tv_sec ) + return true; + return _timeval.tv_usec <= t._timeval.tv_usec; + +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator> (const TimeSpan& t) const { + if ( _timeval.tv_sec < t._timeval.tv_sec ) + return false; + if ( _timeval.tv_sec > t._timeval.tv_sec ) + return true; + return _timeval.tv_usec > t._timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool TimeSpan::operator>=(const TimeSpan& t) const { + if ( _timeval.tv_sec < t._timeval.tv_sec ) + return false; + if ( _timeval.tv_sec > t._timeval.tv_sec ) + return true; + return _timeval.tv_usec >= t._timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::operator double() const { + return (double)_timeval.tv_sec + + (double)_timeval.tv_usec * 0.000001; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan::operator const timeval&() const { + return _timeval; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan& TimeSpan::operator=(long t) { + _timeval.tv_sec = t; + _timeval.tv_usec = 0; + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan& TimeSpan::operator=(double t) { + if( t > (double)0x7fffffff || t < -(double)0x80000000 ) + throw overflow_error("TimeSpan::operator=(): double doesn't fit int"); + _timeval.tv_sec = (long)t; + _timeval.tv_usec = (long)((t-_timeval.tv_sec)*MICROS + 0.5); + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan TimeSpan::operator+(const TimeSpan& t) const { + long diff_usec = _timeval.tv_usec + t._timeval.tv_usec; + long int sec = _timeval.tv_sec + t._timeval.tv_sec; + + normalize(sec, diff_usec); + + return TimeSpan(sec, diff_usec); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan TimeSpan::operator-(const TimeSpan& t) const { + long diff_usec = _timeval.tv_usec - t._timeval.tv_usec; + long int sec = _timeval.tv_sec - t._timeval.tv_sec; + + normalize(sec, diff_usec); + + return TimeSpan(sec, diff_usec); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan& TimeSpan::operator+=(const TimeSpan& t) { + _timeval.tv_sec += t._timeval.tv_sec; + _timeval.tv_usec += t._timeval.tv_usec; + + normalize(_timeval.tv_sec, _timeval.tv_usec); + + return *this; +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +} +TimeSpan& TimeSpan::operator-=(const TimeSpan& t) { + _timeval.tv_usec -= t._timeval.tv_usec; + _timeval.tv_sec -= t._timeval.tv_sec; + + normalize(_timeval.tv_sec, _timeval.tv_usec); + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan& TimeSpan::set(long secs) { + _timeval.tv_sec = secs; + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan& TimeSpan::setUSecs(long usecs) { + _timeval.tv_usec = usecs % MICROS; + _timeval.tv_sec += usecs / MICROS; + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<< +void TimeSpan::elapsedTime(int* days, int* hours, + int* minutes, int* seconds) const +{ + int elapsed = TimeSpan::seconds(); + if (days) + *days = elapsed / 86400; + if (hours) + *hours = (elapsed % 86400) / 3600; + if (minutes) + *minutes = ((elapsed % 86400) % 3600) / 60; + if (seconds) + *seconds = ((elapsed % 86400) % 3600) % 60; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan TimeSpan::abs() const { + return TimeSpan(::abs(_timeval.tv_sec), ::abs(_timeval.tv_usec)); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +double TimeSpan::length() const { + return double(*this); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +long TimeSpan::seconds() const { + return _timeval.tv_sec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +long TimeSpan::microseconds() const { + return _timeval.tv_usec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +const Time Time::Null(0,0); +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time() : TimeSpan() { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(const TimeSpan& ts) + : TimeSpan(ts) { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(const struct timeval& t) + : TimeSpan(t) { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(struct timeval* t) + : TimeSpan(t) { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(double t) { + *this = t; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(int year, int month, int day, + int hour, int min, int sec, + int usec) { + set(year, month, day, hour, min, sec, usec); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(const Time& t) + : TimeSpan(t) { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::Time(long secs, long usecs) + : TimeSpan(secs, usecs) { +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::operator bool() const { + return valid(); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time::operator time_t() const { + return (time_t)_timeval.tv_sec; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator=(const struct timeval& t) { + _timeval = t; + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator=(struct timeval* t) { + _timeval = *t; + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator=(time_t t) { + _timeval.tv_sec = (long)t; + _timeval.tv_usec = 0; + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator=(double t) { + _timeval.tv_sec = (long)t; + _timeval.tv_usec = (long)((t-(double)_timeval.tv_sec)*MICROS + 0.5); + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::operator+(const TimeSpan& t) const { + return Time((TimeSpan&)*this + t); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::operator-(const TimeSpan& ts) const { + return Time(TimeSpan::operator- (ts)); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator+=(const TimeSpan& ts) { + TimeSpan::operator+=(ts); + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::operator-=(const TimeSpan& ts) { + TimeSpan::operator-=(ts); + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +TimeSpan Time::operator-(const Time& ts) const { + return TimeSpan::operator-(ts); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::set(int year, int month, int day, + int hour, int min, int sec, + int usec) { + tm t; + + t.tm_year = year - 1900; + t.tm_mon = month - 1; + t.tm_mday = day; + t.tm_hour = hour; + t.tm_min = min; + t.tm_sec = sec; + t.tm_isdst = -1; + + _timeval.tv_sec = (long)timegm(&t); + setUSecs(usec); + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool Time::get(int *year, int *month, int *day, + int *hour, int *min, int *sec, + int *usec) const { + time_t time = (time_t)_timeval.tv_sec; + struct tm t; + gmtime_r(&time, &t); + + if ( year ) *year = t.tm_year + 1900; + if ( month ) *month = t.tm_mon + 1; + if ( day ) *day = t.tm_mday; + + if ( hour ) *hour = t.tm_hour; + if ( min ) *min = t.tm_min; + if ( sec ) *sec = t.tm_sec; + + if ( usec ) *usec = _timeval.tv_usec; + + return true; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool Time::get2(int *year, int *yday, int *hour, int *min, int *sec, + int *usec) const { + time_t time = (time_t)_timeval.tv_sec; + struct tm t; + gmtime_r(&time, &t); + + if ( year ) *year = t.tm_year + 1900; + if ( yday ) *yday = t.tm_yday; + + if ( hour ) *hour = t.tm_hour; + if ( min ) *min = t.tm_min; + if ( sec ) *sec = t.tm_sec; + + if ( usec ) *usec = _timeval.tv_usec; + + return true; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::LocalTime() { + Time t; + t.localtime(); + return t; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::GMT() { + Time t; + t.gmt(); + return t; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::FromYearDay(int year, int year_day) { + std::stringstream ss; + ss << year << " " << year_day; + return FromString(ss.str().c_str(), "%Y %j"); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::localtime() { + gettimeofday(&_timeval, NULL); + time_t secs = (time_t)_timeval.tv_sec; + struct tm _tm; +#ifndef WIN32 + _timeval.tv_sec = (long)timegm(::localtime_r(&secs, &_tm)); +#else + // We use the native localtime function of windows, which is thread safe. (But it's not reentrant) + _timeval.tv_sec = (long)timegm(::localtime(&secs)); + +#endif + + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time& Time::gmt() { + gettimeofday(&_timeval, NULL); + time_t secs = (time_t)_timeval.tv_sec; + struct tm _tm; +#ifndef WIN32 + _timeval.tv_sec = (long)mktime(::localtime_r(&secs, &_tm)); +#else + // We use the native localtime function of windows, which is thread safe. (But it's not reentrant) + _timeval.tv_sec = (long)timegm(::localtime(&secs)); +#endif + + return *this; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::toLocalTime() const { + Time ret; + time_t secs = _timeval.tv_sec; + struct tm _tm; +#ifndef WIN32 + ret._timeval.tv_sec = (long)timegm(::localtime_r(&secs, &_tm)); +#else + // We use the native localtime function of windows, which is thread safe. (But it's not reentrant) + ret._timeval.tv_sec = (long)timegm(::localtime(&secs)); +#endif + ret._timeval.tv_usec = _timeval.tv_usec; + + return ret; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::toGMT() const { + Time ret; + time_t secs = _timeval.tv_sec; + struct tm _tm; +#ifndef WIN32 + ret._timeval.tv_sec = _timeval.tv_sec - ((long)timegm(::localtime_r(&secs, &_tm)) - _timeval.tv_sec); +#else + ret._timeval.tv_sec = _timeval.tv_sec - ((long)timegm(::localtime(&secs)) - _timeval.tv_sec); +#endif + ret._timeval.tv_usec = _timeval.tv_usec; + + return ret; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool Time::valid() const { + return _timeval.tv_sec != 0 || _timeval.tv_usec != 0; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +std::string Time::toString(const char* fmt) const { +#define BUFFER_SIZE 64 + char data[BUFFER_SIZE]; + char predata[BUFFER_SIZE]; + + time_t secs = (time_t)_timeval.tv_sec, usecs = _timeval.tv_usec; + + tm t; + gmtime_r(&secs, &t); + const char *f = fmt, *last = fmt; + char *tgt = predata; + + while ( (f = strchr(f, '%')) != NULL ) { + int specSize = 3; + + char spec = *(f+1); + if ( spec == '\0' ) break; + char type = *(f+2); + + if ( (spec >= 'a' && spec <= 'z') || (spec >= 'A' && spec <= 'Z') ) { + specSize = 2; + type = spec; + } + + if ( type == 'f' ) { + int width = -1; + if ( spec >= '0' && spec <= '6' ) + width = spec - '0'; + + memcpy(tgt, last, f-last); + tgt += f-last; + + char number[24]; + size_t numberOfDigits; + if ( usecs > 0 ) { + numberOfDigits = sprintf(number, "%06ld", usecs); + if ( width != -1 ) + numberOfDigits = width; + else { + while ( number[numberOfDigits-1] == '0' ) --numberOfDigits; + } + } + else { + if ( width == -1 ) + numberOfDigits = 4; + else + numberOfDigits = width; + sprintf(number, "%0*d", (int)numberOfDigits, 0); + } + + memcpy(tgt, number, numberOfDigits); + tgt += numberOfDigits; + + last = f+specSize; + } +#if defined(WIN32) || defined(NO_COMPACT_DATE) + else if ( type == 'F' ) { + memcpy(tgt, last, f-last); + tgt += f-last; + memcpy(tgt, "%Y-%m-%d", 8); + tgt += 8; + last = f+specSize; + } +#endif +#if defined(WIN32) + else if ( type == 'T' ) { + memcpy(tgt, last, f-last); + tgt += f-last; + memcpy(tgt, "%H:%M:%S", 8); + tgt += 8; + last = f+specSize; + } +#endif + + ++f; + } + + strcpy(tgt, last); + strftime(data, BUFFER_SIZE-1, predata, &t); + + return data; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +std::string Time::iso() const { + return toString("%FT%T.%fZ"); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool Time::fromString(const char* str, const char* fmt) { + struct tm t; + char data[BUFFER_SIZE]; + char tmpFmt[BUFFER_SIZE]; + long usec = 0; + + const char* microSeconds = strstr(fmt, "%f"); + if ( microSeconds != NULL ) { + const char* start = str; + if ( microSeconds != fmt ) { + start = strrchr(str, *(microSeconds-1)); + if ( start == NULL ) + return false; + ++start; + } + + const char* end = start; + while ( *end >= '0' && *end <= '9' ) + ++end; + + int size = end-start; + if ( size > 6 ) size = 6; + + int multiplier = 100000; + char *startNumber, *endNumber; + + memcpy(data, start, size); + data[size] = '\0'; + + for ( startNumber = data; *startNumber == '0' && *startNumber != '\0'; ++startNumber ) + multiplier /= 10; + + for ( endNumber = data + size-1; *endNumber == '0' && endNumber > startNumber; --endNumber ) + *endNumber = '\0'; + + while ( endNumber-- > startNumber ) + multiplier /= 10; + + usec = atoi(data) * multiplier; + + int len = start - str; + if ( len > BUFFER_SIZE ) { + return false; + } + + memcpy(data, str, len); + data[len] = '\0'; + strcat(data, "%"); + strcat(data, end); + str = data; + + strcpy(tmpFmt, fmt); + tmpFmt[microSeconds - fmt + 1] = '%'; + fmt = tmpFmt; + } + +#ifdef NO_COMPACT_DATE + char tmpFmtDate[BUFFER_SIZE]; + const char* compactDate = strstr(fmt, "%F"); + if ( compactDate != NULL ) { + char *dst = tmpFmtDate; + while ( fmt != compactDate ) { *dst++ = *fmt++; } + strcpy(dst, "%Y-%m-%d"); + dst += 8; + fmt += 2; + while ( *fmt != '\0' ) { *dst++ = *fmt++; } + *dst = '\0'; + fmt = tmpFmtDate; + } +#endif + + time_t tmp_t = 0; + gmtime_r(&tmp_t, &t); + if ( strptime(str, fmt, &t) == NULL ) { + *this = (time_t)0; + return false; + } + else { + *this = timegm(&t); + setUSecs(usec); + } + + return true; +#undef BUFFER_SIZE +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Time Time::FromString(const char* str, const char* fmt) { + Time t; + t.fromString(str, fmt); + return t; +} diff --git a/libs/gempa/caps/datetime.h b/libs/gempa/caps/datetime.h new file mode 100644 index 0000000..ef8b4e0 --- /dev/null +++ b/libs/gempa/caps/datetime.h @@ -0,0 +1,245 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_DATETIME_H +#define GEMPA_CAPS_DATETIME_H + +#ifdef WIN32 +#include +#else +#include +#endif + +#include + +struct tm; + +namespace Gempa { +namespace CAPS { + + +class TimeSpan { + // ---------------------------------------------------------------------- + // Xstruction + // ---------------------------------------------------------------------- + public: + TimeSpan(); + TimeSpan(struct timeval*); + TimeSpan(const struct timeval&); + TimeSpan(double); + TimeSpan(long secs, long usecs); + + //! Copy constructor + TimeSpan(const TimeSpan&); + + + // ---------------------------------------------------------------------- + // Operators + // ---------------------------------------------------------------------- + public: + //! Comparison + bool operator==(const TimeSpan&) const; + bool operator!=(const TimeSpan&) const; + bool operator< (const TimeSpan&) const; + bool operator<=(const TimeSpan&) const; + bool operator> (const TimeSpan&) const; + bool operator>=(const TimeSpan&) const; + + //! Conversion + operator double() const; + operator const timeval&() const; + + //! Assignment + TimeSpan& operator=(long t); + TimeSpan& operator=(double t); + + //! Arithmetic + TimeSpan operator+(const TimeSpan&) const; + TimeSpan operator-(const TimeSpan&) const; + + TimeSpan& operator+=(const TimeSpan&); + TimeSpan& operator-=(const TimeSpan&); + + + // ---------------------------------------------------------------------- + // Interface + // ---------------------------------------------------------------------- + public: + //! Returns the absolute value of time + TimeSpan abs() const; + + //! Returns the seconds of the timespan + long seconds() const; + //! Returns the microseconds of the timespan + long microseconds() const; + + //! Returns the (possibly negative) length of the timespan in seconds + double length() const; + + //! Sets the seconds + TimeSpan& set(long seconds); + + //! Sets the microseconds + TimeSpan& setUSecs(long); + + //! Assigns the elapsed time to the passed out parameters + void elapsedTime(int* days , int* hours = NULL, + int* minutes = NULL, int* seconds = NULL) const; + + // ---------------------------------------------------------------------- + // Implementation + // ---------------------------------------------------------------------- + protected: + struct timeval _timeval; +}; + + +class Time : public TimeSpan { + // ---------------------------------------------------------------------- + // Public static data members + // ---------------------------------------------------------------------- + public: + static const Time Null; + + // ---------------------------------------------------------------------- + // Xstruction + // ---------------------------------------------------------------------- + public: + Time(); + Time(long secs, long usecs); + + explicit Time(const TimeSpan&); + explicit Time(const struct timeval&); + explicit Time(struct timeval*); + explicit Time(double); + + Time(int year, int month, int day, + int hour = 0, int min = 0, int sec = 0, + int usec = 0); + + //! Copy constructor + Time(const Time&); + + + // ---------------------------------------------------------------------- + // Operators + // ---------------------------------------------------------------------- + public: + //! Conversion + operator bool() const; + operator time_t() const; + + //! Assignment + Time& operator=(const struct timeval& t); + Time& operator=(struct timeval* t); + Time& operator=(time_t t); + Time& operator=(double t); + + //! Arithmetic + Time operator+(const TimeSpan&) const; + Time operator-(const TimeSpan&) const; + TimeSpan operator-(const Time&) const; + + Time& operator+=(const TimeSpan&); + Time& operator-=(const TimeSpan&); + + + // ---------------------------------------------------------------------- + // Interface + // ---------------------------------------------------------------------- + public: + //! Sets the time + Time& set(int year, int month, int day, + int hour, int min, int sec, + int usec); + + //! Fill the parameters with the currently set time values + //! @return The error flag + bool get(int *year, int *month = NULL, int *day = NULL, + int *hour = NULL, int *min = NULL, int *sec = NULL, + int *usec = NULL) const; + + //! Fill the parameters with the currently set time values + //! @return The error flag + bool get2(int *year, int *yday = NULL, + int *hour = NULL, int *min = NULL, int *sec = NULL, + int *usec = NULL) const; + + //! Returns the current localtime + static Time LocalTime(); + + //! Returns the current gmtime + static Time GMT(); + + /** Creates a time from the year and the day of the year + @param year The year, including the century (for example, 1988) + @param year_day The day of the year [0..365] + @return The time value + */ + static Time FromYearDay(int year, int year_day); + + //! Saves the current localtime in the calling object + Time& localtime(); + + //! Saves the current gmtime in the calling object + Time& gmt(); + + //! Converts the time to localtime + Time toLocalTime() const; + + //! Converts the time to gmtime + Time toGMT() const; + + //! Returns whether the date is valid or not + bool valid() const; + + /** Converts the time to string using format fmt. + @param fmt The format string can contain any specifiers + as allowed for strftime. Additional the '%f' + specifier is replaced by the fraction of the seconds. + Example: + toString("%FT%T.%fZ") = "1970-01-01T00:00:00.0000Z" + @return A formatted string + */ + std::string toString(const char* fmt) const; + + /** + * Converts the time to a string using the ISO time description + * @return A formatted string + */ + std::string iso() const; + + /** + * Converts a string into a time representation. + * @param str The string representation of the time + * @param fmt The format string containing the conversion + * specification (-> toString) + * @return The conversion result + */ + bool fromString(const char* str, const char* fmt); + + /** + * Static method to create a time value from a string. + * The parameters are the same as in Time::fromString. + */ + static Time FromString(const char* str, const char* fmt); +}; + + +} +} + + +#endif diff --git a/libs/gempa/caps/encoderfactory.cpp b/libs/gempa/caps/encoderfactory.cpp new file mode 100644 index 0000000..86f228d --- /dev/null +++ b/libs/gempa/caps/encoderfactory.cpp @@ -0,0 +1,246 @@ +/*************************************************************************** + * Copyright (C) 2016 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include "encoderfactory.h" + +#include "mseed/mseed.h" +#include "mseed/steim1.h" +#include "mseed/steim2.h" +#include "mseed/uncompressed.h" + + +#include + +using namespace std; + +namespace Gempa { +namespace CAPS { + +EncoderFactory::EncoderFactory() {} + +EncoderFactory::~EncoderFactory() {} + +const string& EncoderFactory::errorString() const { + return _errorString; +} + +MSEEDEncoderFactory::MSEEDEncoderFactory() +: _recordLength(9) {} + +bool MSEEDEncoderFactory::setRecordLength(uint recordLength) { + if ( recordLength < 7 || recordLength > 32) { + _errorString = "MSEED record length out of range [7, 32]"; + return false; + } + + _recordLength = uint8_t(recordLength); + return true; +} + +bool SteimEncoderFactory::supportsRecord(DataRecord *rec) { + /* + DataType dt = rec->header()->dataType; + if ( (dt == DT_INT64) || (dt == DT_FLOAT) || + (dt == DT_DOUBLE) ) { + return false; + } + */ + + PacketType type = rec->packetType(); + if ( type == RawDataPacket || type == FixedRawDataPacket ) { + return true; + } + else if ( type == MSEEDPacket ) { + return false; + } + + return false; +} + +bool IdentityEncoderFactory::supportsRecord(DataRecord *rec) { + PacketType type = rec->packetType(); + return type == RawDataPacket || type == FixedRawDataPacket; +} + +Encoder* IdentityEncoderFactory::create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator) { + if ( dt == DT_INT8 ) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_ASCII, + _recordLength); + if ( format == NULL ) return NULL; + + return new UncompressedMSEED(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT16 ) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_INT16, + _recordLength); + if ( format == NULL ) return NULL; + + return new UncompressedMSEED(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT32 ) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_INT32, + _recordLength); + if ( format == NULL ) return NULL; + + return new UncompressedMSEED(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_FLOAT ) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_FLOAT32, + _recordLength); + if ( format == NULL ) return NULL; + + return new UncompressedMSEED(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_DOUBLE ) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_FLOAT64, + _recordLength); + if ( format == NULL ) return NULL; + + return new UncompressedMSEED(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + + return NULL; +} + +Encoder* Steim1EncoderFactory::create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_STEIM1, + _recordLength); + if ( format == NULL ) return NULL; + + if ( dt == DT_INT8 ) { + return new Steim1Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT16 ) { + return new Steim1Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT32 ) { + return new Steim1Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_FLOAT ) { + return new Steim1Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_DOUBLE ) { + return new Steim1Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + + delete format; + + return NULL; +} + +Encoder* Steim2EncoderFactory::create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator) { + MSEEDFormat *format = new MSEEDFormat(networkCode, stationCode, + locationCode, channelCode, + samplingFrequencyNumerator, + samplingFrequencyDenominator, + DE_STEIM2, + _recordLength); + if ( format == NULL ) return NULL; + + if ( dt == DT_INT8 ) { + return new Steim2Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT16 ) { + return new Steim2Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_INT32 ) { + return new Steim2Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_FLOAT ) { + return new Steim2Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + else if ( dt == DT_DOUBLE ) { + return new Steim2Encoder(format, + samplingFrequencyNumerator, + samplingFrequencyDenominator); + } + + delete format; + + return NULL; +} + +} +} diff --git a/libs/gempa/caps/encoderfactory.h b/libs/gempa/caps/encoderfactory.h new file mode 100644 index 0000000..c4e085e --- /dev/null +++ b/libs/gempa/caps/encoderfactory.h @@ -0,0 +1,164 @@ +/*************************************************************************** + * Copyright (C) 2016 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#ifndef GEMPA_CAPS_ENCODERFACTORY_H +#define GEMPA_CAPS_ENCODERFACTORY_H + +#include "mseed/encoder.h" + +#include + +namespace Gempa { +namespace CAPS { + +/** + * @brief Abstract base class of the encoder factory. Each + * derived class must implement the create and the + * supportsRecord method. + */ +class EncoderFactory { + public: + EncoderFactory(); + virtual ~EncoderFactory(); + /** + * @brief Creates encoder from given parameter set + * @param networkCode The nework code + * @param stationCode The station code + * @param locationCode The location code + * @param channelCode The channel code + * @param dt The data encoding + * @param samplingFrequencyNumerator The numerator + * @param samplingFrequencyDenominator The denominator + * @param samplingFrequencyDenominator The timing quality + * @return The encoder object or NULL if creation fails + */ + virtual Encoder* create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator) = 0; + + /** + * @brief Checks if an encoder factory + * supports the given record. + * @param rec The record to check + * @return True if the data type is supported + */ + virtual bool supportsRecord(DataRecord *rec) = 0; + + /** + * @brief Returns a human readable error description + * of the last error occured. + * @return Error description + */ + const std::string& errorString() const; + + protected: + std::string _errorString; +}; + + +/** + * @brief Base class for all MSEED encoders + */ +class MSEEDEncoderFactory : public EncoderFactory { + public: + MSEEDEncoderFactory(); + + /** + * @brief Sets the volume logical record length expressed as a + * power of 2. A 512 byte record would be 9. + * @param recLen The record length expressed as a power of 2 + * @return True if the record length is valid + */ + bool setRecordLength(uint recordLength); + + protected: + uint8_t _recordLength; +}; + +/** + * @brief Implements a general Steim encoder factory + * interface which implements the supportsRecord method + * only. + */ +class SteimEncoderFactory : public MSEEDEncoderFactory { + public: + /** + * @brief Checks if an encoder factory + * supports the given record. In case of data type float or double we + * return true but the values will casted implicitly to int32. + * @param rec The record to check + * @return True if the data type is supported + */ + bool supportsRecord(DataRecord *rec); +}; + + +/** + * @brief The IdentiyEncoderFactory class implements the + * encoder factory interface and supports the creation of + * identiy encoders. + */ +class IdentityEncoderFactory : public MSEEDEncoderFactory { + public: + Encoder* create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator); + bool supportsRecord(DataRecord *rec); +}; + + +/** + * @brief The Steim1EncoderFactory class implements the + * encoder factory interface and supports the creation of + * Steim2 encoders. + */ +class Steim1EncoderFactory : public SteimEncoderFactory { + public: + Encoder* create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator); +}; + +/** + * @brief The Steim2EncoderFactory class implements the + * encoder factory interface and supports the creation of + * Steim2 encoders. + */ +class Steim2EncoderFactory : public SteimEncoderFactory { + public: + Encoder* create(const std::string &networkCode, + const std::string &stationCode, + const std::string &locationCode, + const std::string &channelCode, + int dt, + int samplingFrequencyNumerator, + int samplingFrequencyDenominator); +}; + +} +} + +#endif diff --git a/libs/gempa/caps/endianess.h b/libs/gempa/caps/endianess.h new file mode 100644 index 0000000..75a67e7 --- /dev/null +++ b/libs/gempa/caps/endianess.h @@ -0,0 +1,210 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_ENDIANESS_H +#define GEMPA_CAPS_ENDIANESS_H + +#include +#include +#include + + +namespace Gempa { +namespace CAPS { +namespace Endianess { + +template inline const T1* lvalue(const T2 &value) { + return reinterpret_cast(&value); +} + +template +struct Swapper { + static T Take(const T &v) { + return v; + } + + static void Take(T *ar, int len) {} +}; + + +template +struct Swapper { + static T Take(const T &v) { + return *lvalue((*reinterpret_cast(&v) >> 0x08) | + (*reinterpret_cast(&v) << 0x08)); + } + + static void Take(T *ar, int len) { + for ( int i = 0; i < len; ++i ) + ar[i] = Take(ar[i]); + } +}; + + +template +struct Swapper { + static T Take(const T &v) { + return *lvalue(((*reinterpret_cast(&v) << 24) & 0xFF000000) | + ((*reinterpret_cast(&v) << 8) & 0x00FF0000) | + ((*reinterpret_cast(&v) >> 8) & 0x0000FF00) | + ((*reinterpret_cast(&v) >> 24) & 0x000000FF)); + } + + static void Take(T *ar, int len) { + for ( int i = 0; i < len; ++i ) + ar[i] = Take(ar[i]); + } +}; + + +template +struct Swapper { + static T Take(const T &v) { + return *lvalue(((*reinterpret_cast(&v) << 56) & 0xFF00000000000000LL) | + ((*reinterpret_cast(&v) << 40) & 0x00FF000000000000LL) | + ((*reinterpret_cast(&v) << 24) & 0x0000FF0000000000LL) | + ((*reinterpret_cast(&v) << 8) & 0x000000FF00000000LL) | + ((*reinterpret_cast(&v) >> 8) & 0x00000000FF000000LL) | + ((*reinterpret_cast(&v) >> 24) & 0x0000000000FF0000LL) | + ((*reinterpret_cast(&v) >> 40) & 0x000000000000FF00LL) | + ((*reinterpret_cast(&v) >> 56) & 0x00000000000000FFLL)); + } + + static void Take(T *ar, int len) { + for ( int i = 0; i < len; ++i ) + ar[i] = Take(ar[i]); + } +}; + + +template +struct TypeMap { + typedef void ValueType; +}; + + +template <> +struct TypeMap<1> { + typedef uint8_t ValueType; +}; + + +template <> +struct TypeMap<2> { + typedef uint16_t ValueType; +}; + + +template <> +struct TypeMap<4> { + typedef uint32_t ValueType; +}; + + +template <> +struct TypeMap<8> { + typedef uint64_t ValueType; +}; + + +template +struct ByteSwapper { + static void Take(void *ar, int len) {} +}; + + +template +struct ByteSwapper<1,size> { + static void Take(void *ar, int len) { + typedef typename TypeMap::ValueType T; + Swapper::Take(reinterpret_cast(ar), len); + } +}; + + +struct Current { + enum { + LittleEndian = ((0x1234 >> 8) == 0x12?1:0), + BigEndian = 1-LittleEndian + }; +}; + + +struct Converter { + template + static T ToLittleEndian(const T &v) { + return Swapper::Take(v); + } + + template + static void ToLittleEndian(T *data, int len) { + Swapper::Take(data, len); + } + + template + static T FromLittleEndian(const T &v) { + return Swapper::Take(v); + } + + template + static T ToBigEndian(const T &v) { + return Swapper::Take(v); + } + + template + static T FromBigEndian(const T &v) { + return Swapper::Take(v); + } +}; + +struct Reader { + Reader(std::streambuf &input) : stream(input), good(true) {} + + void operator()(void *data, int size) { + good = stream.sgetn((char*)data, size) == size; + } + + template + void operator()(T &v) { + good = stream.sgetn((char*)&v, sizeof(T)) == sizeof(T); + v = Converter::FromLittleEndian(v); + } + + std::streambuf &stream; + bool good; +}; + +struct Writer { + Writer(std::streambuf &output) : stream(output), good(true) {} + + bool operator()(const void *data, int size) { + return (good = stream.sputn((char*)data, size) == size); + } + + template + bool operator()(T &v) { + T tmp = Converter::ToLittleEndian(v); + return (good = stream.sputn((char*)&tmp, sizeof(T)) == sizeof(T)); + } + + std::streambuf &stream; + bool good; +}; + +} +} +} + +#endif diff --git a/libs/gempa/caps/log.cpp b/libs/gempa/caps/log.cpp new file mode 100644 index 0000000..cd9d95b --- /dev/null +++ b/libs/gempa/caps/log.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include + + +namespace Gempa { +namespace CAPS { + + +void SetLogHandler(LogLevel l, LogOutput o) { + LogHandler[l] = o; +} + +LogOutput LogHandler[LL_QUANTITY] = { NULL, NULL, NULL, NULL, NULL, NULL }; + +} +} diff --git a/libs/gempa/caps/log.h b/libs/gempa/caps/log.h new file mode 100644 index 0000000..9fedd02 --- /dev/null +++ b/libs/gempa/caps/log.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_LOG_H +#define GEMPA_CAPS_LOG_H + + +namespace Gempa { +namespace CAPS { + + +enum LogLevel { + LL_UNDEFINED = 0, + LL_ERROR, + LL_WARNING, + LL_NOTICE, + LL_INFO, + LL_DEBUG, + LL_QUANTITY +}; + + +#define CAPS_LOG_MSG(LogLevel, ...) \ + do {\ + if ( Gempa::CAPS::LogHandler[LogLevel] != NULL )\ + Gempa::CAPS::LogHandler[LogLevel](__VA_ARGS__);\ + } while(0) + + +#define CAPS_ERROR(...) CAPS_LOG_MSG(Gempa::CAPS::LL_ERROR, __VA_ARGS__) +#define CAPS_WARNING(...) CAPS_LOG_MSG(Gempa::CAPS::LL_WARNING, __VA_ARGS__) +#define CAPS_NOTICE(...) CAPS_LOG_MSG(Gempa::CAPS::LL_NOTICE, __VA_ARGS__) +#define CAPS_INFO(...) CAPS_LOG_MSG(Gempa::CAPS::LL_INFO, __VA_ARGS__) +#define CAPS_DEBUG(...) CAPS_LOG_MSG(Gempa::CAPS::LL_DEBUG, __VA_ARGS__) + + +typedef void (*LogOutput)(const char *, ...); + +extern LogOutput LogHandler[LL_QUANTITY]; + + +void SetLogHandler(LogLevel, LogOutput); + + +} +} + + +#endif diff --git a/libs/gempa/caps/metapacket.cpp b/libs/gempa/caps/metapacket.cpp new file mode 100644 index 0000000..6a181e8 --- /dev/null +++ b/libs/gempa/caps/metapacket.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include +#include + + +#include + +namespace Gempa { +namespace CAPS { + +void MetaDataRecord::MetaHeader::setEndTime(const Time &ts) { + int year, yday, hour, min, sec, usec; + ts.get2(&year, &yday, &hour, &min, &sec, &usec); + endTime.year = year; + endTime.yday = yday; + endTime.hour = hour; + endTime.minute = min; + endTime.second = sec; + endTime.usec = usec; +} + +MetaDataRecord::MetaDataRecord() {} + + +MetaDataRecord::Buffer *MetaDataRecord::data() { + return NULL; +} + +const char *MetaDataRecord::formatName() const { + return "META"; +} + +const DataRecord::Header *MetaDataRecord::header() const { + return &_header.dataHeader; +} + + +Time MetaDataRecord::startTime() const { + return _startTime; +} + + +Time MetaDataRecord::endTime() const { + return _endTime; +} + +size_t MetaDataRecord::dataSize(bool /*withHeader*/) const { + return 0; +} + + +DataRecord::ReadStatus MetaDataRecord::get(std::streambuf &buf, int size, + const Time &start, const Time &end, + int maxBytes) { + return RS_Error; +} + +void MetaDataRecord::setHeader(const MetaHeader &header) { + _header = header; + _startTime = timestampToTime(header.dataHeader.samplingTime); + _endTime = timestampToTime(header.endTime); +} + +} +} diff --git a/libs/gempa/caps/metapacket.h b/libs/gempa/caps/metapacket.h new file mode 100644 index 0000000..46abb61 --- /dev/null +++ b/libs/gempa/caps/metapacket.h @@ -0,0 +1,143 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_METAPACKET_H +#define GEMPA_CAPS_METAPACKET_H + +#include +#include + +#include +#include +#include + + + +namespace Gempa { +namespace CAPS { + +struct SC_GEMPA_CAPS_API MetaResponseHeader { + struct Time { + int64_t seconds; + int32_t microSeconds; + }; + + Time startTime; + Time endTime; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + get(startTime.seconds); + get(startTime.microSeconds); + + get(endTime.seconds); + get(endTime.microSeconds); + + return get.good; + } + + int dataSize() const { + return sizeof(startTime.seconds) + sizeof(startTime.microSeconds) + + sizeof(endTime.seconds) + sizeof(endTime.microSeconds); + } +}; + +class MetaDataRecord : public DataRecord { + public: + struct MetaHeader { + Header dataHeader; + TimeStamp endTime; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + get(endTime.year); + get(endTime.yday); + get(endTime.hour); + get(endTime.minute); + get(endTime.second); + get(endTime.usec); + + return get.good; + } + + bool put(std::streambuf &buf) const; + + int dataSize() const { + return dataHeader.dataSize() + + sizeof(endTime.year) + + sizeof(endTime.yday) + + sizeof(endTime.hour) + + sizeof(endTime.minute) + + sizeof(endTime.second) + + sizeof(endTime.usec); + } + + void setEndTime(const Time ×tamp); + }; + + public: + MetaDataRecord(); + + //! Returns the data vector to be filled by the caller + Buffer *data(); + + virtual const char *formatName() const; + + virtual bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, Time &endTime) { + return false; + } + + virtual const Header *header() const; + + //! Sets a custom header and updates all internal structures + //! based on the current data. If the data has changed, make + //! sure to call this method again. If the flag skip reading + //! is set get will not read the header information from stream + void setHeader(const MetaHeader &header); + + virtual Time startTime() const; + virtual Time endTime() const; + + virtual bool canTrim() const { return false; } + virtual bool canMerge() const { return false; } + + virtual bool trim(const Time &start, const Time &end) const { return false; } + + virtual size_t dataSize(bool withHeader) const; + + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &start, const Time &end, + int maxBytes); + + virtual bool put(std::streambuf &buf, bool withHeader) const { return false; } + + PacketType packetType() const { return MetaDataPacket; } + + private: + MetaHeader _header; + + mutable Time _startTime; + mutable Time _endTime; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/mseed/encoder.h b/libs/gempa/caps/mseed/encoder.h new file mode 100644 index 0000000..5c8d037 --- /dev/null +++ b/libs/gempa/caps/mseed/encoder.h @@ -0,0 +1,75 @@ +/***************************************************************************** + * encoder.h + * + * Abstract Encoder interface + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_ENCODER_H +#define CAPS_MSEED_ENCODER_H + +#include "packet.h" +#include "spclock.h" + +#include +#include + +#include +#include + + +namespace Gempa { +namespace CAPS { + +class Encoder { + public: + Encoder(int freqn, int freqd) : _clk(freqn, freqd), + _sampleCount(0), _timingQuality(-1) {} + virtual ~Encoder() {} + + virtual void push(void *sample) = 0; + virtual void flush() = 0; + virtual void reset() { _sampleCount = 0; } + virtual int type() const = 0; + + const SPClock& clk() { return _clk; } + + void setStartTime(const SPClock::INT_TIME &time) { _clk.sync_time(time); } + const SPClock::INT_TIME currentTime() const { return _clk.get_time(0); } + + int timingQuality() { return _timingQuality; } + void setTimingQuality(int quality) { _timingQuality = quality; } + + PacketPtr pop() { + if ( _packetQueue.empty() ) return PacketPtr(); + + PacketPtr rec = _packetQueue.front(); + _packetQueue.pop_front(); + return rec; + } + + protected: + typedef std::list PacketQueue; + SPClock _clk; + int _sampleCount; + PacketQueue _packetQueue; + int _timingQuality; +}; + +} +} + +#endif // __ENCODER_H__ + diff --git a/libs/gempa/caps/mseed/mseed.cpp b/libs/gempa/caps/mseed/mseed.cpp new file mode 100644 index 0000000..8b96648 --- /dev/null +++ b/libs/gempa/caps/mseed/mseed.cpp @@ -0,0 +1,162 @@ +/***************************************************************************** + * mseed.cpp + * + * Mini-SEED format implementation + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#include +#include + +#include "mseed.h" +#include "slink.h" + +#include +#include +#include +#include +#include + +#include +#include + + + +namespace Gempa { +namespace CAPS { + +MSEEDFormat::MSEEDFormat(const std::string &netcode, const std::string &stacode, + const std::string &loccode, const std::string &chacode, + unsigned short freqn, unsigned short freqd, + unsigned short packtype_init, + uint8_t recordLength) + : networkCode(netcode), stationCode(stacode), locationCode(loccode), + channelCode(chacode), packType(packtype_init), recordLength(recordLength) +{ + if(freqn == 0 || freqd == 0) { + sample_rate_factor = 0; + sample_rate_multiplier = 0; + } + else if(!(freqn % freqd)) { + sample_rate_factor = freqn / freqd; + sample_rate_multiplier = 1; + } + else if(!(freqd % freqn)) { + sample_rate_factor = -freqd / freqn; + sample_rate_multiplier = 1; + } + else { + sample_rate_factor = -freqd; + sample_rate_multiplier = freqn; + } +} + +MSEEDDataRecord *MSEEDFormat::get_buffer(const SPClock::INT_TIME &it, int usec_correction, + int timing_quality, void *&dataptr, int &datalen) { + size_t buflen = 1 << recordLength; + MSEEDDataRecord *record = new MSEEDDataRecord(); + record->data()->resize(buflen); + + char *buf = record->data()->data(); + int n; + + sl_fsdh_s* fsdh = (sl_fsdh_s *)buf; + + memset(fsdh, 0, buflen); + + const int start_frames = (sizeof(sl_fsdh_s) + sizeof(sl_blkt_1000_s) + + sizeof(sl_blkt_1001_s) + 63) & 0xffffffc0; // align to 64 bytes + + dataptr = (void *)((char *) fsdh + start_frames); + datalen = buflen - start_frames; + + fsdh->dhq_indicator = 'D'; + fsdh->reserved = ' '; + + strncpy(fsdh->station, stationCode.c_str(), 5); + if((n = stationCode.length()) < 5) memset(fsdh->station + n, 32, 5 - n); + strncpy(fsdh->location, locationCode.c_str(), 2); + if((n = locationCode.length()) < 2) memset(fsdh->location + n, 32, 2 - n); + strncpy(fsdh->channel, channelCode.c_str(), 3); + if((n = channelCode.length()) < 3) memset(fsdh->channel + n, 32, 3 - n); + strncpy(fsdh->network, networkCode.c_str(), 2); + if((n = networkCode.length()) < 2) memset(fsdh->network + n, 32, 2 - n); + + int year, doy, hour, min, sec; + it.get2(&year, &doy, &hour, &min, &sec); + + fsdh->start_time.year = htons(year); + fsdh->start_time.day = htons(doy+1); + fsdh->start_time.hour = hour; + fsdh->start_time.min = min; + fsdh->start_time.sec = sec; + fsdh->start_time.fract = htons(it.microseconds() / 100); + fsdh->samprate_fact = (int16_t)htons(sample_rate_factor); + fsdh->samprate_mult = (int16_t)htons(sample_rate_multiplier); + fsdh->num_blockettes = 1; + + div_t d_corr = div(usec_correction + ((usec_correction < 0) ? -50: 50), 100); + fsdh->time_correct = (int32_t)htonl(d_corr.quot); + + fsdh->begin_data = htons(start_frames); + fsdh->begin_blockette = htons(sizeof(sl_fsdh_s)); + + sl_blkt_1000_s* blkt_1000 = (sl_blkt_1000_s *)((char *) fsdh + sizeof(sl_fsdh_s)); + blkt_1000->blkt_type = htons(1000); // Data Only SEED Blockette + + blkt_1000->encoding = packType; + blkt_1000->word_swap = 1; // big endian + blkt_1000->rec_len = recordLength; // 9 = 512 bytes + + if ( timing_quality >= 0 ) { + blkt_1000->next_blkt = htons(sizeof(sl_fsdh_s) + sizeof(sl_blkt_1000_s)); + ++fsdh->num_blockettes; + + sl_blkt_1001_s* blkt_1001 = (sl_blkt_1001_s *)((char *) fsdh + + sizeof(sl_fsdh_s) + sizeof(sl_blkt_1000_s)); + + blkt_1001->blkt_type = htons(1001); // Data Extension Blockette + blkt_1001->timing_qual = timing_quality; + + blkt_1001->usec = 0; + } + + return record; +} + + +void MSEEDFormat::updateBuffer(MSEEDDataRecord *rec, int samples, int frames) { + sl_fsdh_s* fsdh = (sl_fsdh_s *)rec->data()->data(); + char temp[7]; + + sprintf(temp, "%06d", (int)0); + memcpy(fsdh->sequence_number,temp,6); + fsdh->dhq_indicator = 'D'; + fsdh->num_samples = htons(samples); + + sl_blkt_1000_s* blkt_1000 = (sl_blkt_1000_s *)((char *) fsdh + sizeof(sl_fsdh_s)); + + if ( ntohs(blkt_1000->next_blkt) != 0 ) { + sl_blkt_1001_s* blkt_1001 = (sl_blkt_1001_s *)((char *) fsdh + + sizeof(sl_fsdh_s) + sizeof(sl_blkt_1000_s)); + + blkt_1001->frame_cnt = frames; + } + + rec->unpackHeader(); +} + +} +} diff --git a/libs/gempa/caps/mseed/mseed.h b/libs/gempa/caps/mseed/mseed.h new file mode 100644 index 0000000..48f656a --- /dev/null +++ b/libs/gempa/caps/mseed/mseed.h @@ -0,0 +1,90 @@ +/***************************************************************************** + * mseed.h + * + * Mini-SEED format implementation + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_MSEED_H +#define CAPS_MSEED_MSEED_H + +#include "packet.h" +#include "spclock.h" + +#include + +#include + + +namespace Gempa { +namespace CAPS { + +/* SEED data encoding types */ +enum SEEDDataEncodingType { + DE_ASCII = 0, + DE_INT16 = 1, + DE_INT32 = 3, + DE_FLOAT32 = 4, + DE_FLOAT64 = 5, + DE_STEIM1 = 10, + DE_STEIM2 = 11, + DE_GEOSCOPE24 = 12, + DE_GEOSCOPE163 = 13, + DE_GEOSCOPE164 = 14, + DE_CDSN = 16, + DE_SRO = 30, + DE_DWWSSN = 32 +}; + + +struct MSEEDFormat { + MSEEDFormat(const std::string &networkCode, const std::string &stationCode, + const std::string &locationCode, const std::string &channelCode, + unsigned short freqn, unsigned short freqd, + unsigned short packtype_init, + uint8_t recLen); + + template + MSEEDEncoderPacket + get_packet(const SPClock::INT_TIME &it, int usec_correction, int timing_quality) { + void *dataptr = NULL; + int datalen = 0; + unsigned int size = 0; + MSEEDDataRecord *rec = get_buffer(it, usec_correction, timing_quality, dataptr, datalen); + + return MSEEDEncoderPacket(rec, size, dataptr, datalen); + } + + MSEEDDataRecord *get_buffer(const SPClock::INT_TIME &it, int usec_correction, + int timing_quality, + void *&dataptr, int &datalen); + + void updateBuffer(MSEEDDataRecord *rec, int samples, int frames); + + std::string networkCode; + std::string stationCode; + std::string locationCode; + std::string channelCode; + int sample_rate_factor; + int sample_rate_multiplier; + unsigned short packType; + int timingQuality; + uint8_t recordLength; +}; + +} +} + +#endif diff --git a/libs/gempa/caps/mseed/packet.h b/libs/gempa/caps/mseed/packet.h new file mode 100644 index 0000000..bf47c24 --- /dev/null +++ b/libs/gempa/caps/mseed/packet.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2012 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#ifndef CAPS_MSEED_PACKET_H +#define CAPS_MSEED_PACKET_H + +#include + +#include + +namespace Gempa { +namespace CAPS { + +template struct MSEEDEncoderPacket { + MSEEDEncoderPacket(): record(NULL), data(NULL), datalen(0) {} + MSEEDEncoderPacket(MSEEDDataRecord *rec, unsigned int size_init, + void *data_init, unsigned short datalen_init) + : record(rec), data(static_cast(data_init)), + datalen(datalen_init) {} + ~MSEEDEncoderPacket() {} + + void reset() { record = NULL; data = NULL; datalen = 0; } + bool valid() const { return record != NULL; } + + MSEEDDataRecord *record; + T *data; + unsigned short datalen; +}; + +} +} + +#endif diff --git a/libs/gempa/caps/mseed/slink.h b/libs/gempa/caps/mseed/slink.h new file mode 100644 index 0000000..af46eef --- /dev/null +++ b/libs/gempa/caps/mseed/slink.h @@ -0,0 +1,131 @@ +/***************************************************************************** + * slink.h + * + * SeedLink protocol constants + * + * Token from libslink + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_SLINK_H +#define CAPS_MSEED_SLINK_H + + +#ifdef __cplusplus +extern "C" { +#endif + + + /* Portability to the XScale (ARM) architecture + * requires a packed attribute in certain places + * but this only works with GCC for now. + */ +#if defined (__GNUC__) + #define SLP_PACKED __attribute__ ((packed)) +#else + #define SLP_PACKED +#endif + +#define SIGNATURE "SL" /* SeedLink header signature */ +#define INFOSIGNATURE "SLINFO" /* SeedLink INFO packet signature */ + + +/* SeedLink packet types */ +#define SLDATA 0 /* waveform data record */ +#define SLDET 1 /* detection record */ +#define SLCAL 2 /* calibration record */ +#define SLTIM 3 /* timing record */ +#define SLMSG 4 /* message record */ +#define SLBLK 5 /* general record */ +#define SLNUM 6 /* used as the error indicator (same as SLCHA) */ +#define SLCHA 6 /* for requesting channel info or detectors */ +#define SLINF 7 /* a non-terminating XML formatted message in a miniSEED + log record, used for INFO responses */ +#define SLINFT 8 /* a terminating XML formatted message in a miniSEED log + record, used for INFO responses */ +#define SLKEEP 9 /* an XML formatted message in a miniSEED log + record, used for keepalive/heartbeat responses */ + + +/* SEED binary time (10 bytes) */ +struct sl_btime_s +{ + uint16_t year; + uint16_t day; + uint8_t hour; + uint8_t min; + uint8_t sec; + uint8_t unused; + uint16_t fract; +} SLP_PACKED; + + +/* Fixed section data of header (48 bytes) */ +struct sl_fsdh_s +{ + char sequence_number[6]; + char dhq_indicator; + char reserved; + char station[5]; + char location[2]; + char channel[3]; + char network[2]; + struct sl_btime_s start_time; + uint16_t num_samples; + int16_t samprate_fact; + int16_t samprate_mult; + uint8_t act_flags; + uint8_t io_flags; + uint8_t dq_flags; + uint8_t num_blockettes; + int32_t time_correct; + uint16_t begin_data; + uint16_t begin_blockette; +} SLP_PACKED; + + +/* 1000 Blockette (8 bytes) */ +struct sl_blkt_1000_s +{ + uint16_t blkt_type; + uint16_t next_blkt; + uint8_t encoding; + uint8_t word_swap; + uint8_t rec_len; + uint8_t reserved; +} SLP_PACKED; + +/* 1001 Blockette (8 bytes) */ +struct sl_blkt_1001_s +{ + uint16_t blkt_type; + uint16_t next_blkt; + int8_t timing_qual; + int8_t usec; + uint8_t reserved; + int8_t frame_cnt; +} SLP_PACKED; + +/* Generic struct for head of blockettes */ +struct sl_blkt_head_s +{ + uint16_t blkt_type; + uint16_t next_blkt; +} SLP_PACKED; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libs/gempa/caps/mseed/spclock.h b/libs/gempa/caps/mseed/spclock.h new file mode 100644 index 0000000..3719899 --- /dev/null +++ b/libs/gempa/caps/mseed/spclock.h @@ -0,0 +1,78 @@ +/***************************************************************************** + * spclock.h + * + * Stream Processor Clock + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_SPCLOCK_H +#define CAPS_MSEED_SPCLOCK_H + + +#include + + +namespace Gempa { +namespace CAPS { + + +class SPClock + { + public: + typedef Gempa::CAPS::Time INT_TIME; + + private: + INT_TIME itime; + int ticks; + int corr; + + public: + const int freqn; + const int freqd; + + SPClock(int freqn_init, int freqd_init): ticks(0), corr(0), + freqn(freqn_init), freqd(freqd_init) + {} + + void sync_time(const INT_TIME &time) + { + itime = time; + ticks = 0; + corr = 0; + } + + void tick() + { + ++ticks; + } + + INT_TIME get_time(int tick_diff) const + { + int64_t correctness = (double)freqd / (double)freqn * 1000000 * (ticks - tick_diff - corr); + return itime + Gempa::CAPS::TimeSpan(long(correctness/1000000),long(correctness%1000000)); + } + + int correction() const + { + return corr; + } + }; + + +} +} + + +#endif // SPCLOCK_H diff --git a/libs/gempa/caps/mseed/steim1.h b/libs/gempa/caps/mseed/steim1.h new file mode 100644 index 0000000..a4f0d74 --- /dev/null +++ b/libs/gempa/caps/mseed/steim1.h @@ -0,0 +1,90 @@ +/***************************************************************************** + * steim1.h + * + * Steim1 encoder + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_STEIM1_H +#define CAPS_MSEED_STEIM1_H + +#include "encoder.h" +#include "mseed.h" + + +namespace Gempa { +namespace CAPS { + + +//***************************************************************************** +// Steim1Frame +//***************************************************************************** + +struct Steim1Frame { + u_int32_t nibble_word; + u_int32_t sample_word[15]; +}; + +//***************************************************************************** +// Steim1Encoder +//***************************************************************************** + +template +class Steim1Encoder: public Encoder { + private: + MSEEDFormat *format; + int frame_count; + int bp; + int fp; + int spw; + int32_t last_sample; + int32_t buf[5]; + u_int32_t nibble_word; + MSEEDEncoderPacket current_packet; + + void update_spw(int bp); + void store(int32_t value); + void init_packet(); + void finish_packet(); + void update_packet(); + + MSEEDEncoderPacket get_packet() { + return format->get_packet(_clk.get_time(bp), + _clk.correction(), _timingQuality); + } + + void queue_packet(MSEEDEncoderPacket &pckt); + + int number_of_frames(const MSEEDEncoderPacket &packet) { + return (packet.datalen >> 6); + } + + public: + Steim1Encoder(MSEEDFormat *format, int freqn, int freqd) + : Encoder(freqn, freqd), format(format), frame_count(0), + bp(0), fp(0), spw(4), last_sample(0), nibble_word(0) {} + virtual ~Steim1Encoder(); + virtual void flush(); + virtual void push(void *value); + virtual int type() const { return DE_STEIM1; } +}; + + +} +} + +#include "steim1.ipp" + +#endif // __STEIM1_H__ diff --git a/libs/gempa/caps/mseed/steim1.ipp b/libs/gempa/caps/mseed/steim1.ipp new file mode 100644 index 0000000..d454ca0 --- /dev/null +++ b/libs/gempa/caps/mseed/steim1.ipp @@ -0,0 +1,184 @@ +/***************************************************************************** + * steim1.cc + * + * Steim1 encoder + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + + +#include + +#include +#include +#include + +namespace Gempa { +namespace CAPS { + +template Steim1Encoder::~Steim1Encoder() { + if ( format != NULL ) delete format; +} + +template void Steim1Encoder::update_spw(int bp) { + int spw1 = 4; + + assert(bp < 4); + if(buf[bp] < -32768 || buf[bp] > 32767) spw1 = 1; + else if(buf[bp] < -128 || buf[bp] > 127) spw1 = 2; + if(spw1 < spw) spw = spw1; +} + +template void Steim1Encoder::store(int32_t value) { + assert(bp < 4); + buf[bp] = value - last_sample; + last_sample = value; + update_spw(bp); + ++bp; +} + +template void Steim1Encoder::init_packet() { + int i; + int32_t begin_sample = last_sample; + + for(i = 1; i < bp; ++i) { + begin_sample -= buf[i]; + } + + reset(); + current_packet.data[0].sample_word[0] = htonl(begin_sample); + frame_count = 0; + nibble_word = 0; + fp = 2; +} + +template void Steim1Encoder::finish_packet() { + int i; + int32_t end_sample = last_sample; + + for(i = 0; i < bp; ++i) { + end_sample -= buf[i]; + } + + current_packet.data[0].sample_word[1] = htonl(end_sample); +} + +template void Steim1Encoder::update_packet() { + unsigned int nibble = 0; + u_int32_t sample_word = 0; + + assert(bp < 5); + + int used = bp; + + while(used > spw) { + --used; + spw = 4; + for(int i = 0; i < used; ++i) update_spw(i); + } + + while(used < spw) spw >>= 1; + + used = spw; + + switch(spw) { + case 4: + nibble = 1; + sample_word = ((buf[0] & 0xff) << 24) | ((buf[1] & 0xff) << 16) | + ((buf[2] & 0xff) << 8) | (buf[3] & 0xff); + break; + case 2: + nibble = 2; + sample_word = ((buf[0] & 0xffff) << 16) | (buf[1] & 0xffff); + break; + case 1: + nibble = 3; + sample_word = buf[0]; + break; + default: + assert(0); + } + + nibble_word |= (nibble << (30 - ((fp + 1) << 1))); + + spw = 4; + for(int i = 0; i < bp - used; ++i) { + buf[i] = buf[i + used]; + update_spw(i); + } + + bp -= used; + _sampleCount += used; + + current_packet.data[frame_count].nibble_word = htonl(nibble_word); + current_packet.data[frame_count].sample_word[fp] = htonl(sample_word); + if(++fp < 15) return; + + nibble_word = 0; + fp = 0; + ++frame_count; + return; +} + +template void Steim1Encoder::queue_packet(MSEEDEncoderPacket &pckt) { + format->updateBuffer(pckt.record, _sampleCount, frame_count + (fp > 0)); + + Packet *packet = new Packet(DataRecordPtr(pckt.record), format->networkCode, format->stationCode, + format->locationCode, format->channelCode); + _packetQueue.push_back(PacketPtr(packet)); + pckt.reset(); + reset(); +} + +template void Steim1Encoder::push(void *value) { + int32_t sample_val = *static_cast(value); + store(sample_val); + _clk.tick(); + + while(bp >= spw) { + if(!current_packet.valid()) { + current_packet = get_packet(); + init_packet(); + } + + update_packet(); + if(frame_count == number_of_frames(current_packet)) { + finish_packet(); + queue_packet(current_packet); + } + } +} + +template void Steim1Encoder::flush() { + while(bp) { + if(!current_packet.valid()) { + current_packet = get_packet(); + init_packet(); + } + + update_packet(); + if(frame_count == number_of_frames(current_packet)) { + finish_packet(); + queue_packet(current_packet); + } + } + + if(current_packet.valid()) { + finish_packet(); + queue_packet(current_packet); + } +} + +} +} diff --git a/libs/gempa/caps/mseed/steim2.h b/libs/gempa/caps/mseed/steim2.h new file mode 100644 index 0000000..46bcd98 --- /dev/null +++ b/libs/gempa/caps/mseed/steim2.h @@ -0,0 +1,94 @@ +/***************************************************************************** + * steim2.h + * + * Steim2 encoder + * + * (c) 2000 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#ifndef CAPS_MSEED_STEIM2_H +#define CAPS_MSEED_STEIM2_H + +#include "encoder.h" +#include "mseed.h" + +namespace Gempa { +namespace CAPS { + +//***************************************************************************** +// Steim2Frame +//***************************************************************************** + +struct Steim2Frame { + u_int32_t nibble_word; + u_int32_t sample_word[15]; +}; + +//***************************************************************************** +// Steim2Encoder +//***************************************************************************** + +template +class Steim2Encoder : public Encoder { + public: + Steim2Encoder(MSEEDFormat *format, int freqn, int freqd) + : Encoder(freqn, freqd), format(format), frame_count(0), + bp(0), fp(0), spw(4), last_sample(0), nibble_word(0) { + } + virtual ~Steim2Encoder(); + virtual void flush(); + + virtual void push(void *value); + virtual int type() const { return DE_STEIM2; } + + private: + void update_spw(int bp); + void store(int32_t value); + void init_packet(); + void finish_packet(); + void update_packet(); + + MSEEDEncoderPacket get_packet() { + return format->get_packet(_clk.get_time(bp), + _clk.correction(), _timingQuality); + } + + void queue_packet(MSEEDEncoderPacket &pckt); + + int number_of_frames(const MSEEDEncoderPacket &packet) { + return (packet.datalen >> 6); + } + + private: + MSEEDFormat *format; + int frame_count; + int bp; + int fp; + int32_t last_s; + int spw; + int32_t last_sample; + int32_t buf[8]; + u_int32_t nibble_word; + MSEEDEncoderPacket current_packet; +}; + + +} +} + + +#include "steim2.ipp" + +#endif // __STEIM2_H__ + diff --git a/libs/gempa/caps/mseed/steim2.ipp b/libs/gempa/caps/mseed/steim2.ipp new file mode 100644 index 0000000..44189cd --- /dev/null +++ b/libs/gempa/caps/mseed/steim2.ipp @@ -0,0 +1,241 @@ +/***************************************************************************** + * steim2.cc + * + * Steim2 encoder + * + * (c) 2004 Andres Heinloo, GFZ Potsdam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any later + * version. For more information, see http://www.gnu.org/ + * + * ================ + * Change log + * =============== + * + * 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH) + *****************************************************************************/ + +#include "../log.h" + +#include +#include +#include +#include + +#include + + +namespace Gempa { +namespace CAPS { + + +template Steim2Encoder::~Steim2Encoder() { + if ( format != NULL ) delete format; +} + +template void Steim2Encoder::update_spw(int bp) { + assert(bp < 7); + + if(buf[bp] < -536870912) { + CAPS_WARNING("%s.%s.%s.%s: value %d is too large for Steim2 encoding", + format->networkCode.c_str(), format->stationCode.c_str(), + format->locationCode.c_str(), format->channelCode.c_str(), + buf[bp]); + buf[bp] = -536870912; + spw = 1; + return; + } + + if(buf[bp] > 536870911) { + CAPS_WARNING("%s.%s.%s.%s: value %d is too large for Steim2 encoding", + format->networkCode.c_str(), format->stationCode.c_str(), + format->locationCode.c_str(), format->channelCode.c_str(), + buf[bp]); + buf[bp] = 536870911; + spw = 1; + return; + } + + int spw1 = 7; + if(buf[bp] < -16384 || buf[bp] > 16383) spw1 = 1; + else if(buf[bp] < -512 || buf[bp] > 511) spw1 = 2; + else if(buf[bp] < -128 || buf[bp] > 127) spw1 = 3; + else if(buf[bp] < -32 || buf[bp] > 31) spw1 = 4; + else if(buf[bp] < -16 || buf[bp] > 15) spw1 = 5; + else if(buf[bp] < -8 || buf[bp] > 7) spw1 = 6; + if(spw1 < spw) spw = spw1; +} + +template void Steim2Encoder::store(int32_t value) { + assert(bp < 7); + buf[bp] = value - last_sample; + last_sample = value; + update_spw(bp); + ++bp; +} + +template void Steim2Encoder::init_packet() { + int i; + int32_t begin_sample = last_sample; + + for(i = 1; i < bp; ++i) { + begin_sample -= buf[i]; + } + + reset(); + current_packet.data[0].sample_word[0] = htonl(begin_sample); + frame_count = 0; + nibble_word = 0; + fp = 2; +} + +template void Steim2Encoder::finish_packet() { + int i; + int32_t end_sample = last_sample; + + for(i = 0; i < bp; ++i) { + end_sample -= buf[i]; + } + + current_packet.data[0].sample_word[1] = htonl(end_sample); +} + +template void Steim2Encoder::update_packet() { + unsigned int nibble = 0; + u_int32_t sample_word = 0; + + assert(bp < 8); + + int used = bp; + + while(used > spw) { + --used; + spw = 7; + for(int i = 0; i < used; ++i) update_spw(i); + } + + spw = used; + + switch(spw) { + case 7: + nibble = 3; + sample_word = (2U << 30) | ((buf[0] & 0xf) << 24) | + ((buf[1] & 0xf) << 20) | ((buf[2] & 0xf) << 16) | + ((buf[3] & 0xf) << 12) | ((buf[4] & 0xf) << 8) | + ((buf[5] & 0xf) << 4) | (buf[6] & 0xf); + break; + case 6: + nibble = 3; + sample_word = (1U << 30) | ((buf[0] & 0x1f) << 25) | + ((buf[1] & 0x1f) << 20) | ((buf[2] & 0x1f) << 15) | + ((buf[3] & 0x1f) << 10) | ((buf[4] & 0x1f) << 5) | + (buf[5] & 0x1f); + break; + case 5: + nibble = 3; + sample_word = ((buf[0] & 0x3f) << 24) | ((buf[1] & 0x3f) << 18) | + ((buf[2] & 0x3f) << 12) | ((buf[3] & 0x3f) << 6) | + (buf[4] & 0x3f); + break; + case 4: + nibble = 1; + sample_word = ((buf[0] & 0xff) << 24) | ((buf[1] & 0xff) << 16) | + ((buf[2] & 0xff) << 8) | (buf[3] & 0xff); + break; + case 3: + nibble = 2; + sample_word = (3U << 30) | ((buf[0] & 0x3ff) << 20) | + ((buf[1] & 0x3ff) << 10) | (buf[2] & 0x3ff); + break; + case 2: + nibble = 2; + sample_word = (2U << 30) | ((buf[0] & 0x7fff) << 15) | + (buf[1] & 0x7fff); + break; + case 1: + nibble = 2; + sample_word = (1U << 30) | (buf[0] & 0x3fffffff); + break; + default: + assert(0); + break; + } + + nibble_word |= (nibble << (30 - ((fp + 1) << 1))); + + spw = 7; + for(int i = 0; i < bp - used; ++i) { + buf[i] = buf[i + used]; + update_spw(i); + } + + bp -= used; + _sampleCount += used; + + current_packet.data[frame_count].nibble_word = htonl(nibble_word); + current_packet.data[frame_count].sample_word[fp] = htonl(sample_word); + if(++fp < 15) return; + + nibble_word = 0; + fp = 0; + ++frame_count; + return; +} + +template void Steim2Encoder::queue_packet(MSEEDEncoderPacket &pckt) { + format->updateBuffer(pckt.record, _sampleCount, frame_count + (fp > 0)); + + Packet *packet = new Packet(DataRecordPtr(pckt.record), format->networkCode, format->stationCode, + format->locationCode, format->channelCode); + _packetQueue.push_back(PacketPtr(packet)); + pckt.reset(); + reset(); +} + + +template void Steim2Encoder::push(void *value) { + int32_t sample_val = *static_cast(value); + store(sample_val); + _clk.tick(); + + while ( bp >= spw ) { + if( !current_packet.valid() ) { + current_packet = get_packet(); + init_packet(); + } + + update_packet(); + if ( frame_count == number_of_frames(current_packet) ) { + finish_packet(); + queue_packet(current_packet); + } + } +} + +template void Steim2Encoder::flush() { + while ( bp ) { + if ( !current_packet.valid() ) { + current_packet = get_packet(); + init_packet(); + } + + update_packet(); + if( frame_count == number_of_frames(current_packet) ) { + finish_packet(); + queue_packet(current_packet); + } + } + + if ( current_packet.valid() ) { + finish_packet(); + queue_packet(current_packet); + } +} + + +} +} + + diff --git a/libs/gempa/caps/mseed/uncompressed.h b/libs/gempa/caps/mseed/uncompressed.h new file mode 100644 index 0000000..f6f91a7 --- /dev/null +++ b/libs/gempa/caps/mseed/uncompressed.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#ifndef CAPS_MSEED_UNCOMPRESSED_H +#define CAPS_MSEED_UNCOMPRESSED_H + +#include "encoder.h" +#include "mseed.h" + +#include + +#include + +#include + +namespace Gempa { +namespace CAPS { + +template class UncompressedMSEED : public Encoder { + MSEEDEncoderPacket get_packet() { + return _format->get_packet(_clk.get_time(-_bp), + _clk.correction(), _timingQuality); + } + + void queue_packet(MSEEDEncoderPacket &pckt) { + _format->updateBuffer(pckt.record, _sampleCount, 1); + + Packet *packet = new Packet(DataRecordPtr(pckt.record), _format->networkCode, _format->stationCode, + _format->locationCode, _format->channelCode); + _packetQueue.push_back(PacketPtr(packet)); + pckt.reset(); + reset(); + } + + public: + UncompressedMSEED(MSEEDFormat *format, int freqn, int freqd) + : Encoder(freqn, freqd), + _format(format), _bp(0) { + } + virtual ~UncompressedMSEED() { if ( _format ) delete _format; } + virtual void flush() { + if ( _current_packet.valid() ) { + queue_packet(_current_packet); + } + } + + virtual void push(void *value) { + if ( !_current_packet.valid() ) + _current_packet = get_packet(); + else if ( _sampleCount * sizeof(T) >= _current_packet.datalen ) { + flush(); + _current_packet = get_packet(); + } + + _current_packet.data[_sampleCount] = + Gempa::CAPS::Endianess::Converter::ToBigEndian(*(T*)value); + ++_sampleCount; + ++_bp; + } + + virtual int type() const { return _format->packType; } + + private: + MSEEDFormat *_format; + MSEEDEncoderPacket _current_packet; + int _bp; + +}; + +} +} + +#endif // __STEIM1_H__ diff --git a/libs/gempa/caps/mseedpacket.cpp b/libs/gempa/caps/mseedpacket.cpp new file mode 100644 index 0000000..0fe5351 --- /dev/null +++ b/libs/gempa/caps/mseedpacket.cpp @@ -0,0 +1,491 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include + +#include +#include +#include +#include + +namespace { + +#define LOG_SID(FUNC, format,...)\ +do {\ + char n[6];\ + char s[6];\ + char c[6];\ + char l[6];\ + ms_strncpclean(n, head.network, 2);\ + ms_strncpclean(s, head.station, 5);\ + ms_strncpclean(l, head.location, 2);\ + ms_strncpclean(c, head.channel, 3);\ + FUNC("[%s.%s.%s.%s] " format, n, s, l, c, ##__VA_ARGS__);\ +} while(0) + +} + +namespace Gempa { +namespace CAPS { + + +MSEEDDataRecord::MSEEDDataRecord() {} + +const char *MSEEDDataRecord::formatName() const { + return "MSEED"; +} + + +bool MSEEDDataRecord::readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, + Time &endTime) { +#if 1 // Set this to 1 to enable no-malloc fast MSeed meta parser + fsdh_s head; + + if ( size <= 0 ) { + CAPS_WARNING("read metadata: invalid size of record: %d", size); + return false; + } + + if ( size < MINRECLEN || size > MAXRECLEN ) { + CAPS_WARNING("read metadata: invalid MSEED record size: %d", size); + return false; + } + + // Read first 32 byte + size_t read = buf.sgetn((char*)&head, sizeof(head)); + if ( read < sizeof(head) ) { + CAPS_WARNING("read metadata: input buffer underflow: only %d/%d bytes read", + (int)read, (int)sizeof(head)); + return false; + } + + if ( !MS_ISVALIDHEADER(((char*)&head)) ) { + CAPS_WARNING("read metadata: invalid MSEED header"); + return false; + } + + bool headerswapflag = false; + if ( !MS_ISVALIDYEARDAY(head.start_time.year, head.start_time.day) ) + headerswapflag = true; + + /* Swap byte order? */ + if ( headerswapflag ) { + MS_SWAPBTIME(&head.start_time); + ms_gswap2a(&head.numsamples); + ms_gswap2a(&head.samprate_fact); + ms_gswap2a(&head.samprate_mult); + ms_gswap4a(&head.time_correct); + ms_gswap2a(&head.data_offset); + ms_gswap2a(&head.blockette_offset); + } + + header.dataType = DT_Unknown; + + hptime_t hptime = ms_btime2hptime(&head.start_time); + if ( hptime == HPTERROR ) { + LOG_SID(CAPS_DEBUG, "read metadata: invalid start time"); + return false; + } + + header.quality.ID = 0; + header.quality.str[0] = head.dataquality; + + if ( head.time_correct != 0 && !(head.act_flags & 0x02) ) + hptime += (hptime_t)head.time_correct * (HPTMODULUS / 10000); + + // Parse blockettes + uint32_t blkt_offset = head.blockette_offset; + uint32_t blkt_length; + uint16_t blkt_type; + uint16_t next_blkt; + + if ( blkt_offset < sizeof(head) ) { + LOG_SID(CAPS_DEBUG, "read metadata: blockette " + "offset points into header"); + return false; + } + + uint32_t coffs = 0; + + while ( (blkt_offset != 0) && ((int)blkt_offset < size) && + (blkt_offset < MAXRECLEN) ) { + char bhead[6]; + int seek_ofs = blkt_offset-sizeof(head)-coffs; + buf.pubseekoff(seek_ofs, std::ios_base::cur, std::ios_base::in); + coffs += seek_ofs; + if ( buf.sgetn(bhead, 6) != 6 ) { + LOG_SID(CAPS_DEBUG, "read metadata: " + "failed to read blockette header"); + break; + } + + coffs += 6; + + memcpy(&blkt_type, bhead, 2); + memcpy(&next_blkt, bhead+2, 2); + + if ( headerswapflag ) { + ms_gswap2(&blkt_type); + ms_gswap2(&next_blkt); + } + + blkt_length = ms_blktlen(blkt_type, bhead, headerswapflag); + + if ( blkt_length == 0 ) { + LOG_SID(CAPS_DEBUG, "read metadata: " + "unknown blockette length for type %d", + blkt_type); + break; + } + + /* Make sure blockette is contained within the msrecord buffer */ + if ( (int)(blkt_offset - 4 + blkt_length) > size ) { + LOG_SID(CAPS_DEBUG, "read metadata: blockette " + "%d extends beyond record size, truncated?", + blkt_type); + break; + } + + if ( blkt_type == 1000 ) { + switch ( (int)bhead[4] ) { + case DE_ASCII: + header.dataType = DT_INT8; + break; + case DE_INT16: + header.dataType = DT_INT16; + break; + case DE_INT32: + case DE_STEIM1: + case DE_STEIM2: + case DE_CDSN: + case DE_DWWSSN: + case DE_SRO: + header.dataType = DT_INT32; + break; + case DE_FLOAT32: + header.dataType = DT_FLOAT; + break; + case DE_FLOAT64: + header.dataType = DT_DOUBLE; + break; + case DE_GEOSCOPE24: + case DE_GEOSCOPE163: + case DE_GEOSCOPE164: + header.dataType = DT_FLOAT; + break; + default: + break; + } + } + else if ( blkt_type == 1001 ) { + // Add usec correction + hptime += ((hptime_t)bhead[5]) * (HPTMODULUS / 1000000); + } + + /* Check that the next blockette offset is beyond the current blockette */ + if ( next_blkt && next_blkt < (blkt_offset + blkt_length - 4) ) { + LOG_SID(CAPS_DEBUG, "read metadata: offset to " + "next blockette (%d) is within current blockette " + "ending at byte %d", + blkt_type, (blkt_offset + blkt_length - 4)); + break; + } + /* Check that the offset is within record length */ + else if ( next_blkt && next_blkt > size ) { + LOG_SID(CAPS_DEBUG, "read metadata: offset to " + "next blockette (%d) from type %d is beyond record " + "length", next_blkt, blkt_type); + break; + } + else + blkt_offset = next_blkt; + } + + startTime = Time((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + endTime = startTime; + + if ( head.samprate_fact > 0 ) { + header.samplingFrequencyNumerator = head.samprate_fact; + header.samplingFrequencyDenominator = 1; + } + else { + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = -head.samprate_fact; + } + + if ( head.samprate_mult > 0 ) + header.samplingFrequencyNumerator *= head.samprate_mult; + else + header.samplingFrequencyDenominator *= -head.samprate_mult; + + if ( header.samplingFrequencyNumerator > 0.0 && head.numsamples > 0 ) { + hptime = (hptime_t)head.numsamples * HPTMODULUS * header.samplingFrequencyDenominator / header.samplingFrequencyNumerator; + endTime += TimeSpan((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + } + + timeToTimestamp(_header.samplingTime, startTime); +#else + std::vector data(size); + size_t read = buf.sgetn(&data[0], data.size()); + if ( read != data.size() ) { + CAPS_WARNING("read metadata: input buffer underflow: only %d/%d bytes read", + (int)read, (int)data.size()); + return; + } + + unpackHeader(&data[0], data.size()); + + header = _header; + startTime = _startTime; + endTime = _endTime; +#endif + + return true; +} + + +const DataRecord::Header *MSEEDDataRecord::header() const { + return &_header; +} + + +Time MSEEDDataRecord::startTime() const { + return _startTime; +} + + +Time MSEEDDataRecord::endTime() const { + return _endTime; +} + + +bool MSEEDDataRecord::canTrim() const { + return false; +} + + +bool MSEEDDataRecord::canMerge() const { + return false; +} + + +bool MSEEDDataRecord::trim(const Time &start, + const Time &end) const { + return false; +} + + +size_t MSEEDDataRecord::dataSize(bool /*withHeader*/) const { + return _data.size(); +} + + +DataRecord::ReadStatus MSEEDDataRecord::get(std::streambuf &buf, int size, + const Time &start, + const Time &end, + int) { + //MSRecord *ms_rec = NULL; + + if ( size <= 0 ) { + CAPS_WARNING("get: invalid size of record: %d", size); + return RS_Error; + } + + _data.resize(size); + size_t read = buf.sgetn(&_data[0], _data.size()); + if ( read != _data.size() ) { + CAPS_WARNING("get: input buffer underflow: only %d/%d bytes read", + (int)read, (int)_data.size()); + return RS_Error; + } + + arraybuf tmp(&_data[0], size); + readMetaData(tmp, size, _header, _startTime, _endTime); + + if ( start.valid() || end.valid() ) { + // Out of scope? + if ( end.valid() && (end <= _startTime) ) + return RS_AfterTimeWindow; + + if ( start.valid() && (start >= _endTime) ) + return RS_BeforeTimeWindow; + } + + return RS_Complete; + + /* + // Only unpack the header structure + int state = msr_unpack(&_data[0], _data.size(), &ms_rec, 0, 0); + if ( state != MS_NOERROR ) { + switch ( state ) { + case MS_GENERROR: + CAPS_WARNING("get: generic libmseed error"); + break; + case MS_NOTSEED: + CAPS_WARNING("get: input data is not seed"); + break; + case MS_WRONGLENGTH: + CAPS_WARNING("get: length of data read was not correct"); + break; + case MS_OUTOFRANGE: + CAPS_WARNING("get: SEED record length out of range"); + break; + case MS_UNKNOWNFORMAT: + CAPS_WARNING("get: unknown data encoding format"); + break; + case MS_STBADCOMPFLAG: + CAPS_WARNING("get: invalid Steim compression flag(s)"); + break; + } + if ( ms_rec != NULL ) + msr_free(&ms_rec); + return RS_Error; + } + + hptime_t hptime = msr_starttime(ms_rec); + _startTime = Time((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + _endTime = _startTime; + + if ( ms_rec->samprate > 0.0 && ms_rec->samplecnt > 0 ) { + hptime = (hptime_t)(((double)(ms_rec->samplecnt) / ms_rec->samprate * HPTMODULUS) + 0.5); + _endTime += TimeSpan((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + } + + _header.dataType = DT_Unknown; + timeToTimestamp(_header.samplingTime, _startTime); + + if ( ms_rec->fsdh->samprate_fact > 0 ) { + _header.samplingFrequencyNumerator = ms_rec->fsdh->samprate_fact; + _header.samplingFrequencyDenominator = 1; + } + else { + _header.samplingFrequencyNumerator = 1; + _header.samplingFrequencyDenominator = -ms_rec->fsdh->samprate_fact; + } + + if ( ms_rec->fsdh->samprate_mult > 0 ) + _header.samplingFrequencyNumerator *= ms_rec->fsdh->samprate_mult; + else + _header.samplingFrequencyDenominator *= -ms_rec->fsdh->samprate_mult; + + switch ( ms_rec->sampletype ) { + case 'a': + _header.dataType = DT_INT8; + break; + case 'i': + _header.dataType = DT_INT32; + break; + case 'f': + _header.dataType = DT_FLOAT; + break; + case 'd': + _header.dataType = DT_DOUBLE; + break; + default: + _header.dataType = DT_Unknown; + break; + } + + msr_free(&ms_rec); + + if ( start.valid() || end.valid() ) { + // Out of scope? + if ( end.valid() && (end <= _startTime) ) + return RS_AfterTimeWindow; + + if ( start.valid() && (start >= _endTime) ) + return RS_BeforeTimeWindow; + } + + return RS_Complete; + */ +} + + +bool MSEEDDataRecord::put(std::streambuf &buf, bool /*withHeader*/) const { + return buf.sputn(&_data[0], _data.size()) == (int)_data.size(); +} + +void MSEEDDataRecord::setData(const void *data, size_t size) { + _data.resize(size); + memcpy(_data.data(), data, size); + unpackHeader(); +} + +void MSEEDDataRecord::unpackHeader(char *data, size_t size) { + // Only unpack the header structure + MSRecord *ms_rec = NULL; + int state = msr_unpack(data, size, &ms_rec, 0, 0); + if ( state != MS_NOERROR ) { + CAPS_WARNING("read metadata: read error: %d", state); + if ( ms_rec != NULL ) + msr_free(&ms_rec); + return; + } + + hptime_t hptime = msr_starttime(ms_rec); + _startTime = Time((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + _endTime = _startTime; + + if ( ms_rec->samprate > 0.0 && ms_rec->samplecnt > 0 ) { + hptime = (hptime_t)(((double)(ms_rec->samplecnt) / ms_rec->samprate * HPTMODULUS) + 0.5); + _endTime += TimeSpan((hptime_t)hptime/HPTMODULUS,(hptime_t)hptime%HPTMODULUS); + } + + _header.dataType = DT_Unknown; + timeToTimestamp(_header.samplingTime, _startTime); + + if ( ms_rec->fsdh->samprate_fact > 0 ) { + _header.samplingFrequencyNumerator = ms_rec->fsdh->samprate_fact; + _header.samplingFrequencyDenominator = 1; + } + else { + _header.samplingFrequencyNumerator = 1; + _header.samplingFrequencyDenominator = -ms_rec->fsdh->samprate_fact; + } + + if ( ms_rec->fsdh->samprate_mult > 0 ) + _header.samplingFrequencyNumerator *= ms_rec->fsdh->samprate_mult; + else + _header.samplingFrequencyDenominator *= -ms_rec->fsdh->samprate_mult; + + switch ( ms_rec->sampletype ) { + case 'a': + _header.dataType = DT_INT8; + break; + case 'i': + _header.dataType = DT_INT32; + break; + case 'f': + _header.dataType = DT_FLOAT; + break; + case 'd': + _header.dataType = DT_DOUBLE; + break; + default: + _header.dataType = DT_Unknown; + break; + } + + msr_free(&ms_rec); +} + + +} +} diff --git a/libs/gempa/caps/mseedpacket.h b/libs/gempa/caps/mseedpacket.h new file mode 100644 index 0000000..37518f9 --- /dev/null +++ b/libs/gempa/caps/mseedpacket.h @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_MSEEDPACKET_H +#define GEMPA_CAPS_MSEEDPACKET_H + + +#include +#include + + +namespace Gempa { +namespace CAPS { + + +class MSEEDDataRecord : public DataRecord { + public: + MSEEDDataRecord(); + + virtual const char *formatName() const; + + virtual bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, + Time &endTime); + + virtual const Header *header() const; + virtual Time startTime() const; + virtual Time endTime() const; + + virtual bool canTrim() const; + virtual bool canMerge() const; + + virtual bool trim(const Time &start, + const Time &end) const; + + virtual size_t dataSize(bool withHeader) const; + + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &start = Time(), + const Time &end = Time(), + int maxSize = -1); + + virtual bool put(std::streambuf &buf, bool withHeader) const; + + /** + * @brief Returns the packet type + * @return The packet type + */ + PacketType packetType() const { return MSEEDPacket; } + + /** + * @brief Initializes the internal data vector from the given buffer + * @param The buffer to read the data from + * @param The buffer size + */ + virtual void setData(const void *data, size_t size); + + void unpackHeader() { unpackHeader(_data.data(), _data.size()); } + + + protected: + Header _header; + + Time _startTime; + Time _endTime; + + int _dataType; + + + private: + void unpackHeader(char *data, size_t size); +}; + + +} +} + + +#endif diff --git a/libs/gempa/caps/packet.cpp b/libs/gempa/caps/packet.cpp new file mode 100644 index 0000000..f5fea5f --- /dev/null +++ b/libs/gempa/caps/packet.cpp @@ -0,0 +1,125 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + +#include + +#include + + +namespace Gempa { +namespace CAPS { + + +bool PacketDataHeader::setUOM(const char *type) { + int i; + + if ( type != NULL ) { + for ( i = 0; i < 4; ++i ) { + if ( type[i] == '\0' ) break; + unitOfMeasurement.str[i] = type[i]; + } + + // Input type must not have more than 4 characters + if ( i == 3 && type[i] != '\0' && type[i+1] != '\0' ) { + memset(unitOfMeasurement.str, '\0', 4); + return false; + } + } + else + i = 0; + + // Pad with null bytes + for ( ; i < 4; ++i ) + unitOfMeasurement.str[i] = '\0'; + + return true; +} + + +std::string PacketDataHeader::uom(char fill) const { + std::string s; + for ( int i = 0; i < 4; ++i ) { + if ( unitOfMeasurement.str[i] == '\0' ) break; + s += unitOfMeasurement.str[i]; + } + + if ( s.size() < 4 && fill != '\0' ) { + for ( int i = s.size(); i < 4; ++i ) + s += fill; + } + + return s; +} + + +bool PacketDataHeader::operator!=(const PacketDataHeader &other) const { + return version != other.version || + packetType != other.packetType || + unitOfMeasurement.ID != other.unitOfMeasurement.ID; +} + +bool PacketDataHeaderV2::operator!=(const PacketDataHeaderV2 &other) const { + return PacketDataHeader::operator!=(other) || + samplingFrequencyNumerator != other.samplingFrequencyNumerator || + samplingFrequencyDenominator != other.samplingFrequencyDenominator || + quality.ID != other.quality.ID; +} + +bool DataRecord::Header::put(std::streambuf &buf) const { + Endianess::Writer put(buf); + char dt = (char)dataType; + put(dt); + + put(samplingTime.year); + put(samplingTime.yday); + put(samplingTime.hour); + put(samplingTime.minute); + put(samplingTime.second); + put(samplingTime.usec); + put(samplingFrequencyNumerator); + put(samplingFrequencyDenominator); + + return put.good; +} + + +void DataRecord::Header::setSamplingTime(const Time &ts) { + int year, yday, hour, min, sec, usec; + ts.get2(&year, &yday, &hour, &min, &sec, &usec); + samplingTime.year = year; + samplingTime.yday = yday; + samplingTime.hour = hour; + samplingTime.minute = min; + samplingTime.second = sec; + samplingTime.usec = usec; +} + + +bool DataRecord::Header::compatible(const Header &other) const { + return dataType == other.dataType && + samplingFrequencyNumerator == other.samplingFrequencyNumerator && + samplingFrequencyDenominator == other.samplingFrequencyDenominator; +} + + +bool DataRecord::Header::operator!=(const Header &other) const { + return dataType != other.dataType || + samplingFrequencyNumerator != other.samplingFrequencyNumerator || + samplingFrequencyDenominator != other.samplingFrequencyDenominator; +} + +DataRecord::~DataRecord() {} + +} +} diff --git a/libs/gempa/caps/packet.h b/libs/gempa/caps/packet.h new file mode 100644 index 0000000..7a20864 --- /dev/null +++ b/libs/gempa/caps/packet.h @@ -0,0 +1,420 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_PACKET_H +#define GEMPA_CAPS_PACKET_H + +#include + +#include +#include + + +#include + +#include +#include +#include + + + +namespace Gempa { +namespace CAPS { + + +enum PacketType { + UnknownPacket = 0, + RawDataPacket, + MSEEDPacket, + ANYPacket, + RTCM2Packet, + MetaDataPacket, + FixedRawDataPacket, + PacketTypeCount +}; + + +enum DataType { + DT_Unknown = 0, + DT_DOUBLE = 1, + DT_FLOAT = 2, + DT_INT64 = 100, + DT_INT32 = 101, + DT_INT16 = 102, + DT_INT8 = 103 +}; + + +union UOM { + char str[4]; + int32_t ID; +}; + + +union Quality { + char str[4]; + int32_t ID; +}; + + +struct SC_GEMPA_CAPS_API TimeStamp { + int16_t year; /* year, eg. 2003 */ + uint16_t yday; /* day of year (1-366) */ + uint8_t hour; /* hour (0-23) */ + uint8_t minute; /* minute (0-59) */ + uint8_t second; /* second (0-59), 60 if leap second */ + uint8_t unused; /* unused byte */ + int32_t usec; /* microsecond (0-999999) */ +}; + + +struct SC_GEMPA_CAPS_API PacketDataHeader { + PacketDataHeader() + : version(1), packetType(UnknownPacket) { + unitOfMeasurement.ID = 0; + } + + PacketDataHeader(uint16_t version) + : version(version) + , packetType(UnknownPacket) { + unitOfMeasurement.ID = 0; + } + + uint16_t version; + PacketType packetType; + UOM unitOfMeasurement; + + bool setUOM(const char *type); + std::string uom(char fill = '\0') const; + + bool operator!=(const PacketDataHeader &other) const; + + int dataSize() const { + return sizeof(version) + sizeof((char)packetType) + + sizeof(unitOfMeasurement.ID); + } + + bool put(std::streambuf &buf) const { + Endianess::Writer put(buf); + + char type = char(packetType); + + put(version); + put(type); + put(unitOfMeasurement.ID); + + return put.good; + } + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + char type; + + get(version); + get(type); packetType = PacketType(type); + get(unitOfMeasurement.ID); + + return get.good; + } +}; + + +struct SC_GEMPA_CAPS_API PacketDataHeaderV2 : PacketDataHeader { + PacketDataHeaderV2() + : PacketDataHeader(2) + , samplingFrequencyNumerator(0) + , samplingFrequencyDenominator(0) {} + + uint16_t samplingFrequencyNumerator; + uint16_t samplingFrequencyDenominator; + Quality quality; + + bool operator!=(const PacketDataHeaderV2 &other) const; + + int dataSize() const { + return PacketDataHeader::dataSize() + + sizeof(samplingFrequencyNumerator) + + sizeof(samplingFrequencyDenominator) + + sizeof(quality); + } + + bool put(std::streambuf &buf) const { + Endianess::Writer put(buf); + + PacketDataHeader::put(buf); + + put(samplingFrequencyNumerator); + put(samplingFrequencyDenominator); + put(quality); + + return put.good; + } + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + PacketDataHeader::get(buf); + + get(samplingFrequencyNumerator); + get(samplingFrequencyDenominator); + get(quality); + + return get.good; + } +}; + + +enum StreamIDComponent { + NetworkCode = 0, + StationCode = 1, + LocationCode = 2, + ChannelCode = 3, + StreamIDComponentSize +}; + + +struct SC_GEMPA_CAPS_API PacketHeaderV1 { + uint8_t SIDSize[4]; /* number of bytes of stream ID components */ + uint16_t size; /* number of data bytes */ + + bool put(std::streambuf &buf) { + Endianess::Writer put(buf); + for ( int i = 0; i < 4; ++i ) + put(SIDSize[i]); + + put(size); + + return put.good; + } + + size_t dataSize() const { + return sizeof(uint8_t) * 4 + sizeof(size); + } +}; + +struct SC_GEMPA_CAPS_API PacketHeaderV2 { + uint8_t SIDSize[4]; /* number of bytes of stream ID components */ + uint32_t size; /* number of data bytes */ + + bool put(std::streambuf &buf) { + Endianess::Writer put(buf); + for ( int i = 0; i < 4; ++i ) + put(SIDSize[i]); + + put(size); + + return put.good; + } + size_t dataSize() const { + return sizeof(uint8_t) * 4 + sizeof(size); + } +}; + + +struct SC_GEMPA_CAPS_API ResponseHeader { + uint16_t id; + int32_t size; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + get(id); + get(size); + + return get.good; + } +}; + + +class SC_GEMPA_CAPS_API DataRecord { + public: + typedef std::vector Buffer; + + struct Header { + DataType dataType{DT_Unknown}; + TimeStamp samplingTime; + uint16_t samplingFrequencyNumerator; + uint16_t samplingFrequencyDenominator; + Quality quality{}; + + Header() = default; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + char dt; + get(dt); + dataType = (DataType)dt; + quality.ID = 0; // Quality is not yet part of the header stream + + get(samplingTime.year); + get(samplingTime.yday); + get(samplingTime.hour); + get(samplingTime.minute); + get(samplingTime.second); + get(samplingTime.usec); + get(samplingFrequencyNumerator); + get(samplingFrequencyDenominator); + + return get.good; + } + + bool put(std::streambuf &buf) const; + + int dataSize() const { + return sizeof(samplingTime.year) + + sizeof(samplingTime.yday) + + sizeof(samplingTime.hour) + + sizeof(samplingTime.minute) + + sizeof(samplingTime.second) + + sizeof(samplingTime.usec) + + sizeof(samplingFrequencyNumerator) + + sizeof(samplingFrequencyDenominator) + + sizeof(char); + } + + bool compatible(const Header &other) const; + bool operator!=(const Header &other) const; + + void setSamplingTime(const Time ×tamp); + }; + + enum ReadStatusCode { + RS_Error = 0, + RS_Complete = 1, + RS_Partial = 2, + RS_BeforeTimeWindow = 3, + RS_AfterTimeWindow = 4, + RS_Max + }; + + class ReadStatus { + public: + ReadStatus() {} + ReadStatus(ReadStatusCode code) : _code(code) {} + ReadStatus(const ReadStatus &other) : _code(other._code) {} + + public: + ReadStatus &operator=(const ReadStatus &other) { _code = other._code; return *this; } + operator ReadStatusCode() const { return _code; } + + private: + operator bool() { return _code != RS_Error; } + + private: + ReadStatusCode _code; + }; + + public: + virtual ~DataRecord(); + + virtual const char *formatName() const = 0; + + virtual bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, Time &endTime) = 0; + + //! Returns if data trimming is supported + virtual bool canTrim() const = 0; + + //! Returns if data merging is possible without modifying + //! preceding data + virtual bool canMerge() const = 0; + + //! Trims a record to start and end time. Trimming + //! should not modify any data but give access to trimmed + //! start and end times and the resulting data size. The trimming + //! also influences writing the record to a stream. + //! Trimming requires the resulting start time being greater + //! or equal than the requested start time. + //! (Un)Trimming to the original record is semantically + //! equal to passing an invalid start and end time. + //! It returns true if trimming has been done or false + //! if an error occured or trimming is not supported. + virtual bool trim(const Time &start, const Time &end) const = 0; + + //! Returns the data size in bytes if the current state would + //! be written to a stream. Trimming has also to be taken into + //! account while calculating the size. + virtual size_t dataSize(bool withHeader = true) const = 0; + + //! Reads the packet from a streambuf and trims the data + //! if possible to start and end. If maxBytes is greater + //! than 0 then the record should not use more than this + //! size of memory (in bytes). If not the complete record + //! has been read, RS_Partial must be returned, RS_Complete + //! otherwise. + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &start = Time(), const Time &end = Time(), + int maxBytes = -1) = 0; + + //! writes the packet to a streambuf and trims the data + //! if possible to start and end + virtual bool put(std::streambuf &buf, bool withHeader = true) const = 0; + + //! Returns the meta information of the data if supported + virtual const Header *header() const = 0; + + //! Returns the start time of the record + virtual Time startTime() const = 0; + + //! Returns the end time of the record + virtual Time endTime() const = 0; + + //! Returns the packet type of the record + virtual PacketType packetType() const = 0; + + /** + * @brief Returns the data vector to be filled by the caller + * @return The pointer to the internal buffer + */ + virtual Buffer *buffer() { return &_data; } + + /** + * @brief Returns pointer to raw data. If the record + * is compressed it will be uncompressed + * @return The pointer to the raw data + */ + virtual Buffer *data() { return &_data; } + + protected: + Buffer _data; +}; + +typedef boost::shared_ptr DataRecordPtr; + + +struct RawPacket { + PacketDataHeader header; + std::string SID[4]; + std::vector data; + DataRecord *record; +}; + +struct MetaPacket { + std::string SID[4]; + PacketDataHeader packetDataHeader; + DataRecord *record; + DataRecord::Header recordHeader; + Time startTime; + Time endTime; + Time timestamp; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/plugin.cpp b/libs/gempa/caps/plugin.cpp new file mode 100644 index 0000000..6149a91 --- /dev/null +++ b/libs/gempa/caps/plugin.cpp @@ -0,0 +1,1120 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include + +#ifdef WIN32 +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif + +#if !defined(CAPS_FEATURES_ANY) || CAPS_FEATURES_ANY +#include +#endif + +#if !defined(CAPS_FEATURES_MSEED) || CAPS_FEATURES_MSEED +#include +#endif + +#if !defined(CAPS_FEATURES_RAW) || CAPS_FEATURES_RAW +#include +#endif + +#if !defined(CAPS_FEATURES_RTCM2) || CAPS_FEATURES_RTCM2 +#include +#endif + +#include + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL +#include +#endif + +#include +#include +#include +#include +#include + + +using namespace std; + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL +namespace fs = boost::filesystem; +#endif + +//see, http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/deprecated.html +#if BOOST_FILESYSTEM_VERSION >= 3 + #define BOOST_FILESYSTEM_NO_DEPRECATED + + // path + #define FS_PATH(PATH_STR) boost::filesystem::path(PATH_STR) + #define FS_DECLARE_PATH(NAME, PATH_STR) \ + boost::filesystem::path NAME(PATH_STR); + + #define FS_HAS_PARENT_PATH(PATH) PATH.has_parent_path() + #define FS_PARENT_PATH(PATH) PATH.parent_path() + +#else + // path + #define FS_PATH(PATH_STR) boost::filesystem::path(PATH_STR,\ + boost::filesystem::native) + #define FS_DECLARE_PATH(NAME, PATH_STR) \ + boost::filesystem::path NAME(PATH_STR, boost::filesystem::native); + + #if BOOST_VERSION < 103600 + #define FS_HAS_PARENT_PATH(PATH) PATH.has_branch_path() + #define FS_PARENT_PATH(PATH) PATH.branch_path() + #else + #define FS_HAS_PARENT_PATH(PATH) PATH.has_parent_path() + #define FS_PARENT_PATH(PATH) PATH.parent_path() + #endif +#endif + +namespace { + +#define LOG_CHANNEL(out, fmt) \ + va_list ap;\ + va_start(ap, fmt);\ + fprintf(stderr, #out" "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n");\ + va_end(ap) + +void LogError(const char *fmt, ...) { + LOG_CHANNEL(ERROR, fmt); +} + +void LogWarning(const char *fmt, ...) { + LOG_CHANNEL(WARNING, fmt); +} + +void LogNotice(const char *fmt, ...) { + LOG_CHANNEL(NOTICE, fmt); +} + +void LogInfo(const char *fmt, ...) { + LOG_CHANNEL(INFO, fmt); +} + +void LogDebug(const char *fmt, ...) { + LOG_CHANNEL(DEBUG, fmt); +} + +} + +namespace Gempa { +namespace CAPS { + +namespace { + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL +bool createPath(const string &dir) { + try { + FS_DECLARE_PATH(path, dir) + fs::is_directory(path); + fs::create_directories(path); + return true; + } catch ( ... ) { + return false; + } +} +#endif + +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING +//void dump(const Plugin::BackfillingBuffer &buf) { +// Plugin::BackfillingBuffer::const_iterator it; +// int idx = 0; +// for ( it = buf.begin(); it != buf.end(); ++it, ++idx ) { +// std::cerr << idx << ": " << (*it)->record->startTime().iso() << std::endl; +// } +//} + +template void fillPacket(Packet *packet, uint16_t version) { + PacketDataHeader header; + header.packetType = packet->record->packetType(); + header.setUOM(packet->uom.c_str()); + + T packetHeader; + uint32_t size = packetHeader.dataSize(); + + size_t dataSize = packet->record->dataSize(); + + size += header.dataSize() + dataSize + + packet->networkCode.size() + + packet->stationCode.size() + + packet->locationCode.size() + + packet->channelCode.size(); + + Plugin::BufferPtr buf = Plugin::BufferPtr(new Plugin::Buffer()); + buf->resize(size); + + arraybuf abuf(buf->data(), buf->size()); + + packetHeader.size = dataSize; + packetHeader.SIDSize[NetworkCode] = packet->networkCode.size(); + packetHeader.SIDSize[StationCode] = packet->stationCode.size(); + packetHeader.SIDSize[LocationCode] = packet->locationCode.size(); + packetHeader.SIDSize[ChannelCode] = packet->channelCode.size(); + + header.version = version; + + header.put(abuf); + packetHeader.put(abuf); + + abuf.sputn(packet->networkCode.c_str(), packetHeader.SIDSize[NetworkCode]); + abuf.sputn(packet->stationCode.c_str(), packetHeader.SIDSize[StationCode]); + abuf.sputn(packet->locationCode.c_str(), packetHeader.SIDSize[LocationCode]); + abuf.sputn(packet->channelCode.c_str(), packetHeader.SIDSize[ChannelCode]); + + packet->record->put(abuf); + packet->buffer = buf; +} + +void insertPacket(Plugin::BackfillingBuffer &buf, PacketPtr packet) { + // Brute-force algorithm, should be replaced by something smarter such as + // binary search. A list might be the wrong container for that. + Plugin::BackfillingBuffer::iterator it; + size_t pos = 0; + for ( it = buf.begin(); it != buf.end(); ++it, ++pos ) { + if ( (*it)->record->endTime() > packet->record->endTime() ) { + buf.insert(it, packet); + CAPS_DEBUG("Backfilling buffer: packet inserted at pos: %lu, new " + "size: %lu, time window: %s~%s", (long unsigned) pos, + (long unsigned) buf.size(), + buf.front()->record->startTime().iso().c_str(), + buf.back()->record->endTime().iso().c_str()); + //dump(buf); + return; + } + } + + buf.push_back(packet); + + CAPS_DEBUG("Backfilling buffer: packet appended, new size: %lu, time window: %s~%s", + (long unsigned) buf.size(), + buf.front()->record->startTime().iso().c_str(), + buf.back()->record->endTime().iso().c_str()); + //dump(buf); +} +#endif + +Time getLastSampleTime(DataRecord *rec) { + if ( !rec ) { + return Time(); + } + + const DataRecord::Header *header = rec->header(); + if ( header->samplingFrequencyNumerator != 0 && + header->samplingFrequencyDenominator != 0 ) { + TimeSpan samplingInterval = header->samplingFrequencyDenominator / header->samplingFrequencyNumerator; + return rec->endTime() - samplingInterval; + } + + return rec->endTime(); +} + +} + +Plugin::Plugin(const string &name, const string &options, + const string &description) +: _name(name) +, _options(options) +, _description(description) +, _bufferSize(1 << 14) +, _bytesBuffered(0) +, _port(18003) +, _sendTimeout(60) +, _isExitRequested(false) +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + , _backfillingBufferSize(0) +#endif +{ + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + _lastWrite = Time::GMT(); + _journalDirty = false; + _flushInterval = 10; +#endif + _closed = false; + _wasConnected = false; + _ackTimeout = 5; + _lastAckTimeout = 5; + _encoderFactory = NULL; + _maxFutureEndTime = TimeSpan(120, 0); +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + _useSSL = false; +#endif +} + + +Plugin::~Plugin() { + if ( !_closed ) close(); + + setEncoderFactory(NULL); +} + + +void Plugin::close() { +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + _lastWrite = Time(); +#endif + _closed = true; + + for ( StreamStates::iterator it = _states.begin(); + it != _states.end(); ++it ) { + StreamState &state = it->second; + while ( !state.backfillingBuffer.empty() ) { + PacketPtr &ref_pkt = state.backfillingBuffer.front(); + state.lastCommitEndTime = ref_pkt->record->endTime(); + encodePacket(ref_pkt); + state.backfillingBuffer.pop_front(); + } + } + + flushEncoders(); + + sendBye(); + CAPS_INFO("Closing connection to CAPS at %s:%d", _host.c_str(), _port); + + while ( !_packetBuffer.empty() && readResponse(_lastAckTimeout) ); + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + updateJournal(); +#endif + + disconnect(); + CAPS_INFO("Closed connection to CAPS at %s:%d", _host.c_str(), _port); + + _packetBuffer.clear(); + _wasConnected = false; +} + +void Plugin::quit() { + _isExitRequested = true; +} + +bool Plugin::connect() { +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + _socket = SocketPtr(_useSSL ? new CAPS::SSLSocket() : new CAPS::Socket()); +#else + _socket = SocketPtr(new CAPS::Socket()); +#endif + + CAPS_INFO("Attempting to connect to CAPS at %s:%d", + _host.c_str(), _port); + if ( _socket->connect(_host, _port) != Socket::Success ) { + CAPS_ERROR("Connection failed to CAPS at %s:%d", _host.c_str(), _port); + return false; + } + + // Do handshake + if ( !_user.empty() && !_password.empty() ) { + string auth = "AUTH "+ _user + " " + _password + "\n"; + _socket->write(auth.c_str(), auth.length()); + } + + _socket->setNonBlocking(true); + + FD_ZERO(&_readFDs); + FD_ZERO(&_writeFDs); + + FD_SET(_socket->fd(), &_readFDs); + FD_SET(_socket->fd(), &_writeFDs); + + CAPS_INFO("Connected to CAPS at %s:%d", _host.c_str(), _port); + + _responseBuf[0] = '\0'; + _responseBufIdx = 0; + + bool result = true; + + // Disable packet flushing for the first connection establishment to + // avoid duplicate records + if ( _wasConnected && !flush() ) { + disconnect(); + result = false; + } + + _wasConnected = true; + + return result; +} + +void Plugin::disconnect() { + if ( _socket && _socket->isValid() ) { + CAPS_INFO("Disconnect from %s:%d", _host.c_str(), _port); + _socket->shutdown(); + _socket->close(); + + _responseBuf[0] = '\0'; + _responseBufIdx = 0; + } +} + +bool Plugin::isConnected() const { + return _socket && _socket->isValid(); +} + +bool Plugin::readResponse(unsigned int timeout) { + if ( !_socket || !_socket->isValid() ) return false; + + _socket->setNonBlocking(true); + + bool gotResponse = false; + + #define bufN 512 + char buf[bufN]; + + int res; + + if ( timeout > 0 ) { + struct timeval tv; + tv.tv_sec = timeout; + tv.tv_usec = 0; + + FD_ZERO(&_readFDs); + FD_SET(_socket->fd(), &_readFDs); + + res = select(_socket->fd() + 1, &_readFDs, NULL, NULL, &tv); + if ( res <= 0 ) + return gotResponse; + } + + while ( true ) { + res = _socket->read(buf, bufN); + if ( res < 0 ) { + if ( errno != EAGAIN && errno != EWOULDBLOCK ) { + CAPS_ERROR("Reading failed: %s: disconnect", strerror(errno)); + disconnect(); + } + break; + } + else if ( res == 0 ) { + CAPS_INFO("Peer closed connection"); + disconnect(); + break; + } + + char *in = buf; + // Parse the input buffer into the line buffer + for ( int i = 0; i < res; ++i, ++in ) { + if ( *in == '\n' ) { + _responseBuf[_responseBufIdx] = '\0'; + + // Handle line + if ( (strncasecmp(_responseBuf, "OK ", 3) == 0) && (_responseBufIdx > 3) ) { + // Got OK response + // Read confirmed packets from response + int count = atoi(_responseBuf+3); + + CAPS_DEBUG("Acknowledged %d packets, %d in queue", count, (int)_packetBuffer.size()); + // Update packet buffer + for ( int i = 0; i < count; ++i ) { + if ( _packetBuffer.empty() ) { + CAPS_ERROR("Synchronization error: more packages acknowledged than in queue"); + break; + } + + PacketPtr packet = _packetBuffer.front(); + _states[packet->streamID].lastEndTime = packet->record->endTime(); + _packetBuffer.pop_front(); + _bytesBuffered -= packet->record->dataSize(); + _packetBufferDirty = true; +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + _journalDirty = true; +#endif + gotResponse = true; + + CAPS_DEBUG("Packet acknowledged by CAPS, stream: %s' time window: %s~%s", + packet->streamID.c_str(), packet->record->startTime().iso().c_str(), + packet->record->endTime().iso().c_str()); + + if ( _packetAckFunc ) { + _packetAckFunc(packet->streamID, packet->record->startTime(), packet->record->endTime()); + } + } + + CAPS_DEBUG("Packet buffer state: %d packets, %d bytes", + (int)_packetBuffer.size(), (int)_bytesBuffered); + } + + _responseBuf[0] = '\0'; + _responseBufIdx = 0; + } + else { + _responseBuf[_responseBufIdx] = *in; + ++_responseBufIdx; + } + } + + if ( _packetBuffer.empty() ) break; + } + + return gotResponse; +} + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL +void Plugin::updateJournal() { + Time currentTime = Time::GMT(); + if ( !_journalFile.empty() && _journalDirty && + _lastWrite + TimeSpan(_flushInterval) <= currentTime ) { + writeJournal(); + _journalDirty = false; + _lastWrite = currentTime; + } +} + +bool Plugin::readJournal() { + if ( _journalFile.empty() ) return false; + + ifstream ifs; + ifs.open(_journalFile.c_str()); + + return readJournal(ifs); +} + +bool Plugin::readJournal(istream &is) { + _states.clear(); + + string streamID, strTime; + string line; + Time time; + int lineNumber = 0; + + Time now = Time::GMT(); + Time maxAllowedEndTime = now + TimeSpan(86400); + while ( getline(is, line) ) { + ++lineNumber; + + size_t p = line.find(' '); + if ( p == string::npos ) + streamID = trim(line); + else { + streamID = trim(line.substr(0, p)); + strTime = trim(line.substr(p+1)); + } + + if ( !strTime.empty() ) { + if ( !time.fromString(strTime.c_str(), "%FT%T.%fZ") ) { + CAPS_ERROR("journal:%d: Invalid time: %s", lineNumber, strTime.c_str()); + return false; + } + } + else + time = Time(); + + if ( time > maxAllowedEndTime ) { + CAPS_WARNING("journal:%d:%s: Timestamp %s is more than one day " + "ahead of current time, respecting it nevertheless.", + lineNumber, streamID.c_str(), time.iso().c_str()); + } + + _states[streamID].lastEndTime = time; + } + + return true; +} +#endif + +bool Plugin::flush() { + CAPS_INFO("Flushing %d queued packets", (int)_packetBuffer.size()); + + PacketBuffer::iterator it = _packetBuffer.begin(); + while ( it != _packetBuffer.end() && !_isExitRequested ) { + PacketPtr packet = *it; + _packetBufferDirty = false; + + if ( !sendPacket(packet.get() ) && !_isExitRequested ) { + if ( _packetBufferDirty ) { + CAPS_ERROR("Uh oh, buffer dirty but sending failed!"); + } + + return false; + } + + if ( readResponse() ) { +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + updateJournal(); +#endif + } + + if ( _packetBufferDirty ) { + it = std::find(_packetBuffer.begin(), _packetBuffer.end(), packet); + if ( it != _packetBuffer.end() ) + ++it; + else { + CAPS_DEBUG("Last packet removed, reset flush queue iterator"); + it = _packetBuffer.begin(); + } + } + else + ++it; + } + + return true; +} + +void Plugin::flushEncoders() { + CAPS_INFO("Flushing %d encoders", (int)_encoderItems.size()); + EncoderItems::iterator it = _encoderItems.begin(); + while ( it != _encoderItems.end() ) { + Encoder *encoder = it->second.encoder.get(); + if ( encoder ) { + encoder->flush(); + + PacketPtr encodedPacket; + while ( (encodedPacket = encoder->pop()) ) { + commitPacket(encodedPacket); + } + } + + it++; + } +} + +Plugin::Status Plugin::push(const string &net, const string &sta, + const string &loc, const string &cha, + const Time &stime, + uint16_t numerator, uint16_t denominator, + const string &uom, + void *data, size_t count, DataType dt, + int timingQuality) { + uint8_t dtSize = dataTypeSize(dt); + if ( dtSize == 0 ) return Plugin::PacketLoss; + + RawDataRecord *rec = new RawDataRecord(); + rec->setStartTime(stime); + rec->setSamplingFrequency(numerator, denominator); + rec->setDataType(dt); + rec->setBuffer((char*)data, dtSize * count); + + return push(net, sta, loc, cha, DataRecordPtr(rec), uom, timingQuality); +} + +#if !defined(CAPS_FEATURES_ANY) || CAPS_FEATURES_ANY +Plugin::Status Plugin::push(const string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, uint16_t numerator, + uint16_t denominator, const std::string &format, + char *data, size_t count) { + AnyDataRecord *rec = new AnyDataRecord; + rec->setStartTime(stime); + rec->setEndTime(stime); + rec->setSamplingFrequency(numerator, denominator); + rec->setType(format.c_str()); + rec->setData(data, count); + + return push(net, sta, loc, cha, DataRecordPtr(rec), "px"); +} + +Plugin::Status Plugin::push(const string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, uint16_t numerator, + uint16_t denominator, const std::string &format, + const std::string &str) { + return push(net, sta, loc, cha, stime, numerator, denominator, format, + const_cast(&str[0]), str.size()); +} +#endif + +void Plugin::tryFlushBackfillingBuffer(StreamState &state) { + if ( state.backfillingBuffer.empty() ) + return; + + size_t flushed = 0; + while ( !state.backfillingBuffer.empty() ) { + PacketPtr &ref_pkt = state.backfillingBuffer.front(); + + TimeSpan gap = ref_pkt->record->startTime() - state.lastCommitEndTime; + int64_t dt_us = (int64_t)gap.seconds()*1000000+gap.microseconds(); + + // A gap larger than one sample? + if ( dt_us >= ref_pkt->dt_us ) break; + + state.lastCommitEndTime = ref_pkt->record->endTime(); + encodePacket(ref_pkt); + state.backfillingBuffer.pop_front(); + ++flushed; + //dump(state.backfillingBuffer); + } + + if ( flushed > 0 ) { + if ( state.backfillingBuffer.size() > 0 ) { + CAPS_DEBUG("backfilling buffer: %lu pakets flushed, new size: %lu, time window: %s~%s", + (long unsigned) flushed, + (long unsigned) state.backfillingBuffer.size(), + state.backfillingBuffer.front()->record->startTime().iso().c_str(), + state.backfillingBuffer.back()->record->endTime().iso().c_str()); + } + else { + CAPS_DEBUG("backfilling buffer: %lu pakets flushed, new size: 0", + (long unsigned) flushed); + } + } +} + +void Plugin::trimBackfillingBuffer(StreamState &state) { + if ( state.backfillingBuffer.empty() ) + return; + + size_t trimmed = 0; + while ( !state.backfillingBuffer.empty() ) { + TimeSpan diff = state.backfillingBuffer.back()->record->endTime() - + state.backfillingBuffer.front()->record->startTime(); + if ( diff.seconds() <= _backfillingBufferSize ) + break; + + PacketPtr &ref_pkt = state.backfillingBuffer.front(); + state.lastCommitEndTime = ref_pkt->record->endTime(); + encodePacket(ref_pkt); + state.backfillingBuffer.pop_front(); + } + + if ( trimmed > 0 ) { + if ( state.backfillingBuffer.size() > 0 ) { + CAPS_DEBUG("backfilling buffer: %lu pakets trimmed, new size: %lu, time window: %s~%s", + (long unsigned) trimmed, + (long unsigned) state.backfillingBuffer.size(), + state.backfillingBuffer.front()->record->startTime().iso().c_str(), + state.backfillingBuffer.back()->record->endTime().iso().c_str()); + } + else { + CAPS_DEBUG("backfilling buffer: %lu pakets trimmed, new size: 0", + (long unsigned) trimmed); + } + } +} + +Plugin::Status Plugin::push(const string &net, const string &sta, + const string &loc, const string &cha, + DataRecordPtr rec, const string &uom, + int timingQuality) { + static bool showVersion = true; + if ( showVersion ) { + CAPS_NOTICE("LIB CAPS version %s", version()); + showVersion = false; + } + + if ( rec == NULL ) return PacketNotValid; + if ( rec->dataSize() > _bufferSize ) return PacketSize; + + if ( !rec->endTime().valid() ) return PacketNotValid; + + Time endTime = getLastSampleTime(rec.get()); + Time maxAllowedEndTime = Time::GMT() + TimeSpan(_maxFutureEndTime); + if ( endTime > maxAllowedEndTime ) { + CAPS_WARNING("%s.%s.%s.%s: Future time stamp detected: Packet end time %s exceeds " + "max allowed end time %s. Discard packet.", + net.c_str(), sta.c_str(), loc.c_str(), cha.c_str(), + rec->endTime().iso().c_str(), + maxAllowedEndTime.iso().c_str()); + return MaxFutureEndTimeExceeded; + } + + const DataRecord::Header *header = rec->header(); + PacketPtr packet(new Packet(rec, net, sta, loc, cha)); + packet->uom = uom; + packet->dataType = header->dataType; + packet->timingQuality = timingQuality; +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + if ( header->samplingFrequencyNumerator == 0 ) { + CAPS_DEBUG("detected division by zero, invalid sampling frequency numerator"); + return PacketNotValid; + } + + packet->dt_us = ((int64_t)header->samplingFrequencyDenominator * 1000000) / + header->samplingFrequencyNumerator; +#endif + + StreamState &state = _states[packet->streamID]; + +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + // If buffering is enabled + if ( _backfillingBufferSize > 0 ) { + if ( state.lastCommitEndTime.valid() ) { + int64_t dt_us = ((int64_t)rec->header()->samplingFrequencyDenominator * 1000000) / + rec->header()->samplingFrequencyNumerator; + TimeSpan gap = packet->record->startTime() - state.lastCommitEndTime; + + // A gap larger than one sample? + if ( ((int64_t)gap.seconds()*1000000+gap.microseconds()) >= dt_us ) { + CAPS_DEBUG("detected gap on stream: %s", packet->streamID.c_str()); + insertPacket(state.backfillingBuffer, packet); + trimBackfillingBuffer(state); + tryFlushBackfillingBuffer(state); + return Success; + } + } + + if ( !encodePacket(packet) ) + return PacketLoss; + + if ( rec->endTime() > state.lastCommitEndTime) { + state.lastCommitEndTime = rec->endTime(); + } + + tryFlushBackfillingBuffer(state); + } + else { +#endif + if ( !encodePacket(packet) ) + return PacketLoss; +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + } +#endif + + return Success; +} + +void Plugin::serializePacket(Packet *packet) { + if ( packet->buffer ) return; + + size_t dataSize = packet->record->dataSize(); + bool isV1 = dataSize < (1 << 16); + if ( isV1 ) { + fillPacket(packet, 1); + } + else { + fillPacket(packet, 2); + } +} + +bool Plugin::commitPacket(PacketPtr packet) { + // Initial connect + if ( !_wasConnected && !_socket ) { + while ( !connect() && !_isExitRequested ) { + disconnect(); + wait(); + } + + if ( !isConnected() ) return false; + } + + if ( _bytesBuffered >= _bufferSize ) { + CAPS_DEBUG("Packet buffer is full (%ld/%ld bytes), " + "waiting for server ack messages", + _bytesBuffered, _bufferSize); + + while ( _bytesBuffered >= _bufferSize ) { + if ( !readResponse(_ackTimeout) ) { + disconnect(); + while ( !_isExitRequested && !_socket->isValid() ) { + wait(); + disconnect(); + connect(); + } + + if ( _isExitRequested ) + break; + } + } + + CAPS_DEBUG("%ld/%ld bytes buffered after force wait", + _bytesBuffered, _bufferSize); + + if ( _bytesBuffered >= _bufferSize ) + return false; + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + CAPS_DEBUG("Force journal update"); +#endif + } + + // Serialize data record + serializePacket(packet.get()); + + CAPS_DEBUG("+ buffer state: %d packets, %d bytes", + (int)_packetBuffer.size(), (int)_bytesBuffered); + + while ( !sendPacket(packet.get() ) ) { + CAPS_ERROR("Sending failed: %s", _isExitRequested ? "abort" : "reconnect"); + + readResponse(); + disconnect(); + + while ( !_isExitRequested && !isConnected() ) { + wait(); + disconnect(); + connect(); + } + + if ( !isConnected() ) + return false; + } + + _packetBuffer.push_back(packet); + _bytesBuffered += packet->record->dataSize(); + + _stats.maxBytesBuffered = max(_bytesBuffered, _stats.maxBytesBuffered); + + if ( readResponse() ) { +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + updateJournal(); +#endif + } + + return true; +} + +Encoder* Plugin::getEncoder(PacketPtr packet) { + EncoderItems::iterator it = _encoderItems.find(packet->streamID); + if ( it == _encoderItems.end() ) { + EncoderItem item; + it = _encoderItems.insert(make_pair(packet->streamID, item)).first; + } + + DataRecord *record = packet->record.get(); + const DataRecord::Header *header = record->header(); + + EncoderItem *item = &it->second; + if ( item->encoder != NULL ) { + /* Before we can feed data into the encoder we + have to check if the sampling frequency + or data type have been changed. Also gaps + must be handled. + */ + const SPClock &clk = item->encoder->clk(); + bool needsFlush = false; + if( clk.freqn != header->samplingFrequencyNumerator || + clk.freqd != header->samplingFrequencyDenominator ) { + needsFlush = true; + } + else if ( record->startTime() != clk.get_time(0) ) { + needsFlush = true; + } + else if ( item->dataType != header->dataType ) { + needsFlush = true; + } + else if ( item->encoder->timingQuality() != packet->timingQuality ) { + needsFlush = true; + } + + if ( needsFlush ) { + item->encoder->flush(); + + PacketPtr encodedPacket; + while ( (encodedPacket = item->encoder->pop()) ) { + // TODO check return value? + commitPacket(encodedPacket); + } + + item->encoder = EncoderPtr(); + } + } + + if ( item->encoder == NULL ) { + Encoder *encoder = + _encoderFactory->create(packet->networkCode, packet->stationCode, + packet->locationCode, packet->channelCode, + header->dataType, + header->samplingFrequencyNumerator, + header->samplingFrequencyDenominator); + if ( encoder != NULL ) { + encoder->setStartTime(record->startTime()); + encoder->setTimingQuality(packet->timingQuality); + item->encoder = EncoderPtr(encoder); + item->dataType = header->dataType; + } + } + + return item->encoder.get(); +} + +bool Plugin::encodePacket(PacketPtr packet) { + if ( _encoderFactory == NULL || + !_encoderFactory->supportsRecord(packet->record.get()) ) + return commitPacket(packet); + + Buffer *buffer = packet->record->data(); + if ( buffer == NULL ) return commitPacket(packet); + + Encoder *encoder = getEncoder(packet); + if ( encoder == NULL ) return commitPacket(packet); + + for ( size_t i = 0; i < buffer->size(); i = i + dataTypeSize(packet->dataType) ) { + char *data = buffer->data() + i; + encoder->push(data); + } + + PacketPtr encodedPacket; + while ( (encodedPacket = encoder->pop()) ) { + // TODO check return value? + commitPacket(encodedPacket); + } + + return true; +} + +void Plugin::setEncoderFactory(EncoderFactory *factory) { + if ( _encoderFactory ) { + delete _encoderFactory; + _encoderFactory = NULL; + } + + _encoderFactory = factory; +} + +void Plugin::sendBye() { + if ( _socket == NULL ) return; + + PacketDataHeader header; + memset((char*)&header, 0, header.dataSize()); + _socket->setNonBlocking(false); + + send((char*)&header, header.dataSize(), _sendTimeout); +} + + +bool Plugin::sendPacket(Packet *packet) { + if ( !_packetBuffer.empty() ) { + readResponse(); +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + updateJournal(); +#endif + } + + // Send packet data header and packet header + _socket->setNonBlocking(false); + + // Instead of directly write data to the socket we call + // a wrapper function that checks if we can write data or not. + // If we do not do the check the system send operation + // hangs when the TCP buffer is full and the connection is + // is in a undefined state. + // The check and the system send operation run in a loop until + // the data has been sent successfully or the user requests to + // to stop => The function call might block. + if ( !send(packet->buffer->data(), packet->buffer->size(), _sendTimeout) ) { + return false; + } + + CAPS_DEBUG("Packet sent to CAPS, stream: %s, time window: %s~%s", + packet->streamID.c_str(), packet->record->startTime().iso().c_str(), + packet->record->endTime().iso().c_str()); + + return true; +} + +void Plugin::wait() { + // Wait 5 seconds and keep response latency low + for ( int i = 0; (i < 10) && !_isExitRequested; ++i ) + usleep(500000); +} + + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL +bool Plugin::writeJournal() { + //if ( _states.empty() ) return true; + + if ( !_journalFile.empty() ) { + FS_DECLARE_PATH(path, _journalFile) + + string filename = ".journal.tmp"; + if ( FS_HAS_PARENT_PATH(path) ) { + createPath(FS_PARENT_PATH(path).string()); + filename = (FS_PARENT_PATH(path) / FS_PATH(filename)).string(); + } + + ofstream ofs(filename.c_str()); + if ( !ofs.is_open() ) return false; + + if ( writeJournal(ofs) ) { + ofs.close(); + if ( FS_HAS_PARENT_PATH(path) ) { + createPath(FS_PARENT_PATH(path).string()); + } + + if ( rename(filename.c_str(), path.string().c_str()) != 0 ) + CAPS_ERROR("Failed to create journal %s, %s(%d)", _journalFile.c_str(), + strerror(errno), errno); + } + else { + ofs.close(); + + try { + fs::remove(filename); + } + catch ( ... ) {} + } + } + else + return writeJournal(cout); + + return false; +} + +bool Plugin::writeJournal(ostream &os) { + for ( StreamStates::iterator it = _states.begin(); + it != _states.end(); ++it ) { + os << it->first << " " << it->second.lastEndTime.iso() << endl; + + if ( !os.good() ) return false; + } + + return true; +} + +#endif + +void Plugin::enableLogging() { + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_ERROR, LogError); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_WARNING, LogWarning); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_NOTICE, LogNotice); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_INFO, LogInfo); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_DEBUG, LogDebug); +} + +bool Plugin::send(char *data, int len, int timeout) { + if ( !_socket->isValid() ) + return false; + + struct timeval tv; + tv.tv_sec = timeout; + tv.tv_usec = 0; + + FD_ZERO(&_writeFDs); + FD_SET(_socket->fd(), &_writeFDs); + + int res = select(_socket->fd() + 1, NULL, &_writeFDs, NULL, &tv); + if ( res > 0 ) { + res = _socket->write(data, len); + if ( res == len ) { + return true; + } + else if ( res == -1 ) { + CAPS_ERROR("Failed to send data: %s. " + "Forcing reconnect and trying to send data again.", + strerror(errno)); + } + else { + CAPS_ERROR("Incomplete send operation: " + "Only %d/%d bytes have been sent. " + "Forcing reconnect and trying to send data again.", + len, res); + } + } + else if ( !res ) { + CAPS_ERROR("Detected hanging TCP connection. " + "Forcing reconnect and trying to send data again."); + } + else { + CAPS_ERROR("Send error: %s", strerror(errno)); + } + + return false; +} + +} +} diff --git a/libs/gempa/caps/plugin.h b/libs/gempa/caps/plugin.h new file mode 100644 index 0000000..5a36a28 --- /dev/null +++ b/libs/gempa/caps/plugin.h @@ -0,0 +1,324 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_PLUGIN_H +#define GEMPA_CAPS_PLUGIN_H + +/* +// Enable/disable journal +#define CAPS_FEATURES_JOURNAL 1 +// Enable/disable backfilling of packets +#define CAPS_FEATURES_BACKFILLING 1 +#define CAPS_FEATURES_SSL 1 + +// Supportted CAPS packets +#define CAPS_FEATURES_ANY 1 +#define CAPS_FEATURES_MSEED 1 +#define CAPS_FEATURES_RAW 1 +#define CAPS_FEATURES_RTCM2 1 +*/ + +#include "encoderfactory.h" + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + + + +namespace Gempa { +namespace CAPS { + +class SC_GEMPA_CAPS_API Plugin { + public: + enum Status { + Success, + PacketSize, /* Packet is bigger than the buffer size */ + PacketLoss, /* The other end didn't acknowledge + transmitted data after some time */ + PacketNotValid, /* Read meta data failed*/ + PacketNotSupported, + MaxFutureEndTimeExceeded + }; + + struct Stats { + Stats() : maxBytesBuffered(0) {} + size_t maxBytesBuffered; + }; + + typedef std::vector Buffer; + typedef boost::shared_ptr BufferPtr; + +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + typedef std::list BackfillingBuffer; + +#endif + struct StreamState { + Time lastEndTime; +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + Time lastCommitEndTime; + BackfillingBuffer backfillingBuffer; +#endif + }; + + typedef std::map StreamStates; + + typedef boost::function PacketAckFunc; + + + public: + Plugin(const std::string &name, const std::string &options = "", + const std::string &description = ""); + ~Plugin(); + + void close(); + void quit(); + + void enableLogging(); + +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + void setBackfillingBufferSize(int secs) { _backfillingBufferSize = secs; } + int backfillingBufferSize() const { return _backfillingBufferSize; } + +#endif + + /** + * @brief Returns whether the plugin has been + * requested to quit or not. + * @return True, if the plugin has been requested to quit. + */ + bool isExitRequested() { + return _isExitRequested; + } + + /** + * @brief Returns the stat object + * @return The stat object + */ + const Stats& stats() const { + return _stats; + } + + /** + * @brief Resets the max bytes buffered counter + */ + void resetMaxBytesBuffered() { + _stats.maxBytesBuffered = 0; + } + + /** + * @brief Sets the encoder factory used to created encoders for packet + * encoding, e.g. miniSEED. + * @param factory The ownership of the factory goes to the plugin and + * will be deleted if necessary. + */ + void setEncoderFactory(EncoderFactory *factory); + + void setHost(const std::string &host) { _host = host; } + const std::string &host() const { return _host; } + + void setPort(unsigned short port) { _port = port; } + unsigned short port() const { return _port; } + + void setBufferSize(size_t bufferSize) { _bufferSize = bufferSize; } + size_t bufferSize() const { return _bufferSize; } + + //! Enables SSL feature +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + void setSSLEnabled(bool enable) { _useSSL = enable; } +#endif + + /** + * @brief Sets username and password + * @param user The username + * @param password The password + */ + void setCredentials(const std::string &user, const std::string &password) { + _user = user; + _password = password; + } + + /** + * @brief Sets the maximum allowed relative end time for packets. If + * the packet end time is greater than the current time plus this + * value the packet will be discarded. By default this value is + * set to 120 seconds. + * @param time The time span + */ + void setMaxFutureEndTime(const TimeSpan &span) { + _maxFutureEndTime = span; + } + + void setPacketAckFunc(const PacketAckFunc &func) { _packetAckFunc = func; } + + void setSendTimeout(int timeout) { + _sendTimeout = timeout; + } + + void setTimeouts(int ack, int lastAck) { + _ackTimeout = ack; + _lastAckTimeout = lastAck; + } + + void setTimeouts(int ack, int lastAck, int send) { + _ackTimeout = ack; + _lastAckTimeout = lastAck; + _sendTimeout = send; + } + +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + bool readJournal(); + void setJournal(const std::string &filename) { _journalFile = filename; } + void setFlushInterval(int interval) { _flushInterval = interval; } + + const StreamStates &streamStates() const { return _states; } + bool writeJournal(); + bool writeJournal(std::ostream &ostream); +#endif + Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + DataRecordPtr rec, const std::string &uom, + int timingQuality = -1); + + Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, + uint16_t numerator, uint16_t denominator, + const std::string &uom, + void *data, size_t count, + DataType dt, int timingQuality = -1); + + /* + * Sends given data as any packet. Before sending the data will be + * copied into an internal buffer. We introduced this method + * to simplify the creation of the python wrappers. + */ +#if !defined(CAPS_FEATURES_ANY) || CAPS_FEATURES_ANY + Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, uint16_t numerator, + uint16_t denominator, const std::string &format, + char *data, size_t count); + + Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, uint16_t numerator, + uint16_t denominator, const std::string &format, + const std::string &data); +#endif + + const char *version() { + return LIB_CAPS_VERSION_NAME; + } + + private: + typedef std::deque PacketBuffer; + typedef boost::shared_ptr EncoderPtr; + + struct EncoderItem { + EncoderItem() : dataType(DT_Unknown) {} + EncoderPtr encoder; + DataType dataType; + }; + typedef std::map EncoderItems; + + private: + bool connect(); + void disconnect(); + bool isConnected() const; + Encoder* getEncoder(PacketPtr packet); + bool readResponse(unsigned int sec = 0); +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + bool readJournal(std::istream &istream); + void updateJournal(); +#endif + void sendBye(); + bool commitPacket(PacketPtr packet); + bool encodePacket(PacketPtr packet); + bool sendPacket(Packet *packet); + void serializePacket(Packet *packet); + void tryFlushBackfillingBuffer(StreamState &state); + void trimBackfillingBuffer(StreamState &state); + bool flush(); + void flushEncoders(); + bool send(char *data, int len, int timeout = 60); + void wait(); + + private: + SocketPtr _socket; + std::string _name; + std::string _options; + std::string _description; + size_t _bufferSize; + StreamStates _states; + PacketBuffer _packetBuffer; + bool _packetBufferDirty; + size_t _bytesBuffered; + std::string _host; + unsigned short _port; + char _responseBuf[512]; + int _responseBufIdx; + fd_set _readFDs; + fd_set _writeFDs; + int _sendTimeout; +#if !defined(CAPS_FEATURES_JOURNAL) || CAPS_FEATURES_JOURNAL + std::string _journalFile; + bool _journalDirty; + Time _lastWrite; + int _flushInterval; +#endif + bool _isExitRequested; + bool _closed; + bool _wasConnected; +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + int _backfillingBufferSize; +#endif + int _ackTimeout; + int _lastAckTimeout; + + EncoderFactory *_encoderFactory; + EncoderItems _encoderItems; + + PacketAckFunc _packetAckFunc; + + std::string _user; + std::string _password; +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + bool _useSSL; +#endif + Stats _stats; + TimeSpan _maxFutureEndTime; +}; + +typedef boost::shared_ptr PluginPtr; + +} +} + + +#endif diff --git a/libs/gempa/caps/pluginapplication.cpp b/libs/gempa/caps/pluginapplication.cpp new file mode 100644 index 0000000..452430a --- /dev/null +++ b/libs/gempa/caps/pluginapplication.cpp @@ -0,0 +1,383 @@ +/*************************************************************************** + * Copyright (C) 2015 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#define SEISCOMP_COMPONENT PluginApplication + +#include +#include +#include +#include + +#include +#include + +#include + +#ifdef SC_GEMPA_SEATTLE +#include +#else +#include +#endif + +using namespace std; + +namespace sc = Seiscomp::Core; + +namespace { + +#ifdef SEISCOMP_LOG_VA +#define LOG_CAPS_CHANNEL(out, fmt) \ + va_list ap;\ + va_start(ap, fmt);\ + out(fmt, ap);\ + va_end(ap) +#else +#define LOG_CAPS_CHANNEL(out, fmt) \ + va_list ap;\ + va_start(ap, fmt);\ + fprintf(stderr, #out" "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n");\ + va_end(ap) +#endif + + +void LogError(const char *fmt, ...) { + LOG_CAPS_CHANNEL(SEISCOMP_VERROR, fmt); +} + +void LogWarning(const char *fmt, ...) { + LOG_CAPS_CHANNEL(SEISCOMP_VWARNING, fmt); +} + +void LogNotice(const char *fmt, ...) { + LOG_CAPS_CHANNEL(SEISCOMP_VNOTICE, fmt); +} + +void LogInfo(const char *fmt, ...) { + LOG_CAPS_CHANNEL(SEISCOMP_VINFO, fmt); +} + +void LogDebug(const char *fmt, ...) { + LOG_CAPS_CHANNEL(SEISCOMP_VDEBUG, fmt); +} + +const size_t MIN_BUFFER_SIZE = 1024*16; +const uint16_t DEFAULT_PORT = 18003; + +} + +namespace Gempa { +namespace CAPS { + +PluginApplication::PluginApplication(int argc, char **argv, const string &desc) +: Seiscomp::Client::StreamApplication(argc, argv) +, _plugin(Plugin(desc)) { + _bufferSize = 1 << 20; + _backfillingBufferSize = 180; + _flushInterval = 10; + _ackTimeout = 60; + _lastAckTimeout = 5; + _sendTimeout = 60; + _logStatus = false; + _statusFlushInterval = 10; + + _host = "localhost"; + _port = DEFAULT_PORT; + + _strAddr = "localhost:" + sc::toString(DEFAULT_PORT); + + SC_FS_DECLARE_PATH(path, "@ROOTDIR@/var/run/" + SCCoreApp->name() + "/journal"); + _journalFile = path.string(); + + _mseedEnabled = false; + _mseedEncoding = Steim2; + _mseedRecordLength = 9; + _strMseedEncoding = "Steim2"; + _maxFutureEndTime = 120; + + // By default we disable the acquisition autostart because not all plugins + // require this feature. It must be enabled explicitly if required. + setAutoAcquisitionStart(false); +} + +void PluginApplication::createCommandLineDescription() { + Seiscomp::Client::StreamApplication::createCommandLineDescription(); + commandline().addGroup("Output"); + commandline().addOption("Output", "addr,a", "Data output address, format is [HOST:PORT]", &_strAddr); + commandline().addOption("Output", "buffer-size,b", "Size (bytes) of the packet buffer", &_bufferSize); + commandline().addOption("Output", "backfilling", + "Enable backfilling for out-of-order records. The backfilling buffer size is " + "in seconds", &_backfillingBufferSize); + commandline().addOption("Output", "mseed", "Enable on-the-fly MiniSeed " + "encoding. If the encoder does not support the input" + "type of a packet it will be forwarded. Re encoding of" + "MiniSEED packets is not supported."); + commandline().addOption("Output", "encoding", "MiniSEED encoding to use. (Uncompressed, Steim1 or Steim2)", + &_strMseedEncoding); + commandline().addOption("Output", "rec-len", "MiniSEED record length expressed as a power of 2." + "A 512 byte record would be 9.", + &_mseedRecordLength); + commandline().addOption("Output", "max-future-endtime", "Maximum allowed relative end time for packets. If " + "the packet end time is greater than the current time plus this " + "value the packet will be discarded. By default this value is set to 120 seconds.", + &_maxFutureEndTime); + commandline().addGroup("Journal"); + commandline().addOption("Journal", "journal,j", + "File to store stream states. Use an empty string to disable this feature.", &_journalFile); + commandline().addOption("Journal", "flush", + "Flush stream states every n seconds to disk", &_flushInterval); + commandline().addOption("Journal", "wait-for-ack", + "Wait when a sync has been forced, up to n seconds", &_ackTimeout); + commandline().addOption("Journal", "wait-for-last-ack,w", + "Wait on shutdown to receive acknownledgement messages, up to n seconds", &_lastAckTimeout); + + commandline().addGroup("Status"); + commandline().addOption("Status", "status-log", "Log information status " + "information e.g. max bytes buffered"); + commandline().addOption("Status", "status-flush", "Flush status every n " + "seconds to disk", + &_statusFlushInterval); +} + +void PluginApplication::done() { + LogInfo("Statistics of transmitted data:\n" + " records : %d\n" + " samples : %d\n" + " gaps : %d\n" + " start time: %s\n" + " end time : %s\n" + " files : %d", + _stats.records, _stats.samples, _stats.gaps, + _stats.startTime.valid()?_stats.startTime.iso().c_str():"", + _stats.endTime.valid()?_stats.endTime.iso().c_str():"", + _stats.files); + + Seiscomp::Client::StreamApplication::done(); +} + +void PluginApplication::exit(int returnCode) { + Seiscomp::Client::StreamApplication::exit(returnCode); + + _plugin.quit(); +} + +void PluginApplication::handleTimeout() { + sc::Time time = sc::Time::GMT().toLocalTime(); + + Plugin::Stats stats = _plugin.stats(); + _statusFile.stream() << time.toString("%Y/%m/%d %T") << " " << stats.maxBytesBuffered << endl; + + + _plugin.resetMaxBytesBuffered(); +} + +bool PluginApplication::init() { + if ( !Seiscomp::Client::StreamApplication::init() ) return false; + + // Setup log handlers + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_ERROR, LogError); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_WARNING, LogWarning); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_NOTICE, LogNotice); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_INFO, LogInfo); + Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_DEBUG, LogDebug); + + _plugin.setHost(_host); + _plugin.setPort(_port); + _plugin.setBufferSize(_bufferSize); + _plugin.setFlushInterval(_flushInterval); + _plugin.setTimeouts(_ackTimeout, _lastAckTimeout, _sendTimeout); + _plugin.setMaxFutureEndTime(_maxFutureEndTime); + + if ( _mseedEnabled ) { + MSEEDEncoderFactory *factory = nullptr; + if ( _mseedEncoding == Uncompressed ) { + SEISCOMP_INFO("Output stream encoding set to MiniSEED/Uncompressed"); + factory = new IdentityEncoderFactory(); + _plugin.setEncoderFactory(factory); + } + else if ( _mseedEncoding == Steim1 ) { + SEISCOMP_INFO("Output stream encoding set to MiniSEED/Steim1"); + factory = new Steim1EncoderFactory(); + _plugin.setEncoderFactory(factory); + } + if ( _mseedEncoding == Steim2 ) { + SEISCOMP_INFO("Output stream encoding set to MiniSEED/Steim2"); + factory = new Steim2EncoderFactory(); + _plugin.setEncoderFactory(factory); + } + else { + SEISCOMP_ERROR("Unsupported MiniSEED encoding"); + return false; + } + + if ( !factory->setRecordLength(_mseedRecordLength) ) { + SEISCOMP_ERROR("%s", factory->errorString().c_str()); + return false; + } + } + else { + SEISCOMP_INFO("MiniSEED encoding is disabled."); + } + + if ( _backfillingBufferSize > 0 ) { + _plugin.setBackfillingBufferSize(_backfillingBufferSize); + LogInfo("Backfilling buffer size set to %d", _backfillingBufferSize); + } + + if ( !_journalFile.empty() ) { + _journalFile = Seiscomp::Environment::Instance()->absolutePath(_journalFile); + // Recover states + LogInfo("Reading journal from %s", _journalFile.c_str()); + _plugin.setJournal(_journalFile); + _plugin.readJournal(); + LogInfo("Recovered %d streams", (int)_plugin.streamStates().size()); + } + + if ( _logStatus ) { + string filename = Seiscomp::Environment::Instance()->logDir() + "/" + SCCoreApp->name() + "-stats.log"; + if ( !_statusFile.open(filename.c_str()) ) { + LogError("Could not open status file %s.", filename.c_str()); + return false; + } + + enableTimer(_statusFlushInterval); + } + + return true; +} + +bool PluginApplication::initConfiguration() { + if ( !Seiscomp::Client::StreamApplication::initConfiguration() ) return false; + + try { _host = configGetString("output.host"); } + catch ( ... ) { } + + try { _port = configGetInt("output.port"); } + catch ( ... ) { } + + try { _sendTimeout = configGetInt("output.timeout"); } + catch ( ... ) { } + + try { + string addr = configGetString("output.addr"); + if ( !splitAddress(_host, _port, addr, DEFAULT_PORT) ) { + SEISCOMP_ERROR("%s: Invalid CAPS address, format is [HOST:PORT]", + addr.c_str()); + return false; + } + } + catch ( ... ) {} + + try { + _mseedEnabled = configGetBool("output.mseed.enable"); + } + catch ( ... ) {} + + try { + int length = configGetInt("output.mseed.recordLength"); + if ( length < 0 ) { + SEISCOMP_ERROR("'output.mseed.recordLength' must be a positive integer"); + return false; + } + + _mseedRecordLength = uint(length); + } + catch ( ... ) {} + + try { + string str = configGetString("output.mseed.encoding"); + if ( !fromString(_mseedEncoding, str)) return false; + } + catch ( ... ) {} + + try { _bufferSize = configGetInt("output.bufferSize"); } + catch ( ... ) { } + + try { _backfillingBufferSize = configGetInt("output.backfillingBufferSize"); } + catch ( ... ) { } + + try { _journalFile = configGetString("journal.file"); } + catch ( ... ) {} + + try { _flushInterval = configGetInt("journal.flush"); } + catch ( ... ) { } + + try { _ackTimeout = configGetInt("journal.waitForAck"); } + catch ( ... ) { } + + try { _lastAckTimeout = configGetInt("journal.waitForLastAck"); } + catch ( ... ) { } + + try { _logStatus = configGetBool("statusLog.enable"); } + catch ( ... ) { } + + try { _statusFlushInterval = configGetInt("statusLog.flush"); } + catch ( ... ) {} + + try { _maxFutureEndTime= configGetInt("output.maxFutureEndTime"); } + catch ( ... ) { } + + return true; +} + +bool PluginApplication::validateParameters() { + if ( !Seiscomp::Client::StreamApplication::validateParameters() ) return false; + + if ( commandline().hasOption("mseed") ) { + _mseedEnabled = true; + } + + if ( commandline().hasOption("status-log") ) { + _logStatus = true; + } + + if ( commandline().hasOption("encoding") ) { + if ( !fromString(_mseedEncoding, _strMseedEncoding)) return false; + } + + if ( _bufferSize < MIN_BUFFER_SIZE ) { + SEISCOMP_ERROR("The plugin buffer size must be at least %ld bytes.", + MIN_BUFFER_SIZE); + return false; + } + + if ( commandline().hasOption("addr") ) { + if ( !splitAddress(_host, _port, _strAddr, DEFAULT_PORT) ) { + SEISCOMP_ERROR("%s: Invalid CAPS address, format is [HOST:PORT]", + _strAddr.c_str()); + return false; + } + } + + return true; +} + +bool PluginApplication::fromString(MseedEncoding &enc, string str) { + boost::to_lower(str); + if( str == "uncompressed" ) + enc = Uncompressed; + else if ( str == "steim1" ) + enc = Steim1; + else if ( str == "steim2" ) + enc = Steim2; + else { + SEISCOMP_ERROR("Unsupported encoding %s", str.c_str()); + return false; + } + + return true; +} + +} +} diff --git a/libs/gempa/caps/pluginapplication.h b/libs/gempa/caps/pluginapplication.h new file mode 100644 index 0000000..ba5a46d --- /dev/null +++ b/libs/gempa/caps/pluginapplication.h @@ -0,0 +1,114 @@ +/*************************************************************************** + * Copyright (C) 2015 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_PLUGINAPPLICATION_H +#define GEMPA_CAPS_PLUGINAPPLICATION_H + +#include +#include + +#include +#include +#include + +namespace Gempa { +namespace CAPS { + +class SC_GEMPA_CAPS_API PluginApplication : public Seiscomp::Client::StreamApplication { + public: + PluginApplication(int argc, char **argv, + const std::string &desc = ""); + + protected: + /** + * @brief Adds common plugin commandline options. + */ + virtual void createCommandLineDescription(); + + virtual void done(); + + virtual void exit(int returnCode); + + virtual void handleRecord(Seiscomp::Record *record) {} + virtual void handleTimeout(); + + /** + * @brief Initialization method. + */ + virtual bool init(); + + /** + * @brief Reads common plugin configuration options. + */ + virtual bool initConfiguration(); + + /** + * @brief Validates command line parameters. + */ + virtual bool validateParameters(); + + protected: + struct Statistics { + uint32_t records; + uint32_t samples; + Time startTime; + Time endTime; + uint32_t gaps; + uint32_t files; + + Statistics() : records(0), samples(0), gaps(0), files(0) {} + }; + + enum MseedEncoding {Uncompressed, Steim1, Steim2}; + + bool fromString(MseedEncoding &enc, std::string str); + + protected: + class FileRotator : public Seiscomp::Logging::FileRotatorOutput { + public: + std::ofstream& stream() { return _stream; } + }; + + protected: + Plugin _plugin; + std::string _host; + ushort _port; + std::string _strAddr; + size_t _bufferSize; + size_t _backfillingBufferSize; + bool _mseed; + std::string _journalFile; + int _flushInterval; + int _ackTimeout; + int _lastAckTimeout; + int _sendTimeout; + int _maxFutureEndTime; + Statistics _stats; + bool _mseedEnabled; + MseedEncoding _mseedEncoding; + uint _mseedRecordLength; + std::string _strMseedEncoding; + std::string _strPacketType; + Seiscomp::Util::Timer _timer; + FileRotator _statusFile; + bool _logStatus; + uint _statusFlushInterval; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/pluginpacket.h b/libs/gempa/caps/pluginpacket.h new file mode 100644 index 0000000..9b6604c --- /dev/null +++ b/libs/gempa/caps/pluginpacket.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * Copyright (C) 2016 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_PLUGINPACKET_H +#define GEMPA_CAPS_PLUGINPACKET_H + +#include "mseed/encoder.h" + +namespace Gempa { +namespace CAPS { + +struct Packet { + Packet() : timingQuality(-1) {} + Packet(DataRecordPtr rec, + const std::string &networkCode, const std::string &stationCode, + const std::string &locationCode, const std::string &channelCode) + : record(rec), networkCode(networkCode), stationCode(stationCode), + locationCode(locationCode), channelCode(channelCode), timingQuality(-1) { + streamID = networkCode + "." + stationCode + "." + + locationCode + "." + channelCode; + } + + Packet* clone() { + Packet *packet = new Packet(record, networkCode, stationCode, + locationCode, channelCode); + packet->buffer = buffer; + packet->dt_us = dt_us; + packet->streamID = streamID; + + return packet; + } + + typedef std::vector Buffer; + typedef boost::shared_ptr BufferPtr; + + BufferPtr buffer; // PacketDataHeader, PacketHeader[V1|V2], Data + DataRecordPtr record; + std::string networkCode; + std::string stationCode; + std::string locationCode; + std::string channelCode; + std::string streamID; + DataType dataType; +#if !defined(CAPS_FEATURES_BACKFILLING) || CAPS_FEATURES_BACKFILLING + int64_t dt_us; // Length of one sample in microseconds +#endif + std::string uom; + int timingQuality; + size_t size() const { return buffer->size(); } +}; + +typedef boost::shared_ptr PacketPtr; + +} +} + +#endif diff --git a/libs/gempa/caps/rawpacket.cpp b/libs/gempa/caps/rawpacket.cpp new file mode 100644 index 0000000..2855add --- /dev/null +++ b/libs/gempa/caps/rawpacket.cpp @@ -0,0 +1,418 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include +#include + +using namespace std; + +namespace { + +#define DT2STR(prefix, dt) \ + do { \ + switch ( dt ) { \ + case DT_DOUBLE: \ + return prefix"DOUBLE"; \ + case DT_FLOAT: \ + return prefix"FLOAT"; \ + case DT_INT64: \ + return prefix"INT64"; \ + case DT_INT32: \ + return prefix"INT32"; \ + case DT_INT16: \ + return prefix"INT16"; \ + case DT_INT8: \ + return prefix"INT8"; \ + default: \ + break; \ + } \ + } \ + while (0); \ + return prefix"UNKWN"; \ + +} + +namespace Gempa { +namespace CAPS { + +namespace { + +inline int sizeOf(DataType dt) { + switch ( dt ) { + case DT_DOUBLE: + return sizeof(double); + case DT_FLOAT: + return sizeof(float); + case DT_INT64: + return sizeof(int64_t); + case DT_INT32: + return sizeof(int32_t); + case DT_INT16: + return sizeof(int16_t); + case DT_INT8: + return sizeof(int8_t); + default: + break; + }; + + return 0; +} + +inline Time getEndTime(const Time &stime, size_t count, const DataRecord::Header &header) { + if ( header.samplingFrequencyNumerator == 0 || + header.samplingFrequencyDenominator == 0 ) return stime; + + return stime + samplesToTimeSpan(header, count); +} + +} + +RawDataRecord::RawDataRecord() : _dataOfs(0), _dataSize(0), _dirty(false) {} + +const char *RawDataRecord::formatName() const { + DT2STR("RAW/", _currentHeader.dataType) +} + +bool RawDataRecord::readMetaData(std::streambuf &buf, int size, Header &header, + Time &startTime, Time &endTime) { + if ( !header.get(buf) ) return false; + + _currentHeader.dataType = header.dataType; + + size -= header.dataSize(); + int dtsize = sizeOf(header.dataType); + if ( dtsize == 0 ) { + CAPS_WARNING("unknown data type: %d", header.dataType); + return false; + } + + int count = size / dtsize; + + startTime = timestampToTime(header.samplingTime); + endTime = getEndTime(startTime, count, header); + + return true; +} + +void RawDataRecord::setHeader(const Header &header) { + _header = header; + _currentHeader = _header; + _startTime = timestampToTime(_header.samplingTime); + _dirty = true; +} + +const DataRecord::Header *RawDataRecord::header() const { + return &_header; +} + +void RawDataRecord::setDataType(DataType dt) { + _header.dataType = dt; + _currentHeader = _header; + _dirty = true; +} + +void RawDataRecord::setStartTime(const Time &time) { + _header.setSamplingTime(time); + _currentHeader = _header; + _startTime = time; + _dirty = true; +} + +void RawDataRecord::setSamplingFrequency(uint16_t numerator, uint16_t denominator) { + _header.samplingFrequencyNumerator = numerator; + _header.samplingFrequencyDenominator = denominator; + _currentHeader = _header; + _dirty = true; +} + +Time RawDataRecord::startTime() const { + return _startTime; +} + +Time RawDataRecord::endTime() const { + if ( _dirty ) { + _endTime = getEndTime(_startTime, _data.size() / sizeOf(_header.dataType), _header); + _dirty = false; + } + return _endTime; +} + +bool RawDataRecord::canTrim() const { + return true; +} + +bool RawDataRecord::canMerge() const { + return true; +} + +bool RawDataRecord::trim(const Time &start, const Time &end) const { + if ( _header.samplingFrequencyNumerator <= 0 || _header.samplingFrequencyDenominator <= 0 ) + return false; + + // If the start time is behind the end time return false + if ( start > end ) return false; + + // Initialize original values + int dataTypeSize = sizeOf(_header.dataType); + _dataSize = _data.size(); + if ( dataTypeSize == 0 ) { + CAPS_WARNING("unknown data type: %d", _header.dataType); + return false; + } + + _startTime = timestampToTime(_header.samplingTime); + _endTime = _startTime + samplesToTimeSpan(_header, _dataSize / dataTypeSize); + _dirty = false; + + // Trim front + if ( start > _startTime ) { + TimeSpan ofs = start - _startTime; + int sampleOfs = timeSpanToSamplesCeil(_header, ofs); + _dataOfs = sampleOfs * dataTypeSize; + if ( _dataSize > _dataOfs ) + _dataSize -= _dataOfs; + else + _dataSize = 0; + _startTime += samplesToTimeSpan(_header, sampleOfs); + timeToTimestamp(_currentHeader.samplingTime, _startTime); + } + else { + _currentHeader.samplingTime = _header.samplingTime; + _dataOfs = 0; + } + + // Trim back + if ( end.valid() && (end < _endTime) ) { + TimeSpan ofs = _endTime - end; + int sampleOfs = timeSpanToSamplesFloor(_header, ofs); + _dataSize -= sampleOfs * dataTypeSize; + } + + size_t sampleCount = _dataSize / dataTypeSize; + _endTime = _startTime + samplesToTimeSpan(_currentHeader, sampleCount); + + CAPS_DEBUG("trimmed: %s ~ %s: %d samples", + _startTime.iso().c_str(), + _endTime.iso().c_str(), (int)sampleCount); + + return true; +} + +size_t RawDataRecord::dataSize(bool withHeader) const { + if ( withHeader ) + return _dataSize + _header.dataSize(); + else + return _dataSize; +} + +DataRecord::ReadStatus RawDataRecord::get(streambuf &buf, int size, + const Time &start, const Time &end, + int maxBytes) { + size -= _header.dataSize(); + if ( size < 0 ) return RS_Error; + if ( !_header.get(buf) ) { + CAPS_WARNING("invalid raw header"); + return RS_Error; + } + + return getData(buf, size, start, end, maxBytes); +} + +DataRecord::ReadStatus RawDataRecord::getData(streambuf &buf, int size, + const Time &start, const Time &end, + int maxBytes) { + bool partial = false; + int sampleOfs; + int sampleCount; + int dataTypeSize = sizeOf(_header.dataType); + if ( dataTypeSize == 0 ) { + CAPS_WARNING("unknown data type: %d", _header.dataType); + return RS_Error; + } + + sampleCount = size / dataTypeSize; + + _startTime = timestampToTime(_header.samplingTime); + + if ( _header.samplingFrequencyDenominator > 0 && + _header.samplingFrequencyNumerator > 0 ) + _endTime = _startTime + samplesToTimeSpan(_header, sampleCount); + else + _endTime = Time(); + + if ( (start.valid() || end.valid()) && _endTime.valid() ) { + // Out of bounds? + if ( end.valid() && (end <= _startTime) ) + return RS_AfterTimeWindow; + + if ( start.valid() && (start >= _endTime) ) + return RS_BeforeTimeWindow; + + // Trim packet front + if ( _startTime < start ) { + TimeSpan ofs = start - _startTime; + sampleOfs = timeSpanToSamplesCeil(_header, ofs); + sampleCount -= sampleOfs; + CAPS_DEBUG("Triming packet start: added offset of %d samples", sampleOfs); + _startTime += samplesToTimeSpan(_header, sampleOfs); + // Update header timespan + timeToTimestamp(_header.samplingTime, _startTime); + } + else + sampleOfs = 0; + + if ( maxBytes > 0 ) { + int maxSamples = maxBytes / dataTypeSize; + // Here we need to clip the complete dataset and only + // return a partial record + if ( maxSamples < sampleCount ) { + CAPS_DEBUG("Clip %d available samples to %d", sampleCount, maxSamples); + _endTime -= samplesToTimeSpan(_header, sampleCount-maxSamples); + sampleCount = maxSamples; + partial = true; + } + } + + // Trim back + if ( end.valid() && (end < _endTime) ) { + TimeSpan ofs = _endTime - end; + int trimEnd = timeSpanToSamplesFloor(_header, ofs); + sampleCount -= trimEnd; + _endTime = _startTime + samplesToTimeSpan(_header, sampleCount); + CAPS_DEBUG("Triming packet end: added offset of %d samples", trimEnd); + } + } + else + sampleOfs = 0; + + if ( sampleCount == 0 ) return RS_Error; + + _currentHeader = _header; + + switch ( _header.dataType ) { + case DT_INT8: + { + // Stay with little endian data + RIFF::VectorChunk<1,false> dataChunk(_data, sampleOfs, sampleCount); + if ( !dataChunk.get(buf, size) ) return RS_Error; + } + break; + + case DT_INT16: + { + // Stay with little endian data + RIFF::VectorChunk<2,false> dataChunk(_data, sampleOfs, sampleCount); + if ( !dataChunk.get(buf, size) ) return RS_Error; + } + break; + + case DT_INT32: + case DT_FLOAT: + { + // Stay with little endian data + RIFF::VectorChunk<4,false> dataChunk(_data, sampleOfs, sampleCount); + if ( !dataChunk.get(buf, size) ) return RS_Error; + } + break; + + case DT_INT64: + case DT_DOUBLE: + { + // Stay with little endian data + RIFF::VectorChunk<8,false> dataChunk(_data, sampleOfs, sampleCount); + if ( !dataChunk.get(buf, size) ) return RS_Error; + } + break; + + default: + CAPS_ERROR("THIS SHOULD NEVER HAPPEN: ignored invalid data with type %d", + _header.dataType); + return RS_Error; + }; + + // Initialize indicies + _dataOfs = 0; + _dataSize = _data.size(); + + return partial?RS_Partial:RS_Complete; +} + +bool RawDataRecord::put(std::streambuf &buf, bool withHeader) const { + if ( withHeader && !_currentHeader.put(buf) ) return false; + + switch ( _header.dataType ) { + case DT_INT8: + { + // Data is already in little endian + RIFF::CPtrChunk<1,false> dataChunk(&_data[_dataOfs], _dataSize); + if ( !dataChunk.put(buf) ) + return false; + } + break; + + case DT_INT16: + { + // Data is already in little endian + RIFF::CPtrChunk<2,false> dataChunk(&_data[_dataOfs], _dataSize); + if ( !dataChunk.put(buf) ) + return false; + } + break; + + case DT_INT32: + case DT_FLOAT: + { + // Data is already in little endian + RIFF::CPtrChunk<4,false> dataChunk(&_data[_dataOfs], _dataSize); + if ( !dataChunk.put(buf) ) + return false; + } + break; + + case DT_INT64: + case DT_DOUBLE: + { + // Data is already in little endian + RIFF::CPtrChunk<8,false> dataChunk(&_data[_dataOfs], _dataSize); + if ( !dataChunk.put(buf) ) + return false; + } + break; + + default: + CAPS_ERROR("THIS SHOULD NEVER HAPPEN: ignored invalid data with type %d", + _header.dataType); + return false; + }; + + return true; +} + +void RawDataRecord::setBuffer(const void *data, size_t size) { + _data.resize(size); + _dataSize = size; + _dataOfs = 0; + memcpy(_data.data(), data, size); + _dirty = true; +} + +const char *FixedRawDataRecord::formatName() const { + DT2STR("FIXEDRAW/", _currentHeader.dataType) +} + +} +} diff --git a/libs/gempa/caps/rawpacket.h b/libs/gempa/caps/rawpacket.h new file mode 100644 index 0000000..7066c96 --- /dev/null +++ b/libs/gempa/caps/rawpacket.h @@ -0,0 +1,237 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_RAWPACKET_H +#define GEMPA_CAPS_RAWPACKET_H + + +#include +#include + + +namespace Gempa { +namespace CAPS { + +struct SC_GEMPA_CAPS_API RawResponseHeader { + int64_t timeSeconds; + int32_t timeMicroSeconds; + + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + get(timeSeconds); + get(timeMicroSeconds); + + return get.good; + } + + int dataSize() const { + return sizeof(timeSeconds) + sizeof(timeMicroSeconds); + } +}; + + +class RawDataRecord : public DataRecord { + public: + RawDataRecord(); + + const char *formatName() const; + + /** + * @brief Reads metadata from data record header + * @param The streambuf object + * @param The size of the data record in bytes + * @param The data record header object + * @param The startTime + * @param The endTime + */ + bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, Time &endTime); + + void setHeader(const Header &header); + + /** + * @brief Returns the meta information of the data if supported + * @return The data record header + */ + const Header *header() const; + + /** + * @brief Returns the start time of the record + * @return The start time + */ + Time startTime() const; + + /** + * @brief Returns the end time of the record + * @return The end time + */ + Time endTime() const; + + /** + * @brief canTrim checks if data trimming is possible + * without modifying preceding data + * @return True, if data trimming is possible + */ + bool canTrim() const; + + /** + * @brief canMerge checks if data merging is possible + * without modifying preceding data + * @return True, if data merging is possible + */ + bool canMerge() const; + + /** + * @brief Trims a record to start and end time. Trimming + * should not modify any data but give access to trimmed + * start and end times and the resulting data size. The trimming + * also influences writing the record to a stream. + * Trimming requires the resulting start time being greater + * or equal than the requested start time. + * (Un)Trimming to the original record is semantically + * equal to passing an invalid start and end time. + * @param start The requested start time + * @param end The requested end time + * @return It returns true if trimming has been done or false + * if an error occured or trimming is not supported. + */ + bool trim(const Time &start, const Time &end) const; + + /** + * @brief Returns the data size in bytes if the current state would + * be written to a stream. Trimming has also to be taken into + * account while calculating the size. + * @param withHeader Take header into account + * @return Returns the data size in bytes + */ + size_t dataSize(bool withHeader) const; + + /** + * @brief Reads the packet data including header from a streambuf + * and trims the data if possible to start and end. + * If maxBytes is greater than 0 then the record should + * not use more than this size of memory (in bytes). + * + * @param The streambuf object + * @param The buffer size + * @param The requested start time + * @param The requested end time + * @param The Max bytes to use + * @return If not the complete record has been read, RS_Partial + * must be returned, RS_Complete otherwise. + */ + ReadStatus get(std::streambuf &buf, int size, + const Time &start = Time(), + const Time &end = Time(), + int maxBytes = -1); + + /** + * @brief Reads the packet data without header from a streambuf + * and trims the data if possible to start and end. + * If maxBytes is greater than 0 then the record should + * not use more than this size of memory (in bytes). + * + * @param The streambuf object + * @param The buffer size + * @param The requested start time + * @param The requested end time + * @param The Max bytes to use + * @return If not the complete record has been read, RS_Partial + * must be returned, RS_Complete otherwise. + */ + ReadStatus getData(std::streambuf &buf, int size, + const Time &start = Time(), + const Time &end = Time(), + int maxBytes = -1); + + //! writes the packet to a streambuf and trims the data + //! if possible to start and end + /** + * @brief Writes the packet to a streambuf and trims the data + * if possible to start and end + * @param The streambuf object + * @param Take header into account + * @return True, if the data has been written + */ + bool put(std::streambuf &buf, bool withHeader) const; + + /** + * @brief Returns the packet type + * @return The packet type + */ + PacketType packetType() const { return RawDataPacket; } + + /** + * @brief Sets the start time of the record + * @param The start time + */ + void setStartTime(const Time &time); + + /** + * @brief Sets the sampling frequency of the record + * @param numerator The numerator + * @param denominator The denomintor + */ + void setSamplingFrequency(uint16_t numerator, uint16_t denominator); + + /** + * @brief Sets the data type of the record + * @param The datatype to use + */ + void setDataType(DataType dt); + + /** + * @brief Initializes the internal data vector from the given buffer + * @param The buffer to read the data from + * @param The buffer size + */ + void setBuffer(const void *data, size_t size); + + + protected: + Header _header; + + mutable Header _currentHeader; + mutable size_t _dataOfs; + mutable size_t _dataSize; + + mutable Time _startTime; + mutable Time _endTime; + + mutable bool _dirty; +}; + + +class FixedRawDataRecord : public RawDataRecord { + public: + virtual bool canTrim() const { return false; } + virtual bool canMerge() const { return false; } + virtual bool trim(const Time &start, const Time &end) const { return false; } + virtual const char *formatName() const; + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &/*start*/, const Time &/*end*/, + int maxBytes) { + return RawDataRecord::get(buf, size, Time(), Time(), maxBytes); + } + PacketType packetType() const { return FixedRawDataPacket; } +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/recordbuilder.h b/libs/gempa/caps/recordbuilder.h new file mode 100644 index 0000000..9569e40 --- /dev/null +++ b/libs/gempa/caps/recordbuilder.h @@ -0,0 +1,137 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_RECORD_SAMPLER_H +#define GEMPA_CAPS_RECORD_SAMPLER_H + +#include + +#include + +#include + +namespace Gempa { +namespace CAPS { + +template class RecordBuilder { + public: + struct Record { + Record() : samplingInterval(0.0), sampleCount(0), userData(NULL) {} + std::string netcode; + std::string stacode; + std::string loccode; + std::string chacode; + Time startTime; + double samplingInterval; + size_t sampleCount; + std::vector data; + void *userData; + }; + typedef boost::shared_ptr RecordPtr; + typedef boost::function FlushCallback; + + public: + RecordBuilder() : _bufSize(64) {} + RecordBuilder(const std::string &netcode, const std::string &stacode, + const std::string &loccode, const std::string &chacode, + void *userData = NULL, size_t bufSize = 64) { + _networkCode = netcode; + _stationCode = stacode; + _locationCode = loccode; + _channelCode = chacode; + _userData = userData; + _bufSize = bufSize > 0? bufSize:1; + _record = NULL; + } + + void flush(bool lastSample = false) { + if ( _record != 0 ) { + if ( lastSample ) push(); + + _flushCallback(_record, _userData); + _record = NULL; + } + } + + void push(T value, const Time &time) { + if ( _time.valid() ) { + double interval = time - _time; + if ( interval <= 0.0 ) { + _time = Time(); + flush(true); + return; + } + else { + if ( _record == NULL) { + _record = new Record; + if ( _record ) { + _record->netcode = _networkCode; + _record->stacode = _stationCode; + _record->loccode = _locationCode; + _record->chacode = _channelCode; + _record->startTime = _time; + _record->samplingInterval = interval; + + _record->data.reserve(_bufSize); + _record->data[_record->sampleCount] = _value; + ++_record->sampleCount; + } + } + else if ( interval != _record->samplingInterval ) { + flush(true); + } + else { + push(); + } + } + } + + _time = time; + _value = value; + } + + void setFlushCallback(const FlushCallback &cb) { _flushCallback = cb; } + void setNetworkCode(const std::string &netcode) { _networkCode = netcode; } + void setStationCode(const std::string &stacode) { _stationCode = stacode; } + void setLocationCode(const std::string &loccode) { _locationCode = loccode; } + void setChannelCode(const std::string &chacode) { _channelCode = chacode; } + void setUserData(void *userData) { _userData = userData; } + + private: + void push() { + if ( _record->sampleCount % _bufSize == 0 ) + _record->data.reserve(_record->sampleCount + _bufSize); + _record->data[_record->sampleCount] = _value; + ++_record->sampleCount; + } + + private: + T _value; + Time _time; + Record *_record; + FlushCallback _flushCallback; + size_t _bufSize; + std::string _networkCode; + std::string _stationCode; + std::string _locationCode; + std::string _channelCode; + void *_userData; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/riff.cpp b/libs/gempa/caps/riff.cpp new file mode 100644 index 0000000..412f260 --- /dev/null +++ b/libs/gempa/caps/riff.cpp @@ -0,0 +1,398 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include + +#include +#include + + +namespace Gempa { +namespace CAPS { +namespace RIFF { + + +bool ChunkHeader::setChunkType(const char *t) { + int i; + + if ( t != NULL ) { + for ( i = 0; i < 4; ++i ) { + if ( t[i] == '\0' ) break; + chunkType[i] = t[i]; + } + + // Input type must not have more than 4 characters + if ( i == 3 && t[i] != '\0' && t[i+1] != '\0' ) { + memset(chunkType, ' ', 4); + return false; + } + } + else + i = 0; + + // Pad with whitespaces + for ( ; i < 4; ++i ) + chunkType[i] = ' '; + + return true; +} + + +bool ChunkHeader::isChunkType(const char *t) const { + for ( int i = 0; i < 4; ++i ) { + if ( t[i] == '\0' && chunkType[i] == ' ' ) break; + if ( t[i] != chunkType[i] ) return false; + } + return true; +} + + +bool ChunkHeader::validChunkType() const { + for ( int i = 0; i < 4; ++i ) { + if ( chunkType[i] == '\0' ) continue; + if ( chunkType[i] >= 'a' && chunkType[i] <= 'z' ) continue; + if ( chunkType[i] >= 'A' && chunkType[i] <= 'Z' ) continue; + if ( chunkType[i] >= '0' && chunkType[i] <= '9' ) continue; + if ( chunkType[i] == '-' ) continue; + if ( chunkType[i] == '_' ) continue; + if ( chunkType[i] == ' ' ) continue; + return false; + } + + return true; +} + + +bool ChunkHeader::get(std::streambuf &input) { + Endianess::Reader get(input); + get(chunkType, 4); + get(chunkSize); + return get.good; +} + + +bool ChunkHeader::put(std::streambuf &output) const { + Endianess::Writer put(output); + put(chunkType, 4); + put(chunkSize); + return put.good; +} + + +ChunkIterator::ChunkIterator() : _stream(&_own) {} + + +ChunkIterator::ChunkIterator(const std::string &filename) { + begin(filename); +} + + +ChunkIterator::ChunkIterator(std::istream &input) { + begin(input); +} + + +void ChunkIterator::begin(const std::string &filename) { + _stream = &_own; + _index = 0; + _own.open(filename.c_str()); + memset(&_header, 0, sizeof(_header)); +} + + +void ChunkIterator::begin(std::istream &input) { + _stream = &input; + _index = input.tellg(); + _header.chunkSize = 0; + memset(&_header, 0, sizeof(_header)); +} + + +bool ChunkIterator::next() { + while ( _stream->good() ) { + // Jump to next header + _stream->seekg(_index + _header.chunkSize); + + if ( !_header.read(*_stream) ) + break; + + //std::cout << " - "; std::cout.write(_header.chunkType, 4); std::cout << " : " << _header.chunkSize << std::endl; + + _index = _stream->tellg(); + return true; + } + + return false; +} + + +const ChunkHeader &ChunkIterator::header() const { + return _header; +} + + +size_t ChunkIterator::headerPos() const { + return _index - _header.dataSize(); +} + + +size_t ChunkIterator::contentPos() const { + return _index; +} + + +Chunk::~Chunk() {} + + +bool HeadChunk::get(std::streambuf &input, int size) { + Endianess::Reader r(input); + + r(data.version); + + char dt; + r(dt); + data.packetType = static_cast(dt); + + r(data.unitOfMeasurement.str, 4); + + return r.good; +} + + +bool HeadChunk::put(std::streambuf &output) const { + Endianess::Writer w(output); + + w(data.version); + + char dt = data.packetType; + w(dt); + + w(data.unitOfMeasurement.str, 4); + + return w.good; +} + + +int HeadChunk::chunkSize() const { + return sizeof(data.version) + + sizeof(data.unitOfMeasurement.str) + + sizeof(char); +} + + +bool SIDChunk::put(std::streambuf &output) const { + char null = '\0'; + Endianess::Writer w(output); + + if ( !networkCode.empty() ) + w(networkCode.c_str(), networkCode.size()); + w(&null, 1); + if ( !stationCode.empty() ) + w(stationCode.c_str(), stationCode.size()); + w(&null, 1); + if ( !locationCode.empty() ) + w(locationCode.c_str(), locationCode.size()); + w(&null, 1); + if ( !channelCode.empty() ) + w(channelCode.c_str(), channelCode.size()); + + return w.good; +} + + +bool SIDChunk::get(std::streambuf &input, int size) { + char tmp; + int count = size; + Endianess::Reader r(input); + + r(&tmp, 1); + networkCode.clear(); + while ( r.good && count-- ) { + if ( tmp == '\0' ) break; + networkCode += tmp; + r(&tmp, 1); + } + + if ( !r.good ) return false; + + r(&tmp, 1); + stationCode.clear(); + while ( r.good && count-- ) { + if ( tmp == '\0' ) break; + stationCode += tmp; + r(&tmp, 1); + } + + if ( !r.good ) return false; + + r(&tmp, 1); + locationCode.clear(); + while ( r.good && count-- ) { + if ( tmp == '\0' ) break; + locationCode += tmp; + r(&tmp, 1); + } + + if ( !r.good ) return false; + + r(&tmp, 1); + channelCode.clear(); + while ( r.good && count-- ) { + if ( tmp == '\0' ) break; + channelCode += tmp; + r(&tmp, 1); + } + + return true; +} + + +int SIDChunk::chunkSize() const { + return networkCode.size() + 1 + + stationCode.size() + 1 + + locationCode.size() + 1 + + channelCode.size(); +} + + +template +CPtrChunk::CPtrChunk(const char* d, int len) : data(d), size(len) {} + + +template +int CPtrChunk::chunkSize() const { + return size; +} + + +template +bool CPtrChunk::get(std::streambuf &, int) { + return false; +} + + +template +struct CPtrWriter { + static bool Take(std::streambuf &output, const T*, int count); +}; + + +// To little endian +template +struct CPtrWriter { + static bool Take(std::streambuf &output, const T *data, int count) { + Endianess::Writer w(output); + for ( int i = 0; i < count; ++i ) { + T tmp = Endianess::Swapper::Take(data[i]); + w((const char*)&tmp, SIZE_T); + } + return w.good; + } +}; + + +template +struct CPtrWriter { + static bool Take(std::streambuf &output, const T *data, int count) { + return (int)output.sputn((const char*)data, SIZE_T*count) == SIZE_T*count; + } +}; + + +template +bool CPtrChunk::put(std::streambuf &output) const { + typedef typename Endianess::TypeMap::ValueType T; + return CPtrWriter::Take(output, (const T*)data, size/SIZE_T); +} + + + +template +VectorChunk::VectorChunk(std::vector &d) +: data(d), startOfs(-1), len(-1) {} + + +template +VectorChunk::VectorChunk(std::vector &d, int ofs, int count) +: data(d), startOfs(ofs), len(count) {} + + +template +int VectorChunk::chunkSize() const { + return data.size(); +} + + +template +bool VectorChunk::get(std::streambuf &input, int size) { + int count = size/SIZE_T; + + if ( len >= 0 ) { + if ( len > count ) + return false; + + count = len; + } + + // Skip first samples (bytes = samples*sizeof(T)) + if ( startOfs > 0 ) + input.pubseekoff(startOfs*SIZE_T, std::ios_base::cur, std::ios_base::in); + + Endianess::Reader r(input); + + data.resize(count*SIZE_T); + r(&data[0], data.size()); + + // Convert array to little endian + Endianess::ByteSwapper::Take(&data[0], count); + + // Go the end of chunk + if ( (int)data.size() < size ) + input.pubseekoff(size-data.size(), std::ios_base::cur, std::ios_base::in); + + return r.good; +} + + +template +bool VectorChunk::put(std::streambuf &output) const { + typedef typename Endianess::TypeMap::ValueType T; + return CPtrWriter::Take(output, (const T*)data.data(), data.size()/SIZE_T); +} + + +template struct SC_GEMPA_CAPS_API CPtrChunk<1,false>; +template struct SC_GEMPA_CAPS_API CPtrChunk<1,true>; +template struct SC_GEMPA_CAPS_API CPtrChunk<2,false>; +template struct SC_GEMPA_CAPS_API CPtrChunk<2,true>; +template struct SC_GEMPA_CAPS_API CPtrChunk<4,false>; +template struct SC_GEMPA_CAPS_API CPtrChunk<4,true>; +template struct SC_GEMPA_CAPS_API CPtrChunk<8,false>; +template struct SC_GEMPA_CAPS_API CPtrChunk<8,true>; + +template struct SC_GEMPA_CAPS_API VectorChunk<1,false>; +template struct SC_GEMPA_CAPS_API VectorChunk<1,true>; +template struct SC_GEMPA_CAPS_API VectorChunk<2,false>; +template struct SC_GEMPA_CAPS_API VectorChunk<2,true>; +template struct SC_GEMPA_CAPS_API VectorChunk<4,false>; +template struct SC_GEMPA_CAPS_API VectorChunk<4,true>; +template struct SC_GEMPA_CAPS_API VectorChunk<8,false>; +template struct SC_GEMPA_CAPS_API VectorChunk<8,true>; + + +} +} +} diff --git a/libs/gempa/caps/riff.h b/libs/gempa/caps/riff.h new file mode 100644 index 0000000..b5b9813 --- /dev/null +++ b/libs/gempa/caps/riff.h @@ -0,0 +1,193 @@ +/*************************************************************************** + * Copyright (C) 2009 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef CAPS_IO_RIFF_H +#define CAPS_IO_RIFF_H + + +#include +#include +#include +#include + +#include + + +namespace Gempa { +namespace CAPS { +namespace RIFF { + + +struct SC_GEMPA_CAPS_API ChunkHeader { + union { + char chunkType[4]; + uint32_t chunkID; + }; + + int chunkSize; /* Chunk size in bytes */ + + bool setChunkType(const char *type); + bool isChunkType(const char *type) const; + bool validChunkType() const; + + int dataSize() const { return 8; } + + bool read(std::istream &input) { return get(*input.rdbuf()); } + bool write(std::ostream &output) const { return put(*output.rdbuf()); } + + bool get(std::streambuf &input); + bool put(std::streambuf &output) const; +}; + +const int ChunkHeaderSize = 8; + + +class SC_GEMPA_CAPS_API ChunkIterator { + public: + ChunkIterator(); + ChunkIterator(const std::string &filename); + ChunkIterator(std::istream &input); + + //! Starts iterating over a file or stream + void begin(const std::string &filename); + void begin(std::istream &input); + + //! Jumps to the next chunk. Returns false, + //! if no chunk is available + bool next(); + + //! Returns the current chunk header + const ChunkHeader &header() const; + + //! Returns the file position pointing + //! to the current chunk header + size_t headerPos() const; + + //! Returns the file position pointing + //! to the current chunk content + size_t contentPos() const; + + //! Returns the current input stream + std::istream &istream() const { return *_stream; } + + + private: + ChunkHeader _header; + std::istream *_stream; + size_t _index; + std::ifstream _own; +}; + + +struct SC_GEMPA_CAPS_API Chunk { + virtual ~Chunk(); + + bool read(std::istream &input, int size) { return get(*input.rdbuf(), size); } + bool write(std::ostream &output) const { return put(*output.rdbuf()); } + + virtual bool get(std::streambuf &input, int size) = 0; + virtual bool put(std::streambuf &output) const = 0; + + virtual int chunkSize() const = 0; +}; + + +struct SC_GEMPA_CAPS_API HeadChunk : Chunk { + PacketDataHeader data; + + int chunkSize() const; + + bool get(std::streambuf &input, int size); + bool put(std::streambuf &output) const; +}; + + +struct SC_GEMPA_CAPS_API SID { + std::string networkCode; + std::string stationCode; + std::string locationCode; + std::string channelCode; + + bool operator==(const SID &other ) const { + return networkCode == other.networkCode && + stationCode == other.stationCode && + locationCode == other.locationCode && + channelCode == other.channelCode; + } + + bool operator!=(const SID &other ) const { + return networkCode != other.networkCode || + stationCode != other.stationCode || + locationCode != other.locationCode || + channelCode != other.channelCode; + } + + std::string toString() const { + return networkCode + "." + stationCode + "." + + locationCode + "." + channelCode; + } +}; + + +struct SC_GEMPA_CAPS_API SIDChunk : Chunk, SID { + int chunkSize() const; + + bool get(std::streambuf &input, int size); + bool put(std::streambuf &output) const; +}; + + +template +struct CPtrChunk : Chunk { + const char *data; + int size; + + CPtrChunk(const char* d, int len); + virtual ~CPtrChunk() {} + + int chunkSize() const; + + bool get(std::streambuf &input, int size); + bool put(std::streambuf &output) const; +}; + + +template +struct VectorChunk : Chunk { + std::vector &data; + + VectorChunk(std::vector &d); + + // sampleOfs and sampleCount are not byte offsets but elements of + // type T + VectorChunk(std::vector &d, int sampleOfs, int sampleCount); + virtual ~VectorChunk() {} + + int chunkSize() const; + + bool get(std::streambuf &input, int size); + bool put(std::streambuf &output) const; + + int startOfs; + int len; +}; + + +} +} +} + + +#endif diff --git a/libs/gempa/caps/rtcm2packet.cpp b/libs/gempa/caps/rtcm2packet.cpp new file mode 100644 index 0000000..91485af --- /dev/null +++ b/libs/gempa/caps/rtcm2packet.cpp @@ -0,0 +1,174 @@ +/*************************************************************************** + * Copyright (C) 2012 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include +#include +#include + +#include +#include +#include + + +namespace Gempa { +namespace CAPS { + +bool RTCM2DataRecord::RTCM2Header::put(std::streambuf &buf) const { + Endianess::Writer put(buf); + + put(samplingTime.year); + put(samplingTime.yday); + put(samplingTime.hour); + put(samplingTime.minute); + put(samplingTime.second); + put(samplingTime.usec); + put(samplingFrequencyNumerator); + put(samplingFrequencyDenominator); + + return put.good; +} + + +RTCM2DataRecord::RTCM2DataRecord() { + _header.samplingFrequencyDenominator = 0; + _header.samplingFrequencyNumerator = 0; + // Just a bunch of bytes + _header.dataType = DT_Unknown; +} + +void RTCM2DataRecord::setTimeStamp(const Time &ts) { + timeToTimestamp(_header.samplingTime, ts); + _startTime = ts; +} + + +void RTCM2DataRecord::setSamplingFrequency(uint16_t numerator, uint16_t denominator) { + _header.samplingFrequencyNumerator = numerator; + _header.samplingFrequencyDenominator = denominator; +} + + +const char *RTCM2DataRecord::formatName() const { + return "RTC2"; +} + + +bool RTCM2DataRecord::readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, Time &endTime) { + Endianess::Reader get(buf); + + get(header.samplingTime.year); + get(header.samplingTime.yday); + get(header.samplingTime.hour); + get(header.samplingTime.minute); + get(header.samplingTime.second); + get(header.samplingTime.usec); + get(header.samplingFrequencyNumerator); + get(header.samplingFrequencyDenominator); + + startTime = timestampToTime(header.samplingTime); + + if ( header.samplingFrequencyDenominator == 0 || + header.samplingFrequencyNumerator == 0 ) { + endTime = startTime; + } + else { + TimeSpan ts = + header.samplingFrequencyDenominator / header.samplingFrequencyNumerator; + endTime = startTime + ts; + } + + return true; +} + + +const DataRecord::Header *RTCM2DataRecord::header() const { + return &_header; +} + + +Time RTCM2DataRecord::startTime() const { + return _startTime; +} + + +Time RTCM2DataRecord::endTime() const { + return _endTime; +} + + +bool RTCM2DataRecord::canTrim() const { + return false; +} + + +bool RTCM2DataRecord::canMerge() const { + return false; +} + + +bool RTCM2DataRecord::trim(const Time &start, + const Time &end) const { + return false; +} + + +size_t RTCM2DataRecord::dataSize(bool withHeader) const { + if ( withHeader ) + return _data.size() + _header.dataSize(); + else + return _data.size(); +} + + +DataRecord::ReadStatus RTCM2DataRecord::get(std::streambuf &buf, int size, + const Time &start, const Time &end, + int) { + size -= _header.dataSize(); + if ( size < 0 ) return RS_Error; + if ( !_header.get(buf) ) return RS_Error; + + if ( _header.samplingFrequencyNumerator == 0 || + _header.samplingFrequencyDenominator == 0 ) { + CAPS_ERROR("Sampling frequency not set"); + return RS_Error; + } + + TimeSpan ts = + _header.samplingFrequencyDenominator / _header.samplingFrequencyNumerator; + _startTime = timestampToTime(_header.samplingTime); + _endTime = _startTime + ts; + + if ( end.valid() && (end <= _startTime) ) return RS_AfterTimeWindow; + if ( start.valid() && (start >= _endTime) ) return RS_BeforeTimeWindow; + + RIFF::VectorChunk<1,false> dataChunk(_data, 0, size); + + return dataChunk.get(buf, size)?RS_Complete:RS_Error; +} + + +bool RTCM2DataRecord::put(std::streambuf &buf, bool withHeader) const { + if ( withHeader && !_header.put(buf) ) return false; + + RIFF::CPtrChunk<1,false> dataChunk(&_data[0], _data.size()); + return dataChunk.put(buf); +} + + +} +} diff --git a/libs/gempa/caps/rtcm2packet.h b/libs/gempa/caps/rtcm2packet.h new file mode 100644 index 0000000..856a2fe --- /dev/null +++ b/libs/gempa/caps/rtcm2packet.h @@ -0,0 +1,109 @@ +/*************************************************************************** + * Copyright (C) 2012 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_RTCM2PACKET_H +#define GEMPA_CAPS_RTCM2PACKET_H + + +#include +#include + +#include + +namespace Gempa { +namespace CAPS { + +class RTCM2DataRecord : public DataRecord { + public: + struct RTCM2Header : Header { + bool get(std::streambuf &buf) { + Endianess::Reader get(buf); + + get(samplingTime.year); + get(samplingTime.yday); + get(samplingTime.hour); + get(samplingTime.minute); + get(samplingTime.second); + get(samplingTime.usec); + get(samplingFrequencyNumerator); + get(samplingFrequencyDenominator); + + return get.good; + } + + bool put(std::streambuf &buf) const; + + // size of data header + int dataSize() const { + return + sizeof(samplingTime.year) + + sizeof(samplingTime.yday) + + sizeof(samplingTime.hour) + + sizeof(samplingTime.minute) + + sizeof(samplingTime.second) + + sizeof(samplingTime.usec) + + sizeof(samplingFrequencyNumerator) + + sizeof(samplingFrequencyDenominator); + } + }; + + RTCM2DataRecord(); + + const char* formatName() const; + + void setTimeStamp(const Time &ts); + + void setSamplingFrequency(uint16_t numerator, uint16_t denominator); + + virtual bool readMetaData(std::streambuf &buf, int size, + Header &header, + Time &startTime, + Time &endTime); + + virtual const Header *header() const; + virtual Time startTime() const; + virtual Time endTime() const; + + virtual bool canTrim() const; + virtual bool canMerge() const; + + virtual bool trim(const Time &start, + const Time &end) const; + + virtual size_t dataSize(bool withHeader) const; + + virtual ReadStatus get(std::streambuf &buf, int size, + const Time &start, + const Time &end, + int maxSize = -1); + + virtual bool put(std::streambuf &buf, bool withHeader) const; + + PacketType packetType() const { return RTCM2Packet; } + + + private: + RTCM2Header _header; + Buffer _data; + Time _startTime; + Time _endTime; +}; + + +} +} + + +#endif diff --git a/libs/gempa/caps/sessiontable.cpp b/libs/gempa/caps/sessiontable.cpp new file mode 100644 index 0000000..41ef2be --- /dev/null +++ b/libs/gempa/caps/sessiontable.cpp @@ -0,0 +1,404 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include + +#include +#include + +#include +#include +#include +#include + +using namespace std; + + +namespace Gempa { +namespace CAPS { + +namespace { + +void setDataType(const char *data, int len, Gempa::CAPS::SessionTableItem &item) { + if ( CHECK_STRING(data, "FLOAT", len) ) { + item.dataType = DT_FLOAT; + item.dataSize = 4; + //SEISCOMP_DEBUG("%s: raw format with 32bit floats", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "DOUBLE", len) ) { + item.dataType = DT_DOUBLE; + item.dataSize = 8; + //SEISCOMP_DEBUG("%s: raw format with 64bit doubles", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT64", len) ) { + item.dataType = DT_INT64; + item.dataSize = 8; + //SEISCOMP_DEBUG("%s: raw format with 64bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT32", len) ) { + item.dataType = DT_INT32; + item.dataSize = 4; + //SEISCOMP_DEBUG("%s: raw format with 32bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT16", len) ) { + item.dataType = DT_INT16; + item.dataSize = 2; + //SEISCOMP_DEBUG("%s: raw format with 16bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT8", len) ) { + item.dataType = DT_INT8; + item.dataSize = 1; + //SEISCOMP_DEBUG("%s: raw format with 8bit integers", item.streamID.c_str()); + } + else { + item.dataType = DT_Unknown; + CAPS_WARNING("Unknown raw data type '%s', all packages will be ignored", + string(data, len).c_str()); + } +} + + +} + +bool SessionTableItem::splitStreamID() { + const char *tok; + int tok_len; + int tok_count = 0; + + const char* str = streamID.c_str(); + int len = strlen(str); + + string *items[] = {&net, &sta, &loc, &cha}; + + for ( ; (tok = tokenize(str, ".", len, tok_len)) != NULL; + ++tok_count ) { + if ( tok_count > 4 ) return false; + + items[tok_count]->assign(tok, tok_len); + } + + if ( tok_count == 3 ) { + cha = loc; + loc = ""; + tok_count = 4; + } + + return tok_count == 4; +} + +SessionTable::SessionTable() : _state(Unspecific) {} + +SessionTable::Status SessionTable::handleResponse(const char *src_data, int data_len) { + enum StreamHeaderToken { + REQ_ID = 0, + SID = 1, + SF = 2, + UOM = 3, + FORMAT = 4, + COUNT = 5 + }; + + int src_len = data_len; + const char *src = src_data; + + int len; + const char *data; + if ( (data = tokenize(src_data, " ", data_len, len)) == NULL ) { + CAPS_WARNING("server returned empty line, ignoring"); + return Success; + } + + switch ( _state ) { + case Unspecific: + if ( CHECK_STRING(data, "STATUS", len) ) { + if ( (data = tokenize(src_data, " ", data_len, len)) != NULL ) { + if ( CHECK_STRING(data, "OK", len) ) { + CAPS_DEBUG("server responds OK"); + } + else { + CAPS_ERROR("received unknown status from server: %s", data); + return Error; + } + } + else { + CAPS_ERROR("received empty status from server"); + return Error; + } + } + else if ( CHECK_STRING(data, "REQUESTS", len) ) { + if ( (data = tokenize(src_data, " ", data_len, len)) != NULL ) { + CAPS_WARNING("received unknown REQUESTS parameter: %s", data); + } + CAPS_DEBUG("stream table update started"); + _state = Requests; + } + else if ( CHECK_STRING(data, "EOD", len) ) { + CAPS_DEBUG("server sent EOD"); + return EOD; + } + else { + CAPS_ERROR("received unknown response: %s", data); + return Error; + } + break; + case Requests: + if ( CHECK_STRING(data, "END", len) ) { + if ( (data = tokenize(src_data, " ", data_len, len)) != NULL ) { + CAPS_WARNING("received unknown END parameter: %s", data); + } + CAPS_DEBUG("stream table update complete"); + _state = Unspecific; + break; + } + + CAPS_DEBUG("request response data: %s", string(data, len).c_str()); + + typedef std::pair Buffer; + const char *state = src; + Buffer toks[COUNT]; + for ( int i = 0; i < COUNT; ++i ) + toks[i].second = 0; + + // Update request map + while ( (data = tokenize(src, ",", src_len, len)) != NULL ) { + trim(data, len); + if ( !strncasecmp(data, "ID:", 3) ) + toks[REQ_ID] = Buffer(data+3, len-3); + else if ( !strncasecmp(data, "SID:", 4) ) + toks[SID] = Buffer(data+4, len-4); + else if ( !strncasecmp(data, "SFREQ:", 6) ) + toks[SF] = Buffer(data+6, len-6); + else if ( !strncasecmp(data, "UOM:", 4) ) + toks[UOM] = Buffer(data+4, len-4); + else if ( !strncasecmp(data, "FMT:", 4) ) + toks[FORMAT] = Buffer(data+4, len-4); + } + + SessionTableItem item; + char buffer[7]; + if ( toks[REQ_ID].second > 6 ) { + CAPS_ERROR("request state ID too high: %s", state); + return Error; + } + strncpy(buffer, toks[REQ_ID].first, toks[REQ_ID].second); + buffer[toks[REQ_ID].second] = '\0'; + int req_id; + + if ( (sscanf(buffer, "%d", &req_id) != 1) || req_id == 0 ) { + CAPS_ERROR("invalid request ID: %s", buffer); + return Error; + } + + if ( toks[SID].second == 0 ) { + CAPS_ERROR("missing SID in request response"); + return Error; + } + + item.streamID.assign(toks[SID].first, toks[SID].second); + + if ( req_id < 0 ) { + removeStream(item.streamID); + CAPS_DEBUG("stream %s has finished", item.streamID.c_str()); + return Success; + } + else { + CAPS_DEBUG("new request ID %d for stream %s received", req_id, item.streamID.c_str()); + std::string tmp; + + if ( (data = tokenize(toks[SF].first, "/", toks[SF].second, len)) != NULL ) { + trim(data, len); + tmp.assign(data, len); + if ( !str2int(item.samplingFrequency, tmp.c_str()) ) { + CAPS_ERROR("request state 'samplingFrequency' is not a number: %s", state); + item.samplingFrequency = 0; + } + else { + item.samplingFrequencyDivider = 1; + if ( (data = tokenize(toks[SF].first, "/", toks[SF].second, len)) != NULL ) { + trim(data, len); + tmp.assign(data, len); + if ( !str2int(item.samplingFrequencyDivider, tmp.c_str()) ) { + CAPS_ERROR("request state 'samplingFrequencyDivider' " + "is not a number: %s", state); + } + } + } + } + else { + item.samplingFrequency = 0; + } + + if ( toks[UOM].second > 4 ) { + CAPS_ERROR("request state 'unit of measurement' is invalid, " + "too many characters: %s", state); + item.uom.ID = 0; + } + else { + memcpy(item.uom.str, toks[UOM].first, toks[UOM].second); + } + + if ( (data = tokenize(toks[FORMAT].first, "/", toks[FORMAT].second, len)) != NULL ) { + trim(data, len); + if ( CHECK_STRING(data, "RAW", len) ) { + item.type = RawDataPacket; + if ( (data = tokenize(toks[FORMAT].first, "/", toks[FORMAT].second, len)) != NULL ) { + setDataType(data, len, item); + } + + CAPS_DEBUG("%s: samplingFrequency=%d/%d", + item.streamID.c_str(), item.samplingFrequency, + item.samplingFrequencyDivider); + } + else if ( CHECK_STRING(data, "FIXEDRAW", len) ) { + item.type = FixedRawDataPacket; + if ( (data = tokenize(toks[FORMAT].first, "/", toks[FORMAT].second, len)) != NULL ) { + setDataType(data, len, item); + } + + CAPS_DEBUG("%s: samplingFrequency=%d/%d", + item.streamID.c_str(), item.samplingFrequency, + item.samplingFrequencyDivider); + } + else if ( CHECK_STRING(data, "MSEED", len) ) { + item.type = MSEEDPacket; + } + else if ( CHECK_STRING(data, "META", len ) ) { + item.type = MetaDataPacket; + } + else { + string tmp(data, len); + item.type = ANYPacket; + } + } + + // Register item + registerItem(req_id, item); + } + + break; + } + + return Success; +} + +void setDataType(const char *data, int len, Gempa::CAPS::SessionTableItem &item) { + if ( CHECK_STRING(data, "FLOAT", len) ) { + item.dataType = DT_FLOAT; + //SEISCOMP_DEBUG("%s: raw format with 32bit floats", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "DOUBLE", len) ) { + item.dataType = DT_DOUBLE; + //SEISCOMP_DEBUG("%s: raw format with 64bit doubles", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT64", len) ) { + item.dataType = DT_INT64; + //SEISCOMP_DEBUG("%s: raw format with 64bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT32", len) ) { + item.dataType = DT_INT32; + //SEISCOMP_DEBUG("%s: raw format with 32bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT16", len) ) { + item.dataType = DT_INT16; + //SEISCOMP_DEBUG("%s: raw format with 16bit integers", item.streamID.c_str()); + } + else if ( CHECK_STRING(data, "INT8", len) ) { + item.dataType = DT_INT8; + //SEISCOMP_DEBUG("%s: raw format with 8bit integers", item.streamID.c_str()); + } + else { + string tmp; + item.dataType = DT_Unknown; + tmp.assign(data, len); + CAPS_WARNING("Unknown raw data type '%s', all packages will be ignored", + tmp.c_str()); + } +} + +void SessionTable::registerItem(int id, SessionTableItem &item) { + item.fSamplingFrequency = (double)item.samplingFrequency / + (double)item.samplingFrequencyDivider; + + SessionTable::iterator it = find(id); + if ( it == end() ) { + if ( !item.splitStreamID() ) { + CAPS_WARNING("invalid streamID received: %s", item.streamID.c_str()); + return; + } + + // Copy the item + SessionTableItem &target = operator[](id); + target = item; + + _streamIDLookup[item.streamID] = id; + + if ( _itemAddedFunc ) _itemAddedFunc(&target); + } + else { + bool res = item.splitStreamID(); + + // streamID changed for the same sessionID? + if ( it->second.streamID != item.streamID ) { + CAPS_WARNING("inconsistent state: streamID '%s' for id %d, " + "but streamID '%s' has not been closed before", + item.streamID.c_str(), id, it->second.streamID.c_str()); + // Update lookup table + _streamIDLookup.erase(_streamIDLookup.find(it->second.streamID)); + + if ( !res ) { + CAPS_WARNING("invalid streamID received: %s", item.streamID.c_str()); + erase(it); + return; + } + + _streamIDLookup[item.streamID] = id; + + // TODO: How to update the request list? + } + + it->second = item; + + if ( _itemAddedFunc ) _itemAddedFunc(&it->second); + } +} + +void SessionTable::removeStream(const std::string &streamID) { + StreamIDLookupTable::iterator it = _streamIDLookup.find(streamID); + if ( it == _streamIDLookup.end() ) { + CAPS_WARNING("internal: tried to remove unknown stream '%s'", + streamID.c_str()); + return; + } + + SessionTable::iterator sessionIt = find(it->second); + if ( sessionIt != end() ) { + // Remove session table row + if ( _itemAboutToBeRemovedFunc ) + _itemAboutToBeRemovedFunc(&sessionIt->second); + erase(sessionIt); + } + + // Remove lookup entry + _streamIDLookup.erase(it); +} + +void SessionTable::reset() { + clear(); + _streamIDLookup.clear(); + _state = Unspecific; +} + +} +} diff --git a/libs/gempa/caps/sessiontable.h b/libs/gempa/caps/sessiontable.h new file mode 100644 index 0000000..22c5e80 --- /dev/null +++ b/libs/gempa/caps/sessiontable.h @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_SESSIONTABLE_H +#define GEMPA_CAPS_SESSIONTABLE_H + +#include "packet.h" + +#include +#include +#include + + +namespace Gempa { +namespace CAPS { + +struct SessionTableItem { + SessionTableItem() : samplingFrequency(0), samplingFrequencyDivider(0), + fSamplingFrequency(0.0), dataType(DT_Unknown), + dataSize(0), userData(NULL) {} + std::string streamID; + std::string net; + std::string sta; + std::string loc; + std::string cha; + uint16_t samplingFrequency; + uint16_t samplingFrequencyDivider; + double fSamplingFrequency; + PacketType type; + DataType dataType; + int dataSize; + UOM uom; + Time startTime; + Time endTime; + void *userData; + + bool splitStreamID(); +}; + + +class SC_GEMPA_CAPS_API SessionTable : public std::map { + public: + enum Status {Success, Error, EOD}; + + typedef std::function CallbackFunc; + + public: + //! Default constructor + SessionTable(); + virtual ~SessionTable() {} + + //! Resets state + void reset(); + + SessionTableItem* getItem(int id) { + SessionTable::iterator it = find(id); + if ( it == end() ) return NULL; + + return &it->second; + } + + Status handleResponse(const char *src_data, int data_len); + + void setItemAddedFunc(const CallbackFunc &func) { _itemAddedFunc = func; } + void setItemAboutToBeRemovedFunc(const CallbackFunc &func) { + _itemAboutToBeRemovedFunc = func; + } + + private: + enum ResponseState { + Unspecific, + Requests + }; + + typedef std::map StreamIDLookupTable; + + private: + void registerItem(int id, SessionTableItem &item); + void removeStream(const std::string & streamID); + + private: + ResponseState _state; + StreamIDLookupTable _streamIDLookup; + CallbackFunc _itemAddedFunc; + CallbackFunc _itemAboutToBeRemovedFunc; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/socket.cpp b/libs/gempa/caps/socket.cpp new file mode 100644 index 0000000..2268372 --- /dev/null +++ b/libs/gempa/caps/socket.cpp @@ -0,0 +1,545 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#include +#include + +#include +#include +#ifndef WIN32 +#include +#include +#include +#else +#ifndef SHUT_RDWR +#define SHUT_RDWR SD_BOTH +#endif +#define _WIN32_WINNT 0x0501 // Older versions does not support getaddrinfo +#include +#include +#include +#endif + + + +#include +#include +#include + + +using namespace std; + +namespace { + +inline string toString(unsigned short value) { + stringstream ss; + ss << value; + return ss.str(); +} + +} + +namespace Gempa { +namespace CAPS { + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Socket() { + _fd = -1; + _bytesSent = _bytesReceived = 0; + _timeOutSecs = _timeOutUsecs = 0; + +#ifdef WIN32 + WSADATA wsa; + WSAStartup(MAKEWORD(2,0),&wsa); +#endif +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::~Socket() { + close(); +#ifdef WIN32 + WSACleanup(); +#endif +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +const char *Socket::toString(Status stat) { + switch ( stat ) { + case Success: + return "success"; + default: + case Error: + return "error"; + case AllocationError: + return "allocation error"; + case ReuseAdressError: + return "reusing address failed"; + case BindError: + return "bind error"; + case ListenError: + return "listen error"; + case AcceptError: + return "accept error"; + case ConnectError: + return "connect error"; + case AddrInfoError: + return "address info error"; + case Timeout: + return "timeout"; + case InvalidSocket: + return "invalid socket"; + case InvalidPort: + return "invalid port"; + case InvalidAddressFamily: + return "invalid address family"; + case InvalidAddress: + return "invalid address"; + case InvalidHostname: + return "invalid hostname"; + } + + return ""; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +void Socket::shutdown() { + if ( _fd == -1 ) return; + //CAPS_DEBUG("Socket::shutdown"); + ::shutdown(_fd, SHUT_RDWR); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +void Socket::close() { + if ( _fd != -1 ) { + //CAPS_DEBUG("[socket] close %lX with fd = %d", (long int)this, _fd); + int fd = _fd; + _fd = -1; + ::close(fd); + } +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Status Socket::setSocketTimeout(int secs, int usecs) { + _timeOutSecs = secs; + _timeOutUsecs = usecs; + + if ( _fd != -1 ) + return applySocketTimeout(_timeOutSecs, _timeOutUsecs); + + return Success; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Status Socket::applySocketTimeout(int secs, int usecs) { + if ( _fd != -1 ) { + struct timeval timeout; + void *opt; + int optlen; + + if ( secs >= 0 ) { + timeout.tv_sec = secs; + timeout.tv_usec = usecs; + opt = &timeout; + optlen = sizeof(timeout); + } + else { + opt = NULL; + optlen = 0; + } + + CAPS_DEBUG("set socket timeout to %d.%ds", secs, usecs); + + if ( setsockopt(_fd, SOL_SOCKET, SO_RCVTIMEO, opt, optlen) ) + return Error; + + if ( setsockopt(_fd, SOL_SOCKET, SO_SNDTIMEO, opt, optlen) ) + return Error; + } + else + return InvalidSocket; + + return Success; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Device::Status Socket::setNonBlocking(bool nb) { + if ( !isValid() ) + return Device::InvalidDevice; + +#ifndef WIN32 + int flags = fcntl(_fd, F_GETFL, 0); + + if ( nb ) + flags |= O_NONBLOCK; + else + flags &= ~O_NONBLOCK; + + if ( fcntl(_fd, F_SETFL, flags) == -1 ) + return Device::Error; +#else + u_long arg = nb?1:0; + if ( ioctlsocket(_fd, FIONBIO, &arg) != 0 ) + return Device::Error; +#endif + + return Device::Success; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Status Socket::connect(const std::string &hostname, uint16_t port) { + if ( _fd != -1 ) { + //CAPS_WARNING("closing stale socket"); + close(); + } + + struct sockaddr addr; + size_t addrlen; + + struct addrinfo *res; + struct addrinfo hints; + + memset (&hints, 0, sizeof(hints)); + hints.ai_family = PF_INET; + hints.ai_socktype = SOCK_STREAM; + + string strPort = ::toString(port); + + int ret = getaddrinfo(hostname.c_str(), strPort.c_str(), &hints, &res); + if ( ret ) { + CAPS_DEBUG("Test3 Socket::connect(%s:%d): %s", + hostname.c_str(), port, +#ifndef WIN32 + strerror(errno)); +#else + gai_strerror(ret)); +#endif + return AddrInfoError; + } + + addr = *(res->ai_addr); + addrlen = res->ai_addrlen; + freeaddrinfo(res); + + if ( (_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0 ) { + /*CAPS_DEBUG("Socket::connect(%s:%d): %s", + hostname.c_str(), port, strerror(errno));*/ + return AllocationError; + } + +#ifndef WIN32 + if ( ::connect(_fd, (struct sockaddr *)&addr, addrlen) == -1 ) { + if ( errno != EINPROGRESS ) { + /*CAPS_DEBUG("Socket::connect(%s:%d): %s", + hostname.c_str(), port, strerror(errno));*/ + close(); + return errno == ETIMEDOUT?Timeout:ConnectError; + } + } +#else + if ( ::connect(_fd, (struct sockaddr *)&addr, addrlen) == SOCKET_ERROR ) { + int err = WSAGetLastError(); + if (err != WSAEINPROGRESS && err != WSAEWOULDBLOCK) { + CAPS_DEBUG("Socket::connect(%s:%d): %s", + hostname.c_str(), port, gai_strerror(err)); + close(); + return ConnectError; + } + } +#endif + + return Success; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int Socket::send(const char *data) { + return write(data, strlen(data)); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int Socket::write(const char *data, int len) { +#if !defined(MACOSX) && !defined(WIN32) + int sent = (int)::send(_fd, data, len, MSG_NOSIGNAL); +#else + int sent = (int)::send(_fd, data, len, 0); +#endif + if ( sent > 0 ) { + _bytesSent += sent; + } + return sent; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int Socket::read(char *data, int len) { + int recvd = (int)::recv(_fd, data, len, 0); + if ( recvd > 0 ) _bytesReceived += recvd; + return recvd; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int Socket::flush() { return 1; } +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +bool Socket::isValid() { + return _fd != -1; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +SSLSocket::SSLSocket() : _ssl(NULL), _ctx(NULL) {} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +SSLSocket::SSLSocket(SSL_CTX *ctx) : _ssl(NULL), _ctx(ctx) {} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +SSLSocket::~SSLSocket() { + close(); + cleanUp(); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int SSLSocket::write(const char *data, int len) { + int ret = SSL_write(_ssl, data, len); + if ( ret > 0 ) { + _bytesSent += ret; + return ret; + } + + int err = SSL_get_error(_ssl, ret); + + switch ( err ) { + case SSL_ERROR_WANT_X509_LOOKUP: + errno = EAGAIN; + return -1; + case SSL_ERROR_WANT_READ: + errno = EAGAIN; + return -1; + case SSL_ERROR_WANT_WRITE: + errno = EAGAIN; + return -1; + case SSL_ERROR_ZERO_RETURN: + errno = EINVAL; + return 0; + default: + break; + } + + return ret; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +int SSLSocket::read(char *data, int len) { + int ret = SSL_read(_ssl, data, len); + if ( ret > 0 ) { + _bytesReceived += ret; + return ret; + } + + int err = SSL_get_error(_ssl, ret); + + switch ( err ) { + case SSL_ERROR_WANT_X509_LOOKUP: + errno = EAGAIN; + return -1; + case SSL_ERROR_WANT_READ: + errno = EAGAIN; + return -1; + case SSL_ERROR_WANT_WRITE: + errno = EAGAIN; + return -1; + case SSL_ERROR_ZERO_RETURN: + errno = EINVAL; + return 0; + default: + break; + } + + return ret; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +Socket::Status SSLSocket::connect(const std::string &hostname, uint16_t port) { + cleanUp(); + + _ctx = SSL_CTX_new(SSLv23_client_method()); + if ( _ctx == NULL ) { + CAPS_DEBUG("Invalid SSL context"); + return ConnectError; + } + + SSL_CTX_set_mode(_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); + + Status s = Socket::connect(hostname, port); + if ( s != Success ) + return s; + + _ssl = SSL_new(_ctx); + if ( _ssl == NULL ) { + CAPS_DEBUG("Failed to create SSL context"); + return ConnectError; + } + + SSL_set_fd(_ssl, _fd); + SSL_set_shutdown(_ssl, 0); + SSL_set_connect_state(_ssl); + int err = SSL_connect(_ssl); + if ( err < 0 ) { + CAPS_ERROR("Failed to connect with SSL, error %d", + SSL_get_error(_ssl, err)); + close(); + return ConnectError; + } + + return Success; +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +const unsigned char *SSLSocket::sessionID() const { +#if OPENSSL_VERSION_NUMBER < 0x10100000L + return _ssl?_ssl->session->session_id:NULL; +#else + return _ssl?SSL_SESSION_get0_id_context(SSL_get0_session(_ssl), NULL):NULL; +#endif +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +unsigned int SSLSocket::sessionIDLength() const { +#if OPENSSL_VERSION_NUMBER < 0x10100000L + return _ssl?_ssl->session->session_id_length:0; +#else + unsigned int len; + if ( !_ssl ) return 0; + SSL_SESSION_get0_id_context(SSL_get0_session(_ssl), &len); + return len; +#endif +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +X509 *SSLSocket::peerCertificate() { + if ( _ssl == NULL ) return NULL; + return SSL_get_peer_certificate(_ssl); +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +void SSLSocket::cleanUp() { + if ( _ssl ) { + SSL_free(_ssl); + _ssl = NULL; + } + + if ( _ctx ) { + SSL_CTX_free(_ctx); + _ctx = NULL; + } +} +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +#endif + + + +// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +} +} diff --git a/libs/gempa/caps/socket.h b/libs/gempa/caps/socket.h new file mode 100644 index 0000000..db5c44a --- /dev/null +++ b/libs/gempa/caps/socket.h @@ -0,0 +1,273 @@ +/*************************************************************************** + * Copyright (C) 2013 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_SOCKET_H +#define GEMPA_CAPS_SOCKET_H + +#include + +#include + +#include + +#include +#include +#include +#include + +namespace Gempa { +namespace CAPS { + +class SC_GEMPA_CAPS_API Socket { + public: + typedef uint64_t count_t; + + enum Status { + Success = 0, + Error, + AllocationError, + ReuseAdressError, + BindError, + ListenError, + AcceptError, + ConnectError, + AddrInfoError, + Timeout, + InvalidSocket, + InvalidPort, + InvalidAddressFamily, + InvalidAddress, + InvalidHostname + }; + + struct Device { + enum Status { + Success = 0, + Error, + InvalidDevice, + AllocationError + }; + }; + + public: + Socket(); + virtual ~Socket(); + + + public: + static const char *toString(Status); + + int fd() { return _fd; } + + bool isValid(); + + void shutdown(); + void close(); + + + int send(const char *data); + + virtual int write(const char *data, int len); + virtual int read(char *data, int len); + virtual int flush(); + + //! Sets the socket timeout. This utilizes setsockopt which does not + //! work in non blocking sockets. + Status setSocketTimeout(int secs, int usecs); + + Device::Status setNonBlocking(bool nb); + + virtual Status connect(const std::string &hostname, uint16_t port); + + count_t rx() const { return _bytesReceived; } + count_t tx() const { return _bytesSent; } + + protected: + Status applySocketTimeout(int secs, int usecs); + + + protected: + int _fd; + + count_t _bytesSent; + count_t _bytesReceived; + + int _timeOutSecs; + int _timeOutUsecs; +}; + +typedef boost::shared_ptr SocketPtr; + +#if !defined(CAPS_FEATURES_SSL) || CAPS_FEATURES_SSL + +class SSLSocket : public Socket { + public: + SSLSocket(); + SSLSocket(SSL_CTX *ctx); + ~SSLSocket(); + + public: + int write(const char *data, int len); + int read(char *data, int len); + + Status connect(const std::string &hostname, uint16_t port); + + virtual const unsigned char *sessionID() const; + virtual unsigned int sessionIDLength() const; + + X509 *peerCertificate(); + + private: + void cleanUp(); + + private: + SSL *_ssl; + SSL_CTX *_ctx; +}; + +typedef boost::shared_ptr SSLSocketPtr; + +#endif + +template +class socketbuf : public std::streambuf { + public: + socketbuf() { + setsocket(NULL); + } + + socketbuf(T *sock) { + setsocket(sock); + } + + void setsocket(T *sock) { + _allowed_reads = -1; + _real_buffer_size = 0; + _block_write = false; + setg(_in, _in, _in); + setp(_out, _out + N); + _sock = sock; + } + + void settimeout(const struct timeval &tv) { + _timeout = tv; + } + + void set_read_limit(int bytes) { + _allowed_reads = bytes; + + if ( _allowed_reads >= 0 ) { + if ( egptr() - gptr() > _allowed_reads ) + setg(eback(), gptr(), gptr() + _allowed_reads); + + // Set the number of read bytes to the + // remaining bytes in the buffer + _allowed_reads -= egptr() - gptr(); + } + else + setg(eback(), gptr(), eback() + _real_buffer_size); + + //std::cout << "[" << (void*)eback() << ", " << (void*)gptr() << ", " << (void*)egptr() << "]" << " = " << (egptr() - gptr()) << std::endl; + } + + int read_limit() const { + if ( _allowed_reads < 0 ) return -1; + return egptr() - gptr() + _allowed_reads; + } + + + protected: + virtual int underflow() { + // No more reads allowed? + if ( !_allowed_reads ) + return traits_type::eof(); + + // Read available data from socket + int res = _sock->read(_in, N); + if ( res <= 0 ) { + set_read_limit(0); + return traits_type::eof(); + } + + // Set input sequence pointers + _real_buffer_size = res; + setg(_in, _in, _in + _real_buffer_size); + + // clip to limit + set_read_limit(_allowed_reads); + + return traits_type::to_int_type(*gptr()); + } + + virtual int overflow(int c) { + if ( _block_write ) return traits_type::eof(); + + if ( pptr() - pbase() == N ) { + if ( sync() != 0 ) return traits_type::eof(); + } + + if ( !traits_type::eq_int_type(traits_type::eof(), c)) { + traits_type::assign(*pptr(), traits_type::to_char_type(c)); + + pbump(1); + } + + return traits_type::not_eof(c); + } + + virtual int sync() { + if ( pbase() == pptr() ) return 0; + + int res = _sock->write(pbase(), pptr() - pbase()); + if ( res == pptr() - pbase() ) { + setp(_out, _out + N); + return 0; + } + + return 1; + } + + // Only forward seeking is supported + virtual std::streampos + seekoff(std::streamoff off, std::ios_base::seekdir way, + std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) { + if ( way != std::ios_base::cur || which != std::ios_base::in || off < 0 ) + return -1; + + while ( off > 0 ) { + int ch = sbumpc(); + if ( ch == traits_type::eof() ) + return -1; + --off; + } + + return 0; + } + + private: + T *_sock; + timeval _timeout; + char _in[N]; + char _out[N]; + bool _block_write; + int _real_buffer_size; + int _allowed_reads; +}; + +} +} + + +#endif diff --git a/libs/gempa/caps/strptime.c b/libs/gempa/caps/strptime.c new file mode 100644 index 0000000..dfcb30e --- /dev/null +++ b/libs/gempa/caps/strptime.c @@ -0,0 +1,1009 @@ +/* Convert a string representation of time to a time value. + Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* XXX This version of the implementation is not really complete. + Some of the fields cannot add information alone. But if seeing + some of them in the same format (such as year, week and weekday) + this is enough information for determining the date. */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#ifdef _LIBC +# include "../locale/localeinfo.h" +#endif + +#include "strptime.h" + +#if defined(_MSC_VER) +#define strncasecmp strnicmp +#define strcasecmp stricmp +#endif + +#ifndef __P +# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +# define __P(args) args +# else +# define __P(args) () +# endif /* GCC. */ +#endif /* Not __P. */ + +#if ! HAVE_LOCALTIME_R && ! defined localtime_r +# ifdef _LIBC +# define localtime_r __localtime_r +# else +/* Approximate localtime_r as best we can in its absence. */ +# define localtime_r my_localtime_r +static struct tm *localtime_r __P ((const time_t *, struct tm *)); +static struct tm * +localtime_r (t, tp) + const time_t *t; + struct tm *tp; +{ + struct tm *l = localtime (t); + if (! l) + return 0; + *tp = *l; + return tp; +} +# endif /* ! _LIBC */ +#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */ + + +#define match_char(ch1, ch2) if (ch1 != ch2) return NULL +#if defined __GNUC__ && __GNUC__ >= 2 +# define match_string(cs1, s2) \ + ({ size_t len = strlen (cs1); \ + int result = strncasecmp ((cs1), (s2), len) == 0; \ + if (result) (s2) += len; \ + result; }) +#else +/* Oh come on. Get a reasonable compiler. */ +# define match_string(cs1, s2) \ + (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) +#endif +/* We intentionally do not use isdigit() for testing because this will + lead to problems with the wide character version. */ +#define get_number(from, to, n) \ + do { \ + int __n = n; \ + val = 0; \ + while (*rp == ' ') \ + ++rp; \ + if (*rp < '0' || *rp > '9') \ + return NULL; \ + do { \ + val *= 10; \ + val += *rp++ - '0'; \ + } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \ + if (val < from || val > to) \ + return NULL; \ + } while (0) +#ifdef _NL_CURRENT +# define get_alt_number(from, to, n) \ + ({ \ + __label__ do_normal; \ + if (*decided != raw) \ + { \ + const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \ + int __n = n; \ + int any = 0; \ + while (*rp == ' ') \ + ++rp; \ + val = 0; \ + do { \ + val *= 10; \ + while (*alts != '\0') \ + { \ + size_t len = strlen (alts); \ + if (strncasecmp (alts, rp, len) == 0) \ + break; \ + alts += len + 1; \ + ++val; \ + } \ + if (*alts == '\0') \ + { \ + if (*decided == not && ! any) \ + goto do_normal; \ + /* If we haven't read anything it's an error. */ \ + if (! any) \ + return NULL; \ + /* Correct the premature multiplication. */ \ + val /= 10; \ + break; \ + } \ + else \ + *decided = loc; \ + } while (--__n > 0 && val * 10 <= to); \ + if (val < from || val > to) \ + return NULL; \ + } \ + else \ + { \ + do_normal: \ + get_number (from, to, n); \ + } \ + 0; \ + }) +#else +# define get_alt_number(from, to, n) \ + /* We don't have the alternate representation. */ \ + get_number(from, to, n) +#endif +#define recursive(new_fmt) \ + (*(new_fmt) != '\0' \ + && (rp = strptime_internal (rp, (new_fmt), tm, decided, era_cnt)) != NULL) + + +#ifdef _LIBC +/* This is defined in locale/C-time.c in the GNU libc. */ +extern const struct locale_data _nl_C_LC_TIME; +extern const unsigned short int __mon_yday[2][13]; + +# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string) +# define ab_weekday_name \ + (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) +# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) +# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) +# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) +# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) +# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) +# define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string) +# define HERE_T_FMT_AMPM \ + (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string) +# define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string) + +# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n) +#else +static char const weekday_name[][10] = + { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }; +static char const ab_weekday_name[][4] = + { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; +static char const month_name[][10] = + { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; +static char const ab_month_name[][4] = + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; +# define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y" +# define HERE_D_FMT "%m/%d/%y" +# define HERE_AM_STR "AM" +# define HERE_PM_STR "PM" +# define HERE_T_FMT_AMPM "%I:%M:%S %p" +# define HERE_T_FMT "%H:%M:%S" + +const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; +#endif + +/* Status of lookup: do we use the locale data or the raw data? */ +enum locale_status { not, loc, raw }; + + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + +/* Compute the day of the week. */ +static void +day_of_the_week (struct tm *tm) +{ + /* We know that January 1st 1970 was a Thursday (= 4). Compute the + the difference between this data in the one on TM and so determine + the weekday. */ + int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2); + int wday = (-473 + + (365 * (tm->tm_year - 70)) + + (corr_year / 4) + - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0) + + (((corr_year / 4) / 25) / 4) + + __mon_yday[0][tm->tm_mon] + + tm->tm_mday - 1); + tm->tm_wday = ((wday % 7) + 7) % 7; +} + +/* Compute the day of the year. */ +static void +day_of_the_year (struct tm *tm) +{ + tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon] + + (tm->tm_mday - 1)); +} + +static char * +#ifdef _LIBC +internal_function +#endif +strptime_internal __P ((const char *rp, const char *fmt, struct tm *tm, + enum locale_status *decided, int era_cnt)); + +static char * +#ifdef _LIBC +internal_function +#endif +strptime_internal (rp, fmt, tm, decided, era_cnt) + const char *rp; + const char *fmt; + struct tm *tm; + enum locale_status *decided; + int era_cnt; +{ + const char *rp_backup; + int cnt; + size_t val; + int have_I, is_pm; + int century, want_century; + int want_era; + int have_wday, want_xday; + int have_yday; + int have_mon, have_mday; +#ifdef _NL_CURRENT + size_t num_eras; +#endif + struct era_entry *era; + + have_I = is_pm = 0; + century = -1; + want_century = 0; + want_era = 0; + era = NULL; + + have_wday = want_xday = have_yday = have_mon = have_mday = 0; + + while (*fmt != '\0') + { + /* A white space in the format string matches 0 more or white + space in the input string. */ + if (isspace (*fmt)) + { + while (isspace (*rp)) + ++rp; + ++fmt; + continue; + } + + /* Any character but `%' must be matched by the same character + in the iput string. */ + if (*fmt != '%') + { + match_char (*fmt++, *rp++); + continue; + } + + ++fmt; +#ifndef _NL_CURRENT + /* We need this for handling the `E' modifier. */ + start_over: +#endif + + /* Make back up of current processing pointer. */ + rp_backup = rp; + + switch (*fmt++) + { + case '%': + /* Match the `%' character itself. */ + match_char ('%', *rp++); + break; + case 'a': + case 'A': + /* Match day of week. */ + for (cnt = 0; cnt < 7; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt), + weekday_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), + ab_weekday_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (*decided != loc + && (match_string (weekday_name[cnt], rp) + || match_string (ab_weekday_name[cnt], rp))) + { + *decided = raw; + break; + } + } + if (cnt == 7) + /* Does not match a weekday name. */ + return NULL; + tm->tm_wday = cnt; + have_wday = 1; + break; + case 'b': + case 'B': + case 'h': + /* Match month name. */ + for (cnt = 0; cnt < 12; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt), + month_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), + ab_month_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (match_string (month_name[cnt], rp) + || match_string (ab_month_name[cnt], rp)) + { + *decided = raw; + break; + } + } + if (cnt == 12) + /* Does not match a month name. */ + return NULL; + tm->tm_mon = cnt; + want_xday = 1; + break; + case 'c': + /* Match locale's date and time format. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + /* Match century number. */ +#ifdef _NL_CURRENT + match_century: +#endif + get_number (0, 99, 2); + century = val; + want_xday = 1; + break; + case 'd': + case 'e': + /* Match day of month. */ + get_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'F': + if (!recursive ("%Y-%m-%d")) + return NULL; + want_xday = 1; + break; + case 'x': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'D': + /* Match standard day format. */ + if (!recursive (HERE_D_FMT)) + return NULL; + want_xday = 1; + break; + case 'k': + case 'H': + /* Match hour in 24-hour clock. */ + get_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'I': + /* Match hour in 12-hour clock. */ + get_number (1, 12, 2); + tm->tm_hour = val % 12; + have_I = 1; + break; + case 'j': + /* Match day number of year. */ + get_number (1, 366, 3); + tm->tm_yday = val - 1; + have_yday = 1; + break; + case 'm': + /* Match number of month. */ + get_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minute. */ + get_number (0, 59, 2); + tm->tm_min = val; + break; + case 'n': + case 't': + /* Match any white space. */ + while (isspace (*rp)) + ++rp; + break; + case 'p': + /* Match locale's equivalent of AM/PM. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR)) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR)) + *decided = loc; + is_pm = 1; + break; + } + *decided = raw; + } +#endif + if (!match_string (HERE_AM_STR, rp)) + if (match_string (HERE_PM_STR, rp)) + is_pm = 1; + else + return NULL; + break; + case 'r': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM), + HERE_T_FMT_AMPM)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_T_FMT_AMPM)) + return NULL; + break; + case 'R': + if (!recursive ("%H:%M")) + return NULL; + break; + case 's': + { + /* The number of seconds may be very high so we cannot use + the `get_number' macro. Instead read the number + character for character and construct the result while + doing this. */ + time_t secs = 0; + if (*rp < '0' || *rp > '9') + /* We need at least one digit. */ + return NULL; + + do + { + secs *= 10; + secs += *rp++ - '0'; + } + while (*rp >= '0' && *rp <= '9'); + + if (localtime_r (&secs, tm) == NULL) + /* Error in function. */ + return NULL; + } + break; + case 'S': + get_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'X': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'T': + if (!recursive (HERE_T_FMT)) + return NULL; + break; + case 'u': + get_number (1, 7, 1); + tm->tm_wday = val % 7; + have_wday = 1; + break; + case 'g': + get_number (0, 99, 2); + /* XXX This cannot determine any field in TM. */ + break; + case 'G': + if (*rp < '0' || *rp > '9') + return NULL; + /* XXX Ignore the number since we would need some more + information to compute a real date. */ + do + ++rp; + while (*rp >= '0' && *rp <= '9'); + break; + case 'U': + case 'V': + case 'W': + get_number (0, 53, 2); + /* XXX This cannot determine any field in TM without some + information. */ + break; + case 'w': + /* Match number of weekday. */ + get_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': +#ifdef _NL_CURRENT + match_year_in_century: +#endif + /* Match year within century. */ + get_number (0, 99, 2); + /* The "Year 2000: The Millennium Rollover" paper suggests that + values in the range 69-99 refer to the twentieth century. */ + tm->tm_year = val >= 69 ? val : val + 100; + /* Indicate that we want to use the century, if specified. */ + want_century = 1; + want_xday = 1; + break; + case 'Y': + /* Match year including century number. */ + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'Z': + /* XXX How to handle this? */ + break; + case 'E': +#ifdef _NL_CURRENT + switch (*fmt++) + { + case 'c': + /* Match locale's alternate date and time format. */ + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + if (*decided != raw) + { + if (era_cnt >= 0) + { + era = _nl_select_era_entry (era_cnt); + if (match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + else + return NULL; + } + else + { + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt); + if (match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + } + if (era_cnt == (int) num_eras) + { + era_cnt = -1; + if (*decided == loc) + return NULL; + } + else + break; + } + + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + goto match_century; + case 'y': + if (*decided == raw) + goto match_year_in_century; + + get_number(0, 9999, 4); + tm->tm_year = val; + want_era = 1; + want_xday = 1; + break; + case 'Y': + if (*decided != raw) + { + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt); + if (recursive (era->era_format)) + break; + } + if (era_cnt == (int) num_eras) + { + era_cnt = -1; + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + *decided = loc; + era_cnt = -1; + break; + } + + *decided = raw; + } + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'x': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_D_FMT)) + return NULL; + break; + case 'X': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_T_FMT)) + return NULL; + break; + default: + return NULL; + } + break; +#else + /* We have no information about the era format. Just use + the normal format. */ + if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y' + && *fmt != 'x' && *fmt != 'X') + /* This is an illegal format. */ + return NULL; + + goto start_over; +#endif + case 'O': + switch (*fmt++) + { + case 'd': + case 'e': + /* Match day of month using alternate numeric symbols. */ + get_alt_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'H': + /* Match hour in 24-hour clock using alternate numeric + symbols. */ + get_alt_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'I': + /* Match hour in 12-hour clock using alternate numeric + symbols. */ + get_alt_number (1, 12, 2); + tm->tm_hour = val - 1; + have_I = 1; + break; + case 'm': + /* Match month using alternate numeric symbols. */ + get_alt_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minutes using alternate numeric symbols. */ + get_alt_number (0, 59, 2); + tm->tm_min = val; + break; + case 'S': + /* Match seconds using alternate numeric symbols. */ + get_alt_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'U': + case 'V': + case 'W': + get_alt_number (0, 53, 2); + /* XXX This cannot determine any field in TM without + further information. */ + break; + case 'w': + /* Match number of weekday using alternate numeric symbols. */ + get_alt_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': + /* Match year within century using alternate numeric symbols. */ + get_alt_number (0, 99, 2); + tm->tm_year = val >= 69 ? val : val + 100; + want_xday = 1; + break; + default: + return NULL; + } + break; + default: + return NULL; + } + } + + if (have_I && is_pm) + tm->tm_hour += 12; + + if (century != -1) + { + if (want_century) + tm->tm_year = tm->tm_year % 100 + (century - 19) * 100; + else + /* Only the century, but not the year. Strange, but so be it. */ + tm->tm_year = (century - 19) * 100; + } + +#ifdef _NL_CURRENT + if (era_cnt != -1) + { + era = _nl_select_era_entry(era_cnt); + if (want_era) + tm->tm_year = (era->start_date[0] + + ((tm->tm_year - era->offset) + * era->absolute_direction)); + else + /* Era start year assumed. */ + tm->tm_year = era->start_date[0]; + } + else +#endif + if (want_era) + return NULL; + + if (want_xday && !have_wday) + { + if ( !(have_mon && have_mday) && have_yday) + { + /* We don't have tm_mon and/or tm_mday, compute them. */ + int t_mon = 0; + while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) + t_mon++; + if (!have_mon) + tm->tm_mon = t_mon - 1; + if (!have_mday) + tm->tm_mday = + (tm->tm_yday + - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); + } + day_of_the_week (tm); + } + if (want_xday && !have_yday) + day_of_the_year (tm); + + return (char *) rp; +} + + +char * +strptime (buf, format, tm) + const char *buf; + const char *format; + struct tm *tm; +{ + enum locale_status decided; + +#ifdef _NL_CURRENT + decided = not; +#else + decided = raw; +#endif + return strptime_internal (buf, format, tm, &decided, -1); +} diff --git a/libs/gempa/caps/strptime.h b/libs/gempa/caps/strptime.h new file mode 100644 index 0000000..afa3aa4 --- /dev/null +++ b/libs/gempa/caps/strptime.h @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) by GFZ Potsdam * + * * + * You can redistribute and/or modify this program under the * + * terms of the SeisComP Public License. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * SeisComP Public License for more details. * + ***************************************************************************/ + + +#ifndef STRPTIME_H +#define STRPTIME_H + +/* + * Version of "strptime()", for the benefit of OSes that don't have it. + */ +extern char *strptime(const char *, const char *, struct tm *); + +#endif diff --git a/libs/gempa/caps/test/CMakeLists.txt b/libs/gempa/caps/test/CMakeLists.txt new file mode 100644 index 0000000..c4574c9 --- /dev/null +++ b/libs/gempa/caps/test/CMakeLists.txt @@ -0,0 +1,23 @@ +SET(TESTS + datetime.cpp + rawpacket.cpp + packet.cpp + utils.cpp + datetime_time.cpp + endianess.cpp + mseedpacket.cpp +) + +FOREACH(testSrc ${TESTS}) + GET_FILENAME_COMPONENT(testName ${testSrc} NAME_WE) + SET(testName test_caps_${testName}) + ADD_EXECUTABLE(${testName} ${testSrc}) + SC_LINK_LIBRARIES_INTERNAL(${testName} unittest) + SC_LINK_LIBRARIES(${testName} ${CURL_LIBRARIES} caps_client) + + ADD_TEST( + NAME ${testName} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${testName} + ) +ENDFOREACH(testSrc) diff --git a/libs/gempa/caps/test/data/AM.RFE4F.00.SHZ.20180912.mseed b/libs/gempa/caps/test/data/AM.RFE4F.00.SHZ.20180912.mseed new file mode 100644 index 0000000000000000000000000000000000000000..d43aef96c82a16811412796030f4bbebad6fdaed GIT binary patch literal 512 zcmV+b0{{ImFfcPRIYb~*MnyD6Ffda{T0u<*;sE~&H#h(tRsm7~G5`Sp0006200000 zKmafU=m0ni0SN#D=>Py<000L9YO0z500G7T00Ni)fMoDj&K$S$O+&@^?@(L9UQ^K3 zV>2YfwR_U*kErFr&Coo?3~J#9Cy@!qgy|N-JyS+1nwF~k-fRQUq0fQ9&_gKlK~SsT z+(Rn;KWjYnvnaRs&eWi2Bztnqx)#&+o}56%Z3{TZpGWD+af{9VvWS!#s;a8#4Mvgo z5i_^)4^(BwVFX9^Ox#V!j$}{HZj-XiZ#Js`LYJ}l!}SdF3-o`)TT9y1aWApNK;Q$& z&>ImZrDB^Q2)_$PnXrk9{+5^B9JoxG~JEZ zODP(~uWNn5k{jvvZvYnJ)hSBsBYY&gARN9as+Fn00dwE>z(A%Fx%%ezT)*4;E>LC6 zQViqCJ_Db`KOb)xBF^9KNB!6dw6q%fJ`A4DP;d#%utP4F``*kdSz4;XAGeXnGM|0- za!g3xLs_P*2pjG9&s3c`^(oh}C0H>AE8wg8zd$C=^FPw|{jXT`Pq25w(SZHRZ)fBc CNB-Ub literal 0 HcmV?d00001 diff --git a/libs/gempa/caps/test/datetime.cpp b/libs/gempa/caps/test/datetime.cpp new file mode 100644 index 0000000..8055003 --- /dev/null +++ b/libs/gempa/caps/test/datetime.cpp @@ -0,0 +1,566 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include +#include + +#include + + +namespace gc = Gempa::CAPS; +namespace bu = boost::unit_test; + + + +bool isClose(gc::TimeSpan time, long sec, long micro, int offset = 1) { + long microSeconds = time.microseconds(); + + long secDiff = time.seconds() - sec; + if ( secDiff > 0 ) + microSeconds += secDiff * 1000000; + else if ( secDiff < 0 ) + micro += abs(secDiff) * 1000000; + + if ( abs(microSeconds - micro) <= offset ) + return true; + return false; +} + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE(gempa_common_caps_datetime) + + +BOOST_AUTO_TEST_CASE(construction) { + + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + struct timeval tvPositive; + tvPositive.tv_sec = 60000; + tvPositive.tv_usec = 123456; + gc::TimeSpan k(tvPositive); + BOOST_CHECK(k.seconds() == tvPositive.tv_sec); + BOOST_CHECK(k.microseconds() == tvPositive.tv_usec); + + struct timeval tvNegativeUsec; + tvNegativeUsec.tv_sec = 300; + tvNegativeUsec.tv_usec = -13456; + gc::TimeSpan ki(tvNegativeUsec); + BOOST_CHECK_EQUAL(ki.seconds() , tvNegativeUsec.tv_sec); + BOOST_CHECK_EQUAL(ki.microseconds() , tvNegativeUsec.tv_usec); + + struct timeval tvNegativeSec; + tvNegativeSec.tv_sec = -300; + tvNegativeSec.tv_usec = 13456; + + gc::TimeSpan kj(tvNegativeSec); + BOOST_CHECK_EQUAL(kj.seconds() , tvNegativeSec.tv_sec); + BOOST_CHECK_EQUAL(kj.microseconds() , tvNegativeSec.tv_usec); + + struct timeval tvNegative; + tvNegative.tv_sec = -3000; + tvNegative.tv_usec = -123456; + gc::TimeSpan kk(tvNegative); + BOOST_CHECK_EQUAL(kk.seconds() , tvNegative.tv_sec); + BOOST_CHECK_EQUAL(kk.microseconds() , tvNegative.tv_usec); + + struct timeval tvNull; + gc::TimeSpan kl(tvNull); + BOOST_CHECK_EQUAL(kl.seconds() , tvNull.tv_sec); + BOOST_CHECK_EQUAL(kl.microseconds() , tvNull.tv_usec); + + // copy + gc::TimeSpan copyPositive(gc::TimeSpan(79743.123456)); + BOOST_CHECK(copyPositive.seconds() == 79743); + BOOST_CHECK(copyPositive.microseconds() == 123456); + + gc::TimeSpan copyNegative(gc::TimeSpan(-98765.123456)); + long sec = -98765; + long micro = -123456; + BOOST_CHECK(isClose(copyNegative, sec, micro,20) == true); + + gc::TimeSpan copyNegativeTest(gc::TimeSpan(-98765.000070)); + sec = -98765 ; + micro = 70; + BOOST_CHECK_EQUAL(isClose(copyNegativeTest,sec, micro,500), true); + + // long + gc::TimeSpan longPositive(765432, 456789); + BOOST_CHECK(longPositive.seconds() == 765432); + BOOST_CHECK(longPositive.microseconds() == 456789); + + gc::TimeSpan longNegativeUsec(200, -732); + BOOST_CHECK_EQUAL(longNegativeUsec.seconds(), 200); + BOOST_CHECK_EQUAL(longNegativeUsec.microseconds(), -732); + + gc::TimeSpan longNegativeSec(-800, 73265); + BOOST_CHECK_EQUAL(longNegativeSec.seconds(), -800); + BOOST_CHECK_EQUAL(longNegativeSec.microseconds(), 73265); + + gc::TimeSpan longNegative(-500, -732650); + BOOST_CHECK_EQUAL(longNegative.seconds(), -500); + BOOST_CHECK_EQUAL(longNegative.microseconds(), -732650); + + // double + double number = 123456.98765; + gc::TimeSpan doublePositive(number); + BOOST_CHECK_EQUAL(doublePositive.seconds(), 123456); + BOOST_CHECK_EQUAL(doublePositive.microseconds(), 987650); + + number = -98765.123470; + gc::TimeSpan doubleNegative(number); + BOOST_CHECK_EQUAL(doubleNegative.seconds(), -98765); + BOOST_CHECK_CLOSE((double)doubleNegative.microseconds(), -123470, 0.01); + + number = -98765.000080; + gc::TimeSpan doubleNegativeTest(number); + sec = -98765; + micro = 80; + BOOST_CHECK_EQUAL(isClose(doubleNegativeTest,sec, micro,500), true); + + // pointer + timeval n; + n.tv_sec = 123; + n.tv_usec = 123456; + + gc::TimeSpan pointerPositive(&n); + BOOST_CHECK_EQUAL(pointerPositive.seconds(), 123); + BOOST_CHECK_EQUAL(pointerPositive.microseconds(), 123456); + + n.tv_sec = -123; + n.tv_usec = 123456; + + gc::TimeSpan pointerNegativeSec(&n); + BOOST_CHECK_EQUAL(pointerNegativeSec.seconds(), -123); + BOOST_CHECK_EQUAL(pointerNegativeSec.microseconds(), 123456); + + n.tv_sec = 123; + n.tv_usec = -123456; + + gc::TimeSpan pointerNegativeUsec(&n); + BOOST_CHECK_EQUAL(pointerNegativeUsec.seconds(), 123); + BOOST_CHECK_EQUAL(pointerNegativeUsec.microseconds(), -123456); + + n.tv_sec = -123; + n.tv_usec = -123456; + + gc::TimeSpan pointerNegative(&n); + BOOST_CHECK_EQUAL(pointerNegative.seconds(), -123); + BOOST_CHECK_EQUAL(pointerNegative.microseconds(), -123456); + + timeval *nullPointer = NULL; + gc::TimeSpan pointerNull(nullPointer); + BOOST_CHECK_EQUAL(pointerNull.seconds(), 0); + BOOST_CHECK_EQUAL(pointerNull.microseconds(), 0); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(addition) { + gc::TimeSpan k = 5, l = 7; + BOOST_CHECK(k + l == gc::TimeSpan(12)); + + gc::TimeSpan m = 320.5, n = 60.2; + BOOST_CHECK(m + n == gc::TimeSpan(380.7)); + + gc::TimeSpan g = 55, d = -50; + BOOST_CHECK(d + g == gc::TimeSpan(5)); + + gc::TimeSpan t = -80.0053, s = -70.0044; + gc::TimeSpan result = t + s; + long sec = t.seconds() + s.seconds(); + long micro = t.microseconds() + s.microseconds(); + BOOST_CHECK_EQUAL(isClose(result, sec,micro),true); + + gc::TimeSpan u = -5.035, v = -60.044; + result = u + v; + sec = u.seconds() + v.seconds(); + micro = u.microseconds() + v.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); + + gc::TimeSpan w = -5.0885, x = -6.01111; + result = w + x; + sec = w.seconds() + x.seconds(); + micro = w.microseconds() + x.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(subtraction) { + gc::TimeSpan k = 5, l = 6; + BOOST_CHECK(k - l == gc::TimeSpan(-1)); + + gc::TimeSpan t = 58, i = 68.05; + gc::TimeSpan result = t - i; + long sec = t.seconds() - i.seconds(); + long micro = t.microseconds() - i.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); + + gc::TimeSpan e(30,4); + gc::TimeSpan o(45,3); + result = e - o; + sec = e.seconds() - o.seconds(); + micro = e.microseconds() - o.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); + + gc::TimeSpan f = 30.00004, g = -45.00003; + result = f - g; + sec = f.seconds() - g.seconds(); + micro = f.microseconds() - g.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(setSec) { + gc::TimeSpan h, k, l; + BOOST_CHECK_EQUAL(h.set(4), gc::TimeSpan(4)); + BOOST_CHECK_EQUAL(k.set(2), gc::TimeSpan(2)); + BOOST_CHECK_EQUAL(l.set(1), gc::TimeSpan(1)); + BOOST_CHECK_EQUAL(l.set(-10), gc::TimeSpan(-10)); + BOOST_CHECK_EQUAL(k.set(-9876), gc::TimeSpan(-9876)); + BOOST_CHECK_EQUAL(l.set(0), gc::TimeSpan(0.)); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(setMicro) { + gc::TimeSpan h, k, l, ts; + BOOST_CHECK_EQUAL(h.setUSecs(9), gc::TimeSpan(0.000009)); + BOOST_CHECK_EQUAL(k.setUSecs(2), gc::TimeSpan(0.0000020)); + BOOST_CHECK_EQUAL(l.setUSecs(3), gc::TimeSpan(0.000003)); + BOOST_CHECK_EQUAL(ts.setUSecs(4), gc::TimeSpan(0.000004)); + BOOST_CHECK_EQUAL(l.setUSecs(0), gc::TimeSpan(0.0)); + BOOST_CHECK_EQUAL(h.setUSecs(2000000), gc::TimeSpan(2.00)); + BOOST_CHECK_EQUAL(k.setUSecs(-3000000), gc::TimeSpan(-3.0)); + + bu::unit_test_log.set_threshold_level(bu::log_warnings); + + gc::TimeSpan test = l.setUSecs(-7262); + BOOST_WARN_EQUAL(test.microseconds(), -7262); + + gc::TimeSpan test2 = l.setUSecs(-98744); + BOOST_WARN_EQUAL(test2.microseconds(), -98744); + + gc::TimeSpan test3 = l.setUSecs(-98); + BOOST_WARN_EQUAL(isClose(test3,0, -98), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(secAndMicro) { + gc::TimeSpan ts(2.000002); + BOOST_CHECK(ts.seconds() == 2 && ts.microseconds() == 2); + + gc::TimeSpan h(4.000009); + BOOST_CHECK(h.seconds() == 4 && h.microseconds() == 9); + + gc::TimeSpan t(0.000004); + BOOST_CHECK(t.seconds() == 0 && t.microseconds() == 4); + + gc::TimeSpan k(0.000000); + BOOST_CHECK(k.seconds() == 0 && k.microseconds() == 0); + + gc::TimeSpan m(-8.123456); + long sec = -8; + long micro = -123456; + BOOST_WARN_EQUAL(isClose(m,sec, micro,20), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(absolute) { + gc::TimeSpan k(-2.567); + gc::TimeSpan result = k.abs(); + long sec = result.seconds(); + long micro = result.microseconds(); + BOOST_CHECK_EQUAL(isClose(result,2, 567000,20), true); + + gc::TimeSpan m(-2, -5); + gc::TimeSpan n(2, 5); + BOOST_CHECK_EQUAL(m.abs(), n.abs()); + BOOST_CHECK_EQUAL(m.abs(), n); + + gc::TimeSpan i(600, -700000); + result = i.abs(); + BOOST_CHECK_EQUAL(result.seconds(), 600); + BOOST_CHECK_EQUAL(result.microseconds(),700000); + + gc::TimeSpan r(200, -5); + gc::TimeSpan s(200.000005); + gc::TimeSpan absR = r.abs(); + BOOST_CHECK_EQUAL(r.abs(), s.abs()); + BOOST_CHECK_EQUAL(absR.seconds(), s.seconds()); + BOOST_CHECK_EQUAL(absR.microseconds(), s.microseconds()); + + gc::TimeSpan l = (double)-1.000678; + result = l.abs(); + sec = 1; + micro = 678; + BOOST_CHECK_EQUAL(isClose(result,sec, micro), true); + + gc::TimeSpan h = -4; + BOOST_CHECK_EQUAL(h.abs(), gc::TimeSpan(4)); + + gc::TimeSpan ts; + BOOST_CHECK_EQUAL(ts.abs(), gc::TimeSpan(0.0)); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(length) { + gc::TimeSpan k = 2.000002; + BOOST_CHECK(k.length() == 2.000002); + + gc::TimeSpan l = 1.000003; + BOOST_CHECK(l.length() == 1.000003); + + gc::TimeSpan h = 4.000009; + BOOST_CHECK(h.length() == 4.000009); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(notEqual) { + gc::TimeSpan k = 2.000002, l = 1.000003; + BOOST_CHECK(k != l); + + gc::TimeSpan ts, t = 0.000007; + BOOST_CHECK(ts != t); + + gc::TimeSpan h = 4.000009, j = 2845687.000004; + BOOST_CHECK(h != j); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(assign) { + gc::TimeSpan k = 2.000002; + BOOST_CHECK(k == gc::TimeSpan(2.000002)); + + gc::TimeSpan t; + BOOST_CHECK(t == gc::TimeSpan(0.0)); + + gc::TimeSpan h = 4.000009; + BOOST_CHECK(h == gc::TimeSpan(4.000009)); + + gc::TimeSpan ts = 0.000004; + BOOST_CHECK(ts == gc::TimeSpan(0.000004)); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(plus) { + gc::TimeSpan k = 2.000002, l = 1.000003; + BOOST_CHECK_EQUAL(k += l, gc::TimeSpan(3.000005)); + + gc::TimeSpan h = 4.000009, t; + BOOST_CHECK_EQUAL(t += h, gc::TimeSpan(4.000009)); + + gc::TimeSpan ts = 0.000004, j = 80005.000004; + BOOST_CHECK_EQUAL(ts += j, gc::TimeSpan(80005.000008)); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(minus) { + gc::TimeSpan k = 2.000002, l = 1.000003; + BOOST_CHECK_EQUAL(k -= l, gc::TimeSpan(0.999999)); + + gc::TimeSpan t, j = 6897.098772; + BOOST_CHECK_EQUAL(j -= t, gc::TimeSpan(6897.098772)); + + gc::TimeSpan h = 4.000009, ts = 0.000004; + BOOST_CHECK_EQUAL(h -= ts, gc::TimeSpan(4.000005)); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(lower) { + gc::TimeSpan k = 2.000002, t; + BOOST_CHECK_EQUAL(t < k, true); + + gc::TimeSpan h = 4.000009, j = 2.897665; + BOOST_CHECK_EQUAL(j < h, true); + + gc::TimeSpan ts = 0.000004, z = 7893648.987645; + BOOST_CHECK_EQUAL(z < ts, false); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(greater) { + gc::TimeSpan k = 2.000002, t; + BOOST_CHECK_EQUAL(k > t, true); + + gc::TimeSpan h = 4.000009, j = 3.909888; + BOOST_CHECK_EQUAL(h > j, true); + + gc::TimeSpan ts = 0.000004, g = 0.000001; + BOOST_CHECK_EQUAL(g > ts, false); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(lowerEqual) { + gc::TimeSpan k = 2.000002; + BOOST_CHECK_EQUAL(k <= gc::TimeSpan(2.000002), true); + + gc::TimeSpan t; + BOOST_CHECK_EQUAL(t <= gc::TimeSpan(2), true); + + gc::TimeSpan h = 4.000009; + BOOST_CHECK_EQUAL(h <= gc::TimeSpan(2), false); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(greaterEqual) { + gc::TimeSpan h = 4.000009; + BOOST_CHECK_EQUAL(h >= gc::TimeSpan(2), true); + + gc::TimeSpan ts = 0.000004; + BOOST_CHECK_EQUAL(ts >= gc::TimeSpan(0.000001), true); + + gc::TimeSpan k = 2.000002; + BOOST_CHECK_EQUAL(k >= gc::TimeSpan(2.000002), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(inDouble) { + gc::TimeSpan k = 6.000003; + double kd = k.operator double(); + BOOST_CHECK_EQUAL(kd, 6.000003); + + gc::TimeSpan t = 0.000008; + double td = t.operator double(); + BOOST_CHECK_EQUAL(td, 0.000008); + + gc::TimeSpan ts = 2.000004; + double tsd = ts.operator double(); + BOOST_CHECK_EQUAL(tsd, 2.000004); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(toTimeval) { + const timeval tv = gc::Time(6.000003); + gc::TimeSpan k = 6.000003; + timeval kv = k.operator const timeval &(); + BOOST_CHECK_EQUAL(kv.tv_sec, tv.tv_sec); + BOOST_CHECK_EQUAL(kv.tv_usec, tv.tv_usec); + + const timeval ti = gc::Time(0.000008); + gc::TimeSpan t = 0.000008; + timeval tvi = t.operator const timeval &(); + BOOST_CHECK_EQUAL(tvi.tv_sec, ti.tv_sec); + BOOST_CHECK_EQUAL(tvi.tv_usec, ti.tv_usec); + + const timeval tl = gc::Time(2.000004); + gc::TimeSpan ts = 2.000004; + timeval tsv = ts.operator const timeval &(); + BOOST_CHECK_EQUAL(tsv.tv_sec, tl.tv_sec); + BOOST_CHECK_EQUAL(tsv.tv_usec, tl.tv_usec); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(fromString) { + gc::Time time = gc::Time::FromString("2019-01-01 10:01:59", "%F %T"); + + BOOST_CHECK(time.valid()); + + int year, month, day, hour, min, sec; + BOOST_CHECK(time.get(&year, &month, &day, &hour, &min, &sec)); + BOOST_CHECK_EQUAL(year, 2019); + BOOST_CHECK_EQUAL(month, 1); + BOOST_CHECK_EQUAL(day, 1); + BOOST_CHECK_EQUAL(hour, 10); + BOOST_CHECK_EQUAL(min, 01); + BOOST_CHECK_EQUAL(sec, 59); + + // Buffer overflow test + std::string str; + str.resize(1024); + time = gc::Time::FromString(str.c_str(), "%F %T"); + BOOST_CHECK(!time.valid()); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/test/datetime_time.cpp b/libs/gempa/caps/test/datetime_time.cpp new file mode 100644 index 0000000..6c41858 --- /dev/null +++ b/libs/gempa/caps/test/datetime_time.cpp @@ -0,0 +1,511 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include + +#include + + +namespace gc = Gempa::CAPS; +namespace bu = boost::unit_test; + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_datetime_time) + + +bool isClose(gc::TimeSpan time, long sec, long micro, int offset = 1) { + long microSeconds = time.microseconds(); + + long secDiff = time.seconds() - sec; + if ( secDiff > 0 ) + microSeconds += secDiff * 1000000; + else if ( secDiff < 0 ) + micro += abs(secDiff) * 1000000; + + if ( abs(microSeconds - micro) <= offset ) + return true; + return false; +} + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +BOOST_AUTO_TEST_CASE(construction) { + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + gc::Time time; + BOOST_CHECK(time == gc::Time(0.0)); + + // long + gc::Time tPositive(200, 600); + BOOST_CHECK(tPositive == gc::Time(200.000600)); + + gc::Time tNegativeUsec(3000, -789); + BOOST_WARN_EQUAL(tNegativeUsec.seconds(), 3000); + BOOST_WARN_EQUAL(tNegativeUsec.microseconds(), -789); + + gc::Time tNegativeSec(-12, 12345); + BOOST_WARN_EQUAL(tNegativeSec.seconds(), -12); + BOOST_WARN_EQUAL(tNegativeSec.microseconds(), 12345); + + gc::Time tNegative(-15,-9876); + BOOST_WARN_EQUAL(tNegative.seconds(), -15); + BOOST_WARN_EQUAL(tNegative.microseconds(), -9876); + + // TimeSpan + gc::Time tsPositive(gc::TimeSpan(5.345)); + BOOST_WARN_EQUAL(tsPositive.seconds(), 5); + BOOST_WARN_EQUAL(tsPositive.microseconds(), 345000); + + // timeval + timeval number; + number.tv_sec = 150; + number.tv_usec = 6000; + gc::Time tvPositive(number); + BOOST_WARN_EQUAL(tvPositive.seconds(), 150); + BOOST_WARN_EQUAL(tvPositive.microseconds(), 6000); + + number.tv_sec = -150; + number.tv_usec = 9000; + gc::Time tvNegativeSec(number); + BOOST_WARN_EQUAL(tvNegativeSec.seconds(), -150); + BOOST_WARN_EQUAL(tvNegativeSec.microseconds(),9000); + + number.tv_sec = 4000; + number.tv_usec = -98876; + gc::Time tvNegativeUsec(number); + BOOST_WARN_EQUAL(tvNegativeUsec.seconds(), 4000); + BOOST_WARN_EQUAL(tvNegativeUsec.microseconds(), -98876); + + number.tv_sec = -9877; + number.tv_usec = -874547; + gc::Time tvNegative(number); + BOOST_WARN_EQUAL(tvNegative.seconds(), -9877); + BOOST_WARN_EQUAL(tvNegative.microseconds(), -874547); + + // double + double val = 5678.9864; + gc::Time tdPositive(val); + BOOST_WARN_EQUAL(tdPositive.seconds(), 5678); + BOOST_CHECK_EQUAL(tdPositive.microseconds(), 986400); + + val = -89765.745377; + gc::Time tdNegative(val); + BOOST_WARN_EQUAL(isClose(tdNegative, -89765, -745377), true); + + // pointer + timeval pointer; + pointer.tv_sec = 76656; + pointer.tv_usec = 8900; + + gc::Time tpPositive(&pointer); + BOOST_WARN_EQUAL(tpPositive.seconds(), 76656); + BOOST_WARN_EQUAL(tpPositive.microseconds(), 8900); + + pointer.tv_sec = -76656; + pointer.tv_usec = 8900; + gc::Time tpNegativeSec(&pointer); + BOOST_WARN_EQUAL(tpNegativeSec.seconds(), -76656); + BOOST_WARN_EQUAL(tpNegativeSec.microseconds(), 8900); + + pointer.tv_sec = 98744; + pointer.tv_usec = -8965; + gc::Time tpNegativeUsec(&pointer); + BOOST_WARN_EQUAL(tpNegativeUsec.seconds(), 98744); + BOOST_WARN_EQUAL(tpNegativeUsec.microseconds(), -8965); + + pointer.tv_sec = -44; + pointer.tv_usec = -895; + gc::Time tpNegative(&pointer); + BOOST_WARN_EQUAL(tpNegative.seconds(), -44); + BOOST_WARN_EQUAL(tpNegative.microseconds(), -895); + + // copy + gc::Time copyPositive(gc::Time(758.9975)); + BOOST_CHECK_EQUAL(copyPositive.seconds(), 758); + BOOST_CHECK_EQUAL(copyPositive.microseconds(), 997500); + + gc::Time copyNegative(gc::Time(-877.963)); + BOOST_WARN_EQUAL(isClose(copyNegative, -877, -963000), true); + + // date + gc::Time date(1971,1,3,1,1,4,6544); + double dayInSeconds = 86400; + double yearInSeconds = 31536000; + BOOST_WARN_CLOSE(double(date), dayInSeconds*2 + yearInSeconds,0.3); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(addition) { + gc::Time a(7,5); + gc::TimeSpan b = 9.000004; + gc::TimeSpan result = a + b; + BOOST_CHECK_EQUAL(result.microseconds(), 9); + BOOST_CHECK_EQUAL(result.seconds(), 16); + + gc::Time c(7,5); + gc::TimeSpan d = -3.000004; + result = c + d; + BOOST_CHECK_EQUAL(result.microseconds(), 2); + BOOST_CHECK_EQUAL(result.seconds(), 4); + + gc::Time e(-7,5); + gc::TimeSpan f = 9.000004; + result = e + f; + BOOST_CHECK_EQUAL(result.microseconds(),9); + BOOST_CHECK_EQUAL(result.seconds(), 2); + + gc::Time g(900,789); + gc::TimeSpan h; + result = h += g; + BOOST_CHECK_EQUAL(result.microseconds(),789); + BOOST_CHECK_EQUAL(result.seconds(), 900); + + gc::Time i(455, -355); + gc::TimeSpan j = 80.000444; + i += j; + BOOST_CHECK_EQUAL(i.microseconds(),89); + BOOST_CHECK_EQUAL(i.seconds(), 535); + + gc::Time k(-899, 22255); + gc::TimeSpan l = 773.992; + l += k; + BOOST_WARN_EQUAL(l.seconds(), -125); + BOOST_WARN_EQUAL(l.microseconds(), 14255); + + gc::Time m(500, 987); + gc::TimeSpan n(-30, 876); + int result2 = m.microseconds() + n.microseconds(); + int result3 = m.seconds() + n.seconds(); + m += n; + BOOST_WARN_EQUAL(m.microseconds(),result2); + BOOST_WARN_EQUAL(m.seconds(),result3); + + gc::Time o(-60, 47); + gc::TimeSpan p(-44,5); + long sec = o.seconds() + p.seconds(); + long micro = o.microseconds() + p.microseconds(); + o += p; + BOOST_CHECK_EQUAL(isClose(o, sec, micro), true); + + gc::Time q(9876, -6748); + gc::TimeSpan r = -876.987; + q += r; + BOOST_WARN_EQUAL(q.microseconds(), 6253); + BOOST_CHECK_EQUAL(q.seconds(),8999); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(subtraction) { + gc::Time a(7,5); + gc::TimeSpan b(9,000004); + gc::TimeSpan result = a - b; + long sec = a.seconds() - b.seconds(); + long micro = a.microseconds() - b.microseconds(); + BOOST_WARN_EQUAL(isClose(result, sec, micro),true); + + gc::Time c(7,5); + gc::TimeSpan d = -3.000004; + result = c - d; + BOOST_CHECK_EQUAL(result.microseconds(), 8); + BOOST_CHECK_EQUAL(result.seconds(), 10); + + gc::Time e(-7,5); + gc::TimeSpan f(9,000004); + result = e - f; + sec = e.seconds() - f.seconds(); + micro = e.microseconds() -f.microseconds(); + BOOST_WARN_EQUAL(isClose(result, sec, micro),true); + + gc::Time g(900,789); + gc::TimeSpan h; + sec = h.seconds() - g.seconds(); + micro = h.microseconds() - g.microseconds(); + h -= g; + BOOST_CHECK_EQUAL(isClose(h, sec, micro), true); + + gc::Time i(455, -355); + gc::TimeSpan j(80, 444); + sec = i.seconds() - j.seconds(); + micro = i.microseconds() - j.microseconds(); + i -= j; + BOOST_CHECK_EQUAL(isClose(i, sec, micro), true); + + gc::Time k(-899, 22255); + gc::TimeSpan l(773, 992); + sec = l.seconds() - k.seconds(); + micro = l.microseconds() - k.microseconds(); + l -= k; + BOOST_CHECK_EQUAL(isClose(l, sec, micro), true); + + gc::Time m(500,987); + gc::TimeSpan n = -30.876; + m -= n; + BOOST_CHECK_EQUAL(m.microseconds(),876986); + BOOST_CHECK_EQUAL(m.seconds(), 530); + + gc::Time o(-60, 47); + gc::TimeSpan p = -44.05; + sec = o.seconds() - p.seconds(); + micro = o.microseconds() - p.microseconds(); + o -= p; + BOOST_CHECK_EQUAL(isClose(o, sec, micro), true); + + gc::Time q(9876, -6748); + gc::TimeSpan r = -876.987; + sec = q.seconds() -r.seconds(); + micro = q.microseconds() - r.microseconds(); + q -= r; + BOOST_CHECK_EQUAL(isClose(q, sec, micro), true); + + gc::Time s(50, 778), t(4, 221); + result = s - t; + BOOST_CHECK_EQUAL(result.microseconds(), 557); + BOOST_CHECK_EQUAL(result.seconds(), 46); + + gc::Time u(-30,0),v(60,66); + result = u - v; + sec = u.seconds() -v.seconds(); + micro = u.microseconds() - v.microseconds(); + BOOST_CHECK_EQUAL(isClose(result, sec, micro), true); + + gc::Time w(798, -444),x(6, 0321); + sec = w.seconds() - x.seconds(); + micro = w.microseconds() - x.microseconds(); + result = w - x; + BOOST_CHECK_EQUAL(isClose(result, sec, micro), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(setAndGet) { + gc::Time date; + gc::TimeSpan oneDay (86400); // one day in seconds + gc::TimeSpan oneYear (31536000); // one year in seconds + gc::TimeSpan toNextYear (26524800); // seconds to the next year + int year = 1970, month = 8, day = 5,h = 7,min = 50,sec = 33,uSec= 80; + date.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(year == 1970); + BOOST_CHECK(month == 8); + BOOST_CHECK(day == 5); + BOOST_CHECK(h == 7); + BOOST_CHECK(min = 50); + BOOST_CHECK(sec = 33); + BOOST_CHECK(uSec = 80); + + date -= oneYear; + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(year == 1969); + BOOST_CHECK(month == 8); + BOOST_CHECK_EQUAL(day , 5); + + year = 2017, month = 2, day = 28; + date.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(year == 2017); + BOOST_CHECK(month == 2); + BOOST_CHECK(day == 28); + + date += oneDay; + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(month , 3); + BOOST_CHECK_EQUAL(day , 1); + + year = 2018, month = 2, day = 28; + date.set(year,month,day,h,min,sec,uSec); + date += oneDay; + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(month , 3); + BOOST_CHECK_EQUAL(day, 1); + + date += oneYear; + BOOST_CHECK(date.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(year , 2019); + BOOST_CHECK_EQUAL(day, 1); + BOOST_CHECK_EQUAL(month , 3); + + gc::Time leapYear; + year = 1956, month = 2, day = 28; + leapYear.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(leapYear.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(year == 1956); + BOOST_CHECK(month == 2); + BOOST_CHECK(day == 28); + + leapYear += oneDay; + BOOST_CHECK(leapYear.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(month == 2); + BOOST_CHECK(day == 29); + + leapYear += oneDay; + BOOST_CHECK(leapYear.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(month == 3); + BOOST_CHECK(day == 1); + + gc::Time time; + year = 2011, month = 2, day = 28; + int yday ; + time.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(time.get2(&year,&yday,&h,&min,&sec,&uSec) == true); + BOOST_CHECK(year == 2011); + BOOST_CHECK_EQUAL(yday , 58); + + time += toNextYear; + BOOST_CHECK(time.get2(&year,&yday,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(year , 2012); + BOOST_CHECK_EQUAL(yday , 0); + + year = 1964, month = 2, day = 29; + leapYear.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(leapYear.get2(&year,&yday,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(yday , 59); + + leapYear += toNextYear; + BOOST_CHECK(leapYear.get2(&year,&yday,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(year, 1965); + BOOST_CHECK_EQUAL(yday , 0); + + gc::Time before1900; + day = 28, month = 2, year = 1900; + before1900.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(before1900.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(year , 1900); + BOOST_CHECK_EQUAL(day , 28); + BOOST_CHECK_EQUAL(month, 2); + + gc::Time pure; + pure.get(&year,&month,&day,&h,&min,&sec,&uSec); + BOOST_CHECK_EQUAL(year, 1970); + + pure -= oneYear; + pure.get(&year,&month,&day,&h,&min,&sec,&uSec); + BOOST_CHECK_EQUAL(year, 1969); + + day = 50, month = 4, year = 1566; + before1900.set(year,month,day,h,min,sec,uSec); + BOOST_CHECK(before1900.get(&year,&month,&day,&h,&min,&sec,&uSec) == true); + BOOST_CHECK_EQUAL(year , 1566); + BOOST_CHECK_EQUAL(day , 20); + BOOST_CHECK_EQUAL(month, 5); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(localTime) { + gc::Time local; + local.set(1970,3,14,5,30,3,39); + gc::Time time(local); + BOOST_CHECK_EQUAL(double(local), double(time)); + std::string check1 = local.toString("%FT%T.%fZ"); + std::string check2 = "1970-03-14T05:30:03.000039Z"; + bool equal = boost::iequals(check1,check2); + BOOST_CHECK_EQUAL(equal, true); + gc::Time localtest = local.LocalTime(); + local = local.LocalTime(); + localtest.setUSecs(0); + local.setUSecs(0); + check1 = local.iso(); + check2 = localtest.iso(); + BOOST_CHECK_EQUAL(check1, check2); + + local.set(1970,3,14,5,30,3,39); + check1 = "1970-03-14T05:30:03.000039Z"; + check2 = local.toString("%FT%T.%fZ"); + BOOST_CHECK_EQUAL(check1, check2); + + local.set(1981,9,14,5,30,3,39); + check1 = "1981-09-14T05:30:03.000039Z"; + check2 = local.toString("%FT%T.%fZ"); + BOOST_CHECK_EQUAL(check1, check2); + + local.set(2014,3,14,5,30,3,39); + check1 = "2014-03-14T05:30:03.000039Z"; + check2 = local.toString("%FT%T.%fZ"); + BOOST_CHECK_EQUAL(check1, check2); + + local.set(2000,8,14,5,30,3,39); + check1 = local.toString("%FT%T.%fZ"); + check2 = "2000-08-14T05:30:03.000039Z"; + BOOST_CHECK_EQUAL(check1, check2); + + // before 1970 + gc::Time before1970; + before1970.set(1950,6,4,15,8,66,11); + gc::Time t(before1970); + gc::Time time1 = local.LocalTime(); + time1.setUSecs(0); + gc::Time time2 = before1970.LocalTime(); + time2.setUSecs(0); + check1 = time1.toString("%FT%T.%fZ"); + check2 = time2.toString("%FT%T.%fZ"); + BOOST_CHECK_EQUAL(check1, check2); + + before1970.set(1914,9,4,7,8,66,11); + check1 = "1914-09-04T07:09:06.000011Z"; + check2 = before1970.toString("%FT%T.%fZ"); + BOOST_CHECK_EQUAL(check1, check2); + + gc::Time yearDay = yearDay.FromYearDay(1971, 3); + double dayInSeconds = 86400; + double yearInSeconds = 31536000; + BOOST_CHECK_EQUAL(double(yearDay),dayInSeconds*2 + yearInSeconds); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(validStrings) { + + gc::Time date(2016,8,26,15,44,9,644); + std::string test = date.toString("%FT%T.%fZ"); + std::string check = "2016-08-26T15:44:09.000644Z"; + bool equal = boost::iequals(test,check); + BOOST_CHECK_EQUAL(equal, true); + BOOST_CHECK(date.FromString(test.c_str(),"%FT%T.%fZ") == date); + + BOOST_CHECK(test == date.iso()); + + BOOST_CHECK(date.fromString(test.c_str(),"%FT%T.%fZ") == true); + + BOOST_CHECK_EQUAL(date.valid(), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/test/endianess.cpp b/libs/gempa/caps/test/endianess.cpp new file mode 100644 index 0000000..dfc8729 --- /dev/null +++ b/libs/gempa/caps/test/endianess.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include + +#include +#include + + +namespace gce = Gempa::CAPS::Endianess; +namespace bu = boost::unit_test; + +using namespace std; + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_endianess) + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(converter) { + + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + // Check little_endian int16_t. + const int16_t k16Value{0x0123}; + + if(gce::Current::LittleEndian) { + BOOST_CHECK_EQUAL(gce::Converter::ToLittleEndian(k16Value), k16Value); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(k16Value), k16Value); + int16_t g16Value = gce::Converter::ToBigEndian(k16Value); + BOOST_CHECK_EQUAL(g16Value, 8961); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(g16Value), k16Value); + gce::Converter::ToLittleEndian(&k16Value, 4); + BOOST_CHECK_EQUAL(291, k16Value); + } + else { + BOOST_CHECK_EQUAL(gce::Converter::ToBigEndian(k16Value), k16Value); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(k16Value), k16Value); + int16_t g16Value = gce::Converter::ToLittleEndian(k16Value); + BOOST_CHECK_EQUAL(g16Value, 291); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(g16Value), k16Value); + } + + // Check little_endian int32_t. + const int32_t k32Value{0x01234567}; + if(gce::Current::LittleEndian) { + BOOST_CHECK_EQUAL(gce::Converter::ToLittleEndian(k32Value), k32Value); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(k32Value), k32Value); + int32_t g32Value = gce::Converter::ToBigEndian(k32Value); + BOOST_CHECK_EQUAL(g32Value, 1732584193); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(g32Value), k32Value); + gce::Converter::ToLittleEndian(&k32Value, 11); + BOOST_CHECK_EQUAL(19088743, k32Value); + } + else { + BOOST_CHECK_EQUAL(gce::Converter::ToBigEndian(k32Value), k32Value); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(k32Value), k32Value); + int16_t g32Value = gce::Converter::ToLittleEndian(k32Value); + BOOST_CHECK_EQUAL(g32Value, 19088743); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(g32Value), k32Value); + } + + // Check little_endian int64_t. + const int64_t k64Value{0x0123456789abcdef}; + if(gce::Current::LittleEndian) { + BOOST_CHECK_EQUAL(gce::Converter::ToLittleEndian(k64Value), k64Value); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(k64Value), k64Value); + int64_t g32Value = gce::Converter::ToBigEndian(k64Value); + BOOST_CHECK_EQUAL(g32Value, -1167088121787636991); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(g32Value), k64Value); + gce::Converter::ToLittleEndian(&k64Value, 11); + BOOST_CHECK_EQUAL(81985529216486895, k64Value); + } + else { + BOOST_CHECK_EQUAL(gce::Converter::ToBigEndian(k64Value), k64Value); + BOOST_CHECK_EQUAL(gce::Converter::FromBigEndian(k64Value), k64Value); + int16_t g64Value = gce::Converter::ToLittleEndian(k64Value); + BOOST_CHECK_EQUAL(g64Value, 19088743); + BOOST_CHECK_EQUAL(gce::Converter::FromLittleEndian(g64Value), k64Value); + } +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/test/errors_find b/libs/gempa/caps/test/errors_find new file mode 100644 index 0000000..c82ad88 --- /dev/null +++ b/libs/gempa/caps/test/errors_find @@ -0,0 +1,29 @@ +Bei utils.h + + +--------------------------------------------------------------------------------------------------------------------------- + +Bei datetime.h + + +--------------------------------------------------------------------------------------------------------------------------- + +Bei rawpacket.cpp + + +--------------------------------------------------------------------------------------------------------------------------- + +Bei packet.h + + +--------------------------------------------------------------------------------------------------------------------------- + +Bei endianess.h + +1) Bei reader ist der Pointer nicht an der ersten stelle des Streams. Siehe endianess.cpp (test) Zeile 114 und folgende. +--------------------------------------------------------------------------------------------------------------------------- + +Bei mseedpacket.cpp + +1) +--------------------------------------------------------------------------------------------------------------------------- diff --git a/libs/gempa/caps/test/mseedpacket.cpp b/libs/gempa/caps/test/mseedpacket.cpp new file mode 100644 index 0000000..25f6164 --- /dev/null +++ b/libs/gempa/caps/test/mseedpacket.cpp @@ -0,0 +1,227 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include "test_utils.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace bu = boost::unit_test; + +using namespace std; +using namespace Gempa::CAPS; + +namespace { + +struct Record { + Record() { + vector mseed; + mseed.resize(512); + + ifstream ifs("data/AM.RFE4F.00.SHZ.20180912.mseed"); + if( ifs.is_open() ) { + ifs.read(mseed.data(), 512); + testRec.setData(mseed.data(), 512); + } + else + BOOST_TEST_MESSAGE("unable to open test data file."); + } + MSEEDDataRecord testRec; +}; + +} + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_mseedpacket) +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(equal_functions) { + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + MSEEDDataRecord::Header header; + MSEEDDataRecord::Header otherHeader; + + header.setSamplingTime(fromString("2018-01-01 00:00:01")); + header.samplingFrequencyNumerator = 30; + header.samplingFrequencyDenominator = 1; + BOOST_CHECK_EQUAL(header != otherHeader, true); + + bool valid = header.compatible(otherHeader); + BOOST_CHECK_EQUAL(valid, false); + + otherHeader = header; + valid = header.compatible(otherHeader); + BOOST_CHECK_EQUAL(valid, true); + BOOST_CHECK_EQUAL(header != otherHeader, false); + } +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(header_functions) { + + MSEEDDataRecord::Header header; + header.dataType = DT_INT64; + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = 1; + + char buf[1024]; + arraybuf abuf(buf, 1024); + BOOST_CHECK_EQUAL(header.put(abuf), true); + + MSEEDDataRecord::Header otherHeader; + BOOST_CHECK_EQUAL(otherHeader.get(abuf), true); + BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyNumerator, 1); + BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyDenominator, 1); + BOOST_CHECK_EQUAL(otherHeader.dataType, DT_INT64); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(trim_function) { + // MSEEDs records can not be trimmed -> always false + MSEEDDataRecord testRec; + BOOST_CHECK(!testRec.canTrim()); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(merge_function) { + // MSEEDs records can not be merged -> always false + MSEEDDataRecord testRec; + BOOST_CHECK(!testRec.canMerge()); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(getter_and_setter, Record) { + BOOST_CHECK_EQUAL("MSEED", testRec.formatName()); + + // get data size with and without header + size_t sizeWithout = testRec.dataSize(false); + BOOST_CHECK_EQUAL(sizeWithout, 512); + + size_t sizeWith = testRec.dataSize(true); + BOOST_CHECK_EQUAL(512, sizeWith); + + // check start end end time + BOOST_CHECK_EQUAL(testRec.startTime().iso(), "2018-09-12T10:55:56.751Z"); + BOOST_CHECK_EQUAL(testRec.endTime().iso(), "2018-09-12T10:56:03.511Z"); + + // check sampling frequency + BOOST_CHECK_EQUAL(testRec.header()->samplingFrequencyNumerator, 50); + BOOST_CHECK_EQUAL(testRec.header()->samplingFrequencyDenominator, 1); + + // check packet type + BOOST_CHECK_EQUAL(testRec.packetType(), MSEEDPacket); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(read_header_from_buffer, Record) { + char data[512]; + + // write test record data into a buffer + arraybuf abuf(data, 512); + BOOST_CHECK(testRec.put(abuf, true)); + + Time startTime, endTime; + MSEEDDataRecord::Header header; + + // read start, end time and further information from buffer + MSEEDDataRecord rec; + rec.readMetaData(abuf, 512, header, startTime, endTime); + + BOOST_CHECK_EQUAL(startTime.iso(), "2018-09-12T10:55:56.751Z"); + BOOST_CHECK_EQUAL(endTime.iso(), "2018-09-12T10:56:03.511Z"); + BOOST_CHECK_EQUAL(header.dataType, DT_INT32); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(read_data_from_file, Record) { + ifstream ifs("data/AM.RFE4F.00.SHZ.20180912.mseed"); + BOOST_CHECK(ifs.is_open()); + + vector buf; + buf.resize(512); + ifs.read(buf.data(), 512); + + MSEEDDataRecord rec; + rec.setData(buf.data(),512); + + BOOST_CHECK_EQUAL(rec.header()->samplingFrequencyDenominator, 1); + BOOST_CHECK_EQUAL(rec.header()->samplingFrequencyNumerator, 50); + + TimeSpan timeSpan = samplesToTimeSpan(*rec.header(), 338); + + // check that the record start time + all samples is equal to + // the record end time + Time endTime = rec.startTime() + timeSpan; + BOOST_CHECK(endTime == rec.endTime()); + + // check both header are equal + BOOST_CHECK_EQUAL(rec.header()->compatible(*testRec.header()), true); + +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< diff --git a/libs/gempa/caps/test/packet.cpp b/libs/gempa/caps/test/packet.cpp new file mode 100644 index 0000000..f5dd8fc --- /dev/null +++ b/libs/gempa/caps/test/packet.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include + +#include +#include +#include + + +namespace gc = Gempa::CAPS; +namespace bu = boost::unit_test; + +using namespace std; + + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_packet) +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(equal_function) { + + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + gc::DataRecord::Header header; + gc::DataRecord::Header other; + gc::Time t(1004791084,45368); + + BOOST_CHECK_NO_THROW(header.setSamplingTime(t)); + header.samplingFrequencyNumerator = 3; + header.samplingFrequencyDenominator = 7; + BOOST_CHECK_EQUAL(header != other, true); + + bool valid = header.compatible(other); + BOOST_CHECK_EQUAL(valid, false); + + other = header; + valid = header.compatible(other); + BOOST_CHECK_EQUAL(valid, true); + BOOST_CHECK_EQUAL(header != other, false); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(getAndPut) { + + gc::DataRecord::Header header; + header.dataType = gc::DT_INT64; + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = 1; + char buf[1024]; + gc::arraybuf abuf(buf, 1024); + + BOOST_CHECK_EQUAL(header.samplingFrequencyNumerator, 1); + BOOST_CHECK_EQUAL(header.samplingFrequencyDenominator, 1); + BOOST_CHECK_EQUAL(header.dataType, gc::DT_INT64); + bool valid = header.put(abuf); + BOOST_CHECK_EQUAL(valid, true); + + gc::DataRecord::Header otherHeader; + valid = otherHeader.get(abuf); + BOOST_CHECK_EQUAL(valid,true); + BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyNumerator, 1); + BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyDenominator, 1); + BOOST_CHECK_EQUAL(otherHeader.dataType, gc::DT_INT64); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/test/rawpacket.cpp b/libs/gempa/caps/test/rawpacket.cpp new file mode 100644 index 0000000..1bd7b68 --- /dev/null +++ b/libs/gempa/caps/test/rawpacket.cpp @@ -0,0 +1,288 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#ifndef M_PI +#define M_PI 3.14159265359 +#endif + +#define SEISCOMP_TEST_MODULE gempa +#include "test_utils.h" + +#include + +#include +#include +#include + +#include +#include +#include + + + +namespace gc = Gempa::CAPS; +namespace bu = boost::unit_test; + +using namespace std; + +namespace { + +struct Record { + Record() { + gc::DataRecord::Header header; + header.setSamplingTime(fromString("2018-01-01 00:00:01")); + header.dataType = gc::DT_INT32; + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = 1; + + rdr.setHeader(header); + } + + gc::RawDataRecord rdr; +}; + +} + +template void fillRecord(T *data, size_t len , gc::Time stime, int sample_microsecs, + double amplitude, double period) { + double periodScale = (2 * M_PI) / period; + double x = (double)stime * periodScale; + double xOffset = sample_microsecs * 1E-6 * periodScale; + + for ( size_t i = 0; i < len; ++i ) { + *data = amplitude * sin(x); + ++data; + x += xOffset; + } +} + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_rawpacket) +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(getAndSet, Record) { + + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + vector data; + data.resize(256); + rdr.setBuffer(data.data(), 256); + + // Set data type and get size of it + rdr.setDataType(gc::DT_FLOAT); + BOOST_CHECK_EQUAL(sizeof(float), gc::sizeOf(rdr.header()->dataType)); + BOOST_CHECK_EQUAL("RAW/FLOAT", rdr.formatName()); + + rdr.setDataType(gc::DT_INT64); + BOOST_CHECK_EQUAL(sizeof(int64_t), gc::sizeOf(rdr.header()->dataType)); + BOOST_CHECK_EQUAL("RAW/INT64", rdr.formatName()); + + // get data size with and without header + size_t sizeWithout = rdr.dataSize(false); + BOOST_CHECK_EQUAL(sizeWithout, 256); + + size_t sizeWith = rdr.dataSize(true); + BOOST_CHECK_EQUAL(sizeWithout + rdr.header()->dataSize(), sizeWith); + + data.resize(65536); + rdr.setBuffer(data.data(), 65536); + sizeWithout = rdr.dataSize(false); + BOOST_CHECK_EQUAL(sizeWithout, 65536); + sizeWith = rdr.dataSize(true); + BOOST_CHECK_EQUAL(sizeWithout + rdr.header()->dataSize(), sizeWith); + + // Set new FrequencyNumerator and FrequencyDenominator + rdr.setSamplingFrequency(100,1); + BOOST_CHECK_EQUAL(rdr.header()->samplingFrequencyNumerator, 100); + BOOST_CHECK_EQUAL(rdr.header()->samplingFrequencyDenominator, 1); + + rdr.setSamplingFrequency(20,1); + BOOST_CHECK_EQUAL(rdr.header()->samplingFrequencyNumerator, 20); + BOOST_CHECK_EQUAL(rdr.header()->samplingFrequencyDenominator, 1); + gc::Time t = gc::getEndTime(rdr.startTime(),20, *rdr.header()); + BOOST_CHECK_EQUAL(t.iso(), "2018-01-01T00:00:02.0000Z"); + + gc::DataRecord::Header otherHeader; + BOOST_CHECK_NO_THROW(rdr.setHeader(otherHeader)); + BOOST_CHECK_EQUAL("RAW/UNKWN", rdr.formatName()); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(checkTime, Record) { + + gc::Time t = gc::getEndTime(rdr.startTime(), 3, *rdr.header()); + + BOOST_CHECK_EQUAL(t.iso(), "2018-01-01T00:00:04.0000Z"); + + rdr.setStartTime(fromString("2018-02-01 00:00:03.0000")); + vector data; + data.resize(1024); + rdr.setBuffer(data.data(), 1024); + t = gc::getEndTime(rdr.startTime(), 3, *rdr.header()); + + BOOST_CHECK_EQUAL(rdr.startTime().iso(), "2018-02-01T00:00:03.0000Z"); + BOOST_CHECK_EQUAL(t.iso(), "2018-02-01T00:00:06.0000Z"); + + rdr.setStartTime(fromString("1988-03-14 14:22:57.322")); + t = gc::getEndTime(rdr.startTime(), 2, *rdr.header()); + + BOOST_CHECK_EQUAL(t.iso(), "1988-03-14T14:22:59.0000Z"); + + rdr.setStartTime(fromString("1970-01-01 00:00:00.0000")); + rdr.setSamplingFrequency(20,1); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); + + rdr.setDataType(gc::DT_FLOAT); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); + + rdr.setDataType(gc::DT_DOUBLE); + data.resize(2048); + rdr.setBuffer(data.data(), 2048); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); + + rdr.setDataType(gc::DT_INT64); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); + + rdr.setDataType(gc::DT_INT8); + data.resize(256); + rdr.setBuffer(data.data(), 256); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); + + rdr.setDataType(gc::DT_INT16); + data.resize(512); + rdr.setBuffer(data.data(),512); + BOOST_CHECK_EQUAL(rdr.endTime().iso(), "1970-01-01T00:00:12.8Z"); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(trimTest, Record) { + // Raw records are trimable -> always true + BOOST_CHECK(rdr.canTrim()); + + const gc::Time endT = gc::getEndTime(rdr.startTime(), 1, *rdr.header()); + BOOST_CHECK_EQUAL(rdr.canTrim(), true); + + bool trimTest = rdr.trim(rdr.startTime(), endT); + BOOST_CHECK_EQUAL(trimTest, true); + BOOST_CHECK_EQUAL(rdr.startTime().iso(), "2018-01-01T00:00:01.0000Z"); + BOOST_CHECK_EQUAL(endT.iso(), "2018-01-01T00:00:02.0000Z"); + + trimTest = rdr.trim(endT, rdr.startTime()); + BOOST_CHECK_EQUAL(trimTest, false); + + rdr.setSamplingFrequency(0,0); + trimTest = rdr.trim(rdr.startTime(), endT); + BOOST_CHECK_EQUAL(trimTest, false); + + BOOST_CHECK_EQUAL(rdr.canMerge(), true); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_FIXTURE_TEST_CASE(getAndPut, Record) { + + char data[500000]; + uint64_t sample_microsecs = uint64_t(rdr.header()->samplingFrequencyDenominator) * 1000000 / rdr.header()->samplingFrequencyNumerator; + fillRecord((float*)&data, 1024, rdr.startTime(), (int)sample_microsecs, 4.2, 2.1); + gc::arraybuf abuf(data, 1024); + + vector arr; + arr.resize(1024); + rdr.setBuffer(arr.data(), 1024); + bool check = rdr.put(abuf, true); + BOOST_CHECK_EQUAL(check, false); + + // RS_PARTIAL = 2 + gc::RawDataRecord rdrOther; + gc::DataRecord::ReadStatusCode ret = rdrOther.get(abuf, 1024, rdr.startTime(),rdr.endTime(), 10); + BOOST_CHECK_EQUAL(ret, gc::DataRecord::RS_Partial); + BOOST_CHECK_EQUAL(rdrOther.startTime() == rdr.startTime(), true); + + // RS_COMPLETE = 1 + gc::arraybuf abuf2(data, 1024); + check = rdrOther.put(abuf2, true); + BOOST_CHECK_EQUAL(check, true); + + gc::RawDataRecord rdrOther2; + ret = rdrOther2.get(abuf2, 1024, rdrOther2.startTime(),rdrOther2.endTime(), 10); + BOOST_CHECK_EQUAL(ret, gc::DataRecord::RS_Complete); + + gc::DataRecord::Header header = *rdrOther2.header(); + gc::Time start = rdrOther2.startTime(); + gc::Time end = gc::getEndTime(rdrOther2.startTime(), 2, header); + rdrOther2.readMetaData(abuf, 1024, header, start, end); + BOOST_CHECK_EQUAL(rdrOther2.startTime().iso(), "2018-01-01T00:00:01.0000Z"); + BOOST_CHECK_EQUAL(rdrOther2.endTime().iso(), "2018-01-01T00:04:13.0000Z"); + + + // RS_BEFORE_TIME_WINDOW = 3 + gc::arraybuf abuf3(data, 1024); + gc::RawDataRecord rdrBefore; + header.setSamplingTime(fromString("2018-01-01 00:00:00")); + header.dataType = gc::DT_INT32; + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = 1; + rdrBefore.setHeader(header); + check = rdrBefore.put(abuf3, true); + BOOST_CHECK_EQUAL(check, true); + + ret = rdrOther.get(abuf3, 1024, rdr.endTime(),rdr.startTime(), 10); + BOOST_CHECK_EQUAL(ret, gc::DataRecord::RS_BeforeTimeWindow); + + // RS_AFTER_TIME_WINDOW = 4 + gc::arraybuf abuf4(data, 1024); + gc::RawDataRecord rdrAfter; + header.setSamplingTime(fromString("2020-01-01 00:00:00")); + header.dataType = gc::DT_INT32; + header.samplingFrequencyNumerator = 1; + header.samplingFrequencyDenominator = 1; + rdrAfter.setHeader(header); + check = rdrAfter.put(abuf4, true); + BOOST_CHECK_EQUAL(check, true); + + ret = rdrOther.get(abuf4, 1024, rdrBefore.startTime(),rdrBefore.endTime(), 10); + BOOST_CHECK_EQUAL(ret, gc::DataRecord::RS_AfterTimeWindow); + + // RS_ERROR = 0 + gc::RawDataRecord rdrError; + ret = rdrError.get(abuf, 1248, rdr.startTime(),rdr.endTime(), 10); + BOOST_CHECK_EQUAL(ret, gc::DataRecord::RS_Error); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/test/test_utils.h b/libs/gempa/caps/test/test_utils.h new file mode 100644 index 0000000..ee95275 --- /dev/null +++ b/libs/gempa/caps/test/test_utils.h @@ -0,0 +1,10 @@ +#ifndef __TEST_UTILS_H__ +#define __TEST_UTILS_H__ + +#include + +Gempa::CAPS::Time fromString(const char *str) { + return Gempa::CAPS::Time::FromString(str, "%F %T"); +} + +#endif diff --git a/libs/gempa/caps/test/utils.cpp b/libs/gempa/caps/test/utils.cpp new file mode 100644 index 0000000..a5e68be --- /dev/null +++ b/libs/gempa/caps/test/utils.cpp @@ -0,0 +1,289 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + * * + * Author: Tracey Werner, Enrico Ellguth * + * Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de * + ***************************************************************************/ + + +#define SEISCOMP_TEST_MODULE gempa +#include + +#include + + +namespace gc = Gempa::CAPS; +namespace bu = boost::unit_test; + +using namespace gc; +using namespace std; + + +BOOST_AUTO_TEST_SUITE(gempa_common_caps_utils) +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_CASE(split_address_function) { + bu::unit_test_log.set_threshold_level(bu::log_warnings); + bu::unit_test_log.set_threshold_level(bu::log_messages); + + string name; + unsigned short port; + int defaultPort = 18002; + + string hostname = "localhost"; + bool valid = splitAddress(name, port, hostname,defaultPort); + BOOST_CHECK_EQUAL(valid, true); + BOOST_CHECK_EQUAL(hostname, "localhost"); + BOOST_CHECK_EQUAL(port, 18002); + + hostname = "data.gempa.de:18000"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, true); + BOOST_CHECK_EQUAL(name, "data.gempa.de"); + BOOST_CHECK_EQUAL(port, 18000); + + hostname = ""; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, false); + + + hostname = "localhost:abcde"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, false); + + // port range check. By definition allowed ports are 1 - 65535 + hostname = "localhost:0"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, false); + + hostname = "localhost:1"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, true); + + hostname = "localhost:65536"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, false); + + hostname = "localhost:-1"; + valid = splitAddress(name, port, hostname, defaultPort); + BOOST_CHECK_EQUAL(valid, false); + + hostname = "localhost:"; + valid = splitAddress(name, port, hostname,defaultPort); + BOOST_CHECK_EQUAL(valid, false); +} +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +BOOST_AUTO_TEST_CASE(trim_function) { + // delete whitespaces before and after string + string text = " This is a test text 1"; + BOOST_CHECK_EQUAL(trim(text), "This is a test text 1"); + + const char *str = text.c_str(); + int len = text.length(); + + const char *res = trim(str,len); + BOOST_CHECK_EQUAL(string(res, len), "This is a test text 1"); + + text = " This is a test text 2"; + BOOST_CHECK_EQUAL(trim(text), "This is a test text 2"); + + str = text.c_str(); + len = text.length(); + res = trim(str,len); + BOOST_CHECK_EQUAL(string(res,len), "This is a test text 2"); + + text = "This is a test text "; + BOOST_CHECK_EQUAL(trim(text), "This is a test text"); + + str = text.c_str(); + len = text.length(); + res = trim(str,len); + BOOST_CHECK_EQUAL(string(res,len), "This is a test text"); + + text = " Hello World "; + BOOST_CHECK_EQUAL(trim(text), "Hello World"); + + str = text.c_str(); + len = text.length(); + res = trim(str,len); + BOOST_CHECK_EQUAL(string(res,len), "Hello World"); + + text = " Hello : world"; + BOOST_CHECK_EQUAL(trim(text), "Hello : world"); + + str = text.c_str(); + len = text.length(); + res = trim(str, len); + BOOST_CHECK_EQUAL(string(res,len), "Hello : world"); +} +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +BOOST_AUTO_TEST_CASE(converts_time) { + // Converts time object to timestamp + const Time t(2014,4,14,6,34,39,7389); + TimeStamp ts; + timeToTimestamp(ts, t); + BOOST_CHECK_EQUAL(ts.year, 2014); + BOOST_CHECK_EQUAL(ts.second, 39); + + const Time t2(0,0); + timeToTimestamp(ts,t2); + BOOST_CHECK_EQUAL(ts.year, 1970); + BOOST_CHECK_EQUAL(ts.hour, 0); + BOOST_CHECK_EQUAL(ts.yday, 0); + + // Converts timestamp to time object + Time t3 = timestampToTime(ts); + int year, yday, hour, min, sec, usec; + t3.get2(&year, &yday, &hour, &min, &sec, &usec); + BOOST_CHECK_EQUAL(year, 1970); + BOOST_CHECK_EQUAL(min, 0); +} +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +BOOST_AUTO_TEST_CASE(samples) { + DataRecord::Header head; + head.samplingFrequencyNumerator = 1; + head.samplingFrequencyDenominator = 1; + + // Convert samples to timespan + TimeSpan ts = samplesToTimeSpan(head, 2); + BOOST_CHECK_EQUAL(ts, TimeSpan(2,0)); + + // Convert time span to samples + BOOST_CHECK_EQUAL(timeSpanToSamples(head, ts), 2); + + // Convert time span to samples and round up/down + BOOST_CHECK_EQUAL(timeSpanToSamplesCeil(head, TimeSpan(0, 500000)), 1); + BOOST_CHECK_EQUAL(timeSpanToSamplesFloor(head, TimeSpan(0, 600000)), 0); +} +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +BOOST_AUTO_TEST_CASE(str_to_int) { + // int tests + + const char *str = "1352"; + int i; + bool ret = str2int(i, str); + BOOST_CHECK_EQUAL(ret, true); + BOOST_CHECK_EQUAL(i, 1352); + + str = ""; + ret = str2int(i, str); + BOOST_CHECK_EQUAL(ret, false); + + str = "478a2"; + ret = str2int(i, str); + BOOST_CHECK_EQUAL(ret, false); + + str = " 57721"; + ret = str2int(i, str); + BOOST_CHECK_EQUAL(ret, true); + BOOST_CHECK_EQUAL(i, 57721); + + str = "4876 9742"; + ret = str2int(i, str); + BOOST_CHECK_EQUAL(ret, true); + BOOST_CHECK_EQUAL(i, 4876); + + str = "-98256"; + ret = str2int(i,str); + BOOST_CHECK_EQUAL(ret, true); + BOOST_CHECK_EQUAL(i, -98256); + + str = "-2147483649"; + ret = str2int(i,str); + BOOST_CHECK_EQUAL(ret, false); + + str = "2147483648"; + ret = str2int(i,str); + BOOST_CHECK_EQUAL(ret, false); + + // uint16_t tests + + str = "1"; + uint16_t value; + ret = str2int(value, str); + BOOST_CHECK_EQUAL(ret, true); + + str = "-1"; + ret = str2int(value, str); + BOOST_CHECK_EQUAL(ret, false); + + str = "65535"; + ret = str2int(value, str); + BOOST_CHECK_EQUAL(ret, true); + + str = "65536"; + ret = str2int(value, str); + BOOST_CHECK_EQUAL(ret, false); +} +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +BOOST_AUTO_TEST_CASE(tokenize_function) { + const char *text = "Hello, World!"; + int len = strlen(text), tok_len; + + const char *tok = tokenize(text, ",", len, tok_len); + BOOST_CHECK_EQUAL(string(tok, tok_len), "Hello"); + + tok = tokenize(text, ",", len, tok_len); + BOOST_CHECK_EQUAL(string(tok,tok_len)," World!"); + + text = "This is a book"; + len = strlen(text); + int tok_count = 0; + while ( (tok = tokenize(text, ",", len, tok_len)) != NULL ) { + if ( tok_count == 3 ) { + BOOST_CHECK_EQUAL(string(tok, tok_len), "book"); + } + ++tok_count; + } + + text = ""; + len = strlen(text); + tok = tokenize(text, ";", len,tok_len); + BOOST_CHECK_EQUAL(string(tok,tok_len), ""); +} +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/gempa/caps/utils.h b/libs/gempa/caps/utils.h new file mode 100644 index 0000000..10b10fb --- /dev/null +++ b/libs/gempa/caps/utils.h @@ -0,0 +1,377 @@ +/*************************************************************************** + * Copyright (C) 2014 by gempa GmbH * + * * + * All Rights Reserved. * + * * + * NOTICE: All information contained herein is, and remains * + * the property of gempa GmbH and its suppliers, if any. The intellectual * + * and technical concepts contained herein are proprietary to gempa GmbH * + * and its suppliers. * + * Dissemination of this information or reproduction of this material * + * is strictly forbidden unless prior written permission is obtained * + * from gempa GmbH. * + ***************************************************************************/ + + +#ifndef GEMPA_CAPS_UTILS_H +#define GEMPA_CAPS_UTILS_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Gempa { +namespace CAPS { + +class arraybuf : public std::streambuf { + public: + typedef std::streambuf::pos_type pos_type; + typedef std::streambuf::off_type off_type; + + public: + arraybuf(const char *buf, int len) { + char *tmp = const_cast(buf); + setp(tmp, tmp + len); + setg(tmp, tmp, tmp + len); + } + + arraybuf(const std::string &buf) { + if ( buf.size() > 0 ) { + char *tmp = const_cast(&buf[0]); + setg(tmp, tmp, tmp + buf.size()); + setp(tmp, tmp + buf.size()); + } + } + + void reset(const char *buf, int len) { + char *tmp = const_cast(buf); + setp(tmp, tmp + len); + } + + virtual pos_type seekoff(off_type ofs, std::ios_base::seekdir dir, + std::ios_base::openmode mode) { + if ( mode & std::ios_base::in ) { + char *next; + + switch ( dir ) { + case std::ios_base::beg: + next = eback() + ofs; + break; + case std::ios_base::cur: + next = gptr() + ofs; + break; + case std::ios_base::end: + next = egptr() + ofs; + break; + default: + return pos_type(off_type(-1)); + } + + if ( next > egptr() || next < eback() ) + return pos_type(off_type(-1)); + + gbump(next-gptr()); + } + + if ( mode & std::ios_base::out ) { + return pos_type(off_type(-1)); + } + + return pos_type(off_type(-1)); + } + + virtual pos_type seekpos(pos_type pos, std::ios_base::openmode mode) { + if ( mode & std::ios_base::in ) { + char *next = eback() + pos; + if ( next > egptr() ) + return pos_type(off_type(-1)); + gbump(next-gptr()); + } + + if ( mode & std::ios_base::out ) { + char *next = pbase() + pos; + if ( next > epptr() ) { + return pos_type(off_type(-1)); + } + pbump(pos); + } + + return pos; + } + + virtual std::streamsize xsgetn(char* s, std::streamsize n) { + char *next = gptr() + n; + if ( next >= egptr() ) + n = n - (next - egptr()); + + if ( n == 0 ) return 0; + + memcpy(s, gptr(), n); + setg(eback(), next, egptr()); + + return n; + } + + std::streampos tellg() { + return gptr() - eback(); + } + + std::streampos tellp() { + return pptr() - pbase(); + } +}; + +#define CHECK_STRING(data, str, len) \ + ((len == sizeof(str)-1) && (strncasecmp(data, str, len) == 0)) + + + +/** + * @brief Splits an address string into hostname and port + * @param host The host + * @param port The port + * @param address The address + * @param default_port The default port which will be used + * if the addrees contains no port + * @return True, if the address is valid + */ +inline bool splitAddress(std::string &host, unsigned short &port, + const std::string &address, unsigned short default_port) { + size_t pos = address.find(':'); + if ( pos != std::string::npos ) { + int p = -1; + host = address.substr(0, pos); + std::stringstream ss(address.substr(pos+1)); + ss >> p; + if ( p > 0 && p <= 65535 ) + port = p; + else + return false; + } + else { + host = address; + port = default_port; + } + + return !host.empty(); +} + + +/* + * Returns substring that contains leftmost characters up to the delimiter + */ +inline const char *tokenize(const char *&str, const char *delim, + int &len_source, int &len_tok) { + len_tok = 0; + for ( ; len_source; --len_source, ++str ) { + // Hit first non delimiter? + if ( strchr(delim, *str) == NULL ) { + const char *tok = str; + + ++str; --len_source; + len_tok = 1; + + // Hit first delimiter? + for ( ; len_source; --len_source, ++str, ++len_tok ) { + if ( strchr(delim, *str) != NULL ) + break; + } + + return tok; + } + } + + return NULL; +} + +/* + * Removes whitespaces from start and end of string + */ +inline const char *trim(const char *&str, int &len) { + int i = len; + while ( i > 0 ) { + if ( isspace(*str) ) { + ++str; + --len; + } + else + break; + ++i; + } + + i = len-1; + while ( i > 0 ) { + if ( !isspace(str[i]) ) + break; + + --len; + --i; + } + + return str; +} + + +inline std::string trim(const std::string &s) { + int l = (int)s.size(); + const char *str = &s[0]; + trim(str, l); + return std::string(str, l); +} + + +/* + * Converts time object to timestamp + */ +inline void timeToTimestamp(TimeStamp &ts, const Time &t) { + int year, yday, hour, min, sec, usec; + t.get2(&year, &yday, &hour, &min, &sec, &usec); + ts.year = year; + ts.yday = yday; + ts.hour = hour; + ts.minute = min; + ts.second = sec; + ts.usec = usec; +} + +/** + * @brief Converts string to integer value + * @param v The integer value + * @param s The input string + * @param len The string length. If len is 0 the length + * is calculated from string + * @param base The numeric base + * @return True on success + */ +template +bool str2int(T &v, char const *s, int len = 0, int base = 10) { + // Return false in case of empty string + if (*s == '\0' ) return false; + + char *end; + long l; + errno = 0; + l = strtol(s, &end, base); + if ( errno == ERANGE || + l < std::numeric_limits::min() || + l > std::numeric_limits::max() ) { + return false; + } + + // Check if the string contains invalid chars + if ( len == 0 ) len = strlen(s); + + int bytes_read = end - s; + if ( bytes_read < len && *end != ' ' ) return false; + + v = static_cast(l); + return true; +} + +/** + * @brief Converts string to integer value + * @param v The integer value + * @param s The input string + * @param len The string length. If len is 0 the length + * is calculated from string + * @param base The numeric base + * @return True on success + */ +inline bool str2int(int &v, char const *s, int len = 0, int base = 10) { + return str2int(v, s, len, base); +} + +/** + * @brief Converts string to unsigned int16 value + * @param v The integer value + * @param s The input string + * @param len The string length. If len is 0 the length + * is calculated from string + * @param base The numeric base + * @return True on success + */ +inline bool str2int(uint16_t &v, char const *s, int len = 0, int base = 10) { + return str2int(v, s, len, base); +} + +/* + * Converts timestamp to time object + */ +inline Time +timestampToTime(const TimeStamp &ts) { + Time t; + t.set(ts.year, 1, 1, ts.hour, ts.minute, ts.second, ts.usec); + // Add the day of the year in seconds + t += TimeSpan(ts.yday*86400); + return t; +} + +inline TimeSpan +samplesToTimeSpan(const DataRecord::Header &head, int sampleCount) { + int64_t ms = ((int64_t)(sampleCount)) * 1000000 * head.samplingFrequencyDenominator / head.samplingFrequencyNumerator; + return TimeSpan(ms/1000000, ms%1000000); +} + +inline int +timeSpanToSamples(const DataRecord::Header &head, const TimeSpan &span) { + int64_t ms = ((int64_t)span.seconds())*1000000 + span.microseconds(); + return ms * head.samplingFrequencyNumerator / head.samplingFrequencyDenominator / 1000000; +} + +inline int +timeSpanToSamplesCeil(const DataRecord::Header &head, const TimeSpan &span) { + int64_t ms = ((int64_t)span.seconds())*1000000 + span.microseconds(); + return (ms * head.samplingFrequencyNumerator / head.samplingFrequencyDenominator + 999999) / 1000000; +} + +inline int +timeSpanToSamplesFloor(const DataRecord::Header &head, const TimeSpan &span) { + int64_t ms = ((int64_t)span.seconds())*1000000 + span.microseconds(); + return ms * head.samplingFrequencyNumerator / head.samplingFrequencyDenominator / 1000000; +} + +#if defined(WIN32) +inline void usleep(__int64 usec) +{ + HANDLE timer; + LARGE_INTEGER ft; + + ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time + + timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); +} +#endif + +inline uint8_t dataTypeSize(DataType dt) { + if ( dt == DT_INT8 ) + return sizeof(int8_t); + if ( dt == DT_INT16 ) + return sizeof(int16_t); + else if ( dt == DT_INT32 ) + return sizeof(int32_t); + else if ( dt == DT_INT64 ) + return sizeof(DT_INT64); + else if ( dt == DT_FLOAT ) + return sizeof(float); + else if ( dt == DT_DOUBLE ) + return sizeof(double); + + return 0; +} + +} +} + +#endif diff --git a/libs/gempa/caps/version.h b/libs/gempa/caps/version.h new file mode 100644 index 0000000..a90477b --- /dev/null +++ b/libs/gempa/caps/version.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (C) 2018 by gempa GmbH + * + * Author: Stephan Herrnkind + * Email: herrnkidn@gempa.de + ***************************************************************************/ + + +#ifndef __GEMPA_CAPS_VERSION_H__ +#define __GEMPA_CAPS_VERSION_H__ + + +/* #if (LIB_CAPS_VERSION >= LIB_CAPS_VERSION_CHECK(1, 0, 0)) */ +#define LIB_CAPS_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) + +#define LIB_CAPS_VERSION_MAJOR(v) (v >> 16) +#define LIB_CAPS_VERSION_MINOR(v) ((v >> 8) & 0xff) +#define LIB_CAPS_VERSION_PATCH(v) (v & 0xff) + +/* LIB_CAPS_VERSION is (major << 16) + (minor << 8) + patch. */ +#define LIB_CAPS_VERSION 0x010000 +#define LIB_CAPS_VERSION_NAME "1.0.0" + +/****************************************************************************** + API Changelog + ****************************************************************************** + "1.0.0" 0x010000 + - Initial version + +*/ + +#endif // __GEMPA_CAPS_VERSION_H__ diff --git a/libs/swig/CMakeLists.txt b/libs/swig/CMakeLists.txt new file mode 100644 index 0000000..b803b35 --- /dev/null +++ b/libs/swig/CMakeLists.txt @@ -0,0 +1 @@ +SUBDIRS(gempa) diff --git a/libs/swig/gempa/CAPS.i b/libs/swig/gempa/CAPS.i new file mode 100644 index 0000000..ebd513a --- /dev/null +++ b/libs/swig/gempa/CAPS.i @@ -0,0 +1,125 @@ +%feature("notabstract") Gempa::CAPS::AnyDataRecord; +%include "stdint.i" + +%init +%{ +import_array(); +%} + +%module CAPS +%{ +#define SWIG_FILE_WITH_INIT +#include +#include +#include +#include +#include +#include +#include +typedef Gempa::CAPS::Plugin::Buffer Buffer; +#include +#include +#include +#include +#include +#include + +%} + +%extend Gempa::CAPS::Plugin { + Gempa::CAPS::Plugin::Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, int16_t numerator, int16_t denominator, + const std::string &uom, + PyObject *obj, int type + ) { + PyArrayObject *arr = NULL; + Gempa::CAPS::DataType dataType = (Gempa::CAPS::DataType)type; + Gempa::CAPS::Plugin::Status status = Gempa::CAPS::Plugin::PacketLoss; + switch(type) { + case Gempa::CAPS::DT_INT8: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_CHAR, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int8_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_INT16: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT16, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int16_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_INT32: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT32, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int32_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_FLOAT: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT32, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (float*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_DOUBLE: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT64, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (double*)(arr->data), arr->dimensions[0], dataType); + break; + default: + break; + } + + Py_XDECREF(arr); + return status; + } + + Gempa::CAPS::Plugin::Status push(const std::string &net, const std::string &sta, + const std::string &loc, const std::string &cha, + const Time &stime, uint16_t numerator, + uint16_t denominator, const std::string &format, + PyObject *obj) { + char *data; + Py_ssize_t len; + if ( PyBytes_AsStringAndSize(obj, &data, &len) == -1 ) + return Gempa::CAPS::Plugin::PacketLoss; + + return self->push(net, sta, loc, cha, stime, numerator, + denominator, format, data, len); + } +}; + +%include "exception.i" +%include "std_string.i" +%include "numpy.i" + +%include "gempa/caps/api.h" +%include "gempa/caps/datetime.h" +%include "gempa/caps/packet.h" +%include "gempa/caps/pluginpacket.h" +%include "gempa/caps/anypacket.h" +%include "gempa/caps/log.h" +%include "gempa/caps/mseed/spclock.h" +%include "gempa/caps/mseed/encoder.h" +%include "gempa/caps/encoderfactory.h" +%include "gempa/caps/mseedpacket.h" +typedef Gempa::CAPS::Plugin::Buffer Buffer; +%include "gempa/caps/plugin.h" +%include "gempa/caps/rawpacket.h" +%include "gempa/caps/riff.h" +%include "gempa/caps/rtcm2packet.h" +%include "gempa/caps/socket.h" +%include +%array_class(char, charArray); +%include "gempa/caps/utils.h" diff --git a/libs/swig/gempa/CAPS.py b/libs/swig/gempa/CAPS.py new file mode 100644 index 0000000..86afe85 --- /dev/null +++ b/libs/swig/gempa/CAPS.py @@ -0,0 +1,1928 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 3.0.12 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info >= (2, 7, 0): + def swig_import_helper(): + import importlib + pkg = __name__.rpartition('.')[0] + mname = '.'.join((pkg, '_CAPS')).lstrip('.') + try: + return importlib.import_module(mname) + except ImportError: + return importlib.import_module('_CAPS') + _CAPS = swig_import_helper() + del swig_import_helper +elif _swig_python_version_info >= (2, 6, 0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('_CAPS', [dirname(__file__)]) + except ImportError: + import _CAPS + return _CAPS + try: + _mod = imp.load_module('_CAPS', fp, pathname, description) + finally: + if fp is not None: + fp.close() + return _mod + _CAPS = swig_import_helper() + del swig_import_helper +else: + import _CAPS +del _swig_python_version_info + +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): + if (name == "thisown"): + return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name, None) + if method: + return method(self, value) + if (not static): + if _newclass: + object.__setattr__(self, name, value) + else: + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + + +def _swig_setattr(self, class_type, name, value): + return _swig_setattr_nondynamic(self, class_type, name, value, 0) + + +def _swig_getattr(self, class_type, name): + if (name == "thisown"): + return self.this.own() + method = class_type.__swig_getmethods__.get(name, None) + if method: + return method(self) + raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) + + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +try: + _object = object + _newclass = 1 +except __builtin__.Exception: + class _object: + pass + _newclass = 0 + +class TimeSpan(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, TimeSpan, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, TimeSpan, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_TimeSpan(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def __eq__(self, arg2): + return _CAPS.TimeSpan___eq__(self, arg2) + + def __ne__(self, arg2): + return _CAPS.TimeSpan___ne__(self, arg2) + + def __lt__(self, arg2): + return _CAPS.TimeSpan___lt__(self, arg2) + + def __le__(self, arg2): + return _CAPS.TimeSpan___le__(self, arg2) + + def __gt__(self, arg2): + return _CAPS.TimeSpan___gt__(self, arg2) + + def __ge__(self, arg2): + return _CAPS.TimeSpan___ge__(self, arg2) + + def __add__(self, arg2): + return _CAPS.TimeSpan___add__(self, arg2) + + def __sub__(self, arg2): + return _CAPS.TimeSpan___sub__(self, arg2) + + def __iadd__(self, arg2): + return _CAPS.TimeSpan___iadd__(self, arg2) + + def __isub__(self, arg2): + return _CAPS.TimeSpan___isub__(self, arg2) + + def abs(self): + return _CAPS.TimeSpan_abs(self) + + def seconds(self): + return _CAPS.TimeSpan_seconds(self) + + def microseconds(self): + return _CAPS.TimeSpan_microseconds(self) + + def length(self): + return _CAPS.TimeSpan_length(self) + + def set(self, seconds): + return _CAPS.TimeSpan_set(self, seconds) + + def setUSecs(self, arg2): + return _CAPS.TimeSpan_setUSecs(self, arg2) + + def elapsedTime(self, days, hours=None, minutes=None, seconds=None): + return _CAPS.TimeSpan_elapsedTime(self, days, hours, minutes, seconds) + __swig_destroy__ = _CAPS.delete_TimeSpan + __del__ = lambda self: None +TimeSpan_swigregister = _CAPS.TimeSpan_swigregister +TimeSpan_swigregister(TimeSpan) + +class Time(TimeSpan): + __swig_setmethods__ = {} + for _s in [TimeSpan]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Time, name, value) + __swig_getmethods__ = {} + for _s in [TimeSpan]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, Time, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_Time(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def __nonzero__(self): + return _CAPS.Time___nonzero__(self) + __bool__ = __nonzero__ + + + + def __add__(self, arg2): + return _CAPS.Time___add__(self, arg2) + + def __sub__(self, *args): + return _CAPS.Time___sub__(self, *args) + + def __iadd__(self, arg2): + return _CAPS.Time___iadd__(self, arg2) + + def __isub__(self, arg2): + return _CAPS.Time___isub__(self, arg2) + + def set(self, year, month, day, hour, min, sec, usec): + return _CAPS.Time_set(self, year, month, day, hour, min, sec, usec) + + def get(self, year, month=None, day=None, hour=None, min=None, sec=None, usec=None): + return _CAPS.Time_get(self, year, month, day, hour, min, sec, usec) + + def get2(self, year, yday=None, hour=None, min=None, sec=None, usec=None): + return _CAPS.Time_get2(self, year, yday, hour, min, sec, usec) + if _newclass: + LocalTime = staticmethod(_CAPS.Time_LocalTime) + else: + LocalTime = _CAPS.Time_LocalTime + if _newclass: + GMT = staticmethod(_CAPS.Time_GMT) + else: + GMT = _CAPS.Time_GMT + if _newclass: + FromYearDay = staticmethod(_CAPS.Time_FromYearDay) + else: + FromYearDay = _CAPS.Time_FromYearDay + + def localtime(self): + return _CAPS.Time_localtime(self) + + def gmt(self): + return _CAPS.Time_gmt(self) + + def toLocalTime(self): + return _CAPS.Time_toLocalTime(self) + + def toGMT(self): + return _CAPS.Time_toGMT(self) + + def valid(self): + return _CAPS.Time_valid(self) + + def toString(self, fmt): + return _CAPS.Time_toString(self, fmt) + + def iso(self): + return _CAPS.Time_iso(self) + + def fromString(self, str, fmt): + return _CAPS.Time_fromString(self, str, fmt) + if _newclass: + FromString = staticmethod(_CAPS.Time_FromString) + else: + FromString = _CAPS.Time_FromString + __swig_destroy__ = _CAPS.delete_Time + __del__ = lambda self: None +Time_swigregister = _CAPS.Time_swigregister +Time_swigregister(Time) +cvar = _CAPS.cvar +Time.Null = _CAPS.cvar.Time_Null + +def Time_LocalTime(): + return _CAPS.Time_LocalTime() +Time_LocalTime = _CAPS.Time_LocalTime + +def Time_GMT(): + return _CAPS.Time_GMT() +Time_GMT = _CAPS.Time_GMT + +def Time_FromYearDay(year, year_day): + return _CAPS.Time_FromYearDay(year, year_day) +Time_FromYearDay = _CAPS.Time_FromYearDay + +def Time_FromString(str, fmt): + return _CAPS.Time_FromString(str, fmt) +Time_FromString = _CAPS.Time_FromString + +UnknownPacket = _CAPS.UnknownPacket +RawDataPacket = _CAPS.RawDataPacket +MSEEDPacket = _CAPS.MSEEDPacket +ANYPacket = _CAPS.ANYPacket +RTCM2Packet = _CAPS.RTCM2Packet +MetaDataPacket = _CAPS.MetaDataPacket +FixedRawDataPacket = _CAPS.FixedRawDataPacket +PacketTypeCount = _CAPS.PacketTypeCount +DT_Unknown = _CAPS.DT_Unknown +DT_DOUBLE = _CAPS.DT_DOUBLE +DT_FLOAT = _CAPS.DT_FLOAT +DT_INT64 = _CAPS.DT_INT64 +DT_INT32 = _CAPS.DT_INT32 +DT_INT16 = _CAPS.DT_INT16 +DT_INT8 = _CAPS.DT_INT8 +class UOM(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, UOM, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, UOM, name) + __repr__ = _swig_repr + __swig_setmethods__["str"] = _CAPS.UOM_str_set + __swig_getmethods__["str"] = _CAPS.UOM_str_get + if _newclass: + str = _swig_property(_CAPS.UOM_str_get, _CAPS.UOM_str_set) + __swig_setmethods__["ID"] = _CAPS.UOM_ID_set + __swig_getmethods__["ID"] = _CAPS.UOM_ID_get + if _newclass: + ID = _swig_property(_CAPS.UOM_ID_get, _CAPS.UOM_ID_set) + + def __init__(self): + this = _CAPS.new_UOM() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_UOM + __del__ = lambda self: None +UOM_swigregister = _CAPS.UOM_swigregister +UOM_swigregister(UOM) + +class Quality(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Quality, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Quality, name) + __repr__ = _swig_repr + __swig_setmethods__["str"] = _CAPS.Quality_str_set + __swig_getmethods__["str"] = _CAPS.Quality_str_get + if _newclass: + str = _swig_property(_CAPS.Quality_str_get, _CAPS.Quality_str_set) + __swig_setmethods__["ID"] = _CAPS.Quality_ID_set + __swig_getmethods__["ID"] = _CAPS.Quality_ID_get + if _newclass: + ID = _swig_property(_CAPS.Quality_ID_get, _CAPS.Quality_ID_set) + + def __init__(self): + this = _CAPS.new_Quality() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_Quality + __del__ = lambda self: None +Quality_swigregister = _CAPS.Quality_swigregister +Quality_swigregister(Quality) + +class TimeStamp(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, TimeStamp, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, TimeStamp, name) + __repr__ = _swig_repr + __swig_setmethods__["year"] = _CAPS.TimeStamp_year_set + __swig_getmethods__["year"] = _CAPS.TimeStamp_year_get + if _newclass: + year = _swig_property(_CAPS.TimeStamp_year_get, _CAPS.TimeStamp_year_set) + __swig_setmethods__["yday"] = _CAPS.TimeStamp_yday_set + __swig_getmethods__["yday"] = _CAPS.TimeStamp_yday_get + if _newclass: + yday = _swig_property(_CAPS.TimeStamp_yday_get, _CAPS.TimeStamp_yday_set) + __swig_setmethods__["hour"] = _CAPS.TimeStamp_hour_set + __swig_getmethods__["hour"] = _CAPS.TimeStamp_hour_get + if _newclass: + hour = _swig_property(_CAPS.TimeStamp_hour_get, _CAPS.TimeStamp_hour_set) + __swig_setmethods__["minute"] = _CAPS.TimeStamp_minute_set + __swig_getmethods__["minute"] = _CAPS.TimeStamp_minute_get + if _newclass: + minute = _swig_property(_CAPS.TimeStamp_minute_get, _CAPS.TimeStamp_minute_set) + __swig_setmethods__["second"] = _CAPS.TimeStamp_second_set + __swig_getmethods__["second"] = _CAPS.TimeStamp_second_get + if _newclass: + second = _swig_property(_CAPS.TimeStamp_second_get, _CAPS.TimeStamp_second_set) + __swig_setmethods__["unused"] = _CAPS.TimeStamp_unused_set + __swig_getmethods__["unused"] = _CAPS.TimeStamp_unused_get + if _newclass: + unused = _swig_property(_CAPS.TimeStamp_unused_get, _CAPS.TimeStamp_unused_set) + __swig_setmethods__["usec"] = _CAPS.TimeStamp_usec_set + __swig_getmethods__["usec"] = _CAPS.TimeStamp_usec_get + if _newclass: + usec = _swig_property(_CAPS.TimeStamp_usec_get, _CAPS.TimeStamp_usec_set) + + def __init__(self): + this = _CAPS.new_TimeStamp() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_TimeStamp + __del__ = lambda self: None +TimeStamp_swigregister = _CAPS.TimeStamp_swigregister +TimeStamp_swigregister(TimeStamp) + +class PacketDataHeader(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, PacketDataHeader, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, PacketDataHeader, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_PacketDataHeader(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_setmethods__["version"] = _CAPS.PacketDataHeader_version_set + __swig_getmethods__["version"] = _CAPS.PacketDataHeader_version_get + if _newclass: + version = _swig_property(_CAPS.PacketDataHeader_version_get, _CAPS.PacketDataHeader_version_set) + __swig_setmethods__["packetType"] = _CAPS.PacketDataHeader_packetType_set + __swig_getmethods__["packetType"] = _CAPS.PacketDataHeader_packetType_get + if _newclass: + packetType = _swig_property(_CAPS.PacketDataHeader_packetType_get, _CAPS.PacketDataHeader_packetType_set) + __swig_setmethods__["unitOfMeasurement"] = _CAPS.PacketDataHeader_unitOfMeasurement_set + __swig_getmethods__["unitOfMeasurement"] = _CAPS.PacketDataHeader_unitOfMeasurement_get + if _newclass: + unitOfMeasurement = _swig_property(_CAPS.PacketDataHeader_unitOfMeasurement_get, _CAPS.PacketDataHeader_unitOfMeasurement_set) + + def setUOM(self, type): + return _CAPS.PacketDataHeader_setUOM(self, type) + + def uom(self, *args): + return _CAPS.PacketDataHeader_uom(self, *args) + + def __ne__(self, other): + return _CAPS.PacketDataHeader___ne__(self, other) + + def dataSize(self): + return _CAPS.PacketDataHeader_dataSize(self) + + def put(self, buf): + return _CAPS.PacketDataHeader_put(self, buf) + + def get(self, buf): + return _CAPS.PacketDataHeader_get(self, buf) + __swig_destroy__ = _CAPS.delete_PacketDataHeader + __del__ = lambda self: None +PacketDataHeader_swigregister = _CAPS.PacketDataHeader_swigregister +PacketDataHeader_swigregister(PacketDataHeader) + +class PacketDataHeaderV2(PacketDataHeader): + __swig_setmethods__ = {} + for _s in [PacketDataHeader]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, PacketDataHeaderV2, name, value) + __swig_getmethods__ = {} + for _s in [PacketDataHeader]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, PacketDataHeaderV2, name) + __repr__ = _swig_repr + + def __init__(self): + this = _CAPS.new_PacketDataHeaderV2() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_setmethods__["samplingFrequencyNumerator"] = _CAPS.PacketDataHeaderV2_samplingFrequencyNumerator_set + __swig_getmethods__["samplingFrequencyNumerator"] = _CAPS.PacketDataHeaderV2_samplingFrequencyNumerator_get + if _newclass: + samplingFrequencyNumerator = _swig_property(_CAPS.PacketDataHeaderV2_samplingFrequencyNumerator_get, _CAPS.PacketDataHeaderV2_samplingFrequencyNumerator_set) + __swig_setmethods__["samplingFrequencyDenominator"] = _CAPS.PacketDataHeaderV2_samplingFrequencyDenominator_set + __swig_getmethods__["samplingFrequencyDenominator"] = _CAPS.PacketDataHeaderV2_samplingFrequencyDenominator_get + if _newclass: + samplingFrequencyDenominator = _swig_property(_CAPS.PacketDataHeaderV2_samplingFrequencyDenominator_get, _CAPS.PacketDataHeaderV2_samplingFrequencyDenominator_set) + __swig_setmethods__["quality"] = _CAPS.PacketDataHeaderV2_quality_set + __swig_getmethods__["quality"] = _CAPS.PacketDataHeaderV2_quality_get + if _newclass: + quality = _swig_property(_CAPS.PacketDataHeaderV2_quality_get, _CAPS.PacketDataHeaderV2_quality_set) + + def __ne__(self, other): + return _CAPS.PacketDataHeaderV2___ne__(self, other) + + def dataSize(self): + return _CAPS.PacketDataHeaderV2_dataSize(self) + + def put(self, buf): + return _CAPS.PacketDataHeaderV2_put(self, buf) + + def get(self, buf): + return _CAPS.PacketDataHeaderV2_get(self, buf) + __swig_destroy__ = _CAPS.delete_PacketDataHeaderV2 + __del__ = lambda self: None +PacketDataHeaderV2_swigregister = _CAPS.PacketDataHeaderV2_swigregister +PacketDataHeaderV2_swigregister(PacketDataHeaderV2) + +NetworkCode = _CAPS.NetworkCode +StationCode = _CAPS.StationCode +LocationCode = _CAPS.LocationCode +ChannelCode = _CAPS.ChannelCode +StreamIDComponentSize = _CAPS.StreamIDComponentSize +class PacketHeaderV1(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, PacketHeaderV1, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, PacketHeaderV1, name) + __repr__ = _swig_repr + __swig_setmethods__["SIDSize"] = _CAPS.PacketHeaderV1_SIDSize_set + __swig_getmethods__["SIDSize"] = _CAPS.PacketHeaderV1_SIDSize_get + if _newclass: + SIDSize = _swig_property(_CAPS.PacketHeaderV1_SIDSize_get, _CAPS.PacketHeaderV1_SIDSize_set) + __swig_setmethods__["size"] = _CAPS.PacketHeaderV1_size_set + __swig_getmethods__["size"] = _CAPS.PacketHeaderV1_size_get + if _newclass: + size = _swig_property(_CAPS.PacketHeaderV1_size_get, _CAPS.PacketHeaderV1_size_set) + + def put(self, buf): + return _CAPS.PacketHeaderV1_put(self, buf) + + def dataSize(self): + return _CAPS.PacketHeaderV1_dataSize(self) + + def __init__(self): + this = _CAPS.new_PacketHeaderV1() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_PacketHeaderV1 + __del__ = lambda self: None +PacketHeaderV1_swigregister = _CAPS.PacketHeaderV1_swigregister +PacketHeaderV1_swigregister(PacketHeaderV1) + +class PacketHeaderV2(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, PacketHeaderV2, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, PacketHeaderV2, name) + __repr__ = _swig_repr + __swig_setmethods__["SIDSize"] = _CAPS.PacketHeaderV2_SIDSize_set + __swig_getmethods__["SIDSize"] = _CAPS.PacketHeaderV2_SIDSize_get + if _newclass: + SIDSize = _swig_property(_CAPS.PacketHeaderV2_SIDSize_get, _CAPS.PacketHeaderV2_SIDSize_set) + __swig_setmethods__["size"] = _CAPS.PacketHeaderV2_size_set + __swig_getmethods__["size"] = _CAPS.PacketHeaderV2_size_get + if _newclass: + size = _swig_property(_CAPS.PacketHeaderV2_size_get, _CAPS.PacketHeaderV2_size_set) + + def put(self, buf): + return _CAPS.PacketHeaderV2_put(self, buf) + + def dataSize(self): + return _CAPS.PacketHeaderV2_dataSize(self) + + def __init__(self): + this = _CAPS.new_PacketHeaderV2() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_PacketHeaderV2 + __del__ = lambda self: None +PacketHeaderV2_swigregister = _CAPS.PacketHeaderV2_swigregister +PacketHeaderV2_swigregister(PacketHeaderV2) + +class ResponseHeader(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ResponseHeader, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ResponseHeader, name) + __repr__ = _swig_repr + __swig_setmethods__["id"] = _CAPS.ResponseHeader_id_set + __swig_getmethods__["id"] = _CAPS.ResponseHeader_id_get + if _newclass: + id = _swig_property(_CAPS.ResponseHeader_id_get, _CAPS.ResponseHeader_id_set) + __swig_setmethods__["size"] = _CAPS.ResponseHeader_size_set + __swig_getmethods__["size"] = _CAPS.ResponseHeader_size_get + if _newclass: + size = _swig_property(_CAPS.ResponseHeader_size_get, _CAPS.ResponseHeader_size_set) + + def get(self, buf): + return _CAPS.ResponseHeader_get(self, buf) + + def __init__(self): + this = _CAPS.new_ResponseHeader() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_ResponseHeader + __del__ = lambda self: None +ResponseHeader_swigregister = _CAPS.ResponseHeader_swigregister +ResponseHeader_swigregister(ResponseHeader) + +class DataRecord(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, DataRecord, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, DataRecord, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + RS_Error = _CAPS.DataRecord_RS_Error + RS_Complete = _CAPS.DataRecord_RS_Complete + RS_Partial = _CAPS.DataRecord_RS_Partial + RS_BeforeTimeWindow = _CAPS.DataRecord_RS_BeforeTimeWindow + RS_AfterTimeWindow = _CAPS.DataRecord_RS_AfterTimeWindow + RS_Max = _CAPS.DataRecord_RS_Max + __swig_destroy__ = _CAPS.delete_DataRecord + __del__ = lambda self: None + + def formatName(self): + return _CAPS.DataRecord_formatName(self) + + def readMetaData(self, buf, size, header, startTime, endTime): + return _CAPS.DataRecord_readMetaData(self, buf, size, header, startTime, endTime) + + def canTrim(self): + return _CAPS.DataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.DataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.DataRecord_trim(self, start, end) + + def dataSize(self, withHeader=True): + return _CAPS.DataRecord_dataSize(self, withHeader) + + def get(self, *args): + return _CAPS.DataRecord_get(self, *args) + + def put(self, buf, withHeader=True): + return _CAPS.DataRecord_put(self, buf, withHeader) + + def header(self): + return _CAPS.DataRecord_header(self) + + def startTime(self): + return _CAPS.DataRecord_startTime(self) + + def endTime(self): + return _CAPS.DataRecord_endTime(self) + + def packetType(self): + return _CAPS.DataRecord_packetType(self) + + def buffer(self): + return _CAPS.DataRecord_buffer(self) + + def data(self): + return _CAPS.DataRecord_data(self) +DataRecord_swigregister = _CAPS.DataRecord_swigregister +DataRecord_swigregister(DataRecord) + +class RawPacket(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, RawPacket, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, RawPacket, name) + __repr__ = _swig_repr + __swig_setmethods__["header"] = _CAPS.RawPacket_header_set + __swig_getmethods__["header"] = _CAPS.RawPacket_header_get + if _newclass: + header = _swig_property(_CAPS.RawPacket_header_get, _CAPS.RawPacket_header_set) + __swig_setmethods__["SID"] = _CAPS.RawPacket_SID_set + __swig_getmethods__["SID"] = _CAPS.RawPacket_SID_get + if _newclass: + SID = _swig_property(_CAPS.RawPacket_SID_get, _CAPS.RawPacket_SID_set) + __swig_setmethods__["data"] = _CAPS.RawPacket_data_set + __swig_getmethods__["data"] = _CAPS.RawPacket_data_get + if _newclass: + data = _swig_property(_CAPS.RawPacket_data_get, _CAPS.RawPacket_data_set) + __swig_setmethods__["record"] = _CAPS.RawPacket_record_set + __swig_getmethods__["record"] = _CAPS.RawPacket_record_get + if _newclass: + record = _swig_property(_CAPS.RawPacket_record_get, _CAPS.RawPacket_record_set) + + def __init__(self): + this = _CAPS.new_RawPacket() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_RawPacket + __del__ = lambda self: None +RawPacket_swigregister = _CAPS.RawPacket_swigregister +RawPacket_swigregister(RawPacket) + +class MetaPacket(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, MetaPacket, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, MetaPacket, name) + __repr__ = _swig_repr + __swig_setmethods__["SID"] = _CAPS.MetaPacket_SID_set + __swig_getmethods__["SID"] = _CAPS.MetaPacket_SID_get + if _newclass: + SID = _swig_property(_CAPS.MetaPacket_SID_get, _CAPS.MetaPacket_SID_set) + __swig_setmethods__["packetDataHeader"] = _CAPS.MetaPacket_packetDataHeader_set + __swig_getmethods__["packetDataHeader"] = _CAPS.MetaPacket_packetDataHeader_get + if _newclass: + packetDataHeader = _swig_property(_CAPS.MetaPacket_packetDataHeader_get, _CAPS.MetaPacket_packetDataHeader_set) + __swig_setmethods__["record"] = _CAPS.MetaPacket_record_set + __swig_getmethods__["record"] = _CAPS.MetaPacket_record_get + if _newclass: + record = _swig_property(_CAPS.MetaPacket_record_get, _CAPS.MetaPacket_record_set) + __swig_setmethods__["recordHeader"] = _CAPS.MetaPacket_recordHeader_set + __swig_getmethods__["recordHeader"] = _CAPS.MetaPacket_recordHeader_get + if _newclass: + recordHeader = _swig_property(_CAPS.MetaPacket_recordHeader_get, _CAPS.MetaPacket_recordHeader_set) + __swig_setmethods__["startTime"] = _CAPS.MetaPacket_startTime_set + __swig_getmethods__["startTime"] = _CAPS.MetaPacket_startTime_get + if _newclass: + startTime = _swig_property(_CAPS.MetaPacket_startTime_get, _CAPS.MetaPacket_startTime_set) + __swig_setmethods__["endTime"] = _CAPS.MetaPacket_endTime_set + __swig_getmethods__["endTime"] = _CAPS.MetaPacket_endTime_get + if _newclass: + endTime = _swig_property(_CAPS.MetaPacket_endTime_get, _CAPS.MetaPacket_endTime_set) + __swig_setmethods__["timestamp"] = _CAPS.MetaPacket_timestamp_set + __swig_getmethods__["timestamp"] = _CAPS.MetaPacket_timestamp_get + if _newclass: + timestamp = _swig_property(_CAPS.MetaPacket_timestamp_get, _CAPS.MetaPacket_timestamp_set) + + def __init__(self): + this = _CAPS.new_MetaPacket() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_MetaPacket + __del__ = lambda self: None +MetaPacket_swigregister = _CAPS.MetaPacket_swigregister +MetaPacket_swigregister(MetaPacket) + +class Packet(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Packet, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Packet, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_Packet(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def clone(self): + return _CAPS.Packet_clone(self) + __swig_setmethods__["buffer"] = _CAPS.Packet_buffer_set + __swig_getmethods__["buffer"] = _CAPS.Packet_buffer_get + if _newclass: + buffer = _swig_property(_CAPS.Packet_buffer_get, _CAPS.Packet_buffer_set) + __swig_setmethods__["record"] = _CAPS.Packet_record_set + __swig_getmethods__["record"] = _CAPS.Packet_record_get + if _newclass: + record = _swig_property(_CAPS.Packet_record_get, _CAPS.Packet_record_set) + __swig_setmethods__["networkCode"] = _CAPS.Packet_networkCode_set + __swig_getmethods__["networkCode"] = _CAPS.Packet_networkCode_get + if _newclass: + networkCode = _swig_property(_CAPS.Packet_networkCode_get, _CAPS.Packet_networkCode_set) + __swig_setmethods__["stationCode"] = _CAPS.Packet_stationCode_set + __swig_getmethods__["stationCode"] = _CAPS.Packet_stationCode_get + if _newclass: + stationCode = _swig_property(_CAPS.Packet_stationCode_get, _CAPS.Packet_stationCode_set) + __swig_setmethods__["locationCode"] = _CAPS.Packet_locationCode_set + __swig_getmethods__["locationCode"] = _CAPS.Packet_locationCode_get + if _newclass: + locationCode = _swig_property(_CAPS.Packet_locationCode_get, _CAPS.Packet_locationCode_set) + __swig_setmethods__["channelCode"] = _CAPS.Packet_channelCode_set + __swig_getmethods__["channelCode"] = _CAPS.Packet_channelCode_get + if _newclass: + channelCode = _swig_property(_CAPS.Packet_channelCode_get, _CAPS.Packet_channelCode_set) + __swig_setmethods__["streamID"] = _CAPS.Packet_streamID_set + __swig_getmethods__["streamID"] = _CAPS.Packet_streamID_get + if _newclass: + streamID = _swig_property(_CAPS.Packet_streamID_get, _CAPS.Packet_streamID_set) + __swig_setmethods__["dataType"] = _CAPS.Packet_dataType_set + __swig_getmethods__["dataType"] = _CAPS.Packet_dataType_get + if _newclass: + dataType = _swig_property(_CAPS.Packet_dataType_get, _CAPS.Packet_dataType_set) + __swig_setmethods__["dt_us"] = _CAPS.Packet_dt_us_set + __swig_getmethods__["dt_us"] = _CAPS.Packet_dt_us_get + if _newclass: + dt_us = _swig_property(_CAPS.Packet_dt_us_get, _CAPS.Packet_dt_us_set) + __swig_setmethods__["uom"] = _CAPS.Packet_uom_set + __swig_getmethods__["uom"] = _CAPS.Packet_uom_get + if _newclass: + uom = _swig_property(_CAPS.Packet_uom_get, _CAPS.Packet_uom_set) + __swig_setmethods__["timingQuality"] = _CAPS.Packet_timingQuality_set + __swig_getmethods__["timingQuality"] = _CAPS.Packet_timingQuality_get + if _newclass: + timingQuality = _swig_property(_CAPS.Packet_timingQuality_get, _CAPS.Packet_timingQuality_set) + + def size(self): + return _CAPS.Packet_size(self) + __swig_destroy__ = _CAPS.delete_Packet + __del__ = lambda self: None +Packet_swigregister = _CAPS.Packet_swigregister +Packet_swigregister(Packet) + +class AnyDataRecord(DataRecord): + __swig_setmethods__ = {} + for _s in [DataRecord]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, AnyDataRecord, name, value) + __swig_getmethods__ = {} + for _s in [DataRecord]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, AnyDataRecord, name) + __repr__ = _swig_repr + + def __init__(self): + this = _CAPS.new_AnyDataRecord() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def setType(self, type): + return _CAPS.AnyDataRecord_setType(self, type) + + def type(self): + return _CAPS.AnyDataRecord_type(self) + + def formatName(self): + return _CAPS.AnyDataRecord_formatName(self) + + def readMetaData(self, buf, size, header, startTime, endTime): + return _CAPS.AnyDataRecord_readMetaData(self, buf, size, header, startTime, endTime) + + def header(self): + return _CAPS.AnyDataRecord_header(self) + + def startTime(self): + return _CAPS.AnyDataRecord_startTime(self) + + def endTime(self): + return _CAPS.AnyDataRecord_endTime(self) + + def canTrim(self): + return _CAPS.AnyDataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.AnyDataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.AnyDataRecord_trim(self, start, end) + + def dataSize(self, withHeader): + return _CAPS.AnyDataRecord_dataSize(self, withHeader) + + def get(self, *args): + return _CAPS.AnyDataRecord_get(self, *args) + + def put(self, buf, withHeader): + return _CAPS.AnyDataRecord_put(self, buf, withHeader) + + def packetType(self): + return _CAPS.AnyDataRecord_packetType(self) + + def setStartTime(self, time): + return _CAPS.AnyDataRecord_setStartTime(self, time) + + def setEndTime(self, time): + return _CAPS.AnyDataRecord_setEndTime(self, time) + + def setSamplingFrequency(self, numerator, denominator): + return _CAPS.AnyDataRecord_setSamplingFrequency(self, numerator, denominator) + + def data(self): + return _CAPS.AnyDataRecord_data(self) + + def setData(self, data, size): + return _CAPS.AnyDataRecord_setData(self, data, size) + __swig_destroy__ = _CAPS.delete_AnyDataRecord + __del__ = lambda self: None +AnyDataRecord_swigregister = _CAPS.AnyDataRecord_swigregister +AnyDataRecord_swigregister(AnyDataRecord) + +LL_UNDEFINED = _CAPS.LL_UNDEFINED +LL_ERROR = _CAPS.LL_ERROR +LL_WARNING = _CAPS.LL_WARNING +LL_NOTICE = _CAPS.LL_NOTICE +LL_INFO = _CAPS.LL_INFO +LL_DEBUG = _CAPS.LL_DEBUG +LL_QUANTITY = _CAPS.LL_QUANTITY + +def SetLogHandler(arg1, arg2): + return _CAPS.SetLogHandler(arg1, arg2) +SetLogHandler = _CAPS.SetLogHandler +class SPClock(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SPClock, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SPClock, name) + __repr__ = _swig_repr + __swig_getmethods__["freqn"] = _CAPS.SPClock_freqn_get + if _newclass: + freqn = _swig_property(_CAPS.SPClock_freqn_get) + __swig_getmethods__["freqd"] = _CAPS.SPClock_freqd_get + if _newclass: + freqd = _swig_property(_CAPS.SPClock_freqd_get) + + def __init__(self, freqn_init, freqd_init): + this = _CAPS.new_SPClock(freqn_init, freqd_init) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def sync_time(self, time): + return _CAPS.SPClock_sync_time(self, time) + + def tick(self): + return _CAPS.SPClock_tick(self) + + def get_time(self, tick_diff): + return _CAPS.SPClock_get_time(self, tick_diff) + + def correction(self): + return _CAPS.SPClock_correction(self) + __swig_destroy__ = _CAPS.delete_SPClock + __del__ = lambda self: None +SPClock_swigregister = _CAPS.SPClock_swigregister +SPClock_swigregister(SPClock) + +class Encoder(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Encoder, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Encoder, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + __swig_destroy__ = _CAPS.delete_Encoder + __del__ = lambda self: None + + def push(self, sample): + return _CAPS.Encoder_push(self, sample) + + def flush(self): + return _CAPS.Encoder_flush(self) + + def reset(self): + return _CAPS.Encoder_reset(self) + + def type(self): + return _CAPS.Encoder_type(self) + + def clk(self): + return _CAPS.Encoder_clk(self) + + def setStartTime(self, time): + return _CAPS.Encoder_setStartTime(self, time) + + def currentTime(self): + return _CAPS.Encoder_currentTime(self) + + def timingQuality(self): + return _CAPS.Encoder_timingQuality(self) + + def setTimingQuality(self, quality): + return _CAPS.Encoder_setTimingQuality(self, quality) + + def pop(self): + return _CAPS.Encoder_pop(self) +Encoder_swigregister = _CAPS.Encoder_swigregister +Encoder_swigregister(Encoder) + +class EncoderFactory(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, EncoderFactory, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, EncoderFactory, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + __swig_destroy__ = _CAPS.delete_EncoderFactory + __del__ = lambda self: None + + def create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator): + return _CAPS.EncoderFactory_create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator) + + def supportsRecord(self, rec): + return _CAPS.EncoderFactory_supportsRecord(self, rec) + + def errorString(self): + return _CAPS.EncoderFactory_errorString(self) +EncoderFactory_swigregister = _CAPS.EncoderFactory_swigregister +EncoderFactory_swigregister(EncoderFactory) + +class MSEEDEncoderFactory(EncoderFactory): + __swig_setmethods__ = {} + for _s in [EncoderFactory]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, MSEEDEncoderFactory, name, value) + __swig_getmethods__ = {} + for _s in [EncoderFactory]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, MSEEDEncoderFactory, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def setRecordLength(self, recordLength): + return _CAPS.MSEEDEncoderFactory_setRecordLength(self, recordLength) + __swig_destroy__ = _CAPS.delete_MSEEDEncoderFactory + __del__ = lambda self: None +MSEEDEncoderFactory_swigregister = _CAPS.MSEEDEncoderFactory_swigregister +MSEEDEncoderFactory_swigregister(MSEEDEncoderFactory) + +class SteimEncoderFactory(MSEEDEncoderFactory): + __swig_setmethods__ = {} + for _s in [MSEEDEncoderFactory]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, SteimEncoderFactory, name, value) + __swig_getmethods__ = {} + for _s in [MSEEDEncoderFactory]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, SteimEncoderFactory, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def supportsRecord(self, rec): + return _CAPS.SteimEncoderFactory_supportsRecord(self, rec) + __swig_destroy__ = _CAPS.delete_SteimEncoderFactory + __del__ = lambda self: None +SteimEncoderFactory_swigregister = _CAPS.SteimEncoderFactory_swigregister +SteimEncoderFactory_swigregister(SteimEncoderFactory) + +class IdentityEncoderFactory(MSEEDEncoderFactory): + __swig_setmethods__ = {} + for _s in [MSEEDEncoderFactory]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, IdentityEncoderFactory, name, value) + __swig_getmethods__ = {} + for _s in [MSEEDEncoderFactory]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, IdentityEncoderFactory, name) + __repr__ = _swig_repr + + def create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator): + return _CAPS.IdentityEncoderFactory_create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator) + + def supportsRecord(self, rec): + return _CAPS.IdentityEncoderFactory_supportsRecord(self, rec) + + def __init__(self): + this = _CAPS.new_IdentityEncoderFactory() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_IdentityEncoderFactory + __del__ = lambda self: None +IdentityEncoderFactory_swigregister = _CAPS.IdentityEncoderFactory_swigregister +IdentityEncoderFactory_swigregister(IdentityEncoderFactory) + +class Steim1EncoderFactory(SteimEncoderFactory): + __swig_setmethods__ = {} + for _s in [SteimEncoderFactory]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Steim1EncoderFactory, name, value) + __swig_getmethods__ = {} + for _s in [SteimEncoderFactory]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, Steim1EncoderFactory, name) + __repr__ = _swig_repr + + def create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator): + return _CAPS.Steim1EncoderFactory_create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator) + + def __init__(self): + this = _CAPS.new_Steim1EncoderFactory() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_Steim1EncoderFactory + __del__ = lambda self: None +Steim1EncoderFactory_swigregister = _CAPS.Steim1EncoderFactory_swigregister +Steim1EncoderFactory_swigregister(Steim1EncoderFactory) + +class Steim2EncoderFactory(SteimEncoderFactory): + __swig_setmethods__ = {} + for _s in [SteimEncoderFactory]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, Steim2EncoderFactory, name, value) + __swig_getmethods__ = {} + for _s in [SteimEncoderFactory]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, Steim2EncoderFactory, name) + __repr__ = _swig_repr + + def create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator): + return _CAPS.Steim2EncoderFactory_create(self, networkCode, stationCode, locationCode, channelCode, dt, samplingFrequencyNumerator, samplingFrequencyDenominator) + + def __init__(self): + this = _CAPS.new_Steim2EncoderFactory() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_Steim2EncoderFactory + __del__ = lambda self: None +Steim2EncoderFactory_swigregister = _CAPS.Steim2EncoderFactory_swigregister +Steim2EncoderFactory_swigregister(Steim2EncoderFactory) + +class MSEEDDataRecord(DataRecord): + __swig_setmethods__ = {} + for _s in [DataRecord]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, MSEEDDataRecord, name, value) + __swig_getmethods__ = {} + for _s in [DataRecord]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, MSEEDDataRecord, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def formatName(self): + return _CAPS.MSEEDDataRecord_formatName(self) + + def readMetaData(self, buf, size, header, startTime, endTime): + return _CAPS.MSEEDDataRecord_readMetaData(self, buf, size, header, startTime, endTime) + + def header(self): + return _CAPS.MSEEDDataRecord_header(self) + + def startTime(self): + return _CAPS.MSEEDDataRecord_startTime(self) + + def endTime(self): + return _CAPS.MSEEDDataRecord_endTime(self) + + def canTrim(self): + return _CAPS.MSEEDDataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.MSEEDDataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.MSEEDDataRecord_trim(self, start, end) + + def dataSize(self, withHeader): + return _CAPS.MSEEDDataRecord_dataSize(self, withHeader) + + def get(self, *args): + return _CAPS.MSEEDDataRecord_get(self, *args) + + def put(self, buf, withHeader): + return _CAPS.MSEEDDataRecord_put(self, buf, withHeader) + + def packetType(self): + return _CAPS.MSEEDDataRecord_packetType(self) + + def setData(self, data, size): + return _CAPS.MSEEDDataRecord_setData(self, data, size) + + def unpackHeader(self): + return _CAPS.MSEEDDataRecord_unpackHeader(self) + __swig_destroy__ = _CAPS.delete_MSEEDDataRecord + __del__ = lambda self: None +MSEEDDataRecord_swigregister = _CAPS.MSEEDDataRecord_swigregister +MSEEDDataRecord_swigregister(MSEEDDataRecord) + +class Plugin(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Plugin, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Plugin, name) + __repr__ = _swig_repr + Success = _CAPS.Plugin_Success + PacketSize = _CAPS.Plugin_PacketSize + PacketLoss = _CAPS.Plugin_PacketLoss + PacketNotValid = _CAPS.Plugin_PacketNotValid + PacketNotSupported = _CAPS.Plugin_PacketNotSupported + MaxFutureEndTimeExceeded = _CAPS.Plugin_MaxFutureEndTimeExceeded + + def __init__(self, *args): + this = _CAPS.new_Plugin(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_Plugin + __del__ = lambda self: None + + def close(self): + return _CAPS.Plugin_close(self) + + def quit(self): + return _CAPS.Plugin_quit(self) + + def enableLogging(self): + return _CAPS.Plugin_enableLogging(self) + + def setBackfillingBufferSize(self, secs): + return _CAPS.Plugin_setBackfillingBufferSize(self, secs) + + def backfillingBufferSize(self): + return _CAPS.Plugin_backfillingBufferSize(self) + + def isExitRequested(self): + return _CAPS.Plugin_isExitRequested(self) + + def stats(self): + return _CAPS.Plugin_stats(self) + + def resetMaxBytesBuffered(self): + return _CAPS.Plugin_resetMaxBytesBuffered(self) + + def setEncoderFactory(self, factory): + return _CAPS.Plugin_setEncoderFactory(self, factory) + + def setHost(self, host): + return _CAPS.Plugin_setHost(self, host) + + def host(self): + return _CAPS.Plugin_host(self) + + def setPort(self, port): + return _CAPS.Plugin_setPort(self, port) + + def port(self): + return _CAPS.Plugin_port(self) + + def setBufferSize(self, bufferSize): + return _CAPS.Plugin_setBufferSize(self, bufferSize) + + def bufferSize(self): + return _CAPS.Plugin_bufferSize(self) + + def setSSLEnabled(self, enable): + return _CAPS.Plugin_setSSLEnabled(self, enable) + + def setCredentials(self, user, password): + return _CAPS.Plugin_setCredentials(self, user, password) + + def setMaxFutureEndTime(self, span): + return _CAPS.Plugin_setMaxFutureEndTime(self, span) + + def setPacketAckFunc(self, func): + return _CAPS.Plugin_setPacketAckFunc(self, func) + + def setSendTimeout(self, timeout): + return _CAPS.Plugin_setSendTimeout(self, timeout) + + def setTimeouts(self, *args): + return _CAPS.Plugin_setTimeouts(self, *args) + + def readJournal(self): + return _CAPS.Plugin_readJournal(self) + + def setJournal(self, filename): + return _CAPS.Plugin_setJournal(self, filename) + + def setFlushInterval(self, interval): + return _CAPS.Plugin_setFlushInterval(self, interval) + + def streamStates(self): + return _CAPS.Plugin_streamStates(self) + + def writeJournal(self, *args): + return _CAPS.Plugin_writeJournal(self, *args) + + def version(self): + return _CAPS.Plugin_version(self) + + def push(self, *args): + return _CAPS.Plugin_push(self, *args) +Plugin_swigregister = _CAPS.Plugin_swigregister +Plugin_swigregister(Plugin) + +class RawResponseHeader(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, RawResponseHeader, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, RawResponseHeader, name) + __repr__ = _swig_repr + __swig_setmethods__["timeSeconds"] = _CAPS.RawResponseHeader_timeSeconds_set + __swig_getmethods__["timeSeconds"] = _CAPS.RawResponseHeader_timeSeconds_get + if _newclass: + timeSeconds = _swig_property(_CAPS.RawResponseHeader_timeSeconds_get, _CAPS.RawResponseHeader_timeSeconds_set) + __swig_setmethods__["timeMicroSeconds"] = _CAPS.RawResponseHeader_timeMicroSeconds_set + __swig_getmethods__["timeMicroSeconds"] = _CAPS.RawResponseHeader_timeMicroSeconds_get + if _newclass: + timeMicroSeconds = _swig_property(_CAPS.RawResponseHeader_timeMicroSeconds_get, _CAPS.RawResponseHeader_timeMicroSeconds_set) + + def get(self, buf): + return _CAPS.RawResponseHeader_get(self, buf) + + def dataSize(self): + return _CAPS.RawResponseHeader_dataSize(self) + + def __init__(self): + this = _CAPS.new_RawResponseHeader() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_RawResponseHeader + __del__ = lambda self: None +RawResponseHeader_swigregister = _CAPS.RawResponseHeader_swigregister +RawResponseHeader_swigregister(RawResponseHeader) + +class RawDataRecord(DataRecord): + __swig_setmethods__ = {} + for _s in [DataRecord]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, RawDataRecord, name, value) + __swig_getmethods__ = {} + for _s in [DataRecord]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, RawDataRecord, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def formatName(self): + return _CAPS.RawDataRecord_formatName(self) + + def readMetaData(self, buf, size, header, startTime, endTime): + return _CAPS.RawDataRecord_readMetaData(self, buf, size, header, startTime, endTime) + + def setHeader(self, header): + return _CAPS.RawDataRecord_setHeader(self, header) + + def header(self): + return _CAPS.RawDataRecord_header(self) + + def startTime(self): + return _CAPS.RawDataRecord_startTime(self) + + def endTime(self): + return _CAPS.RawDataRecord_endTime(self) + + def canTrim(self): + return _CAPS.RawDataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.RawDataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.RawDataRecord_trim(self, start, end) + + def dataSize(self, withHeader): + return _CAPS.RawDataRecord_dataSize(self, withHeader) + + def get(self, *args): + return _CAPS.RawDataRecord_get(self, *args) + + def getData(self, *args): + return _CAPS.RawDataRecord_getData(self, *args) + + def put(self, buf, withHeader): + return _CAPS.RawDataRecord_put(self, buf, withHeader) + + def packetType(self): + return _CAPS.RawDataRecord_packetType(self) + + def setStartTime(self, time): + return _CAPS.RawDataRecord_setStartTime(self, time) + + def setSamplingFrequency(self, numerator, denominator): + return _CAPS.RawDataRecord_setSamplingFrequency(self, numerator, denominator) + + def setDataType(self, dt): + return _CAPS.RawDataRecord_setDataType(self, dt) + + def setBuffer(self, data, size): + return _CAPS.RawDataRecord_setBuffer(self, data, size) + __swig_destroy__ = _CAPS.delete_RawDataRecord + __del__ = lambda self: None +RawDataRecord_swigregister = _CAPS.RawDataRecord_swigregister +RawDataRecord_swigregister(RawDataRecord) + +class FixedRawDataRecord(RawDataRecord): + __swig_setmethods__ = {} + for _s in [RawDataRecord]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, FixedRawDataRecord, name, value) + __swig_getmethods__ = {} + for _s in [RawDataRecord]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, FixedRawDataRecord, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def canTrim(self): + return _CAPS.FixedRawDataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.FixedRawDataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.FixedRawDataRecord_trim(self, start, end) + + def formatName(self): + return _CAPS.FixedRawDataRecord_formatName(self) + + def get(self, buf, size, arg4, arg5, maxBytes): + return _CAPS.FixedRawDataRecord_get(self, buf, size, arg4, arg5, maxBytes) + + def packetType(self): + return _CAPS.FixedRawDataRecord_packetType(self) + __swig_destroy__ = _CAPS.delete_FixedRawDataRecord + __del__ = lambda self: None +FixedRawDataRecord_swigregister = _CAPS.FixedRawDataRecord_swigregister +FixedRawDataRecord_swigregister(FixedRawDataRecord) + +class ChunkHeader(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ChunkHeader, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ChunkHeader, name) + __repr__ = _swig_repr + __swig_setmethods__["chunkSize"] = _CAPS.ChunkHeader_chunkSize_set + __swig_getmethods__["chunkSize"] = _CAPS.ChunkHeader_chunkSize_get + if _newclass: + chunkSize = _swig_property(_CAPS.ChunkHeader_chunkSize_get, _CAPS.ChunkHeader_chunkSize_set) + + def setChunkType(self, type): + return _CAPS.ChunkHeader_setChunkType(self, type) + + def isChunkType(self, type): + return _CAPS.ChunkHeader_isChunkType(self, type) + + def validChunkType(self): + return _CAPS.ChunkHeader_validChunkType(self) + + def dataSize(self): + return _CAPS.ChunkHeader_dataSize(self) + + def read(self, input): + return _CAPS.ChunkHeader_read(self, input) + + def write(self, output): + return _CAPS.ChunkHeader_write(self, output) + + def get(self, input): + return _CAPS.ChunkHeader_get(self, input) + + def put(self, output): + return _CAPS.ChunkHeader_put(self, output) + + def __init__(self): + this = _CAPS.new_ChunkHeader() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_ChunkHeader + __del__ = lambda self: None +ChunkHeader_swigregister = _CAPS.ChunkHeader_swigregister +ChunkHeader_swigregister(ChunkHeader) + +class ChunkIterator(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ChunkIterator, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ChunkIterator, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_ChunkIterator(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def begin(self, *args): + return _CAPS.ChunkIterator_begin(self, *args) + + def next(self): + return _CAPS.ChunkIterator_next(self) + + def header(self): + return _CAPS.ChunkIterator_header(self) + + def headerPos(self): + return _CAPS.ChunkIterator_headerPos(self) + + def contentPos(self): + return _CAPS.ChunkIterator_contentPos(self) + + def istream(self): + return _CAPS.ChunkIterator_istream(self) + __swig_destroy__ = _CAPS.delete_ChunkIterator + __del__ = lambda self: None +ChunkIterator_swigregister = _CAPS.ChunkIterator_swigregister +ChunkIterator_swigregister(ChunkIterator) +ChunkHeaderSize = cvar.ChunkHeaderSize + +class Chunk(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Chunk, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Chunk, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + __swig_destroy__ = _CAPS.delete_Chunk + __del__ = lambda self: None + + def read(self, input, size): + return _CAPS.Chunk_read(self, input, size) + + def write(self, output): + return _CAPS.Chunk_write(self, output) + + def get(self, input, size): + return _CAPS.Chunk_get(self, input, size) + + def put(self, output): + return _CAPS.Chunk_put(self, output) + + def chunkSize(self): + return _CAPS.Chunk_chunkSize(self) +Chunk_swigregister = _CAPS.Chunk_swigregister +Chunk_swigregister(Chunk) + +class HeadChunk(Chunk): + __swig_setmethods__ = {} + for _s in [Chunk]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, HeadChunk, name, value) + __swig_getmethods__ = {} + for _s in [Chunk]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, HeadChunk, name) + __repr__ = _swig_repr + __swig_setmethods__["data"] = _CAPS.HeadChunk_data_set + __swig_getmethods__["data"] = _CAPS.HeadChunk_data_get + if _newclass: + data = _swig_property(_CAPS.HeadChunk_data_get, _CAPS.HeadChunk_data_set) + + def chunkSize(self): + return _CAPS.HeadChunk_chunkSize(self) + + def get(self, input, size): + return _CAPS.HeadChunk_get(self, input, size) + + def put(self, output): + return _CAPS.HeadChunk_put(self, output) + + def __init__(self): + this = _CAPS.new_HeadChunk() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_HeadChunk + __del__ = lambda self: None +HeadChunk_swigregister = _CAPS.HeadChunk_swigregister +HeadChunk_swigregister(HeadChunk) + +class SID(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SID, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SID, name) + __repr__ = _swig_repr + __swig_setmethods__["networkCode"] = _CAPS.SID_networkCode_set + __swig_getmethods__["networkCode"] = _CAPS.SID_networkCode_get + if _newclass: + networkCode = _swig_property(_CAPS.SID_networkCode_get, _CAPS.SID_networkCode_set) + __swig_setmethods__["stationCode"] = _CAPS.SID_stationCode_set + __swig_getmethods__["stationCode"] = _CAPS.SID_stationCode_get + if _newclass: + stationCode = _swig_property(_CAPS.SID_stationCode_get, _CAPS.SID_stationCode_set) + __swig_setmethods__["locationCode"] = _CAPS.SID_locationCode_set + __swig_getmethods__["locationCode"] = _CAPS.SID_locationCode_get + if _newclass: + locationCode = _swig_property(_CAPS.SID_locationCode_get, _CAPS.SID_locationCode_set) + __swig_setmethods__["channelCode"] = _CAPS.SID_channelCode_set + __swig_getmethods__["channelCode"] = _CAPS.SID_channelCode_get + if _newclass: + channelCode = _swig_property(_CAPS.SID_channelCode_get, _CAPS.SID_channelCode_set) + + def __eq__(self, other): + return _CAPS.SID___eq__(self, other) + + def __ne__(self, other): + return _CAPS.SID___ne__(self, other) + + def toString(self): + return _CAPS.SID_toString(self) + + def __init__(self): + this = _CAPS.new_SID() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_SID + __del__ = lambda self: None +SID_swigregister = _CAPS.SID_swigregister +SID_swigregister(SID) + +class SIDChunk(Chunk, SID): + __swig_setmethods__ = {} + for _s in [Chunk, SID]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, SIDChunk, name, value) + __swig_getmethods__ = {} + for _s in [Chunk, SID]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, SIDChunk, name) + __repr__ = _swig_repr + + def chunkSize(self): + return _CAPS.SIDChunk_chunkSize(self) + + def get(self, input, size): + return _CAPS.SIDChunk_get(self, input, size) + + def put(self, output): + return _CAPS.SIDChunk_put(self, output) + + def __init__(self): + this = _CAPS.new_SIDChunk() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_SIDChunk + __del__ = lambda self: None +SIDChunk_swigregister = _CAPS.SIDChunk_swigregister +SIDChunk_swigregister(SIDChunk) + +class RTCM2DataRecord(DataRecord): + __swig_setmethods__ = {} + for _s in [DataRecord]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, RTCM2DataRecord, name, value) + __swig_getmethods__ = {} + for _s in [DataRecord]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, RTCM2DataRecord, name) + + def __init__(self, *args, **kwargs): + raise AttributeError("No constructor defined - class is abstract") + __repr__ = _swig_repr + + def formatName(self): + return _CAPS.RTCM2DataRecord_formatName(self) + + def setTimeStamp(self, ts): + return _CAPS.RTCM2DataRecord_setTimeStamp(self, ts) + + def setSamplingFrequency(self, numerator, denominator): + return _CAPS.RTCM2DataRecord_setSamplingFrequency(self, numerator, denominator) + + def readMetaData(self, buf, size, header, startTime, endTime): + return _CAPS.RTCM2DataRecord_readMetaData(self, buf, size, header, startTime, endTime) + + def header(self): + return _CAPS.RTCM2DataRecord_header(self) + + def startTime(self): + return _CAPS.RTCM2DataRecord_startTime(self) + + def endTime(self): + return _CAPS.RTCM2DataRecord_endTime(self) + + def canTrim(self): + return _CAPS.RTCM2DataRecord_canTrim(self) + + def canMerge(self): + return _CAPS.RTCM2DataRecord_canMerge(self) + + def trim(self, start, end): + return _CAPS.RTCM2DataRecord_trim(self, start, end) + + def dataSize(self, withHeader): + return _CAPS.RTCM2DataRecord_dataSize(self, withHeader) + + def get(self, buf, size, start, end, maxSize=-1): + return _CAPS.RTCM2DataRecord_get(self, buf, size, start, end, maxSize) + + def put(self, buf, withHeader): + return _CAPS.RTCM2DataRecord_put(self, buf, withHeader) + + def packetType(self): + return _CAPS.RTCM2DataRecord_packetType(self) + __swig_destroy__ = _CAPS.delete_RTCM2DataRecord + __del__ = lambda self: None +RTCM2DataRecord_swigregister = _CAPS.RTCM2DataRecord_swigregister +RTCM2DataRecord_swigregister(RTCM2DataRecord) + +class Socket(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Socket, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Socket, name) + __repr__ = _swig_repr + Success = _CAPS.Socket_Success + Error = _CAPS.Socket_Error + AllocationError = _CAPS.Socket_AllocationError + ReuseAdressError = _CAPS.Socket_ReuseAdressError + BindError = _CAPS.Socket_BindError + ListenError = _CAPS.Socket_ListenError + AcceptError = _CAPS.Socket_AcceptError + ConnectError = _CAPS.Socket_ConnectError + AddrInfoError = _CAPS.Socket_AddrInfoError + Timeout = _CAPS.Socket_Timeout + InvalidSocket = _CAPS.Socket_InvalidSocket + InvalidPort = _CAPS.Socket_InvalidPort + InvalidAddressFamily = _CAPS.Socket_InvalidAddressFamily + InvalidAddress = _CAPS.Socket_InvalidAddress + InvalidHostname = _CAPS.Socket_InvalidHostname + + def __init__(self): + this = _CAPS.new_Socket() + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_Socket + __del__ = lambda self: None + if _newclass: + toString = staticmethod(_CAPS.Socket_toString) + else: + toString = _CAPS.Socket_toString + + def fd(self): + return _CAPS.Socket_fd(self) + + def isValid(self): + return _CAPS.Socket_isValid(self) + + def shutdown(self): + return _CAPS.Socket_shutdown(self) + + def close(self): + return _CAPS.Socket_close(self) + + def send(self, data): + return _CAPS.Socket_send(self, data) + + def write(self, data, len): + return _CAPS.Socket_write(self, data, len) + + def read(self, data, len): + return _CAPS.Socket_read(self, data, len) + + def flush(self): + return _CAPS.Socket_flush(self) + + def setSocketTimeout(self, secs, usecs): + return _CAPS.Socket_setSocketTimeout(self, secs, usecs) + + def setNonBlocking(self, nb): + return _CAPS.Socket_setNonBlocking(self, nb) + + def connect(self, hostname, port): + return _CAPS.Socket_connect(self, hostname, port) + + def rx(self): + return _CAPS.Socket_rx(self) + + def tx(self): + return _CAPS.Socket_tx(self) +Socket_swigregister = _CAPS.Socket_swigregister +Socket_swigregister(Socket) + +def Socket_toString(arg2): + return _CAPS.Socket_toString(arg2) +Socket_toString = _CAPS.Socket_toString + +class SSLSocket(Socket): + __swig_setmethods__ = {} + for _s in [Socket]: + __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {})) + __setattr__ = lambda self, name, value: _swig_setattr(self, SSLSocket, name, value) + __swig_getmethods__ = {} + for _s in [Socket]: + __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {})) + __getattr__ = lambda self, name: _swig_getattr(self, SSLSocket, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_SSLSocket(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_SSLSocket + __del__ = lambda self: None + + def write(self, data, len): + return _CAPS.SSLSocket_write(self, data, len) + + def read(self, data, len): + return _CAPS.SSLSocket_read(self, data, len) + + def connect(self, hostname, port): + return _CAPS.SSLSocket_connect(self, hostname, port) + + def sessionID(self): + return _CAPS.SSLSocket_sessionID(self) + + def sessionIDLength(self): + return _CAPS.SSLSocket_sessionIDLength(self) + + def peerCertificate(self): + return _CAPS.SSLSocket_peerCertificate(self) +SSLSocket_swigregister = _CAPS.SSLSocket_swigregister +SSLSocket_swigregister(SSLSocket) + +class charArray(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, charArray, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, charArray, name) + __repr__ = _swig_repr + + def __init__(self, nelements): + this = _CAPS.new_charArray(nelements) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + __swig_destroy__ = _CAPS.delete_charArray + __del__ = lambda self: None + + def __getitem__(self, index): + return _CAPS.charArray___getitem__(self, index) + + def __setitem__(self, index, value): + return _CAPS.charArray___setitem__(self, index, value) + + def cast(self): + return _CAPS.charArray_cast(self) + if _newclass: + frompointer = staticmethod(_CAPS.charArray_frompointer) + else: + frompointer = _CAPS.charArray_frompointer +charArray_swigregister = _CAPS.charArray_swigregister +charArray_swigregister(charArray) + +def charArray_frompointer(t): + return _CAPS.charArray_frompointer(t) +charArray_frompointer = _CAPS.charArray_frompointer + +class arraybuf(_object): + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, arraybuf, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, arraybuf, name) + __repr__ = _swig_repr + + def __init__(self, *args): + this = _CAPS.new_arraybuf(*args) + try: + self.this.append(this) + except __builtin__.Exception: + self.this = this + + def reset(self, buf, len): + return _CAPS.arraybuf_reset(self, buf, len) + + def seekoff(self, ofs, dir, mode): + return _CAPS.arraybuf_seekoff(self, ofs, dir, mode) + + def seekpos(self, pos, mode): + return _CAPS.arraybuf_seekpos(self, pos, mode) + + def xsgetn(self, s, n): + return _CAPS.arraybuf_xsgetn(self, s, n) + + def tellg(self): + return _CAPS.arraybuf_tellg(self) + + def tellp(self): + return _CAPS.arraybuf_tellp(self) + __swig_destroy__ = _CAPS.delete_arraybuf + __del__ = lambda self: None +arraybuf_swigregister = _CAPS.arraybuf_swigregister +arraybuf_swigregister(arraybuf) + + +def splitAddress(host, port, address, default_port): + return _CAPS.splitAddress(host, port, address, default_port) +splitAddress = _CAPS.splitAddress + +def tokenize(str, delim, len_source, len_tok): + return _CAPS.tokenize(str, delim, len_source, len_tok) +tokenize = _CAPS.tokenize + +def trim(*args): + return _CAPS.trim(*args) +trim = _CAPS.trim + +def timeToTimestamp(ts, t): + return _CAPS.timeToTimestamp(ts, t) +timeToTimestamp = _CAPS.timeToTimestamp + +def str2int(*args): + return _CAPS.str2int(*args) +str2int = _CAPS.str2int + +def timestampToTime(ts): + return _CAPS.timestampToTime(ts) +timestampToTime = _CAPS.timestampToTime + +def samplesToTimeSpan(head, sampleCount): + return _CAPS.samplesToTimeSpan(head, sampleCount) +samplesToTimeSpan = _CAPS.samplesToTimeSpan + +def timeSpanToSamples(head, span): + return _CAPS.timeSpanToSamples(head, span) +timeSpanToSamples = _CAPS.timeSpanToSamples + +def timeSpanToSamplesCeil(head, span): + return _CAPS.timeSpanToSamplesCeil(head, span) +timeSpanToSamplesCeil = _CAPS.timeSpanToSamplesCeil + +def timeSpanToSamplesFloor(head, span): + return _CAPS.timeSpanToSamplesFloor(head, span) +timeSpanToSamplesFloor = _CAPS.timeSpanToSamplesFloor + +def dataTypeSize(dt): + return _CAPS.dataTypeSize(dt) +dataTypeSize = _CAPS.dataTypeSize +# This file is compatible with both classic and new-style classes. + + diff --git a/libs/swig/gempa/CAPSPYTHON_wrap.cxx b/libs/swig/gempa/CAPSPYTHON_wrap.cxx new file mode 100644 index 0000000..636319a --- /dev/null +++ b/libs/swig/gempa/CAPSPYTHON_wrap.cxx @@ -0,0 +1,26030 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 3.0.12 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIGPYTHON +#define SWIGPYTHON +#endif + +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + + +#ifdef __cplusplus +/* SwigValueWrapper is described in swig.swg */ +template class SwigValueWrapper { + struct SwigMovePointer { + T *ptr; + SwigMovePointer(T *p) : ptr(p) { } + ~SwigMovePointer() { delete ptr; } + SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); +public: + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } + operator T&() const { return *pointer.ptr; } + T *operator&() { return pointer.ptr; } +}; + +template T SwigValueInit() { + return T(); +} +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + char *newstr; + Py_ssize_t len; + str = PyUnicode_AsUTF8String(str); + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif + +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +typedef inquiry lenfunc; +typedef intargfunc ssizeargfunc; +typedef intintargfunc ssizessizeargfunc; +typedef intobjargproc ssizeobjargproc; +typedef intintobjargproc ssizessizeobjargproc; +typedef getreadbufferproc readbufferproc; +typedef getwritebufferproc writebufferproc; +typedef getsegcountproc segcountproc; +typedef getcharbufferproc charbufferproc; +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) +{ + long result = 0; + PyObject *i = PyNumber_Int(x); + if (i) { + result = PyInt_AsLong(i); + Py_DECREF(i); + } + return result; +} +#endif + +#if PY_VERSION_HEX < 0x02050000 +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) +#endif + +#if PY_VERSION_HEX < 0x02040000 +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; + PyBufferProcs as_buffer; + PyObject *name, *slots; +} PyHeapTypeObject; +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef destructor freefunc; +#endif + +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ + (PY_MAJOR_VERSION > 3)) +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +#endif + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX >= 0x03000000 +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + return PyInstanceMethod_New(func); +} +#else +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) +{ + return NULL; +} +#endif + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 + PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN Py_ssize_t +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +SwigPyObject_repr(SwigPyObject *v) +#else +SwigPyObject_repr(SwigPyObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); + if (v->next) { +# ifdef METH_NOARGS + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# else + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); +# endif +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *val = NULL, *type = NULL, *tb = NULL; + PyErr_Fetch(&val, &type, &tb); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(val, type, tb); + + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +SwigPyObject_next(PyObject* v) +#else +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_disown(PyObject *v) +#else +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_acquire(PyObject *v) +#else +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#elif (PY_VERSION_HEX < 0x02050000) + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +SwigPyObject_getattr(SwigPyObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpyobject_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; +#endif + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME int +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + (printfunc)SwigPyPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpypacked_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; +#endif + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst = 0; + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else +# ifdef SWIGPY_USE_CAPSULE + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); +# else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); +# endif + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +#ifdef SWIGPY_USE_CAPSULE +SWIG_Python_DestroyModule(PyObject *obj) +#else +SWIG_Python_DestroyModule(void *vptr) +#endif +{ +#ifdef SWIGPY_USE_CAPSULE + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); +#else + swig_module_info *swig_module = (swig_module_info *) vptr; +#endif + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + swig_this = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif +#ifdef SWIGPY_USE_CAPSULE + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#else + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#endif +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { +#ifdef SWIGPY_USE_CAPSULE + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); +#else + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); +#endif + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { +#ifdef SWIGPY_USE_CAPSULE + obj = PyCapsule_New((void*) descriptor, NULL, NULL); +#else + obj = PyCObject_FromVoidPtr(descriptor, NULL); +#endif + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + } else { + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_BackfillingBuffer swig_types[0] +#define SWIGTYPE_p_BufferPtr swig_types[1] +#define SWIGTYPE_p_Gempa__CAPS__AnyDataRecord swig_types[2] +#define SWIGTYPE_p_Gempa__CAPS__DataRecord swig_types[3] +#define SWIGTYPE_p_Gempa__CAPS__DataRecord__Header swig_types[4] +#define SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus swig_types[5] +#define SWIGTYPE_p_Gempa__CAPS__Encoder swig_types[6] +#define SWIGTYPE_p_Gempa__CAPS__EncoderFactory swig_types[7] +#define SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord swig_types[8] +#define SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory swig_types[9] +#define SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord swig_types[10] +#define SWIGTYPE_p_Gempa__CAPS__MSEEDEncoderFactory swig_types[11] +#define SWIGTYPE_p_Gempa__CAPS__MetaPacket swig_types[12] +#define SWIGTYPE_p_Gempa__CAPS__Packet swig_types[13] +#define SWIGTYPE_p_Gempa__CAPS__PacketDataHeader swig_types[14] +#define SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2 swig_types[15] +#define SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1 swig_types[16] +#define SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2 swig_types[17] +#define SWIGTYPE_p_Gempa__CAPS__Plugin swig_types[18] +#define SWIGTYPE_p_Gempa__CAPS__Plugin__Stats swig_types[19] +#define SWIGTYPE_p_Gempa__CAPS__Quality swig_types[20] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk swig_types[21] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader swig_types[22] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator swig_types[23] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk swig_types[24] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__SID swig_types[25] +#define SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk swig_types[26] +#define SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord swig_types[27] +#define SWIGTYPE_p_Gempa__CAPS__RawDataRecord swig_types[28] +#define SWIGTYPE_p_Gempa__CAPS__RawPacket swig_types[29] +#define SWIGTYPE_p_Gempa__CAPS__RawResponseHeader swig_types[30] +#define SWIGTYPE_p_Gempa__CAPS__ResponseHeader swig_types[31] +#define SWIGTYPE_p_Gempa__CAPS__SPClock swig_types[32] +#define SWIGTYPE_p_Gempa__CAPS__SSLSocket swig_types[33] +#define SWIGTYPE_p_Gempa__CAPS__Socket swig_types[34] +#define SWIGTYPE_p_Gempa__CAPS__Socket__Device__Status swig_types[35] +#define SWIGTYPE_p_Gempa__CAPS__Steim1EncoderFactory swig_types[36] +#define SWIGTYPE_p_Gempa__CAPS__Steim2EncoderFactory swig_types[37] +#define SWIGTYPE_p_Gempa__CAPS__SteimEncoderFactory swig_types[38] +#define SWIGTYPE_p_Gempa__CAPS__Time swig_types[39] +#define SWIGTYPE_p_Gempa__CAPS__TimeSpan swig_types[40] +#define SWIGTYPE_p_Gempa__CAPS__TimeStamp swig_types[41] +#define SWIGTYPE_p_Gempa__CAPS__UOM swig_types[42] +#define SWIGTYPE_p_Gempa__CAPS__arraybuf swig_types[43] +#define SWIGTYPE_p_INT_TIME swig_types[44] +#define SWIGTYPE_p_PacketAckFunc swig_types[45] +#define SWIGTYPE_p_SSL_CTX swig_types[46] +#define SWIGTYPE_p_StreamStates swig_types[47] +#define SWIGTYPE_p_X509 swig_types[48] +#define SWIGTYPE_p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t swig_types[49] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t swig_types[50] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t swig_types[51] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Packet_t swig_types[52] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Plugin_t swig_types[53] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t swig_types[54] +#define SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Socket_t swig_types[55] +#define SWIGTYPE_p_char swig_types[56] +#define SWIGTYPE_p_charArray swig_types[57] +#define SWIGTYPE_p_count_t swig_types[58] +#define SWIGTYPE_p_f_p_q_const__char_v_______void swig_types[59] +#define SWIGTYPE_p_int swig_types[60] +#define SWIGTYPE_p_long_long swig_types[61] +#define SWIGTYPE_p_off_type swig_types[62] +#define SWIGTYPE_p_p_f_p_q_const__char_v_______void swig_types[63] +#define SWIGTYPE_p_pos_type swig_types[64] +#define SWIGTYPE_p_short swig_types[65] +#define SWIGTYPE_p_signed_char swig_types[66] +#define SWIGTYPE_p_std__ios_base__openmode swig_types[67] +#define SWIGTYPE_p_std__ios_base__seekdir swig_types[68] +#define SWIGTYPE_p_std__istream swig_types[69] +#define SWIGTYPE_p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t swig_types[70] +#define SWIGTYPE_p_std__ostream swig_types[71] +#define SWIGTYPE_p_std__streambuf swig_types[72] +#define SWIGTYPE_p_std__streambuf__off_type swig_types[73] +#define SWIGTYPE_p_std__streambuf__pos_type swig_types[74] +#define SWIGTYPE_p_std__streampos swig_types[75] +#define SWIGTYPE_p_std__streamsize swig_types[76] +#define SWIGTYPE_p_std__string swig_types[77] +#define SWIGTYPE_p_std__vectorT_char_t swig_types[78] +#define SWIGTYPE_p_timeval swig_types[79] +#define SWIGTYPE_p_uint swig_types[80] +#define SWIGTYPE_p_unsigned_char swig_types[81] +#define SWIGTYPE_p_unsigned_int swig_types[82] +#define SWIGTYPE_p_unsigned_long_long swig_types[83] +#define SWIGTYPE_p_unsigned_short swig_types[84] +static swig_type_info *swig_types[86]; +static swig_module_info swig_module = {swig_types, 85, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# error "This python version requires swig to be run with the '-classic' option" +# endif +#endif + +/*----------------------------------------------- + @(target):= _CAPS.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__CAPS + +#else +# define SWIG_init init_CAPS + +#endif +#define SWIG_name "_CAPS" + +#define SWIGVERSION 0x030012 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include + + +namespace swig { + class SwigPtr_PyObject { + protected: + PyObject *_obj; + + public: + SwigPtr_PyObject() :_obj(0) + { + } + + SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_XINCREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; + } + + SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) + { + if (initial_ref) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_XINCREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_XINCREF(item._obj); + Py_XDECREF(_obj); + _obj = item._obj; + SWIG_PYTHON_THREAD_END_BLOCK; + return *this; + } + + ~SwigPtr_PyObject() + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_XDECREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; + } + + operator PyObject *() const + { + return _obj; + } + + PyObject *operator->() const + { + return _obj; + } + }; +} + + +namespace swig { + struct SwigVar_PyObject : SwigPtr_PyObject { + SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } + + SwigVar_PyObject & operator = (PyObject* obj) + { + Py_XDECREF(_obj); + _obj = obj; + return *this; + } + }; +} + + +#include // Use the C99 official header + + +#define SWIG_FILE_WITH_INIT +#include +#include +#include +#include +#include +#include +#include +typedef Gempa::CAPS::Plugin::Buffer Buffer; +#include +#include +#include +#include +#include +#include + + + +#include + + +#ifndef SWIG_FILE_WITH_INIT +#define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include + + +#include + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; +#endif + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else +#endif + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_bool (bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} + + + #define SWIG_From_long PyInt_FromLong + + + #define SWIG_From_double PyFloat_FromDouble + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if(alloc) *alloc = SWIG_NEWOBJ; +#endif + PyBytes_AsStringAndSize(obj, &cstr, &len); +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { + *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return SWIG_OK; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); +#else +#if PY_VERSION_HEX >= 0x03010000 + return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape"); +#else + return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); +#endif +#endif +#else + return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_std_string (const std::string& s) +{ + return SWIG_FromCharPtrAndSize(s.data(), s.size()); +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + +SWIGINTERN int +SWIG_AsCharArray(PyObject * obj, char *val, size_t size) +{ + char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; + int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); + if (SWIG_IsOK(res)) { + /* special case of single char conversion when we don't need space for NUL */ + if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize; + if (csize <= size) { + if (val) { + if (csize) memcpy(val, cptr, csize*sizeof(char)); + if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char)); + } + if (alloc == SWIG_NEWOBJ) { + delete[] cptr; + res = SWIG_DelNewMask(res); + } + return res; + } + if (alloc == SWIG_NEWOBJ) delete[] cptr; + } + return SWIG_TypeError; +} + + +SWIGINTERN size_t +SWIG_strnlen(const char* s, size_t maxlen) +{ + const char *p; + for (p = s; maxlen-- && *p; p++) + ; + return p - s; +} + + +SWIGINTERN int +SWIG_AsVal_short (PyObject * obj, short *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < SHRT_MIN || v > SHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< short >(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_short (short value) +{ + return SWIG_From_long (value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else +#endif + if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > USHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< unsigned short >(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value)); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_short (unsigned short value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UCHAR_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< unsigned char >(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_char (unsigned char value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERN int +SWIG_AsVal_char (PyObject * obj, char *val) +{ + int res = SWIG_AsCharArray(obj, val, 1); + if (!SWIG_IsOK(res)) { + long v; + res = SWIG_AddCast(SWIG_AsVal_long (obj, &v)); + if (SWIG_IsOK(res)) { + if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { + if (val) *val = static_cast< char >(v); + } else { + res = SWIG_OverflowError; + } + } + } + return res; +} + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(static_cast< long >(value)); +} +#endif + + +SWIGINTERNINLINE PyObject * +SWIG_From_size_t (size_t value) +{ +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value)); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(size_t) <= sizeof(unsigned long long) */ + return SWIG_From_unsigned_SS_long_SS_long (static_cast< unsigned long long >(value)); + } +#endif +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< unsigned int >(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_unsigned_SS_int (unsigned int value) +{ + return PyInt_FromSize_t((size_t) value); +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +SWIGINTERN int +SWIG_AsVal_bool (PyObject *obj, bool *val) +{ + int r; + if (!PyBool_Check(obj)) + return SWIG_ERROR; + r = PyObject_IsTrue(obj); + if (r == -1) + return SWIG_ERROR; + if (val) *val = r ? true : false; + return SWIG_OK; +} + + +SWIGINTERN int +SWIG_AsPtr_std_string (PyObject * obj, std::string **val) +{ + char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ; + if (SWIG_IsOK((SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc)))) { + if (buf) { + if (val) *val = new std::string(buf, size - 1); + if (alloc == SWIG_NEWOBJ) delete[] buf; + return SWIG_NEWOBJ; + } else { + if (val) *val = 0; + return SWIG_OLDOBJ; + } + } else { + static int init = 0; + static swig_type_info* descriptor = 0; + if (!init) { + descriptor = SWIG_TypeQuery("std::string" " *"); + init = 1; + } + if (descriptor) { + std::string *vptr; + int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0); + if (SWIG_IsOK(res) && val) *val = vptr; + return res; + } + } + return SWIG_ERROR; +} + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_long_SS_long (PyObject *obj, long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + long long v = PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + long v; + res = SWIG_AsVal_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE PyObject* +SWIG_From_long_SS_long (long long value) +{ + return ((value < LONG_MIN) || (value > LONG_MAX)) ? + PyLong_FromLongLong(value) : PyInt_FromLong(static_cast< long >(value)); +} +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v); + } +#endif + return res; +} + +SWIGINTERN Gempa::CAPS::Plugin::Status Gempa_CAPS_Plugin_push__SWIG_6(Gempa::CAPS::Plugin *self,std::string const &net,std::string const &sta,std::string const &loc,std::string const &cha,Gempa::CAPS::Time const &stime,int16_t numerator,int16_t denominator,std::string const &uom,PyObject *obj,int type){ + PyArrayObject *arr = NULL; + Gempa::CAPS::DataType dataType = (Gempa::CAPS::DataType)type; + Gempa::CAPS::Plugin::Status status = Gempa::CAPS::Plugin::PacketLoss; + switch(type) { + case Gempa::CAPS::DT_INT8: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_CHAR, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int8_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_INT16: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT16, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int16_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_INT32: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT32, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (int32_t*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_FLOAT: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT32, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (float*)(arr->data), arr->dimensions[0], dataType); + break; + case Gempa::CAPS::DT_DOUBLE: + arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT64, 1, 1); + if ( arr == NULL ) + break; + + status = self->push(net, sta, loc, cha, stime, numerator, denominator, + uom, (double*)(arr->data), arr->dimensions[0], dataType); + break; + default: + break; + } + + Py_XDECREF(arr); + return status; + } +SWIGINTERN Gempa::CAPS::Plugin::Status Gempa_CAPS_Plugin_push__SWIG_7(Gempa::CAPS::Plugin *self,std::string const &net,std::string const &sta,std::string const &loc,std::string const &cha,Gempa::CAPS::Time const &stime,uint16_t numerator,uint16_t denominator,std::string const &format,PyObject *obj){ + char *data; + Py_ssize_t len; + if ( PyBytes_AsStringAndSize(obj, &data, &len) == -1 ) + return Gempa::CAPS::Plugin::PacketLoss; + + return self->push(net, sta, loc, cha, stime, numerator, + denominator, format, data, len); + } + +typedef char charArray; + +SWIGINTERN charArray *new_charArray(size_t nelements){ + return (new char[nelements]()); + } +SWIGINTERN void delete_charArray(charArray *self){ + delete[] self; + } +SWIGINTERN char charArray___getitem__(charArray *self,size_t index){ + return self[index]; + } + +SWIGINTERNINLINE PyObject * +SWIG_From_char (char c) +{ + return SWIG_FromCharPtrAndSize(&c,1); +} + +SWIGINTERN void charArray___setitem__(charArray *self,size_t index,char value){ + self[index] = value; + } +SWIGINTERN char *charArray_cast(charArray *self){ + return self; + } +SWIGINTERN charArray *charArray_frompointer(char *t){ + return static_cast< charArray * >(t); + } +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_TimeSpan")) SWIG_fail; + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + timeval *arg1 = (timeval *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_TimeSpan",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_timeval, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TimeSpan" "', argument " "1"" of type '" "timeval *""'"); + } + arg1 = reinterpret_cast< timeval * >(argp1); + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + timeval *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_TimeSpan",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_timeval, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TimeSpan" "', argument " "1"" of type '" "timeval const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_TimeSpan" "', argument " "1"" of type '" "timeval const &""'"); + } + arg1 = reinterpret_cast< timeval * >(argp1); + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan((timeval const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double arg1 ; + double val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_TimeSpan",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_double(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_TimeSpan" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long arg1 ; + long arg2 ; + long val1 ; + int ecode1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_TimeSpan",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_TimeSpan" "', argument " "1"" of type '" "long""'"); + } + arg1 = static_cast< long >(val1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_TimeSpan" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_TimeSpan",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TimeSpan" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_TimeSpan" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = (Gempa::CAPS::TimeSpan *)new Gempa::CAPS::TimeSpan((Gempa::CAPS::TimeSpan const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeSpan(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_TimeSpan__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_timeval, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_TimeSpan__SWIG_1(self, args); + } + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_timeval, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_TimeSpan__SWIG_2(self, args); + } + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_TimeSpan__SWIG_5(self, args); + } + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_TimeSpan__SWIG_3(self, args); + } + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_TimeSpan__SWIG_4(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_TimeSpan'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::TimeSpan::TimeSpan()\n" + " Gempa::CAPS::TimeSpan::TimeSpan(timeval *)\n" + " Gempa::CAPS::TimeSpan::TimeSpan(timeval const &)\n" + " Gempa::CAPS::TimeSpan::TimeSpan(double)\n" + " Gempa::CAPS::TimeSpan::TimeSpan(long,long)\n" + " Gempa::CAPS::TimeSpan::TimeSpan(Gempa::CAPS::TimeSpan const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___eq__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___eq__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___eq__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___eq__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator ==((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___ne__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___ne__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___ne__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___ne__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator !=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___lt__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___lt__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___lt__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___lt__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___lt__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator <((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___le__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___le__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___le__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___le__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___le__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator <=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___gt__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___gt__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___gt__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___gt__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___gt__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator >((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___ge__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___ge__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___ge__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___ge__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___ge__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (bool)((Gempa::CAPS::TimeSpan const *)arg1)->operator >=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___add__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___add__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___add__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___add__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = ((Gempa::CAPS::TimeSpan const *)arg1)->operator +((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::TimeSpan(static_cast< const Gempa::CAPS::TimeSpan& >(result))), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___sub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan result; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___sub__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___sub__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___sub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___sub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = ((Gempa::CAPS::TimeSpan const *)arg1)->operator -((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::TimeSpan(static_cast< const Gempa::CAPS::TimeSpan& >(result))), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___iadd__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___iadd__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___iadd__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___iadd__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (Gempa::CAPS::TimeSpan *) &(arg1)->operator +=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan___isub__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan___isub__" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan___isub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TimeSpan___isub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (Gempa::CAPS::TimeSpan *) &(arg1)->operator -=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_abs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::TimeSpan result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeSpan_abs",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_abs" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = ((Gempa::CAPS::TimeSpan const *)arg1)->abs(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::TimeSpan(static_cast< const Gempa::CAPS::TimeSpan& >(result))), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_seconds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + long result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeSpan_seconds",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_seconds" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = (long)((Gempa::CAPS::TimeSpan const *)arg1)->seconds(); + resultobj = SWIG_From_long(static_cast< long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_microseconds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + long result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeSpan_microseconds",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_microseconds" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = (long)((Gempa::CAPS::TimeSpan const *)arg1)->microseconds(); + resultobj = SWIG_From_long(static_cast< long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_length(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + double result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeSpan_length",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_length" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = (double)((Gempa::CAPS::TimeSpan const *)arg1)->length(); + resultobj = SWIG_From_double(static_cast< double >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeSpan_set" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + result = (Gempa::CAPS::TimeSpan *) &(arg1)->set(arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_setUSecs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan_setUSecs",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_setUSecs" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeSpan_setUSecs" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + result = (Gempa::CAPS::TimeSpan *) &(arg1)->setUSecs(arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_elapsedTime__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:TimeSpan_elapsedTime",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_elapsedTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan_elapsedTime" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TimeSpan_elapsedTime" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "TimeSpan_elapsedTime" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "TimeSpan_elapsedTime" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + ((Gempa::CAPS::TimeSpan const *)arg1)->elapsedTime(arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_elapsedTime__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:TimeSpan_elapsedTime",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_elapsedTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan_elapsedTime" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TimeSpan_elapsedTime" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "TimeSpan_elapsedTime" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + ((Gempa::CAPS::TimeSpan const *)arg1)->elapsedTime(arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_elapsedTime__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:TimeSpan_elapsedTime",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_elapsedTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan_elapsedTime" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TimeSpan_elapsedTime" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + ((Gempa::CAPS::TimeSpan const *)arg1)->elapsedTime(arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_elapsedTime__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeSpan_elapsedTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeSpan_elapsedTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TimeSpan_elapsedTime" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + ((Gempa::CAPS::TimeSpan const *)arg1)->elapsedTime(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeSpan_elapsedTime(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[6] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 5) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_TimeSpan_elapsedTime__SWIG_3(self, args); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_TimeSpan_elapsedTime__SWIG_2(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_TimeSpan_elapsedTime__SWIG_1(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_TimeSpan_elapsedTime__SWIG_0(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'TimeSpan_elapsedTime'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::TimeSpan::elapsedTime(int *,int *,int *,int *) const\n" + " Gempa::CAPS::TimeSpan::elapsedTime(int *,int *,int *) const\n" + " Gempa::CAPS::TimeSpan::elapsedTime(int *,int *) const\n" + " Gempa::CAPS::TimeSpan::elapsedTime(int *) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_TimeSpan(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = (Gempa::CAPS::TimeSpan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_TimeSpan",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_TimeSpan" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *TimeSpan_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN int Swig_var_Time_Null_set(PyObject *) { + SWIG_Error(SWIG_AttributeError,"Variable Time_Null is read-only."); + return 1; +} + + +SWIGINTERN PyObject *Swig_var_Time_Null_get(void) { + PyObject *pyobj = 0; + + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&Gempa::CAPS::Time::Null), SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Time")) SWIG_fail; + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + long arg1 ; + long arg2 ; + long val1 ; + int ecode1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_Time",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "long""'"); + } + arg1 = static_cast< long >(val1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeSpan *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Time",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Time" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Time" "', argument " "1"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp1); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time((Gempa::CAPS::TimeSpan const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + timeval *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Time",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_timeval, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Time" "', argument " "1"" of type '" "timeval const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Time" "', argument " "1"" of type '" "timeval const &""'"); + } + arg1 = reinterpret_cast< timeval * >(argp1); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time((timeval const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + timeval *arg1 = (timeval *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Time",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_timeval, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Time" "', argument " "1"" of type '" "timeval *""'"); + } + arg1 = reinterpret_cast< timeval * >(argp1); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + double arg1 ; + double val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Time",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_double(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:new_Time",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Time" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Time" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Time" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "new_Time" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "new_Time" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:new_Time",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Time" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Time" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Time" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "new_Time" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:new_Time",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Time" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Time" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Time" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_9(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:new_Time",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Time" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Time" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2,arg3,arg4); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_10(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_Time",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Time" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Time" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time(arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time__SWIG_11(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Time",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Time" "', argument " "1"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Time" "', argument " "1"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = (Gempa::CAPS::Time *)new Gempa::CAPS::Time((Gempa::CAPS::Time const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Time(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[8] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 7) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_Time__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Time__SWIG_11(self, args); + } + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_timeval, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Time__SWIG_3(self, args); + } + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_timeval, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Time__SWIG_4(self, args); + } + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Time__SWIG_2(self, args); + } + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_5(self, args); + } + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_long(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_long(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_1(self, args); + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_10(self, args); + } + } + } + } + if (argc == 4) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_9(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_8(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_7(self, args); + } + } + } + } + } + } + } + if (argc == 7) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[4], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_Time__SWIG_6(self, args); + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_Time'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Time::Time()\n" + " Gempa::CAPS::Time::Time(long,long)\n" + " Gempa::CAPS::Time::Time(Gempa::CAPS::TimeSpan const &)\n" + " Gempa::CAPS::Time::Time(timeval const &)\n" + " Gempa::CAPS::Time::Time(timeval *)\n" + " Gempa::CAPS::Time::Time(double)\n" + " Gempa::CAPS::Time::Time(int,int,int,int,int,int,int)\n" + " Gempa::CAPS::Time::Time(int,int,int,int,int,int)\n" + " Gempa::CAPS::Time::Time(int,int,int,int,int)\n" + " Gempa::CAPS::Time::Time(int,int,int,int)\n" + " Gempa::CAPS::Time::Time(int,int,int)\n" + " Gempa::CAPS::Time::Time(Gempa::CAPS::Time const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Time___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Time___nonzero__",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___nonzero__" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = (bool)((Gempa::CAPS::Time const *)arg1)->operator bool(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time___add__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___add__" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time___add__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Time___add__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = ((Gempa::CAPS::Time const *)arg1)->operator +((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time___sub__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___sub__" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time___sub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Time___sub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = ((Gempa::CAPS::Time const *)arg1)->operator -((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time___sub__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___sub__" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time___sub__" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Time___sub__" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + result = ((Gempa::CAPS::Time const *)arg1)->operator -((Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::TimeSpan(static_cast< const Gempa::CAPS::TimeSpan& >(result))), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time___sub__(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time___sub____SWIG_1(self, args); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time___sub____SWIG_0(self, args); + } + } + } + +fail: + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; +} + + +SWIGINTERN PyObject *_wrap_Time___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time___iadd__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___iadd__" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time___iadd__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Time___iadd__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (Gempa::CAPS::Time *) &(arg1)->operator +=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time___isub__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time___isub__" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time___isub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Time___isub__" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (Gempa::CAPS::Time *) &(arg1)->operator -=((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:Time_set",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_set" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Time_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Time_set" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Time_set" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Time_set" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Time_set" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Time_set" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Time_set" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Time *) &(arg1)->set(arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int *arg6 = (int *) 0 ; + int *arg7 = (int *) 0 ; + int *arg8 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + void *argp7 = 0 ; + int res7 = 0 ; + void *argp8 = 0 ; + int res8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:Time_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Time_get" "', argument " "6"" of type '" "int *""'"); + } + arg6 = reinterpret_cast< int * >(argp6); + res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "Time_get" "', argument " "7"" of type '" "int *""'"); + } + arg7 = reinterpret_cast< int * >(argp7); + res8 = SWIG_ConvertPtr(obj7, &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "Time_get" "', argument " "8"" of type '" "int *""'"); + } + arg8 = reinterpret_cast< int * >(argp8); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int *arg6 = (int *) 0 ; + int *arg7 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + void *argp7 = 0 ; + int res7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:Time_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Time_get" "', argument " "6"" of type '" "int *""'"); + } + arg6 = reinterpret_cast< int * >(argp6); + res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "Time_get" "', argument " "7"" of type '" "int *""'"); + } + arg7 = reinterpret_cast< int * >(argp7); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int *arg6 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:Time_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Time_get" "', argument " "6"" of type '" "int *""'"); + } + arg6 = reinterpret_cast< int * >(argp6); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:Time_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3,arg4,arg5); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:Time_get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3,arg4); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Time_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[9] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 8) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_6(self, args); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_5(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_4(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 7) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[6], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_1(self, args); + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[6], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[7], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get__SWIG_0(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'Time_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Time::get(int *,int *,int *,int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get(int *,int *,int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get(int *,int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get(int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get(int *,int *,int *) const\n" + " Gempa::CAPS::Time::get(int *,int *) const\n" + " Gempa::CAPS::Time::get(int *) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int *arg6 = (int *) 0 ; + int *arg7 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + void *argp7 = 0 ; + int res7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:Time_get2",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get2" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get2" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get2" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Time_get2" "', argument " "6"" of type '" "int *""'"); + } + arg6 = reinterpret_cast< int * >(argp6); + res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "Time_get2" "', argument " "7"" of type '" "int *""'"); + } + arg7 = reinterpret_cast< int * >(argp7); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int *arg6 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:Time_get2",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get2" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get2" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get2" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Time_get2" "', argument " "6"" of type '" "int *""'"); + } + arg6 = reinterpret_cast< int * >(argp6); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:Time_get2",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get2" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get2" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Time_get2" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast< int * >(argp5); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2,arg3,arg4,arg5); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:Time_get2",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get2" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Time_get2" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2,arg3,arg4); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Time_get2",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_get2" "', argument " "3"" of type '" "int *""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time_get2",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_get2" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_get2" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + result = (bool)((Gempa::CAPS::Time const *)arg1)->get2(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_get2(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[8] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 7) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_5(self, args); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_4(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_3(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 7) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[6], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Time_get2__SWIG_0(self, args); + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'Time_get2'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Time::get2(int *,int *,int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get2(int *,int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get2(int *,int *,int *,int *) const\n" + " Gempa::CAPS::Time::get2(int *,int *,int *) const\n" + " Gempa::CAPS::Time::get2(int *,int *) const\n" + " Gempa::CAPS::Time::get2(int *) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Time_LocalTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)":Time_LocalTime")) SWIG_fail; + result = Gempa::CAPS::Time::LocalTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_GMT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)":Time_GMT")) SWIG_fail; + result = Gempa::CAPS::Time::GMT(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_FromYearDay(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time_FromYearDay",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "Time_FromYearDay" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Time_FromYearDay" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = Gempa::CAPS::Time::FromYearDay(arg1,arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_localtime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_localtime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_localtime" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = (Gempa::CAPS::Time *) &(arg1)->localtime(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_gmt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_gmt",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_gmt" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = (Gempa::CAPS::Time *) &(arg1)->gmt(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_toLocalTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_toLocalTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_toLocalTime" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = ((Gempa::CAPS::Time const *)arg1)->toLocalTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_toGMT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_toGMT",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_toGMT" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = ((Gempa::CAPS::Time const *)arg1)->toGMT(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_valid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_valid",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_valid" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = (bool)((Gempa::CAPS::Time const *)arg1)->valid(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_toString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time_toString",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_toString" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_toString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = ((Gempa::CAPS::Time const *)arg1)->toString((char const *)arg2); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_iso(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"O:Time_iso",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_iso" "', argument " "1"" of type '" "Gempa::CAPS::Time const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + result = ((Gempa::CAPS::Time const *)arg1)->iso(); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_fromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Time_fromString",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_fromString" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_fromString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Time_fromString" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + result = (bool)(arg1)->fromString((char const *)arg2,(char const *)arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Time_FromString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Time_FromString",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Time_FromString" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Time_FromString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = Gempa::CAPS::Time::FromString((char const *)arg1,(char const *)arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Time(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Time *arg1 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Time",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Time" "', argument " "1"" of type '" "Gempa::CAPS::Time *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Time * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Time_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Time, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_UOM_str_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *arg1 = (Gempa::CAPS::UOM *) 0 ; + char *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + char temp2[4] ; + int res2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:UOM_str_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "UOM_str_set" "', argument " "1"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::UOM * >(argp1); + res2 = SWIG_AsCharArray(obj1, temp2, 4); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "UOM_str_set" "', argument " "2"" of type '" "char [4]""'"); + } + arg2 = reinterpret_cast< char * >(temp2); + if (arg2) memcpy(arg1->str,arg2,4*sizeof(char)); + else memset(arg1->str,0,4*sizeof(char)); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_UOM_str_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *arg1 = (Gempa::CAPS::UOM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:UOM_str_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "UOM_str_get" "', argument " "1"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::UOM * >(argp1); + result = (char *)(char *) ((arg1)->str); + { + size_t size = SWIG_strnlen(result, 4); + + + + resultobj = SWIG_FromCharPtrAndSize(result, size); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_UOM_ID_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *arg1 = (Gempa::CAPS::UOM *) 0 ; + int32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:UOM_ID_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "UOM_ID_set" "', argument " "1"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::UOM * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "UOM_ID_set" "', argument " "2"" of type '" "int32_t""'"); + } + arg2 = static_cast< int32_t >(val2); + if (arg1) (arg1)->ID = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_UOM_ID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *arg1 = (Gempa::CAPS::UOM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:UOM_ID_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "UOM_ID_get" "', argument " "1"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::UOM * >(argp1); + result = (int32_t) ((arg1)->ID); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_UOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_UOM")) SWIG_fail; + result = (Gempa::CAPS::UOM *)new Gempa::CAPS::UOM(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__UOM, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_UOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::UOM *arg1 = (Gempa::CAPS::UOM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_UOM",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__UOM, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_UOM" "', argument " "1"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::UOM * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *UOM_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__UOM, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_Quality_str_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *arg1 = (Gempa::CAPS::Quality *) 0 ; + char *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + char temp2[4] ; + int res2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Quality_str_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Quality_str_set" "', argument " "1"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Quality * >(argp1); + res2 = SWIG_AsCharArray(obj1, temp2, 4); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Quality_str_set" "', argument " "2"" of type '" "char [4]""'"); + } + arg2 = reinterpret_cast< char * >(temp2); + if (arg2) memcpy(arg1->str,arg2,4*sizeof(char)); + else memset(arg1->str,0,4*sizeof(char)); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Quality_str_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *arg1 = (Gempa::CAPS::Quality *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Quality_str_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Quality_str_get" "', argument " "1"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Quality * >(argp1); + result = (char *)(char *) ((arg1)->str); + { + size_t size = SWIG_strnlen(result, 4); + + + + resultobj = SWIG_FromCharPtrAndSize(result, size); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Quality_ID_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *arg1 = (Gempa::CAPS::Quality *) 0 ; + int32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Quality_ID_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Quality_ID_set" "', argument " "1"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Quality * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Quality_ID_set" "', argument " "2"" of type '" "int32_t""'"); + } + arg2 = static_cast< int32_t >(val2); + if (arg1) (arg1)->ID = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Quality_ID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *arg1 = (Gempa::CAPS::Quality *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Quality_ID_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Quality_ID_get" "', argument " "1"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Quality * >(argp1); + result = (int32_t) ((arg1)->ID); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Quality(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Quality")) SWIG_fail; + result = (Gempa::CAPS::Quality *)new Gempa::CAPS::Quality(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Quality, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Quality(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Quality *arg1 = (Gempa::CAPS::Quality *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Quality",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Quality, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Quality" "', argument " "1"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Quality * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Quality_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Quality, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_TimeStamp_year_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + int16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_year_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_year_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_year_set" "', argument " "2"" of type '" "int16_t""'"); + } + arg2 = static_cast< int16_t >(val2); + if (arg1) (arg1)->year = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_year_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_year_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_year_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (int16_t) ((arg1)->year); + resultobj = SWIG_From_short(static_cast< short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_yday_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_yday_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_yday_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_yday_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->yday = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_yday_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_yday_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_yday_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (uint16_t) ((arg1)->yday); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_hour_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + uint8_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_hour_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_hour_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_hour_set" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = static_cast< uint8_t >(val2); + if (arg1) (arg1)->hour = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_hour_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_hour_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_hour_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (uint8_t) ((arg1)->hour); + resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_minute_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + uint8_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_minute_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_minute_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_minute_set" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = static_cast< uint8_t >(val2); + if (arg1) (arg1)->minute = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_minute_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_minute_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_minute_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (uint8_t) ((arg1)->minute); + resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_second_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + uint8_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_second_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_second_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_second_set" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = static_cast< uint8_t >(val2); + if (arg1) (arg1)->second = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_second_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_second_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_second_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (uint8_t) ((arg1)->second); + resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_unused_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + uint8_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_unused_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_unused_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_unused_set" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = static_cast< uint8_t >(val2); + if (arg1) (arg1)->unused = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_unused_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_unused_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_unused_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (uint8_t) ((arg1)->unused); + resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_usec_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + int32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:TimeStamp_usec_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_usec_set" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TimeStamp_usec_set" "', argument " "2"" of type '" "int32_t""'"); + } + arg2 = static_cast< int32_t >(val2); + if (arg1) (arg1)->usec = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_TimeStamp_usec_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:TimeStamp_usec_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TimeStamp_usec_get" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = (int32_t) ((arg1)->usec); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_TimeStamp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_TimeStamp")) SWIG_fail; + result = (Gempa::CAPS::TimeStamp *)new Gempa::CAPS::TimeStamp(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__TimeStamp, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_TimeStamp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = (Gempa::CAPS::TimeStamp *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_TimeStamp",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__TimeStamp, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_TimeStamp" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *TimeStamp_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__TimeStamp, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_PacketDataHeader__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_PacketDataHeader")) SWIG_fail; + result = (Gempa::CAPS::PacketDataHeader *)new Gempa::CAPS::PacketDataHeader(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_PacketDataHeader__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint16_t arg1 ; + unsigned short val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketDataHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_PacketDataHeader",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_short(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_PacketDataHeader" "', argument " "1"" of type '" "uint16_t""'"); + } + arg1 = static_cast< uint16_t >(val1); + result = (Gempa::CAPS::PacketDataHeader *)new Gempa::CAPS::PacketDataHeader(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_PacketDataHeader(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_PacketDataHeader__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_unsigned_SS_short(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_PacketDataHeader__SWIG_1(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_PacketDataHeader'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::PacketDataHeader::PacketDataHeader()\n" + " Gempa::CAPS::PacketDataHeader::PacketDataHeader(uint16_t)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_version_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_version_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_version_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketDataHeader_version_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->version = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_version_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeader_version_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_version_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + result = (uint16_t) ((arg1)->version); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_packetType_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + Gempa::CAPS::PacketType arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_packetType_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_packetType_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketDataHeader_packetType_set" "', argument " "2"" of type '" "Gempa::CAPS::PacketType""'"); + } + arg2 = static_cast< Gempa::CAPS::PacketType >(val2); + if (arg1) (arg1)->packetType = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_packetType_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeader_packetType_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_packetType_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + result = (Gempa::CAPS::PacketType) ((arg1)->packetType); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_unitOfMeasurement_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + Gempa::CAPS::UOM *arg2 = (Gempa::CAPS::UOM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_unitOfMeasurement_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_unitOfMeasurement_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeader_unitOfMeasurement_set" "', argument " "2"" of type '" "Gempa::CAPS::UOM *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::UOM * >(argp2); + if (arg1) (arg1)->unitOfMeasurement = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_unitOfMeasurement_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::UOM *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeader_unitOfMeasurement_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_unitOfMeasurement_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + result = (Gempa::CAPS::UOM *)& ((arg1)->unitOfMeasurement); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__UOM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_setUOM(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_setUOM",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_setUOM" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeader_setUOM" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)(arg1)->setUOM((char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_uom__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + char arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_uom",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_uom" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + ecode2 = SWIG_AsVal_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketDataHeader_uom" "', argument " "2"" of type '" "char""'"); + } + arg2 = static_cast< char >(val2); + result = ((Gempa::CAPS::PacketDataHeader const *)arg1)->uom(arg2); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_uom__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeader_uom",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_uom" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + result = ((Gempa::CAPS::PacketDataHeader const *)arg1)->uom(); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_uom(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_PacketDataHeader_uom__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_char(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_PacketDataHeader_uom__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'PacketDataHeader_uom'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::PacketDataHeader::uom(char) const\n" + " Gempa::CAPS::PacketDataHeader::uom() const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + Gempa::CAPS::PacketDataHeader *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader___ne__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader___ne__" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeader___ne__" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeader const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeader___ne__" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeader const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp2); + result = (bool)((Gempa::CAPS::PacketDataHeader const *)arg1)->operator !=((Gempa::CAPS::PacketDataHeader const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeader_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + result = (int)((Gempa::CAPS::PacketDataHeader const *)arg1)->dataSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_put" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeader_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeader_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::PacketDataHeader const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeader_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->get(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_PacketDataHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeader *arg1 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_PacketDataHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PacketDataHeader" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *PacketDataHeader_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_PacketDataHeaderV2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_PacketDataHeaderV2")) SWIG_fail; + result = (Gempa::CAPS::PacketDataHeaderV2 *)new Gempa::CAPS::PacketDataHeaderV2(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_samplingFrequencyNumerator_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2_samplingFrequencyNumerator_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_samplingFrequencyNumerator_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketDataHeaderV2_samplingFrequencyNumerator_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->samplingFrequencyNumerator = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_samplingFrequencyNumerator_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeaderV2_samplingFrequencyNumerator_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_samplingFrequencyNumerator_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + result = (uint16_t) ((arg1)->samplingFrequencyNumerator); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_samplingFrequencyDenominator_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2_samplingFrequencyDenominator_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_samplingFrequencyDenominator_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketDataHeaderV2_samplingFrequencyDenominator_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->samplingFrequencyDenominator = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_samplingFrequencyDenominator_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeaderV2_samplingFrequencyDenominator_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_samplingFrequencyDenominator_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + result = (uint16_t) ((arg1)->samplingFrequencyDenominator); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_quality_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + Gempa::CAPS::Quality *arg2 = (Gempa::CAPS::Quality *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2_quality_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_quality_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeaderV2_quality_set" "', argument " "2"" of type '" "Gempa::CAPS::Quality *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Quality * >(argp2); + if (arg1) (arg1)->quality = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_quality_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Quality *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeaderV2_quality_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_quality_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + result = (Gempa::CAPS::Quality *)& ((arg1)->quality); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Quality, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + Gempa::CAPS::PacketDataHeaderV2 *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2___ne__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2___ne__" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeaderV2___ne__" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeaderV2 const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeaderV2___ne__" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeaderV2 const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp2); + result = (bool)((Gempa::CAPS::PacketDataHeaderV2 const *)arg1)->operator !=((Gempa::CAPS::PacketDataHeaderV2 const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketDataHeaderV2_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + result = (int)((Gempa::CAPS::PacketDataHeaderV2 const *)arg1)->dataSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_put" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeaderV2_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeaderV2_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::PacketDataHeaderV2 const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketDataHeaderV2_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketDataHeaderV2_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketDataHeaderV2_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketDataHeaderV2_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketDataHeaderV2_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->get(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_PacketDataHeaderV2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketDataHeaderV2 *arg1 = (Gempa::CAPS::PacketDataHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_PacketDataHeaderV2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PacketDataHeaderV2" "', argument " "1"" of type '" "Gempa::CAPS::PacketDataHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketDataHeaderV2 * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *PacketDataHeaderV2_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__PacketDataHeaderV2, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_SIDSize_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + uint8_t *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV1_SIDSize_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_SIDSize_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketHeaderV1_SIDSize_set" "', argument " "2"" of type '" "uint8_t [4]""'"); + } + arg2 = reinterpret_cast< uint8_t * >(argp2); + { + if (arg2) { + size_t ii = 0; + for (; ii < (size_t)4; ++ii) *(uint8_t *)&arg1->SIDSize[ii] = *((uint8_t *)arg2 + ii); + } else { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""SIDSize""' of type '""uint8_t [4]""'"); + } + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_SIDSize_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV1_SIDSize_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_SIDSize_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + result = (uint8_t *)(uint8_t *) ((arg1)->SIDSize); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_size_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV1_size_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_size_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketHeaderV1_size_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->size = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV1_size_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_size_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + result = (uint16_t) ((arg1)->size); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV1_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_put" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketHeaderV1_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketHeaderV1_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV1_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV1_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV1_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + result = ((Gempa::CAPS::PacketHeaderV1 const *)arg1)->dataSize(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_PacketHeaderV1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_PacketHeaderV1")) SWIG_fail; + result = (Gempa::CAPS::PacketHeaderV1 *)new Gempa::CAPS::PacketHeaderV1(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_PacketHeaderV1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV1 *arg1 = (Gempa::CAPS::PacketHeaderV1 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_PacketHeaderV1",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PacketHeaderV1" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV1 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV1 * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *PacketHeaderV1_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__PacketHeaderV1, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_SIDSize_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + uint8_t *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV2_SIDSize_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_SIDSize_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketHeaderV2_SIDSize_set" "', argument " "2"" of type '" "uint8_t [4]""'"); + } + arg2 = reinterpret_cast< uint8_t * >(argp2); + { + if (arg2) { + size_t ii = 0; + for (; ii < (size_t)4; ++ii) *(uint8_t *)&arg1->SIDSize[ii] = *((uint8_t *)arg2 + ii); + } else { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""SIDSize""' of type '""uint8_t [4]""'"); + } + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_SIDSize_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV2_SIDSize_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_SIDSize_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + result = (uint8_t *)(uint8_t *) ((arg1)->SIDSize); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_size_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + uint32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV2_size_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_size_set" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PacketHeaderV2_size_set" "', argument " "2"" of type '" "uint32_t""'"); + } + arg2 = static_cast< uint32_t >(val2); + if (arg1) (arg1)->size = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV2_size_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_size_get" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + result = (uint32_t) ((arg1)->size); + resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:PacketHeaderV2_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_put" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PacketHeaderV2_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PacketHeaderV2_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PacketHeaderV2_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:PacketHeaderV2_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PacketHeaderV2_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + result = ((Gempa::CAPS::PacketHeaderV2 const *)arg1)->dataSize(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_PacketHeaderV2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_PacketHeaderV2")) SWIG_fail; + result = (Gempa::CAPS::PacketHeaderV2 *)new Gempa::CAPS::PacketHeaderV2(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_PacketHeaderV2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::PacketHeaderV2 *arg1 = (Gempa::CAPS::PacketHeaderV2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_PacketHeaderV2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PacketHeaderV2" "', argument " "1"" of type '" "Gempa::CAPS::PacketHeaderV2 *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::PacketHeaderV2 * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *PacketHeaderV2_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__PacketHeaderV2, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_ResponseHeader_id_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + uint16_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ResponseHeader_id_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ResponseHeader_id_set" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ResponseHeader_id_set" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + if (arg1) (arg1)->id = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ResponseHeader_id_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + uint16_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:ResponseHeader_id_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ResponseHeader_id_get" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + result = (uint16_t) ((arg1)->id); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ResponseHeader_size_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + int32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ResponseHeader_size_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ResponseHeader_size_set" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ResponseHeader_size_set" "', argument " "2"" of type '" "int32_t""'"); + } + arg2 = static_cast< int32_t >(val2); + if (arg1) (arg1)->size = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ResponseHeader_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:ResponseHeader_size_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ResponseHeader_size_get" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + result = (int32_t) ((arg1)->size); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ResponseHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ResponseHeader_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ResponseHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ResponseHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ResponseHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->get(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ResponseHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_ResponseHeader")) SWIG_fail; + result = (Gempa::CAPS::ResponseHeader *)new Gempa::CAPS::ResponseHeader(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__ResponseHeader, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ResponseHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::ResponseHeader *arg1 = (Gempa::CAPS::ResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_ResponseHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__ResponseHeader, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ResponseHeader" "', argument " "1"" of type '" "Gempa::CAPS::ResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::ResponseHeader * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ResponseHeader_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__ResponseHeader, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_delete_DataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_DataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DataRecord" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (char *)((Gempa::CAPS::DataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_readMetaData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::DataRecord::Header *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:DataRecord_readMetaData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_readMetaData" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_readMetaData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "DataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "DataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + result = (bool)(arg1)->readMetaData(*arg2,arg3,*arg4,*arg5,*arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (bool)((Gempa::CAPS::DataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (bool)((Gempa::CAPS::DataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:DataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::DataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_dataSize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"OO:DataRecord_dataSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DataRecord_dataSize" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = ((Gempa::CAPS::DataRecord const *)arg1)->dataSize(arg2); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_dataSize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = ((Gempa::CAPS::DataRecord const *)arg1)->dataSize(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_dataSize(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_DataRecord_dataSize__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_bool(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_DataRecord_dataSize__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DataRecord_dataSize'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::DataRecord::dataSize(bool) const\n" + " Gempa::CAPS::DataRecord::dataSize() const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:DataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "DataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:DataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_get__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:DataRecord_get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_get__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:DataRecord_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (arg1)->get(*arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_DataRecord_get__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_DataRecord_get__SWIG_2(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_DataRecord_get__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_DataRecord_get__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DataRecord_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::DataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::DataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::DataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::DataRecord::get(std::streambuf &,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_put__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + bool arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:DataRecord_put",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_bool(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DataRecord_put" "', argument " "3"" of type '" "bool""'"); + } + arg3 = static_cast< bool >(val3); + result = (bool)((Gempa::CAPS::DataRecord const *)arg1)->put(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_put__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:DataRecord_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::DataRecord const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_put(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 3) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_DataRecord_put__SWIG_1(self, args); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_bool(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_DataRecord_put__SWIG_0(self, args); + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DataRecord_put'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::DataRecord::put(std::streambuf &,bool) const\n" + " Gempa::CAPS::DataRecord::put(std::streambuf &) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_header" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)((Gempa::CAPS::DataRecord const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_startTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_startTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_startTime" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = ((Gempa::CAPS::DataRecord const *)arg1)->startTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_endTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_endTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_endTime" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = ((Gempa::CAPS::DataRecord const *)arg1)->endTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::DataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_buffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Buffer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_buffer",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_buffer" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Buffer *)(arg1)->buffer(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_char_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_DataRecord_data(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord *arg1 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Buffer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:DataRecord_data",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataRecord_data" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Buffer *)(arg1)->data(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_char_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *DataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__DataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_RawPacket_header_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + Gempa::CAPS::PacketDataHeader *arg2 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawPacket_header_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_header_set" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawPacket_header_set" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp2); + if (arg1) (arg1)->header = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_header_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketDataHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RawPacket_header_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_header_get" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + result = (Gempa::CAPS::PacketDataHeader *)& ((arg1)->header); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_SID_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + std::string *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawPacket_SID_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_SID_set" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__string, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawPacket_SID_set" "', argument " "2"" of type '" "std::string [4]""'"); + } + arg2 = reinterpret_cast< std::string * >(argp2); + { + if (arg2) { + size_t ii = 0; + for (; ii < (size_t)4; ++ii) *(std::string *)&arg1->SID[ii] = *((std::string *)arg2 + ii); + } else { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""SID""' of type '""std::string [4]""'"); + } + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_SID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RawPacket_SID_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_SID_get" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + result = (std::string *)(std::string *) ((arg1)->SID); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__string, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_data_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + std::vector< char > arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawPacket_data_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_data_set" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_char_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawPacket_data_set" "', argument " "2"" of type '" "std::vector< char >""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawPacket_data_set" "', argument " "2"" of type '" "std::vector< char >""'"); + } else { + std::vector< char > * temp = reinterpret_cast< std::vector< char > * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + if (arg1) (arg1)->data = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_data_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::vector< char > result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawPacket_data_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_data_get" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + result = ((arg1)->data); + resultobj = SWIG_NewPointerObj((new std::vector< char >(static_cast< const std::vector< char >& >(result))), SWIGTYPE_p_std__vectorT_char_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_record_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + Gempa::CAPS::DataRecord *arg2 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawPacket_record_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_record_set" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawPacket_record_set" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp2); + if (arg1) (arg1)->record = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawPacket_record_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RawPacket_record_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawPacket_record_get" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + result = (Gempa::CAPS::DataRecord *) ((arg1)->record); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_RawPacket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_RawPacket")) SWIG_fail; + result = (Gempa::CAPS::RawPacket *)new Gempa::CAPS::RawPacket(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RawPacket, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_RawPacket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawPacket *arg1 = (Gempa::CAPS::RawPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_RawPacket",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawPacket, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_RawPacket" "', argument " "1"" of type '" "Gempa::CAPS::RawPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawPacket * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *RawPacket_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RawPacket, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_MetaPacket_SID_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + std::string *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_SID_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_SID_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__string, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_SID_set" "', argument " "2"" of type '" "std::string [4]""'"); + } + arg2 = reinterpret_cast< std::string * >(argp2); + { + if (arg2) { + size_t ii = 0; + for (; ii < (size_t)4; ++ii) *(std::string *)&arg1->SID[ii] = *((std::string *)arg2 + ii); + } else { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""SID""' of type '""std::string [4]""'"); + } + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_SID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_SID_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_SID_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (std::string *)(std::string *) ((arg1)->SID); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__string, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_packetDataHeader_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::PacketDataHeader *arg2 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_packetDataHeader_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_packetDataHeader_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_packetDataHeader_set" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp2); + if (arg1) (arg1)->packetDataHeader = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_packetDataHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketDataHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_packetDataHeader_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_packetDataHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::PacketDataHeader *)& ((arg1)->packetDataHeader); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_record_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::DataRecord *arg2 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_record_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_record_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_record_set" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp2); + if (arg1) (arg1)->record = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_record_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_record_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_record_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::DataRecord *) ((arg1)->record); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_recordHeader_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::DataRecord::Header *arg2 = (Gempa::CAPS::DataRecord::Header *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_recordHeader_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_recordHeader_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_recordHeader_set" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord::Header *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp2); + if (arg1) (arg1)->recordHeader = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_recordHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_recordHeader_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_recordHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)& ((arg1)->recordHeader); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_startTime_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::Time *arg2 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_startTime_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_startTime_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_startTime_set" "', argument " "2"" of type '" "Gempa::CAPS::Time *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + if (arg1) (arg1)->startTime = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_startTime_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_startTime_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_startTime_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::Time *)& ((arg1)->startTime); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_endTime_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::Time *arg2 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_endTime_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_endTime_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_endTime_set" "', argument " "2"" of type '" "Gempa::CAPS::Time *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + if (arg1) (arg1)->endTime = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_endTime_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_endTime_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_endTime_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::Time *)& ((arg1)->endTime); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_timestamp_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + Gempa::CAPS::Time *arg2 = (Gempa::CAPS::Time *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:MetaPacket_timestamp_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_timestamp_set" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MetaPacket_timestamp_set" "', argument " "2"" of type '" "Gempa::CAPS::Time *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + if (arg1) (arg1)->timestamp = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MetaPacket_timestamp_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MetaPacket_timestamp_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MetaPacket_timestamp_get" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + result = (Gempa::CAPS::Time *)& ((arg1)->timestamp); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_MetaPacket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_MetaPacket")) SWIG_fail; + result = (Gempa::CAPS::MetaPacket *)new Gempa::CAPS::MetaPacket(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__MetaPacket, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_MetaPacket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MetaPacket *arg1 = (Gempa::CAPS::MetaPacket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_MetaPacket",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MetaPacket, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MetaPacket" "', argument " "1"" of type '" "Gempa::CAPS::MetaPacket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MetaPacket * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *MetaPacket_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__MetaPacket, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_Packet__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Packet")) SWIG_fail; + result = (Gempa::CAPS::Packet *)new Gempa::CAPS::Packet(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Packet, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Packet__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecordPtr arg1 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + void *argp1 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::Packet *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:new_Packet",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Packet" "', argument " "1"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Packet" "', argument " "1"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } else { + Gempa::CAPS::DataRecordPtr * temp = reinterpret_cast< Gempa::CAPS::DataRecordPtr * >(argp1); + arg1 = *temp; + if (SWIG_IsNewObj(res1)) delete temp; + } + } + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Packet" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Packet" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Packet" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Packet" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_Packet" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Packet" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "new_Packet" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Packet" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + result = (Gempa::CAPS::Packet *)new Gempa::CAPS::Packet(arg1,(std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Packet, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Packet(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[6] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 5) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_Packet__SWIG_0(self, args); + } + if (argc == 5) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Packet__SWIG_1(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_Packet'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Packet::Packet()\n" + " Gempa::CAPS::Packet::Packet(Gempa::CAPS::DataRecordPtr,std::string const &,std::string const &,std::string const &,std::string const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Packet_clone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Packet *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_clone",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_clone" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (Gempa::CAPS::Packet *)(arg1)->clone(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_buffer_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + Gempa::CAPS::Packet::BufferPtr arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_buffer_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_buffer_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_buffer_set" "', argument " "2"" of type '" "Gempa::CAPS::Packet::BufferPtr""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_buffer_set" "', argument " "2"" of type '" "Gempa::CAPS::Packet::BufferPtr""'"); + } else { + Gempa::CAPS::Packet::BufferPtr * temp = reinterpret_cast< Gempa::CAPS::Packet::BufferPtr * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + if (arg1) (arg1)->buffer = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_buffer_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Packet::BufferPtr result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_buffer_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_buffer_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = ((arg1)->buffer); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Packet::BufferPtr(static_cast< const Gempa::CAPS::Packet::BufferPtr& >(result))), SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_record_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + Gempa::CAPS::DataRecordPtr arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_record_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_record_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_record_set" "', argument " "2"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_record_set" "', argument " "2"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } else { + Gempa::CAPS::DataRecordPtr * temp = reinterpret_cast< Gempa::CAPS::DataRecordPtr * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + if (arg1) (arg1)->record = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_record_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecordPtr result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_record_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_record_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = ((arg1)->record); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecordPtr(static_cast< const Gempa::CAPS::DataRecordPtr& >(result))), SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_networkCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_networkCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_networkCode_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_networkCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_networkCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->networkCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_networkCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_networkCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_networkCode_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->networkCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_stationCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_stationCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_stationCode_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_stationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_stationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->stationCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_stationCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_stationCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_stationCode_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->stationCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_locationCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_locationCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_locationCode_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_locationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_locationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->locationCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_locationCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_locationCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_locationCode_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->locationCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_channelCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_channelCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_channelCode_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_channelCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_channelCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->channelCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_channelCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_channelCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_channelCode_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->channelCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_streamID_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_streamID_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_streamID_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_streamID_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_streamID_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->streamID = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_streamID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_streamID_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_streamID_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->streamID); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_dataType_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + Gempa::CAPS::DataType arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_dataType_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_dataType_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_dataType_set" "', argument " "2"" of type '" "Gempa::CAPS::DataType""'"); + } + arg2 = static_cast< Gempa::CAPS::DataType >(val2); + if (arg1) (arg1)->dataType = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_dataType_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataType result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_dataType_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_dataType_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (Gempa::CAPS::DataType) ((arg1)->dataType); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_dt_us_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + int64_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_dt_us_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_dt_us_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_dt_us_set" "', argument " "2"" of type '" "int64_t""'"); + } + arg2 = static_cast< int64_t >(val2); + if (arg1) (arg1)->dt_us = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_dt_us_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int64_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_dt_us_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_dt_us_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (int64_t) ((arg1)->dt_us); + resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_uom_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_uom_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_uom_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_uom_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Packet_uom_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->uom = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_uom_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_uom_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_uom_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (std::string *) & ((arg1)->uom); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_timingQuality_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Packet_timingQuality_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_timingQuality_set" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_timingQuality_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + if (arg1) (arg1)->timingQuality = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_timingQuality_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_timingQuality_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_timingQuality_get" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = (int) ((arg1)->timingQuality); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Packet_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Packet_size",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_size" "', argument " "1"" of type '" "Gempa::CAPS::Packet const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + result = ((Gempa::CAPS::Packet const *)arg1)->size(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Packet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Packet *arg1 = (Gempa::CAPS::Packet *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Packet",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Packet, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Packet" "', argument " "1"" of type '" "Gempa::CAPS::Packet *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Packet * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Packet_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Packet, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_AnyDataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_AnyDataRecord")) SWIG_fail; + result = (Gempa::CAPS::AnyDataRecord *)new Gempa::CAPS::AnyDataRecord(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_setType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:AnyDataRecord_setType",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_setType" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_setType" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)(arg1)->setType((char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_type",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_type" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (char *)((Gempa::CAPS::AnyDataRecord const *)arg1)->type(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (char *)((Gempa::CAPS::AnyDataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_readMetaData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::DataRecord::Header *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:AnyDataRecord_readMetaData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_readMetaData" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_readMetaData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AnyDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "AnyDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "AnyDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + result = (bool)(arg1)->readMetaData(*arg2,arg3,*arg4,*arg5,*arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_header" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)((Gempa::CAPS::AnyDataRecord const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_startTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_startTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_startTime" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = ((Gempa::CAPS::AnyDataRecord const *)arg1)->startTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_endTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_endTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_endTime" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = ((Gempa::CAPS::AnyDataRecord const *)arg1)->endTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::AnyDataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::AnyDataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:AnyDataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "AnyDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::AnyDataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"OO:AnyDataRecord_dataSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AnyDataRecord_dataSize" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = ((Gempa::CAPS::AnyDataRecord const *)arg1)->dataSize(arg2); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:AnyDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "AnyDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "AnyDataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:AnyDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "AnyDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_get__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:AnyDataRecord_get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_get__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:AnyDataRecord_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (arg1)->get(*arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_AnyDataRecord_get__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_AnyDataRecord_get__SWIG_2(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_AnyDataRecord_get__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_AnyDataRecord_get__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'AnyDataRecord_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::AnyDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::AnyDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::AnyDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::AnyDataRecord::get(std::streambuf &,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + bool arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:AnyDataRecord_put",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_bool(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_put" "', argument " "3"" of type '" "bool""'"); + } + arg3 = static_cast< bool >(val3); + result = (bool)((Gempa::CAPS::AnyDataRecord const *)arg1)->put(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::AnyDataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_setStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:AnyDataRecord_setStartTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_setStartTime" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + (arg1)->setStartTime((Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_setEndTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:AnyDataRecord_setEndTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_setEndTime" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_setEndTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "AnyDataRecord_setEndTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + (arg1)->setEndTime((Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_setSamplingFrequency(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + uint16_t arg2 ; + uint16_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + unsigned short val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:AnyDataRecord_setSamplingFrequency",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_setSamplingFrequency" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AnyDataRecord_setSamplingFrequency" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_setSamplingFrequency" "', argument " "3"" of type '" "uint16_t""'"); + } + arg3 = static_cast< uint16_t >(val3); + (arg1)->setSamplingFrequency(arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_data(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::AnyDataRecord::Buffer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:AnyDataRecord_data",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_data" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + result = (Gempa::CAPS::AnyDataRecord::Buffer *)(arg1)->data(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_char_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AnyDataRecord_setData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + char *arg2 = (char *) 0 ; + size_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + size_t val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:AnyDataRecord_setData",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AnyDataRecord_setData" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AnyDataRecord_setData" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_size_t(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AnyDataRecord_setData" "', argument " "3"" of type '" "size_t""'"); + } + arg3 = static_cast< size_t >(val3); + (arg1)->setData(arg2,arg3); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_AnyDataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::AnyDataRecord *arg1 = (Gempa::CAPS::AnyDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_AnyDataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_AnyDataRecord" "', argument " "1"" of type '" "Gempa::CAPS::AnyDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::AnyDataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *AnyDataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__AnyDataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN int Swig_var_LogHandler_set(PyObject *_val) { + { + Gempa::CAPS::LogOutput *inp = 0; + int res = SWIG_ConvertPtr(_val, SWIG_as_voidptrptr(&inp), SWIGTYPE_p_p_f_p_q_const__char_v_______void, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""Gempa::CAPS::LogHandler""' of type '""Gempa::CAPS::LogOutput [Gempa::CAPS::LL_QUANTITY]""'"); + } else if (inp) { + size_t ii = 0; + for (; ii < (size_t)Gempa::CAPS::LL_QUANTITY; ++ii) *(Gempa::CAPS::LogOutput *)&Gempa::CAPS::LogHandler[ii] = *((Gempa::CAPS::LogOutput *)inp + ii); + } else { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""Gempa::CAPS::LogHandler""' of type '""Gempa::CAPS::LogOutput [Gempa::CAPS::LL_QUANTITY]""'"); + } + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var_LogHandler_get(void) { + PyObject *pyobj = 0; + + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(Gempa::CAPS::LogHandler), SWIGTYPE_p_p_f_p_q_const__char_v_______void, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_SetLogHandler(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::LogLevel arg1 ; + Gempa::CAPS::LogOutput arg2 = (Gempa::CAPS::LogOutput) 0 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SetLogHandler",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SetLogHandler" "', argument " "1"" of type '" "Gempa::CAPS::LogLevel""'"); + } + arg1 = static_cast< Gempa::CAPS::LogLevel >(val1); + { + int res = SWIG_ConvertFunctionPtr(obj1, (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char_v_______void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "SetLogHandler" "', argument " "2"" of type '" "Gempa::CAPS::LogOutput""'"); + } + } + Gempa::CAPS::SetLogHandler(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_freqn_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:SPClock_freqn_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_freqn_get" "', argument " "1"" of type '" "Gempa::CAPS::SPClock *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + result = (int)(int) ((arg1)->freqn); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_freqd_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:SPClock_freqd_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_freqd_get" "', argument " "1"" of type '" "Gempa::CAPS::SPClock *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + result = (int)(int) ((arg1)->freqd); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SPClock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::SPClock *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_SPClock",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_SPClock" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_SPClock" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = (Gempa::CAPS::SPClock *)new Gempa::CAPS::SPClock(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__SPClock, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_sync_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + Gempa::CAPS::SPClock::INT_TIME *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SPClock_sync_time",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_sync_time" "', argument " "1"" of type '" "Gempa::CAPS::SPClock *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SPClock_sync_time" "', argument " "2"" of type '" "Gempa::CAPS::SPClock::INT_TIME const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SPClock_sync_time" "', argument " "2"" of type '" "Gempa::CAPS::SPClock::INT_TIME const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::SPClock::INT_TIME * >(argp2); + (arg1)->sync_time((Gempa::CAPS::SPClock::INT_TIME const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_tick(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SPClock_tick",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_tick" "', argument " "1"" of type '" "Gempa::CAPS::SPClock *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + (arg1)->tick(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_get_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::SPClock::INT_TIME result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SPClock_get_time",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_get_time" "', argument " "1"" of type '" "Gempa::CAPS::SPClock const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SPClock_get_time" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = ((Gempa::CAPS::SPClock const *)arg1)->get_time(arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::SPClock::INT_TIME(static_cast< const Gempa::CAPS::SPClock::INT_TIME& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SPClock_correction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:SPClock_correction",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SPClock_correction" "', argument " "1"" of type '" "Gempa::CAPS::SPClock const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + result = (int)((Gempa::CAPS::SPClock const *)arg1)->correction(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SPClock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SPClock *arg1 = (Gempa::CAPS::SPClock *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SPClock",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SPClock, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SPClock" "', argument " "1"" of type '" "Gempa::CAPS::SPClock *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SPClock * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SPClock_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__SPClock, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_delete_Encoder(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Encoder",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Encoder" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_push(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Encoder_push",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_push" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Encoder_push" "', argument " "2"" of type '" "void *""'"); + } + (arg1)->push(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_flush(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_flush",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_flush" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + (arg1)->flush(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_reset",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_reset" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + (arg1)->reset(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_type",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_type" "', argument " "1"" of type '" "Gempa::CAPS::Encoder const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + result = (int)((Gempa::CAPS::Encoder const *)arg1)->type(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_clk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::SPClock *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_clk",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_clk" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + result = (Gempa::CAPS::SPClock *) &(arg1)->clk(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__SPClock, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_setStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + Gempa::CAPS::SPClock::INT_TIME *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Encoder_setStartTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_setStartTime" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Encoder_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::SPClock::INT_TIME const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Encoder_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::SPClock::INT_TIME const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::SPClock::INT_TIME * >(argp2); + (arg1)->setStartTime((Gempa::CAPS::SPClock::INT_TIME const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_currentTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::SPClock::INT_TIME result; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_currentTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_currentTime" "', argument " "1"" of type '" "Gempa::CAPS::Encoder const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + result = ((Gempa::CAPS::Encoder const *)arg1)->currentTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::SPClock::INT_TIME(static_cast< const Gempa::CAPS::SPClock::INT_TIME& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_timingQuality(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_timingQuality",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_timingQuality" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + result = (int)(arg1)->timingQuality(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_setTimingQuality(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Encoder_setTimingQuality",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_setTimingQuality" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Encoder_setTimingQuality" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + (arg1)->setTimingQuality(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Encoder_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Encoder *arg1 = (Gempa::CAPS::Encoder *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketPtr result; + + if (!PyArg_ParseTuple(args,(char *)"O:Encoder_pop",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Encoder_pop" "', argument " "1"" of type '" "Gempa::CAPS::Encoder *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Encoder * >(argp1); + result = (arg1)->pop(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::PacketPtr(static_cast< const Gempa::CAPS::PacketPtr& >(result))), SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__Packet_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Encoder_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Encoder, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_delete_EncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::EncoderFactory *arg1 = (Gempa::CAPS::EncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_EncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__EncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_EncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::EncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_EncoderFactory_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::EncoderFactory *arg1 = (Gempa::CAPS::EncoderFactory *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Encoder *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:EncoderFactory_create",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EncoderFactory_create" "', argument " "1"" of type '" "Gempa::CAPS::EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::EncoderFactory * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "EncoderFactory_create" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "EncoderFactory_create" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "EncoderFactory_create" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Encoder *)(arg1)->create((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,arg7,arg8); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_EncoderFactory_supportsRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::EncoderFactory *arg1 = (Gempa::CAPS::EncoderFactory *) 0 ; + Gempa::CAPS::DataRecord *arg2 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:EncoderFactory_supportsRecord",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EncoderFactory_supportsRecord" "', argument " "1"" of type '" "Gempa::CAPS::EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::EncoderFactory * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "EncoderFactory_supportsRecord" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp2); + result = (bool)(arg1)->supportsRecord(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_EncoderFactory_errorString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::EncoderFactory *arg1 = (Gempa::CAPS::EncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:EncoderFactory_errorString",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "EncoderFactory_errorString" "', argument " "1"" of type '" "Gempa::CAPS::EncoderFactory const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::EncoderFactory * >(argp1); + result = (std::string *) &((Gempa::CAPS::EncoderFactory const *)arg1)->errorString(); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *EncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__EncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_MSEEDEncoderFactory_setRecordLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDEncoderFactory *arg1 = (Gempa::CAPS::MSEEDEncoderFactory *) 0 ; + uint arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:MSEEDEncoderFactory_setRecordLength",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDEncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDEncoderFactory_setRecordLength" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDEncoderFactory * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_uint, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDEncoderFactory_setRecordLength" "', argument " "2"" of type '" "uint""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDEncoderFactory_setRecordLength" "', argument " "2"" of type '" "uint""'"); + } else { + uint * temp = reinterpret_cast< uint * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + result = (bool)(arg1)->setRecordLength(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_MSEEDEncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDEncoderFactory *arg1 = (Gempa::CAPS::MSEEDEncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_MSEEDEncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDEncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MSEEDEncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDEncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *MSEEDEncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__MSEEDEncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_SteimEncoderFactory_supportsRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SteimEncoderFactory *arg1 = (Gempa::CAPS::SteimEncoderFactory *) 0 ; + Gempa::CAPS::DataRecord *arg2 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SteimEncoderFactory_supportsRecord",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SteimEncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SteimEncoderFactory_supportsRecord" "', argument " "1"" of type '" "Gempa::CAPS::SteimEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SteimEncoderFactory * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SteimEncoderFactory_supportsRecord" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp2); + result = (bool)(arg1)->supportsRecord(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SteimEncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SteimEncoderFactory *arg1 = (Gempa::CAPS::SteimEncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SteimEncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SteimEncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SteimEncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::SteimEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SteimEncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SteimEncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__SteimEncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_IdentityEncoderFactory_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::IdentityEncoderFactory *arg1 = (Gempa::CAPS::IdentityEncoderFactory *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Encoder *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:IdentityEncoderFactory_create",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IdentityEncoderFactory_create" "', argument " "1"" of type '" "Gempa::CAPS::IdentityEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::IdentityEncoderFactory * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IdentityEncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IdentityEncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IdentityEncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IdentityEncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IdentityEncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IdentityEncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IdentityEncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IdentityEncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "IdentityEncoderFactory_create" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "IdentityEncoderFactory_create" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "IdentityEncoderFactory_create" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Encoder *)(arg1)->create((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,arg7,arg8); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IdentityEncoderFactory_supportsRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::IdentityEncoderFactory *arg1 = (Gempa::CAPS::IdentityEncoderFactory *) 0 ; + Gempa::CAPS::DataRecord *arg2 = (Gempa::CAPS::DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:IdentityEncoderFactory_supportsRecord",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IdentityEncoderFactory_supportsRecord" "', argument " "1"" of type '" "Gempa::CAPS::IdentityEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::IdentityEncoderFactory * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IdentityEncoderFactory_supportsRecord" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord * >(argp2); + result = (bool)(arg1)->supportsRecord(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IdentityEncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::IdentityEncoderFactory *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_IdentityEncoderFactory")) SWIG_fail; + result = (Gempa::CAPS::IdentityEncoderFactory *)new Gempa::CAPS::IdentityEncoderFactory(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IdentityEncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::IdentityEncoderFactory *arg1 = (Gempa::CAPS::IdentityEncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_IdentityEncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IdentityEncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::IdentityEncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::IdentityEncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IdentityEncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__IdentityEncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_Steim1EncoderFactory_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim1EncoderFactory *arg1 = (Gempa::CAPS::Steim1EncoderFactory *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Encoder *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:Steim1EncoderFactory_create",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Steim1EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Steim1EncoderFactory_create" "', argument " "1"" of type '" "Gempa::CAPS::Steim1EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Steim1EncoderFactory * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Steim1EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim1EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Steim1EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim1EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Steim1EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim1EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Steim1EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim1EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Steim1EncoderFactory_create" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Steim1EncoderFactory_create" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Steim1EncoderFactory_create" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Encoder *)(arg1)->create((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,arg7,arg8); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Steim1EncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim1EncoderFactory *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Steim1EncoderFactory")) SWIG_fail; + result = (Gempa::CAPS::Steim1EncoderFactory *)new Gempa::CAPS::Steim1EncoderFactory(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Steim1EncoderFactory, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Steim1EncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim1EncoderFactory *arg1 = (Gempa::CAPS::Steim1EncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Steim1EncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Steim1EncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Steim1EncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::Steim1EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Steim1EncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Steim1EncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Steim1EncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_Steim2EncoderFactory_create(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim2EncoderFactory *arg1 = (Gempa::CAPS::Steim2EncoderFactory *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + int arg6 ; + int arg7 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Encoder *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:Steim2EncoderFactory_create",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Steim2EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Steim2EncoderFactory_create" "', argument " "1"" of type '" "Gempa::CAPS::Steim2EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Steim2EncoderFactory * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Steim2EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim2EncoderFactory_create" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Steim2EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim2EncoderFactory_create" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Steim2EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim2EncoderFactory_create" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Steim2EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Steim2EncoderFactory_create" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Steim2EncoderFactory_create" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Steim2EncoderFactory_create" "', argument " "7"" of type '" "int""'"); + } + arg7 = static_cast< int >(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Steim2EncoderFactory_create" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Encoder *)(arg1)->create((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,arg7,arg8); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Encoder, 0 | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Steim2EncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim2EncoderFactory *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Steim2EncoderFactory")) SWIG_fail; + result = (Gempa::CAPS::Steim2EncoderFactory *)new Gempa::CAPS::Steim2EncoderFactory(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Steim2EncoderFactory, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Steim2EncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Steim2EncoderFactory *arg1 = (Gempa::CAPS::Steim2EncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Steim2EncoderFactory",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Steim2EncoderFactory, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Steim2EncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::Steim2EncoderFactory *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Steim2EncoderFactory * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Steim2EncoderFactory_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Steim2EncoderFactory, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = (char *)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_readMetaData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::DataRecord::Header *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:MSEEDDataRecord_readMetaData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "MSEEDDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + result = (bool)(arg1)->readMetaData(*arg2,arg3,*arg4,*arg5,*arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_header" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_startTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_startTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_startTime" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = ((Gempa::CAPS::MSEEDDataRecord const *)arg1)->startTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_endTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_endTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_endTime" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = ((Gempa::CAPS::MSEEDDataRecord const *)arg1)->endTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:MSEEDDataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "MSEEDDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"OO:MSEEDDataRecord_dataSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MSEEDDataRecord_dataSize" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = ((Gempa::CAPS::MSEEDDataRecord const *)arg1)->dataSize(arg2); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:MSEEDDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "MSEEDDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "MSEEDDataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:MSEEDDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "MSEEDDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_get__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:MSEEDDataRecord_get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_get__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:MSEEDDataRecord_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (arg1)->get(*arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_MSEEDDataRecord_get__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_MSEEDDataRecord_get__SWIG_2(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_MSEEDDataRecord_get__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_MSEEDDataRecord_get__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'MSEEDDataRecord_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::MSEEDDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::MSEEDDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::MSEEDDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::MSEEDDataRecord::get(std::streambuf &,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + bool arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:MSEEDDataRecord_put",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "MSEEDDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_bool(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_put" "', argument " "3"" of type '" "bool""'"); + } + arg3 = static_cast< bool >(val3); + result = (bool)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->put(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::MSEEDDataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_setData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *arg2 = (void *) 0 ; + size_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + size_t val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:MSEEDDataRecord_setData",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_setData" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MSEEDDataRecord_setData" "', argument " "2"" of type '" "void const *""'"); + } + ecode3 = SWIG_AsVal_size_t(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "MSEEDDataRecord_setData" "', argument " "3"" of type '" "size_t""'"); + } + arg3 = static_cast< size_t >(val3); + (arg1)->setData((void const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MSEEDDataRecord_unpackHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:MSEEDDataRecord_unpackHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MSEEDDataRecord_unpackHeader" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + (arg1)->unpackHeader(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_MSEEDDataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::MSEEDDataRecord *arg1 = (Gempa::CAPS::MSEEDDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_MSEEDDataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MSEEDDataRecord" "', argument " "1"" of type '" "Gempa::CAPS::MSEEDDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::MSEEDDataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *MSEEDDataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__MSEEDDataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_Plugin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + int res1 = SWIG_OLDOBJ ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::Plugin *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_Plugin",&obj0,&obj1,&obj2)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Plugin" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Plugin" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + result = (Gempa::CAPS::Plugin *)new Gempa::CAPS::Plugin((std::string const &)*arg1,(std::string const &)*arg2,(std::string const &)*arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Plugin, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Plugin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + std::string *arg2 = 0 ; + int res1 = SWIG_OLDOBJ ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Plugin *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_Plugin",&obj0,&obj1)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Plugin" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + result = (Gempa::CAPS::Plugin *)new Gempa::CAPS::Plugin((std::string const &)*arg1,(std::string const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Plugin, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Plugin__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + int res1 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Plugin *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_Plugin",&obj0)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Plugin" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + result = (Gempa::CAPS::Plugin *)new Gempa::CAPS::Plugin((std::string const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Plugin, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Plugin(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 3) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Plugin__SWIG_2(self, args); + } + } + if (argc == 2) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Plugin__SWIG_1(self, args); + } + } + } + if (argc == 3) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Plugin__SWIG_0(self, args); + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_Plugin'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Plugin::Plugin(std::string const &,std::string const &,std::string const &)\n" + " Gempa::CAPS::Plugin::Plugin(std::string const &,std::string const &)\n" + " Gempa::CAPS::Plugin::Plugin(std::string const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_Plugin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Plugin",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Plugin" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_close",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_close" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + (arg1)->close(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_quit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_quit",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_quit" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + (arg1)->quit(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_enableLogging(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_enableLogging",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_enableLogging" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + (arg1)->enableLogging(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setBackfillingBufferSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setBackfillingBufferSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setBackfillingBufferSize" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setBackfillingBufferSize" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + (arg1)->setBackfillingBufferSize(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_backfillingBufferSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_backfillingBufferSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_backfillingBufferSize" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (int)((Gempa::CAPS::Plugin const *)arg1)->backfillingBufferSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_isExitRequested(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_isExitRequested",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_isExitRequested" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (bool)(arg1)->isExitRequested(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_stats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Plugin::Stats *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_stats",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_stats" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (Gempa::CAPS::Plugin::Stats *) &((Gempa::CAPS::Plugin const *)arg1)->stats(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Plugin__Stats, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_resetMaxBytesBuffered(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_resetMaxBytesBuffered",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_resetMaxBytesBuffered" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + (arg1)->resetMaxBytesBuffered(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setEncoderFactory(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + Gempa::CAPS::EncoderFactory *arg2 = (Gempa::CAPS::EncoderFactory *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setEncoderFactory",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setEncoderFactory" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__EncoderFactory, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setEncoderFactory" "', argument " "2"" of type '" "Gempa::CAPS::EncoderFactory *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::EncoderFactory * >(argp2); + (arg1)->setEncoderFactory(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setHost",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setHost" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setHost" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setHost" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + (arg1)->setHost((std::string const &)*arg2); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_host(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_host",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_host" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (std::string *) &((Gempa::CAPS::Plugin const *)arg1)->host(); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setPort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + unsigned short arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setPort",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setPort" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setPort" "', argument " "2"" of type '" "unsigned short""'"); + } + arg2 = static_cast< unsigned short >(val2); + (arg1)->setPort(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_port(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + unsigned short result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_port",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_port" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (unsigned short)((Gempa::CAPS::Plugin const *)arg1)->port(); + resultobj = SWIG_From_unsigned_SS_short(static_cast< unsigned short >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setBufferSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setBufferSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setBufferSize" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_size_t(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setBufferSize" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = static_cast< size_t >(val2); + (arg1)->setBufferSize(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_bufferSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_bufferSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_bufferSize" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = ((Gempa::CAPS::Plugin const *)arg1)->bufferSize(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setSSLEnabled(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setSSLEnabled",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setSSLEnabled" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setSSLEnabled" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + (arg1)->setSSLEnabled(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setCredentials(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Plugin_setCredentials",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setCredentials" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setCredentials" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setCredentials" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_setCredentials" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setCredentials" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + (arg1)->setCredentials((std::string const &)*arg2,(std::string const &)*arg3); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setMaxFutureEndTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setMaxFutureEndTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setMaxFutureEndTime" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setMaxFutureEndTime" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setMaxFutureEndTime" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + (arg1)->setMaxFutureEndTime((Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setPacketAckFunc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + Gempa::CAPS::Plugin::PacketAckFunc *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setPacketAckFunc",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setPacketAckFunc" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setPacketAckFunc" "', argument " "2"" of type '" "Gempa::CAPS::Plugin::PacketAckFunc const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setPacketAckFunc" "', argument " "2"" of type '" "Gempa::CAPS::Plugin::PacketAckFunc const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Plugin::PacketAckFunc * >(argp2); + (arg1)->setPacketAckFunc((Gempa::CAPS::Plugin::PacketAckFunc const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setSendTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setSendTimeout",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setSendTimeout" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setSendTimeout" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + (arg1)->setSendTimeout(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setTimeouts__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + int arg2 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Plugin_setTimeouts",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setTimeouts" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setTimeouts" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Plugin_setTimeouts" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + (arg1)->setTimeouts(arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setTimeouts__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:Plugin_setTimeouts",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setTimeouts" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setTimeouts" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Plugin_setTimeouts" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Plugin_setTimeouts" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + (arg1)->setTimeouts(arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setTimeouts(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 4) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_setTimeouts__SWIG_0(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_setTimeouts__SWIG_1(self, args); + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'Plugin_setTimeouts'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Plugin::setTimeouts(int,int)\n" + " Gempa::CAPS::Plugin::setTimeouts(int,int,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Plugin_readJournal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_readJournal",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_readJournal" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (bool)(arg1)->readJournal(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setJournal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setJournal",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setJournal" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_setJournal" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_setJournal" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + (arg1)->setJournal((std::string const &)*arg2); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_setFlushInterval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_setFlushInterval",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_setFlushInterval" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Plugin_setFlushInterval" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + (arg1)->setFlushInterval(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_streamStates(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Plugin::StreamStates *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_streamStates",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_streamStates" "', argument " "1"" of type '" "Gempa::CAPS::Plugin const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (Gempa::CAPS::Plugin::StreamStates *) &((Gempa::CAPS::Plugin const *)arg1)->streamStates(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_writeJournal__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_writeJournal",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_writeJournal" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (bool)(arg1)->writeJournal(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_writeJournal__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::ostream *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Plugin_writeJournal",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_writeJournal" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__ostream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_writeJournal" "', argument " "2"" of type '" "std::ostream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_writeJournal" "', argument " "2"" of type '" "std::ostream &""'"); + } + arg2 = reinterpret_cast< std::ostream * >(argp2); + result = (bool)(arg1)->writeJournal(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_writeJournal(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Plugin_writeJournal__SWIG_0(self, args); + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__ostream, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Plugin_writeJournal__SWIG_1(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'Plugin_writeJournal'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Plugin::writeJournal()\n" + " Gempa::CAPS::Plugin::writeJournal(std::ostream &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::DataRecordPtr arg6 ; + std::string *arg7 = 0 ; + int arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 ; + int res6 = 0 ; + int res7 = SWIG_OLDOBJ ; + int val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + { + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } else { + Gempa::CAPS::DataRecordPtr * temp = reinterpret_cast< Gempa::CAPS::DataRecordPtr * >(argp6); + arg6 = *temp; + if (SWIG_IsNewObj(res6)) delete temp; + } + } + { + std::string *ptr = (std::string *)0; + res7 = SWIG_AsPtr_std_string(obj6, &ptr); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "Plugin_push" "', argument " "7"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "7"" of type '" "std::string const &""'"); + } + arg7 = ptr; + } + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "int""'"); + } + arg8 = static_cast< int >(val8); + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,(std::string const &)*arg7,arg8); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res7)) delete arg7; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res7)) delete arg7; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::DataRecordPtr arg6 ; + std::string *arg7 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 ; + int res6 = 0 ; + int res7 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + { + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::DataRecordPtr""'"); + } else { + Gempa::CAPS::DataRecordPtr * temp = reinterpret_cast< Gempa::CAPS::DataRecordPtr * >(argp6); + arg6 = *temp; + if (SWIG_IsNewObj(res6)) delete temp; + } + } + { + std::string *ptr = (std::string *)0; + res7 = SWIG_AsPtr_std_string(obj6, &ptr); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "Plugin_push" "', argument " "7"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "7"" of type '" "std::string const &""'"); + } + arg7 = ptr; + } + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,arg6,(std::string const &)*arg7); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res7)) delete arg7; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res7)) delete arg7; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + uint16_t arg7 ; + uint16_t arg8 ; + std::string *arg9 = 0 ; + void *arg10 = (void *) 0 ; + size_t arg11 ; + Gempa::CAPS::DataType arg12 ; + int arg13 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + unsigned short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + int res10 ; + size_t val11 ; + int ecode11 = 0 ; + int val12 ; + int ecode12 = 0 ; + int val13 ; + int ecode13 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + PyObject * obj11 = 0 ; + PyObject * obj12 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10,&obj11,&obj12)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "uint16_t""'"); + } + arg7 = static_cast< uint16_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "uint16_t""'"); + } + arg8 = static_cast< uint16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + res10 = SWIG_ConvertPtr(obj9,SWIG_as_voidptrptr(&arg10), 0, 0); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "Plugin_push" "', argument " "10"" of type '" "void *""'"); + } + ecode11 = SWIG_AsVal_size_t(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "Plugin_push" "', argument " "11"" of type '" "size_t""'"); + } + arg11 = static_cast< size_t >(val11); + ecode12 = SWIG_AsVal_int(obj11, &val12); + if (!SWIG_IsOK(ecode12)) { + SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "Plugin_push" "', argument " "12"" of type '" "Gempa::CAPS::DataType""'"); + } + arg12 = static_cast< Gempa::CAPS::DataType >(val12); + ecode13 = SWIG_AsVal_int(obj12, &val13); + if (!SWIG_IsOK(ecode13)) { + SWIG_exception_fail(SWIG_ArgError(ecode13), "in method '" "Plugin_push" "', argument " "13"" of type '" "int""'"); + } + arg13 = static_cast< int >(val13); + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,arg10,arg11,arg12,arg13); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + uint16_t arg7 ; + uint16_t arg8 ; + std::string *arg9 = 0 ; + void *arg10 = (void *) 0 ; + size_t arg11 ; + Gempa::CAPS::DataType arg12 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + unsigned short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + int res10 ; + size_t val11 ; + int ecode11 = 0 ; + int val12 ; + int ecode12 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + PyObject * obj11 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10,&obj11)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "uint16_t""'"); + } + arg7 = static_cast< uint16_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "uint16_t""'"); + } + arg8 = static_cast< uint16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + res10 = SWIG_ConvertPtr(obj9,SWIG_as_voidptrptr(&arg10), 0, 0); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "Plugin_push" "', argument " "10"" of type '" "void *""'"); + } + ecode11 = SWIG_AsVal_size_t(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "Plugin_push" "', argument " "11"" of type '" "size_t""'"); + } + arg11 = static_cast< size_t >(val11); + ecode12 = SWIG_AsVal_int(obj11, &val12); + if (!SWIG_IsOK(ecode12)) { + SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "Plugin_push" "', argument " "12"" of type '" "Gempa::CAPS::DataType""'"); + } + arg12 = static_cast< Gempa::CAPS::DataType >(val12); + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,arg10,arg11,arg12); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + uint16_t arg7 ; + uint16_t arg8 ; + std::string *arg9 = 0 ; + char *arg10 = (char *) 0 ; + size_t arg11 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + unsigned short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + int res10 ; + char *buf10 = 0 ; + int alloc10 = 0 ; + size_t val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "uint16_t""'"); + } + arg7 = static_cast< uint16_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "uint16_t""'"); + } + arg8 = static_cast< uint16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + res10 = SWIG_AsCharPtrAndSize(obj9, &buf10, NULL, &alloc10); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "Plugin_push" "', argument " "10"" of type '" "char *""'"); + } + arg10 = reinterpret_cast< char * >(buf10); + ecode11 = SWIG_AsVal_size_t(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "Plugin_push" "', argument " "11"" of type '" "size_t""'"); + } + arg11 = static_cast< size_t >(val11); + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,arg10,arg11); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + if (alloc10 == SWIG_NEWOBJ) delete[] buf10; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + if (alloc10 == SWIG_NEWOBJ) delete[] buf10; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + uint16_t arg7 ; + uint16_t arg8 ; + std::string *arg9 = 0 ; + std::string *arg10 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + unsigned short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + int res10 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "uint16_t""'"); + } + arg7 = static_cast< uint16_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "uint16_t""'"); + } + arg8 = static_cast< uint16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + { + std::string *ptr = (std::string *)0; + res10 = SWIG_AsPtr_std_string(obj9, &ptr); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "Plugin_push" "', argument " "10"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "10"" of type '" "std::string const &""'"); + } + arg10 = ptr; + } + result = (Gempa::CAPS::Plugin::Status)(arg1)->push((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,(std::string const &)*arg10); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + if (SWIG_IsNewObj(res10)) delete arg10; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + if (SWIG_IsNewObj(res10)) delete arg10; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_version(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Plugin_version",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_version" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + result = (char *)(arg1)->version(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + int16_t arg7 ; + int16_t arg8 ; + std::string *arg9 = 0 ; + PyObject *arg10 = (PyObject *) 0 ; + int arg11 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + short val7 ; + int ecode7 = 0 ; + short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + int val11 ; + int ecode11 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "int16_t""'"); + } + arg7 = static_cast< int16_t >(val7); + ecode8 = SWIG_AsVal_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "int16_t""'"); + } + arg8 = static_cast< int16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + arg10 = obj9; + ecode11 = SWIG_AsVal_int(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "Plugin_push" "', argument " "11"" of type '" "int""'"); + } + arg11 = static_cast< int >(val11); + result = (Gempa::CAPS::Plugin::Status)Gempa_CAPS_Plugin_push__SWIG_6(arg1,(std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,arg10,arg11); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Plugin *arg1 = (Gempa::CAPS::Plugin *) 0 ; + std::string *arg2 = 0 ; + std::string *arg3 = 0 ; + std::string *arg4 = 0 ; + std::string *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + uint16_t arg7 ; + uint16_t arg8 ; + std::string *arg9 = 0 ; + PyObject *arg10 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + int res3 = SWIG_OLDOBJ ; + int res4 = SWIG_OLDOBJ ; + int res5 = SWIG_OLDOBJ ; + void *argp6 = 0 ; + int res6 = 0 ; + unsigned short val7 ; + int ecode7 = 0 ; + unsigned short val8 ; + int ecode8 = 0 ; + int res9 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + Gempa::CAPS::Plugin::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:Plugin_push",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Plugin, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Plugin_push" "', argument " "1"" of type '" "Gempa::CAPS::Plugin *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Plugin * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(obj3, &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "4"" of type '" "std::string const &""'"); + } + arg4 = ptr; + } + { + std::string *ptr = (std::string *)0; + res5 = SWIG_AsPtr_std_string(obj4, &ptr); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "5"" of type '" "std::string const &""'"); + } + arg5 = ptr; + } + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "6"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Plugin_push" "', argument " "7"" of type '" "uint16_t""'"); + } + arg7 = static_cast< uint16_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_short(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Plugin_push" "', argument " "8"" of type '" "uint16_t""'"); + } + arg8 = static_cast< uint16_t >(val8); + { + std::string *ptr = (std::string *)0; + res9 = SWIG_AsPtr_std_string(obj8, &ptr); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Plugin_push" "', argument " "9"" of type '" "std::string const &""'"); + } + arg9 = ptr; + } + arg10 = obj9; + result = (Gempa::CAPS::Plugin::Status)Gempa_CAPS_Plugin_push__SWIG_7(arg1,(std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,(std::string const &)*arg5,(Gempa::CAPS::Time const &)*arg6,arg7,arg8,(std::string const &)*arg9,arg10); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + if (SWIG_IsNewObj(res3)) delete arg3; + if (SWIG_IsNewObj(res4)) delete arg4; + if (SWIG_IsNewObj(res5)) delete arg5; + if (SWIG_IsNewObj(res9)) delete arg9; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Plugin_push(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[14] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 13) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 7) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[6], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Plugin_push__SWIG_1(self, args); + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[6], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_push__SWIG_0(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[9], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Plugin_push__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 10) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + _v = (argv[9] != 0); + if (_v) { + return _wrap_Plugin_push__SWIG_7(self, args); + } + } + } + } + } + } + } + } + } + } + } + if (argc == 11) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[9], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_push__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + if (argc == 11) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + _v = (argv[9] != 0); + if (_v) { + { + int res = SWIG_AsVal_int(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_push__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + if (argc == 12) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + void *ptr = 0; + int res = SWIG_ConvertPtr(argv[9], &ptr, 0, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[11], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_push__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + } + if (argc == 13) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__Plugin, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[4], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[5], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[6], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_unsigned_SS_short(argv[7], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[8], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + void *ptr = 0; + int res = SWIG_ConvertPtr(argv[9], &ptr, 0, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[10], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[11], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[12], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Plugin_push__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'Plugin_push'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::DataRecordPtr,std::string const &,int)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::DataRecordPtr,std::string const &)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,uint16_t,uint16_t,std::string const &,void *,size_t,Gempa::CAPS::DataType,int)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,uint16_t,uint16_t,std::string const &,void *,size_t,Gempa::CAPS::DataType)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,uint16_t,uint16_t,std::string const &,char *,size_t)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,uint16_t,uint16_t,std::string const &,std::string const &)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,int16_t,int16_t,std::string const &,PyObject *,int)\n" + " Gempa::CAPS::Plugin::push(std::string const &,std::string const &,std::string const &,std::string const &,Gempa::CAPS::Time const &,uint16_t,uint16_t,std::string const &,PyObject *)\n"); + return 0; +} + + +SWIGINTERN PyObject *Plugin_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Plugin, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_RawResponseHeader_timeSeconds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + int64_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long long val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawResponseHeader_timeSeconds_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_timeSeconds_set" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RawResponseHeader_timeSeconds_set" "', argument " "2"" of type '" "int64_t""'"); + } + arg2 = static_cast< int64_t >(val2); + if (arg1) (arg1)->timeSeconds = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawResponseHeader_timeSeconds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int64_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawResponseHeader_timeSeconds_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_timeSeconds_get" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + result = (int64_t) ((arg1)->timeSeconds); + resultobj = SWIG_From_long_SS_long(static_cast< long long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawResponseHeader_timeMicroSeconds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + int32_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawResponseHeader_timeMicroSeconds_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_timeMicroSeconds_set" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RawResponseHeader_timeMicroSeconds_set" "', argument " "2"" of type '" "int32_t""'"); + } + arg2 = static_cast< int32_t >(val2); + if (arg1) (arg1)->timeMicroSeconds = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawResponseHeader_timeMicroSeconds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int32_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawResponseHeader_timeMicroSeconds_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_timeMicroSeconds_get" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + result = (int32_t) ((arg1)->timeMicroSeconds); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawResponseHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawResponseHeader_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawResponseHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawResponseHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->get(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawResponseHeader_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawResponseHeader_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawResponseHeader_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + result = (int)((Gempa::CAPS::RawResponseHeader const *)arg1)->dataSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_RawResponseHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_RawResponseHeader")) SWIG_fail; + result = (Gempa::CAPS::RawResponseHeader *)new Gempa::CAPS::RawResponseHeader(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_RawResponseHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawResponseHeader *arg1 = (Gempa::CAPS::RawResponseHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_RawResponseHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_RawResponseHeader" "', argument " "1"" of type '" "Gempa::CAPS::RawResponseHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawResponseHeader * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *RawResponseHeader_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RawResponseHeader, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_RawDataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = (char *)((Gempa::CAPS::RawDataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_readMetaData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::DataRecord::Header *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:RawDataRecord_readMetaData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_readMetaData" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_readMetaData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RawDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "RawDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + result = (bool)(arg1)->readMetaData(*arg2,arg3,*arg4,*arg5,*arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_setHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + Gempa::CAPS::DataRecord::Header *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawDataRecord_setHeader",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_setHeader" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_setHeader" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_setHeader" "', argument " "2"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp2); + (arg1)->setHeader((Gempa::CAPS::DataRecord::Header const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_header" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)((Gempa::CAPS::RawDataRecord const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_startTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_startTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_startTime" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = ((Gempa::CAPS::RawDataRecord const *)arg1)->startTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_endTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_endTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_endTime" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = ((Gempa::CAPS::RawDataRecord const *)arg1)->endTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::RawDataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::RawDataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "RawDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::RawDataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawDataRecord_dataSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RawDataRecord_dataSize" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = ((Gempa::CAPS::RawDataRecord const *)arg1)->dataSize(arg2); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:RawDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "RawDataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:RawDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_get__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:RawDataRecord_get",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_get__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (arg1)->get(*arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_RawDataRecord_get__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_RawDataRecord_get__SWIG_2(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_RawDataRecord_get__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_RawDataRecord_get__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'RawDataRecord_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::RawDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::RawDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::RawDataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::RawDataRecord::get(std::streambuf &,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_getData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:RawDataRecord_getData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_getData" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_getData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RawDataRecord_getData" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "RawDataRecord_getData" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->getData(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_getData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:RawDataRecord_getData",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_getData" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_getData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RawDataRecord_getData" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->getData(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_getData__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:RawDataRecord_getData",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_getData" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_getData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + result = (arg1)->getData(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_getData__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_getData",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_getData" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_getData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_getData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (arg1)->getData(*arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_getData(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_RawDataRecord_getData__SWIG_3(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_RawDataRecord_getData__SWIG_2(self, args); + } + } + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_RawDataRecord_getData__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_RawDataRecord_getData__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'RawDataRecord_getData'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::RawDataRecord::getData(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::RawDataRecord::getData(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::RawDataRecord::getData(std::streambuf &,int,Gempa::CAPS::Time const &)\n" + " Gempa::CAPS::RawDataRecord::getData(std::streambuf &,int)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + bool arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_put",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_bool(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_put" "', argument " "3"" of type '" "bool""'"); + } + arg3 = static_cast< bool >(val3); + result = (bool)((Gempa::CAPS::RawDataRecord const *)arg1)->put(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:RawDataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::RawDataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_setStartTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawDataRecord_setStartTime",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_setStartTime" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RawDataRecord_setStartTime" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + (arg1)->setStartTime((Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_setSamplingFrequency(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + uint16_t arg2 ; + uint16_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + unsigned short val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_setSamplingFrequency",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_setSamplingFrequency" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RawDataRecord_setSamplingFrequency" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_setSamplingFrequency" "', argument " "3"" of type '" "uint16_t""'"); + } + arg3 = static_cast< uint16_t >(val3); + (arg1)->setSamplingFrequency(arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_setDataType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + Gempa::CAPS::DataType arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RawDataRecord_setDataType",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_setDataType" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RawDataRecord_setDataType" "', argument " "2"" of type '" "Gempa::CAPS::DataType""'"); + } + arg2 = static_cast< Gempa::CAPS::DataType >(val2); + (arg1)->setDataType(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RawDataRecord_setBuffer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *arg2 = (void *) 0 ; + size_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + size_t val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RawDataRecord_setBuffer",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RawDataRecord_setBuffer" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RawDataRecord_setBuffer" "', argument " "2"" of type '" "void const *""'"); + } + ecode3 = SWIG_AsVal_size_t(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RawDataRecord_setBuffer" "', argument " "3"" of type '" "size_t""'"); + } + arg3 = static_cast< size_t >(val3); + (arg1)->setBuffer((void const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_RawDataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RawDataRecord *arg1 = (Gempa::CAPS::RawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_RawDataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RawDataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_RawDataRecord" "', argument " "1"" of type '" "Gempa::CAPS::RawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RawDataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *RawDataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RawDataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:FixedRawDataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::FixedRawDataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:FixedRawDataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + result = (bool)((Gempa::CAPS::FixedRawDataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:FixedRawDataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FixedRawDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FixedRawDataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "FixedRawDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FixedRawDataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::FixedRawDataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:FixedRawDataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + result = (char *)((Gempa::CAPS::FixedRawDataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:FixedRawDataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FixedRawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FixedRawDataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "FixedRawDataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "FixedRawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FixedRawDataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "FixedRawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FixedRawDataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "FixedRawDataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_FixedRawDataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:FixedRawDataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FixedRawDataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::FixedRawDataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_FixedRawDataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::FixedRawDataRecord *arg1 = (Gempa::CAPS::FixedRawDataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_FixedRawDataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_FixedRawDataRecord" "', argument " "1"" of type '" "Gempa::CAPS::FixedRawDataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::FixedRawDataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *FixedRawDataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__FixedRawDataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_ChunkHeader_chunkSize_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_chunkSize_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_chunkSize_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ChunkHeader_chunkSize_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + if (arg1) (arg1)->chunkSize = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_chunkSize_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkHeader_chunkSize_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_chunkSize_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + result = (int) ((arg1)->chunkSize); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_setChunkType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_setChunkType",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_setChunkType" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_setChunkType" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)(arg1)->setChunkType((char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_isChunkType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_isChunkType",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_isChunkType" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_isChunkType" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)((Gempa::CAPS::RIFF::ChunkHeader const *)arg1)->isChunkType((char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_validChunkType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkHeader_validChunkType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_validChunkType" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + result = (bool)((Gempa::CAPS::RIFF::ChunkHeader const *)arg1)->validChunkType(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkHeader_dataSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + result = (int)((Gempa::CAPS::RIFF::ChunkHeader const *)arg1)->dataSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + std::istream *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_read",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_read" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__istream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_read" "', argument " "2"" of type '" "std::istream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkHeader_read" "', argument " "2"" of type '" "std::istream &""'"); + } + arg2 = reinterpret_cast< std::istream * >(argp2); + result = (bool)(arg1)->read(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_write(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + std::ostream *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_write",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_write" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__ostream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_write" "', argument " "2"" of type '" "std::ostream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkHeader_write" "', argument " "2"" of type '" "std::ostream &""'"); + } + arg2 = reinterpret_cast< std::ostream * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::ChunkHeader const *)arg1)->write(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_get",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkHeader_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)(arg1)->get(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkHeader_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkHeader_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkHeader_put" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkHeader_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkHeader_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::ChunkHeader const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ChunkHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_ChunkHeader")) SWIG_fail; + result = (Gempa::CAPS::RIFF::ChunkHeader *)new Gempa::CAPS::RIFF::ChunkHeader(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ChunkHeader(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkHeader *arg1 = (Gempa::CAPS::RIFF::ChunkHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_ChunkHeader",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ChunkHeader" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkHeader *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkHeader * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ChunkHeader_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN int Swig_var_ChunkHeaderSize_set(PyObject *) { + SWIG_Error(SWIG_AttributeError,"Variable ChunkHeaderSize is read-only."); + return 1; +} + + +SWIGINTERN PyObject *Swig_var_ChunkHeaderSize_get(void) { + PyObject *pyobj = 0; + + pyobj = SWIG_From_int(static_cast< int >(Gempa::CAPS::RIFF::ChunkHeaderSize)); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_new_ChunkIterator__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_ChunkIterator")) SWIG_fail; + result = (Gempa::CAPS::RIFF::ChunkIterator *)new Gempa::CAPS::RIFF::ChunkIterator(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ChunkIterator__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + int res1 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + Gempa::CAPS::RIFF::ChunkIterator *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_ChunkIterator",&obj0)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ChunkIterator" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ChunkIterator" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + result = (Gempa::CAPS::RIFF::ChunkIterator *)new Gempa::CAPS::RIFF::ChunkIterator((std::string const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ChunkIterator__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::istream *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::RIFF::ChunkIterator *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_ChunkIterator",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__istream, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ChunkIterator" "', argument " "1"" of type '" "std::istream &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ChunkIterator" "', argument " "1"" of type '" "std::istream &""'"); + } + arg1 = reinterpret_cast< std::istream * >(argp1); + result = (Gempa::CAPS::RIFF::ChunkIterator *)new Gempa::CAPS::RIFF::ChunkIterator(*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ChunkIterator(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_ChunkIterator__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_std__istream, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ChunkIterator__SWIG_2(self, args); + } + } + if (argc == 1) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_ChunkIterator__SWIG_1(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_ChunkIterator'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::RIFF::ChunkIterator::ChunkIterator()\n" + " Gempa::CAPS::RIFF::ChunkIterator::ChunkIterator(std::string const &)\n" + " Gempa::CAPS::RIFF::ChunkIterator::ChunkIterator(std::istream &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkIterator_begin",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_begin" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkIterator_begin" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkIterator_begin" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + (arg1)->begin((std::string const &)*arg2); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + std::istream *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ChunkIterator_begin",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_begin" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__istream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ChunkIterator_begin" "', argument " "2"" of type '" "std::istream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ChunkIterator_begin" "', argument " "2"" of type '" "std::istream &""'"); + } + arg2 = reinterpret_cast< std::istream * >(argp2); + (arg1)->begin(*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_begin(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__istream, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ChunkIterator_begin__SWIG_1(self, args); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_ChunkIterator_begin__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'ChunkIterator_begin'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::RIFF::ChunkIterator::begin(std::string const &)\n" + " Gempa::CAPS::RIFF::ChunkIterator::begin(std::istream &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkIterator_next",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_next" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + result = (bool)(arg1)->next(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::RIFF::ChunkHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkIterator_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_header" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + result = (Gempa::CAPS::RIFF::ChunkHeader *) &((Gempa::CAPS::RIFF::ChunkIterator const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkHeader, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_headerPos(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkIterator_headerPos",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_headerPos" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + result = ((Gempa::CAPS::RIFF::ChunkIterator const *)arg1)->headerPos(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_contentPos(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkIterator_contentPos",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_contentPos" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + result = ((Gempa::CAPS::RIFF::ChunkIterator const *)arg1)->contentPos(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ChunkIterator_istream(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::istream *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ChunkIterator_istream",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ChunkIterator_istream" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + result = (std::istream *) &((Gempa::CAPS::RIFF::ChunkIterator const *)arg1)->istream(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__istream, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ChunkIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::ChunkIterator *arg1 = (Gempa::CAPS::RIFF::ChunkIterator *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_ChunkIterator",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ChunkIterator" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::ChunkIterator *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::ChunkIterator * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ChunkIterator_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__ChunkIterator, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_delete_Chunk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Chunk",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Chunk" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Chunk_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + std::istream *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Chunk_read",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Chunk_read" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__istream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Chunk_read" "', argument " "2"" of type '" "std::istream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Chunk_read" "', argument " "2"" of type '" "std::istream &""'"); + } + arg2 = reinterpret_cast< std::istream * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Chunk_read" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)(arg1)->read(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Chunk_write(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + std::ostream *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Chunk_write",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Chunk_write" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__ostream, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Chunk_write" "', argument " "2"" of type '" "std::ostream &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Chunk_write" "', argument " "2"" of type '" "std::ostream &""'"); + } + arg2 = reinterpret_cast< std::ostream * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::Chunk const *)arg1)->write(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Chunk_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Chunk_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Chunk_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Chunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Chunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Chunk_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)(arg1)->get(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Chunk_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Chunk_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Chunk_put" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Chunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Chunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::Chunk const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Chunk_chunkSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::Chunk *arg1 = (Gempa::CAPS::RIFF::Chunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Chunk_chunkSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Chunk_chunkSize" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::Chunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::Chunk * >(argp1); + result = (int)((Gempa::CAPS::RIFF::Chunk const *)arg1)->chunkSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Chunk_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__Chunk, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_HeadChunk_data_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + Gempa::CAPS::PacketDataHeader *arg2 = (Gempa::CAPS::PacketDataHeader *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:HeadChunk_data_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HeadChunk_data_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "HeadChunk_data_set" "', argument " "2"" of type '" "Gempa::CAPS::PacketDataHeader *""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::PacketDataHeader * >(argp2); + if (arg1) (arg1)->data = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_HeadChunk_data_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketDataHeader *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:HeadChunk_data_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HeadChunk_data_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + result = (Gempa::CAPS::PacketDataHeader *)& ((arg1)->data); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__PacketDataHeader, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_HeadChunk_chunkSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:HeadChunk_chunkSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HeadChunk_chunkSize" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + result = (int)((Gempa::CAPS::RIFF::HeadChunk const *)arg1)->chunkSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_HeadChunk_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:HeadChunk_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HeadChunk_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "HeadChunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "HeadChunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "HeadChunk_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)(arg1)->get(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_HeadChunk_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:HeadChunk_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "HeadChunk_put" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "HeadChunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "HeadChunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::HeadChunk const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_HeadChunk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_HeadChunk")) SWIG_fail; + result = (Gempa::CAPS::RIFF::HeadChunk *)new Gempa::CAPS::RIFF::HeadChunk(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_HeadChunk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::HeadChunk *arg1 = (Gempa::CAPS::RIFF::HeadChunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_HeadChunk",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_HeadChunk" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::HeadChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::HeadChunk * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *HeadChunk_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__HeadChunk, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_SID_networkCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID_networkCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_networkCode_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID_networkCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID_networkCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->networkCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_networkCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SID_networkCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_networkCode_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + result = (std::string *) & ((arg1)->networkCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_stationCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID_stationCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_stationCode_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID_stationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID_stationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->stationCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_stationCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SID_stationCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_stationCode_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + result = (std::string *) & ((arg1)->stationCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_locationCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID_locationCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_locationCode_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID_locationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID_locationCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->locationCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_locationCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SID_locationCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_locationCode_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + result = (std::string *) & ((arg1)->locationCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_channelCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + std::string *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID_channelCode_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_channelCode_set" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID_channelCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID_channelCode_set" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + if (arg1) (arg1)->channelCode = *arg2; + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_channelCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SID_channelCode_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_channelCode_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + result = (std::string *) & ((arg1)->channelCode); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + Gempa::CAPS::RIFF::SID *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID___eq__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID___eq__" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID___eq__" "', argument " "2"" of type '" "Gempa::CAPS::RIFF::SID const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID___eq__" "', argument " "2"" of type '" "Gempa::CAPS::RIFF::SID const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::SID const *)arg1)->operator ==((Gempa::CAPS::RIFF::SID const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + Gempa::CAPS::RIFF::SID *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SID___ne__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID___ne__" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SID___ne__" "', argument " "2"" of type '" "Gempa::CAPS::RIFF::SID const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SID___ne__" "', argument " "2"" of type '" "Gempa::CAPS::RIFF::SID const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::SID const *)arg1)->operator !=((Gempa::CAPS::RIFF::SID const &)*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SID_toString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"O:SID_toString",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SID_toString" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + result = ((Gempa::CAPS::RIFF::SID const *)arg1)->toString(); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SID(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_SID")) SWIG_fail; + result = (Gempa::CAPS::RIFF::SID *)new Gempa::CAPS::RIFF::SID(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__SID, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SID(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SID *arg1 = (Gempa::CAPS::RIFF::SID *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SID",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SID, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SID" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SID *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SID * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SID_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__SID, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_SIDChunk_chunkSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SIDChunk *arg1 = (Gempa::CAPS::RIFF::SIDChunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:SIDChunk_chunkSize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SIDChunk_chunkSize" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SIDChunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SIDChunk * >(argp1); + result = (int)((Gempa::CAPS::RIFF::SIDChunk const *)arg1)->chunkSize(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SIDChunk_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SIDChunk *arg1 = (Gempa::CAPS::RIFF::SIDChunk *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:SIDChunk_get",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SIDChunk_get" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SIDChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SIDChunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SIDChunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SIDChunk_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SIDChunk_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)(arg1)->get(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SIDChunk_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SIDChunk *arg1 = (Gempa::CAPS::RIFF::SIDChunk *) 0 ; + std::streambuf *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SIDChunk_put",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SIDChunk_put" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SIDChunk const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SIDChunk * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SIDChunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SIDChunk_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + result = (bool)((Gempa::CAPS::RIFF::SIDChunk const *)arg1)->put(*arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SIDChunk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SIDChunk *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_SIDChunk")) SWIG_fail; + result = (Gempa::CAPS::RIFF::SIDChunk *)new Gempa::CAPS::RIFF::SIDChunk(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SIDChunk(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RIFF::SIDChunk *arg1 = (Gempa::CAPS::RIFF::SIDChunk *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SIDChunk",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SIDChunk" "', argument " "1"" of type '" "Gempa::CAPS::RIFF::SIDChunk *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RIFF::SIDChunk * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SIDChunk_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RIFF__SIDChunk, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_formatName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_formatName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_formatName" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = (char *)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->formatName(); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_setTimeStamp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:RTCM2DataRecord_setTimeStamp",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_setTimeStamp" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_setTimeStamp" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_setTimeStamp" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + (arg1)->setTimeStamp((Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_setSamplingFrequency(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + uint16_t arg2 ; + uint16_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + unsigned short val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RTCM2DataRecord_setSamplingFrequency",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_setSamplingFrequency" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RTCM2DataRecord_setSamplingFrequency" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RTCM2DataRecord_setSamplingFrequency" "', argument " "3"" of type '" "uint16_t""'"); + } + arg3 = static_cast< uint16_t >(val3); + (arg1)->setSamplingFrequency(arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_readMetaData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::DataRecord::Header *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + Gempa::CAPS::Time *arg6 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:RTCM2DataRecord_readMetaData",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_readMetaData" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_readMetaData" "', argument " "4"" of type '" "Gempa::CAPS::DataRecord::Header &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_readMetaData" "', argument " "5"" of type '" "Gempa::CAPS::Time &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_Gempa__CAPS__Time, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "RTCM2DataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_readMetaData" "', argument " "6"" of type '" "Gempa::CAPS::Time &""'"); + } + arg6 = reinterpret_cast< Gempa::CAPS::Time * >(argp6); + result = (bool)(arg1)->readMetaData(*arg2,arg3,*arg4,*arg5,*arg6); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_header(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::DataRecord::Header *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_header",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_header" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = (Gempa::CAPS::DataRecord::Header *)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->header(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_startTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_startTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_startTime" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = ((Gempa::CAPS::RTCM2DataRecord const *)arg1)->startTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_endTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_endTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_endTime" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = ((Gempa::CAPS::RTCM2DataRecord const *)arg1)->endTime(); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_canTrim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_canTrim",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_canTrim" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = (bool)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->canTrim(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_canMerge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_canMerge",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_canMerge" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = (bool)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->canMerge(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_trim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + Gempa::CAPS::Time *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RTCM2DataRecord_trim",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_trim" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_trim" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "RTCM2DataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_trim" "', argument " "3"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg3 = reinterpret_cast< Gempa::CAPS::Time * >(argp3); + result = (bool)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->trim((Gempa::CAPS::Time const &)*arg2,(Gempa::CAPS::Time const &)*arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_dataSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"OO:RTCM2DataRecord_dataSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_dataSize" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "RTCM2DataRecord_dataSize" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = ((Gempa::CAPS::RTCM2DataRecord const *)arg1)->dataSize(arg2); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_get__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:RTCM2DataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RTCM2DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RTCM2DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RTCM2DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "RTCM2DataRecord_get" "', argument " "6"" of type '" "int""'"); + } + arg6 = static_cast< int >(val6); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5,arg6); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_get__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + int arg3 ; + Gempa::CAPS::Time *arg4 = 0 ; + Gempa::CAPS::Time *arg5 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + Gempa::CAPS::DataRecord::ReadStatus result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:RTCM2DataRecord_get",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_get" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RTCM2DataRecord_get" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "RTCM2DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "4"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg4 = reinterpret_cast< Gempa::CAPS::Time * >(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "RTCM2DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp5) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_get" "', argument " "5"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg5 = reinterpret_cast< Gempa::CAPS::Time * >(argp5); + result = (arg1)->get(*arg2,arg3,(Gempa::CAPS::Time const &)*arg4,(Gempa::CAPS::Time const &)*arg5); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::DataRecord::ReadStatus(static_cast< const Gempa::CAPS::DataRecord::ReadStatus& >(result))), SWIGTYPE_p_Gempa__CAPS__DataRecord__ReadStatus, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_get(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[7] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 6) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_RTCM2DataRecord_get__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 6) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__streambuf, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[4], 0, SWIGTYPE_p_Gempa__CAPS__Time, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[5], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_RTCM2DataRecord_get__SWIG_0(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'RTCM2DataRecord_get'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::RTCM2DataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &,int)\n" + " Gempa::CAPS::RTCM2DataRecord::get(std::streambuf &,int,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_put(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + std::streambuf *arg2 = 0 ; + bool arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + bool val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:RTCM2DataRecord_put",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_put" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RTCM2DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RTCM2DataRecord_put" "', argument " "2"" of type '" "std::streambuf &""'"); + } + arg2 = reinterpret_cast< std::streambuf * >(argp2); + ecode3 = SWIG_AsVal_bool(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "RTCM2DataRecord_put" "', argument " "3"" of type '" "bool""'"); + } + arg3 = static_cast< bool >(val3); + result = (bool)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->put(*arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_RTCM2DataRecord_packetType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::PacketType result; + + if (!PyArg_ParseTuple(args,(char *)"O:RTCM2DataRecord_packetType",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RTCM2DataRecord_packetType" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + result = (Gempa::CAPS::PacketType)((Gempa::CAPS::RTCM2DataRecord const *)arg1)->packetType(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_RTCM2DataRecord(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::RTCM2DataRecord *arg1 = (Gempa::CAPS::RTCM2DataRecord *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_RTCM2DataRecord",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_RTCM2DataRecord" "', argument " "1"" of type '" "Gempa::CAPS::RTCM2DataRecord *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::RTCM2DataRecord * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *RTCM2DataRecord_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__RTCM2DataRecord, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_Socket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_Socket")) SWIG_fail; + result = (Gempa::CAPS::Socket *)new Gempa::CAPS::Socket(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__Socket, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_Socket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_Socket",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Socket" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_toString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket::Status arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_toString",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "Socket_toString" "', argument " "1"" of type '" "Gempa::CAPS::Socket::Status""'"); + } + arg1 = static_cast< Gempa::CAPS::Socket::Status >(val1); + result = (char *)Gempa::CAPS::Socket::toString(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_fd(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_fd",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_fd" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + result = (int)(arg1)->fd(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_isValid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_isValid",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_isValid" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + result = (bool)(arg1)->isValid(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_shutdown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_shutdown",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_shutdown" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + (arg1)->shutdown(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_close",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_close" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + (arg1)->close(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_send(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Socket_send",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_send" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Socket_send" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (int)(arg1)->send((char const *)arg2); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_write(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Socket_write",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_write" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Socket_write" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Socket_write" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (int)(arg1)->write((char const *)arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Socket_read",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_read" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Socket_read" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Socket_read" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (int)(arg1)->read(arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_flush(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_flush",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_flush" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + result = (int)(arg1)->flush(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_setSocketTimeout(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + int arg2 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::Socket::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Socket_setSocketTimeout",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_setSocketTimeout" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Socket_setSocketTimeout" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Socket_setSocketTimeout" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (Gempa::CAPS::Socket::Status)(arg1)->setSocketTimeout(arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_setNonBlocking(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::Socket::Device::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Socket_setNonBlocking",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_setNonBlocking" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Socket_setNonBlocking" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + result = (arg1)->setNonBlocking(arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Socket::Device::Status(static_cast< const Gempa::CAPS::Socket::Device::Status& >(result))), SWIGTYPE_p_Gempa__CAPS__Socket__Device__Status, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_connect(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + std::string *arg2 = 0 ; + uint16_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + unsigned short val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::Socket::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:Socket_connect",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_connect" "', argument " "1"" of type '" "Gempa::CAPS::Socket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Socket_connect" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Socket_connect" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Socket_connect" "', argument " "3"" of type '" "uint16_t""'"); + } + arg3 = static_cast< uint16_t >(val3); + result = (Gempa::CAPS::Socket::Status)(arg1)->connect((std::string const &)*arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_rx(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Socket::count_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_rx",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_rx" "', argument " "1"" of type '" "Gempa::CAPS::Socket const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + result = (Gempa::CAPS::Socket::count_t)((Gempa::CAPS::Socket const *)arg1)->rx(); + resultobj = SWIG_From_unsigned_SS_long_SS_long(static_cast< unsigned long long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Socket_tx(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::Socket *arg1 = (Gempa::CAPS::Socket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Socket::count_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:Socket_tx",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__Socket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Socket_tx" "', argument " "1"" of type '" "Gempa::CAPS::Socket const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::Socket * >(argp1); + result = (Gempa::CAPS::Socket::count_t)((Gempa::CAPS::Socket const *)arg1)->tx(); + resultobj = SWIG_From_unsigned_SS_long_SS_long(static_cast< unsigned long long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *Socket_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__Socket, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_SSLSocket__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_SSLSocket")) SWIG_fail; + result = (Gempa::CAPS::SSLSocket *)new Gempa::CAPS::SSLSocket(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__SSLSocket, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SSLSocket__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::SSLSocket *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_SSLSocket",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_SSLSocket" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = reinterpret_cast< SSL_CTX * >(argp1); + result = (Gempa::CAPS::SSLSocket *)new Gempa::CAPS::SSLSocket(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__SSLSocket, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SSLSocket(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[2] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_SSLSocket__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SSL_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_SSLSocket__SWIG_1(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_SSLSocket'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::SSLSocket::SSLSocket()\n" + " Gempa::CAPS::SSLSocket::SSLSocket(SSL_CTX *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_SSLSocket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SSLSocket",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SSLSocket" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_write(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:SSLSocket_write",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_write" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SSLSocket_write" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SSLSocket_write" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (int)(arg1)->write((char const *)arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:SSLSocket_read",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_read" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SSLSocket_read" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SSLSocket_read" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (int)(arg1)->read(arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_connect(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + std::string *arg2 = 0 ; + uint16_t arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + unsigned short val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::Socket::Status result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:SSLSocket_connect",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_connect" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(obj1, &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SSLSocket_connect" "', argument " "2"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SSLSocket_connect" "', argument " "2"" of type '" "std::string const &""'"); + } + arg2 = ptr; + } + ecode3 = SWIG_AsVal_unsigned_SS_short(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SSLSocket_connect" "', argument " "3"" of type '" "uint16_t""'"); + } + arg3 = static_cast< uint16_t >(val3); + result = (Gempa::CAPS::Socket::Status)(arg1)->connect((std::string const &)*arg2,arg3); + resultobj = SWIG_From_int(static_cast< int >(result)); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_sessionID(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + unsigned char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SSLSocket_sessionID",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_sessionID" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + result = (unsigned char *)((Gempa::CAPS::SSLSocket const *)arg1)->sessionID(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_sessionIDLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + unsigned int result; + + if (!PyArg_ParseTuple(args,(char *)"O:SSLSocket_sessionIDLength",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_sessionIDLength" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket const *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + result = (unsigned int)((Gempa::CAPS::SSLSocket const *)arg1)->sessionIDLength(); + resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SSLSocket_peerCertificate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::SSLSocket *arg1 = (Gempa::CAPS::SSLSocket *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + X509 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SSLSocket_peerCertificate",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__SSLSocket, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SSLSocket_peerCertificate" "', argument " "1"" of type '" "Gempa::CAPS::SSLSocket *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::SSLSocket * >(argp1); + result = (X509 *)(arg1)->peerCertificate(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *SSLSocket_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__SSLSocket, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_charArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + size_t arg1 ; + size_t val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + charArray *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_charArray",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_size_t(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_charArray" "', argument " "1"" of type '" "size_t""'"); + } + arg1 = static_cast< size_t >(val1); + result = (charArray *)new_charArray(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_charArray, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_charArray(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + charArray *arg1 = (charArray *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_charArray",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_charArray, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_charArray" "', argument " "1"" of type '" "charArray *""'"); + } + arg1 = reinterpret_cast< charArray * >(argp1); + delete_charArray(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_charArray___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + charArray *arg1 = (charArray *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char result; + + if (!PyArg_ParseTuple(args,(char *)"OO:charArray___getitem__",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_charArray, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "charArray___getitem__" "', argument " "1"" of type '" "charArray *""'"); + } + arg1 = reinterpret_cast< charArray * >(argp1); + ecode2 = SWIG_AsVal_size_t(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "charArray___getitem__" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = static_cast< size_t >(val2); + result = (char)charArray___getitem__(arg1,arg2); + resultobj = SWIG_From_char(static_cast< char >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_charArray___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + charArray *arg1 = (charArray *) 0 ; + size_t arg2 ; + char arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + char val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:charArray___setitem__",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_charArray, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "charArray___setitem__" "', argument " "1"" of type '" "charArray *""'"); + } + arg1 = reinterpret_cast< charArray * >(argp1); + ecode2 = SWIG_AsVal_size_t(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "charArray___setitem__" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = static_cast< size_t >(val2); + ecode3 = SWIG_AsVal_char(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "charArray___setitem__" "', argument " "3"" of type '" "char""'"); + } + arg3 = static_cast< char >(val3); + charArray___setitem__(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_charArray_cast(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + charArray *arg1 = (charArray *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:charArray_cast",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_charArray, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "charArray_cast" "', argument " "1"" of type '" "charArray *""'"); + } + arg1 = reinterpret_cast< charArray * >(argp1); + result = (char *)charArray_cast(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_charArray_frompointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject * obj0 = 0 ; + charArray *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:charArray_frompointer",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "charArray_frompointer" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + result = (charArray *)charArray_frompointer(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_charArray, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return NULL; +} + + +SWIGINTERN PyObject *charArray_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_charArray, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_new_arraybuf__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::arraybuf *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_arraybuf",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_arraybuf" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_arraybuf" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = (Gempa::CAPS::arraybuf *)new Gempa::CAPS::arraybuf((char const *)arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__arraybuf, SWIG_POINTER_NEW | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_arraybuf__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + int res1 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + Gempa::CAPS::arraybuf *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_arraybuf",&obj0)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_arraybuf" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_arraybuf" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + result = (Gempa::CAPS::arraybuf *)new Gempa::CAPS::arraybuf((std::string const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gempa__CAPS__arraybuf, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_arraybuf(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_arraybuf__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_arraybuf__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_arraybuf'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::arraybuf::arraybuf(char const *,int)\n" + " Gempa::CAPS::arraybuf::arraybuf(std::string const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:arraybuf_reset",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_reset" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "arraybuf_reset" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "arraybuf_reset" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + (arg1)->reset((char const *)arg2,arg3); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_seekoff(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + Gempa::CAPS::arraybuf::off_type arg2 ; + std::ios_base::seekdir arg3 ; + std::ios_base::openmode arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + void *argp3 ; + int res3 = 0 ; + void *argp4 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + Gempa::CAPS::arraybuf::pos_type result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:arraybuf_seekoff",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_seekoff" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf__off_type, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "arraybuf_seekoff" "', argument " "2"" of type '" "Gempa::CAPS::arraybuf::off_type""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_seekoff" "', argument " "2"" of type '" "Gempa::CAPS::arraybuf::off_type""'"); + } else { + Gempa::CAPS::arraybuf::off_type * temp = reinterpret_cast< Gempa::CAPS::arraybuf::off_type * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + { + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__ios_base__seekdir, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "arraybuf_seekoff" "', argument " "3"" of type '" "std::ios_base::seekdir""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_seekoff" "', argument " "3"" of type '" "std::ios_base::seekdir""'"); + } else { + std::ios_base::seekdir * temp = reinterpret_cast< std::ios_base::seekdir * >(argp3); + arg3 = *temp; + if (SWIG_IsNewObj(res3)) delete temp; + } + } + { + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_std__ios_base__openmode, 0 | 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "arraybuf_seekoff" "', argument " "4"" of type '" "std::ios_base::openmode""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_seekoff" "', argument " "4"" of type '" "std::ios_base::openmode""'"); + } else { + std::ios_base::openmode * temp = reinterpret_cast< std::ios_base::openmode * >(argp4); + arg4 = *temp; + if (SWIG_IsNewObj(res4)) delete temp; + } + } + result = (arg1)->seekoff(arg2,arg3,arg4); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::arraybuf::pos_type(static_cast< const Gempa::CAPS::arraybuf::pos_type& >(result))), SWIGTYPE_p_std__streambuf__pos_type, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_seekpos(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + Gempa::CAPS::arraybuf::pos_type arg2 ; + std::ios_base::openmode arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + void *argp3 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + Gempa::CAPS::arraybuf::pos_type result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:arraybuf_seekpos",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_seekpos" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__streambuf__pos_type, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "arraybuf_seekpos" "', argument " "2"" of type '" "Gempa::CAPS::arraybuf::pos_type""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_seekpos" "', argument " "2"" of type '" "Gempa::CAPS::arraybuf::pos_type""'"); + } else { + Gempa::CAPS::arraybuf::pos_type * temp = reinterpret_cast< Gempa::CAPS::arraybuf::pos_type * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + { + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__ios_base__openmode, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "arraybuf_seekpos" "', argument " "3"" of type '" "std::ios_base::openmode""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_seekpos" "', argument " "3"" of type '" "std::ios_base::openmode""'"); + } else { + std::ios_base::openmode * temp = reinterpret_cast< std::ios_base::openmode * >(argp3); + arg3 = *temp; + if (SWIG_IsNewObj(res3)) delete temp; + } + } + result = (arg1)->seekpos(arg2,arg3); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::arraybuf::pos_type(static_cast< const Gempa::CAPS::arraybuf::pos_type& >(result))), SWIGTYPE_p_std__streambuf__pos_type, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_xsgetn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + char *arg2 = (char *) 0 ; + std::streamsize arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + std::streamsize result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:arraybuf_xsgetn",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_xsgetn" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "arraybuf_xsgetn" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__streamsize, 0 | 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "arraybuf_xsgetn" "', argument " "3"" of type '" "std::streamsize""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "arraybuf_xsgetn" "', argument " "3"" of type '" "std::streamsize""'"); + } else { + std::streamsize * temp = reinterpret_cast< std::streamsize * >(argp3); + arg3 = *temp; + if (SWIG_IsNewObj(res3)) delete temp; + } + } + result = (arg1)->xsgetn(arg2,arg3); + resultobj = SWIG_NewPointerObj((new std::streamsize(static_cast< const std::streamsize& >(result))), SWIGTYPE_p_std__streamsize, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_tellg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::streampos result; + + if (!PyArg_ParseTuple(args,(char *)"O:arraybuf_tellg",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_tellg" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + result = (arg1)->tellg(); + resultobj = SWIG_NewPointerObj((new std::streampos(static_cast< const std::streampos& >(result))), SWIGTYPE_p_std__streampos, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_arraybuf_tellp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::streampos result; + + if (!PyArg_ParseTuple(args,(char *)"O:arraybuf_tellp",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "arraybuf_tellp" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + result = (arg1)->tellp(); + resultobj = SWIG_NewPointerObj((new std::streampos(static_cast< const std::streampos& >(result))), SWIGTYPE_p_std__streampos, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_arraybuf(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::arraybuf *arg1 = (Gempa::CAPS::arraybuf *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_arraybuf",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Gempa__CAPS__arraybuf, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_arraybuf" "', argument " "1"" of type '" "Gempa::CAPS::arraybuf *""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::arraybuf * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *arraybuf_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_Gempa__CAPS__arraybuf, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *_wrap_splitAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + unsigned short *arg2 = 0 ; + std::string *arg3 = 0 ; + unsigned short arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 = SWIG_OLDOBJ ; + unsigned short val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:splitAddress",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "splitAddress" "', argument " "1"" of type '" "std::string &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "splitAddress" "', argument " "1"" of type '" "std::string &""'"); + } + arg1 = reinterpret_cast< std::string * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_unsigned_short, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "splitAddress" "', argument " "2"" of type '" "unsigned short &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "splitAddress" "', argument " "2"" of type '" "unsigned short &""'"); + } + arg2 = reinterpret_cast< unsigned short * >(argp2); + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(obj2, &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "splitAddress" "', argument " "3"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "splitAddress" "', argument " "3"" of type '" "std::string const &""'"); + } + arg3 = ptr; + } + ecode4 = SWIG_AsVal_unsigned_SS_short(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "splitAddress" "', argument " "4"" of type '" "unsigned short""'"); + } + arg4 = static_cast< unsigned short >(val4); + result = (bool)Gempa::CAPS::splitAddress(*arg1,*arg2,(std::string const &)*arg3,arg4); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (SWIG_IsNewObj(res3)) delete arg3; + return resultobj; +fail: + if (SWIG_IsNewObj(res3)) delete arg3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_tokenize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char **arg1 = 0 ; + char *arg2 = (char *) 0 ; + int *arg3 = 0 ; + int *arg4 = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:tokenize",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tokenize" "', argument " "1"" of type '" "char const *&""'"); + } + arg1 = &buf1; + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "tokenize" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "tokenize" "', argument " "3"" of type '" "int &""'"); + } + if (!argp3) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "tokenize" "', argument " "3"" of type '" "int &""'"); + } + arg3 = reinterpret_cast< int * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "tokenize" "', argument " "4"" of type '" "int &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "tokenize" "', argument " "4"" of type '" "int &""'"); + } + arg4 = reinterpret_cast< int * >(argp4); + result = (char *)Gempa::CAPS::tokenize((char const *&)*arg1,(char const *)arg2,*arg3,*arg4); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_trim__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char **arg1 = 0 ; + int *arg2 = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:trim",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "trim" "', argument " "1"" of type '" "char const *&""'"); + } + arg1 = &buf1; + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "trim" "', argument " "2"" of type '" "int &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "trim" "', argument " "2"" of type '" "int &""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + result = (char *)Gempa::CAPS::trim((char const *&)*arg1,*arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_trim__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + std::string *arg1 = 0 ; + int res1 = SWIG_OLDOBJ ; + PyObject * obj0 = 0 ; + std::string result; + + if (!PyArg_ParseTuple(args,(char *)"O:trim",&obj0)) SWIG_fail; + { + std::string *ptr = (std::string *)0; + res1 = SWIG_AsPtr_std_string(obj0, &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "trim" "', argument " "1"" of type '" "std::string const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "trim" "', argument " "1"" of type '" "std::string const &""'"); + } + arg1 = ptr; + } + result = Gempa::CAPS::trim((std::string const &)*arg1); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + if (SWIG_IsNewObj(res1)) delete arg1; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_trim(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + int res = SWIG_AsPtr_std_string(argv[0], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_trim__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_trim__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'trim'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::trim(char const *&,int &)\n" + " Gempa::CAPS::trim(std::string const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_timeToTimestamp(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = 0 ; + Gempa::CAPS::Time *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:timeToTimestamp",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "timeToTimestamp" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeToTimestamp" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__Time, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "timeToTimestamp" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeToTimestamp" "', argument " "2"" of type '" "Gempa::CAPS::Time const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::Time * >(argp2); + Gempa::CAPS::timeToTimestamp(*arg1,(Gempa::CAPS::Time const &)*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:str2int",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + arg1 = reinterpret_cast< int * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "str2int" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "str2int" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:str2int",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + arg1 = reinterpret_cast< int * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "str2int" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:str2int",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_int, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "int &""'"); + } + arg1 = reinterpret_cast< int * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint16_t *arg1 = 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:str2int",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_unsigned_short, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + arg1 = reinterpret_cast< uint16_t * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "str2int" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "str2int" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_7(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint16_t *arg1 = 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:str2int",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_unsigned_short, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + arg1 = reinterpret_cast< uint16_t * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "str2int" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2,arg3); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int__SWIG_8(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint16_t *arg1 = 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:str2int",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_unsigned_short, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "str2int" "', argument " "1"" of type '" "uint16_t &""'"); + } + arg1 = reinterpret_cast< uint16_t * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "str2int" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + result = (bool)Gempa::CAPS::str2int(*arg1,(char const *)arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_str2int(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + Py_ssize_t ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? PyObject_Length(args) : 0; + for (ii = 0; (ii < 4) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_str2int__SWIG_5(self, args); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_unsigned_short, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_str2int__SWIG_8(self, args); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_unsigned_short, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_str2int__SWIG_7(self, args); + } + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_str2int__SWIG_4(self, args); + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_int, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_str2int__SWIG_3(self, args); + } + } + } + } + } + if (argc == 4) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_unsigned_short, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_str2int__SWIG_6(self, args); + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'str2int'.\n" + " Possible C/C++ prototypes are:\n" + " Gempa::CAPS::str2int(int &,char const *,int,int)\n" + " Gempa::CAPS::str2int(int &,char const *,int)\n" + " Gempa::CAPS::str2int(int &,char const *)\n" + " Gempa::CAPS::str2int(uint16_t &,char const *,int,int)\n" + " Gempa::CAPS::str2int(uint16_t &,char const *,int)\n" + " Gempa::CAPS::str2int(uint16_t &,char const *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_timestampToTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::TimeStamp *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + Gempa::CAPS::Time result; + + if (!PyArg_ParseTuple(args,(char *)"O:timestampToTime",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__TimeStamp, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "timestampToTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timestampToTime" "', argument " "1"" of type '" "Gempa::CAPS::TimeStamp const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::TimeStamp * >(argp1); + result = Gempa::CAPS::timestampToTime((Gempa::CAPS::TimeStamp const &)*arg1); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::Time(static_cast< const Gempa::CAPS::Time& >(result))), SWIGTYPE_p_Gempa__CAPS__Time, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_samplesToTimeSpan(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord::Header *arg1 = 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + Gempa::CAPS::TimeSpan result; + + if (!PyArg_ParseTuple(args,(char *)"OO:samplesToTimeSpan",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "samplesToTimeSpan" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "samplesToTimeSpan" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "samplesToTimeSpan" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = Gempa::CAPS::samplesToTimeSpan((Gempa::CAPS::DataRecord::Header const &)*arg1,arg2); + resultobj = SWIG_NewPointerObj((new Gempa::CAPS::TimeSpan(static_cast< const Gempa::CAPS::TimeSpan& >(result))), SWIGTYPE_p_Gempa__CAPS__TimeSpan, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_timeSpanToSamples(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord::Header *arg1 = 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:timeSpanToSamples",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "timeSpanToSamples" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamples" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "timeSpanToSamples" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamples" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (int)Gempa::CAPS::timeSpanToSamples((Gempa::CAPS::DataRecord::Header const &)*arg1,(Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_timeSpanToSamplesCeil(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord::Header *arg1 = 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:timeSpanToSamplesCeil",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "timeSpanToSamplesCeil" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamplesCeil" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "timeSpanToSamplesCeil" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamplesCeil" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (int)Gempa::CAPS::timeSpanToSamplesCeil((Gempa::CAPS::DataRecord::Header const &)*arg1,(Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_timeSpanToSamplesFloor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataRecord::Header *arg1 = 0 ; + Gempa::CAPS::TimeSpan *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:timeSpanToSamplesFloor",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_Gempa__CAPS__DataRecord__Header, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "timeSpanToSamplesFloor" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamplesFloor" "', argument " "1"" of type '" "Gempa::CAPS::DataRecord::Header const &""'"); + } + arg1 = reinterpret_cast< Gempa::CAPS::DataRecord::Header * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_Gempa__CAPS__TimeSpan, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "timeSpanToSamplesFloor" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "timeSpanToSamplesFloor" "', argument " "2"" of type '" "Gempa::CAPS::TimeSpan const &""'"); + } + arg2 = reinterpret_cast< Gempa::CAPS::TimeSpan * >(argp2); + result = (int)Gempa::CAPS::timeSpanToSamplesFloor((Gempa::CAPS::DataRecord::Header const &)*arg1,(Gempa::CAPS::TimeSpan const &)*arg2); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dataTypeSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Gempa::CAPS::DataType arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:dataTypeSize",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dataTypeSize" "', argument " "1"" of type '" "Gempa::CAPS::DataType""'"); + } + arg1 = static_cast< Gempa::CAPS::DataType >(val1); + result = (uint8_t)Gempa::CAPS::dataTypeSize(arg1); + resultobj = SWIG_From_unsigned_SS_char(static_cast< unsigned char >(result)); + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"new_TimeSpan", _wrap_new_TimeSpan, METH_VARARGS, NULL}, + { (char *)"TimeSpan___eq__", _wrap_TimeSpan___eq__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___ne__", _wrap_TimeSpan___ne__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___lt__", _wrap_TimeSpan___lt__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___le__", _wrap_TimeSpan___le__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___gt__", _wrap_TimeSpan___gt__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___ge__", _wrap_TimeSpan___ge__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___add__", _wrap_TimeSpan___add__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___sub__", _wrap_TimeSpan___sub__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___iadd__", _wrap_TimeSpan___iadd__, METH_VARARGS, NULL}, + { (char *)"TimeSpan___isub__", _wrap_TimeSpan___isub__, METH_VARARGS, NULL}, + { (char *)"TimeSpan_abs", _wrap_TimeSpan_abs, METH_VARARGS, NULL}, + { (char *)"TimeSpan_seconds", _wrap_TimeSpan_seconds, METH_VARARGS, NULL}, + { (char *)"TimeSpan_microseconds", _wrap_TimeSpan_microseconds, METH_VARARGS, NULL}, + { (char *)"TimeSpan_length", _wrap_TimeSpan_length, METH_VARARGS, NULL}, + { (char *)"TimeSpan_set", _wrap_TimeSpan_set, METH_VARARGS, NULL}, + { (char *)"TimeSpan_setUSecs", _wrap_TimeSpan_setUSecs, METH_VARARGS, NULL}, + { (char *)"TimeSpan_elapsedTime", _wrap_TimeSpan_elapsedTime, METH_VARARGS, NULL}, + { (char *)"delete_TimeSpan", _wrap_delete_TimeSpan, METH_VARARGS, NULL}, + { (char *)"TimeSpan_swigregister", TimeSpan_swigregister, METH_VARARGS, NULL}, + { (char *)"new_Time", _wrap_new_Time, METH_VARARGS, NULL}, + { (char *)"Time___nonzero__", _wrap_Time___nonzero__, METH_VARARGS, NULL}, + { (char *)"Time___add__", _wrap_Time___add__, METH_VARARGS, NULL}, + { (char *)"Time___sub__", _wrap_Time___sub__, METH_VARARGS, NULL}, + { (char *)"Time___iadd__", _wrap_Time___iadd__, METH_VARARGS, NULL}, + { (char *)"Time___isub__", _wrap_Time___isub__, METH_VARARGS, NULL}, + { (char *)"Time_set", _wrap_Time_set, METH_VARARGS, NULL}, + { (char *)"Time_get", _wrap_Time_get, METH_VARARGS, NULL}, + { (char *)"Time_get2", _wrap_Time_get2, METH_VARARGS, NULL}, + { (char *)"Time_LocalTime", _wrap_Time_LocalTime, METH_VARARGS, NULL}, + { (char *)"Time_GMT", _wrap_Time_GMT, METH_VARARGS, NULL}, + { (char *)"Time_FromYearDay", _wrap_Time_FromYearDay, METH_VARARGS, NULL}, + { (char *)"Time_localtime", _wrap_Time_localtime, METH_VARARGS, NULL}, + { (char *)"Time_gmt", _wrap_Time_gmt, METH_VARARGS, NULL}, + { (char *)"Time_toLocalTime", _wrap_Time_toLocalTime, METH_VARARGS, NULL}, + { (char *)"Time_toGMT", _wrap_Time_toGMT, METH_VARARGS, NULL}, + { (char *)"Time_valid", _wrap_Time_valid, METH_VARARGS, NULL}, + { (char *)"Time_toString", _wrap_Time_toString, METH_VARARGS, NULL}, + { (char *)"Time_iso", _wrap_Time_iso, METH_VARARGS, NULL}, + { (char *)"Time_fromString", _wrap_Time_fromString, METH_VARARGS, NULL}, + { (char *)"Time_FromString", _wrap_Time_FromString, METH_VARARGS, NULL}, + { (char *)"delete_Time", _wrap_delete_Time, METH_VARARGS, NULL}, + { (char *)"Time_swigregister", Time_swigregister, METH_VARARGS, NULL}, + { (char *)"UOM_str_set", _wrap_UOM_str_set, METH_VARARGS, NULL}, + { (char *)"UOM_str_get", _wrap_UOM_str_get, METH_VARARGS, NULL}, + { (char *)"UOM_ID_set", _wrap_UOM_ID_set, METH_VARARGS, NULL}, + { (char *)"UOM_ID_get", _wrap_UOM_ID_get, METH_VARARGS, NULL}, + { (char *)"new_UOM", _wrap_new_UOM, METH_VARARGS, NULL}, + { (char *)"delete_UOM", _wrap_delete_UOM, METH_VARARGS, NULL}, + { (char *)"UOM_swigregister", UOM_swigregister, METH_VARARGS, NULL}, + { (char *)"Quality_str_set", _wrap_Quality_str_set, METH_VARARGS, NULL}, + { (char *)"Quality_str_get", _wrap_Quality_str_get, METH_VARARGS, NULL}, + { (char *)"Quality_ID_set", _wrap_Quality_ID_set, METH_VARARGS, NULL}, + { (char *)"Quality_ID_get", _wrap_Quality_ID_get, METH_VARARGS, NULL}, + { (char *)"new_Quality", _wrap_new_Quality, METH_VARARGS, NULL}, + { (char *)"delete_Quality", _wrap_delete_Quality, METH_VARARGS, NULL}, + { (char *)"Quality_swigregister", Quality_swigregister, METH_VARARGS, NULL}, + { (char *)"TimeStamp_year_set", _wrap_TimeStamp_year_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_year_get", _wrap_TimeStamp_year_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_yday_set", _wrap_TimeStamp_yday_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_yday_get", _wrap_TimeStamp_yday_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_hour_set", _wrap_TimeStamp_hour_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_hour_get", _wrap_TimeStamp_hour_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_minute_set", _wrap_TimeStamp_minute_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_minute_get", _wrap_TimeStamp_minute_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_second_set", _wrap_TimeStamp_second_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_second_get", _wrap_TimeStamp_second_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_unused_set", _wrap_TimeStamp_unused_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_unused_get", _wrap_TimeStamp_unused_get, METH_VARARGS, NULL}, + { (char *)"TimeStamp_usec_set", _wrap_TimeStamp_usec_set, METH_VARARGS, NULL}, + { (char *)"TimeStamp_usec_get", _wrap_TimeStamp_usec_get, METH_VARARGS, NULL}, + { (char *)"new_TimeStamp", _wrap_new_TimeStamp, METH_VARARGS, NULL}, + { (char *)"delete_TimeStamp", _wrap_delete_TimeStamp, METH_VARARGS, NULL}, + { (char *)"TimeStamp_swigregister", TimeStamp_swigregister, METH_VARARGS, NULL}, + { (char *)"new_PacketDataHeader", _wrap_new_PacketDataHeader, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_version_set", _wrap_PacketDataHeader_version_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_version_get", _wrap_PacketDataHeader_version_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_packetType_set", _wrap_PacketDataHeader_packetType_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_packetType_get", _wrap_PacketDataHeader_packetType_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_unitOfMeasurement_set", _wrap_PacketDataHeader_unitOfMeasurement_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_unitOfMeasurement_get", _wrap_PacketDataHeader_unitOfMeasurement_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_setUOM", _wrap_PacketDataHeader_setUOM, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_uom", _wrap_PacketDataHeader_uom, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader___ne__", _wrap_PacketDataHeader___ne__, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_dataSize", _wrap_PacketDataHeader_dataSize, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_put", _wrap_PacketDataHeader_put, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_get", _wrap_PacketDataHeader_get, METH_VARARGS, NULL}, + { (char *)"delete_PacketDataHeader", _wrap_delete_PacketDataHeader, METH_VARARGS, NULL}, + { (char *)"PacketDataHeader_swigregister", PacketDataHeader_swigregister, METH_VARARGS, NULL}, + { (char *)"new_PacketDataHeaderV2", _wrap_new_PacketDataHeaderV2, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_samplingFrequencyNumerator_set", _wrap_PacketDataHeaderV2_samplingFrequencyNumerator_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_samplingFrequencyNumerator_get", _wrap_PacketDataHeaderV2_samplingFrequencyNumerator_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_samplingFrequencyDenominator_set", _wrap_PacketDataHeaderV2_samplingFrequencyDenominator_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_samplingFrequencyDenominator_get", _wrap_PacketDataHeaderV2_samplingFrequencyDenominator_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_quality_set", _wrap_PacketDataHeaderV2_quality_set, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_quality_get", _wrap_PacketDataHeaderV2_quality_get, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2___ne__", _wrap_PacketDataHeaderV2___ne__, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_dataSize", _wrap_PacketDataHeaderV2_dataSize, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_put", _wrap_PacketDataHeaderV2_put, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_get", _wrap_PacketDataHeaderV2_get, METH_VARARGS, NULL}, + { (char *)"delete_PacketDataHeaderV2", _wrap_delete_PacketDataHeaderV2, METH_VARARGS, NULL}, + { (char *)"PacketDataHeaderV2_swigregister", PacketDataHeaderV2_swigregister, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_SIDSize_set", _wrap_PacketHeaderV1_SIDSize_set, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_SIDSize_get", _wrap_PacketHeaderV1_SIDSize_get, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_size_set", _wrap_PacketHeaderV1_size_set, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_size_get", _wrap_PacketHeaderV1_size_get, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_put", _wrap_PacketHeaderV1_put, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_dataSize", _wrap_PacketHeaderV1_dataSize, METH_VARARGS, NULL}, + { (char *)"new_PacketHeaderV1", _wrap_new_PacketHeaderV1, METH_VARARGS, NULL}, + { (char *)"delete_PacketHeaderV1", _wrap_delete_PacketHeaderV1, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV1_swigregister", PacketHeaderV1_swigregister, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_SIDSize_set", _wrap_PacketHeaderV2_SIDSize_set, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_SIDSize_get", _wrap_PacketHeaderV2_SIDSize_get, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_size_set", _wrap_PacketHeaderV2_size_set, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_size_get", _wrap_PacketHeaderV2_size_get, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_put", _wrap_PacketHeaderV2_put, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_dataSize", _wrap_PacketHeaderV2_dataSize, METH_VARARGS, NULL}, + { (char *)"new_PacketHeaderV2", _wrap_new_PacketHeaderV2, METH_VARARGS, NULL}, + { (char *)"delete_PacketHeaderV2", _wrap_delete_PacketHeaderV2, METH_VARARGS, NULL}, + { (char *)"PacketHeaderV2_swigregister", PacketHeaderV2_swigregister, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_id_set", _wrap_ResponseHeader_id_set, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_id_get", _wrap_ResponseHeader_id_get, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_size_set", _wrap_ResponseHeader_size_set, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_size_get", _wrap_ResponseHeader_size_get, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_get", _wrap_ResponseHeader_get, METH_VARARGS, NULL}, + { (char *)"new_ResponseHeader", _wrap_new_ResponseHeader, METH_VARARGS, NULL}, + { (char *)"delete_ResponseHeader", _wrap_delete_ResponseHeader, METH_VARARGS, NULL}, + { (char *)"ResponseHeader_swigregister", ResponseHeader_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_DataRecord", _wrap_delete_DataRecord, METH_VARARGS, NULL}, + { (char *)"DataRecord_formatName", _wrap_DataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"DataRecord_readMetaData", _wrap_DataRecord_readMetaData, METH_VARARGS, NULL}, + { (char *)"DataRecord_canTrim", _wrap_DataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"DataRecord_canMerge", _wrap_DataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"DataRecord_trim", _wrap_DataRecord_trim, METH_VARARGS, NULL}, + { (char *)"DataRecord_dataSize", _wrap_DataRecord_dataSize, METH_VARARGS, NULL}, + { (char *)"DataRecord_get", _wrap_DataRecord_get, METH_VARARGS, NULL}, + { (char *)"DataRecord_put", _wrap_DataRecord_put, METH_VARARGS, NULL}, + { (char *)"DataRecord_header", _wrap_DataRecord_header, METH_VARARGS, NULL}, + { (char *)"DataRecord_startTime", _wrap_DataRecord_startTime, METH_VARARGS, NULL}, + { (char *)"DataRecord_endTime", _wrap_DataRecord_endTime, METH_VARARGS, NULL}, + { (char *)"DataRecord_packetType", _wrap_DataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"DataRecord_buffer", _wrap_DataRecord_buffer, METH_VARARGS, NULL}, + { (char *)"DataRecord_data", _wrap_DataRecord_data, METH_VARARGS, NULL}, + { (char *)"DataRecord_swigregister", DataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"RawPacket_header_set", _wrap_RawPacket_header_set, METH_VARARGS, NULL}, + { (char *)"RawPacket_header_get", _wrap_RawPacket_header_get, METH_VARARGS, NULL}, + { (char *)"RawPacket_SID_set", _wrap_RawPacket_SID_set, METH_VARARGS, NULL}, + { (char *)"RawPacket_SID_get", _wrap_RawPacket_SID_get, METH_VARARGS, NULL}, + { (char *)"RawPacket_data_set", _wrap_RawPacket_data_set, METH_VARARGS, NULL}, + { (char *)"RawPacket_data_get", _wrap_RawPacket_data_get, METH_VARARGS, NULL}, + { (char *)"RawPacket_record_set", _wrap_RawPacket_record_set, METH_VARARGS, NULL}, + { (char *)"RawPacket_record_get", _wrap_RawPacket_record_get, METH_VARARGS, NULL}, + { (char *)"new_RawPacket", _wrap_new_RawPacket, METH_VARARGS, NULL}, + { (char *)"delete_RawPacket", _wrap_delete_RawPacket, METH_VARARGS, NULL}, + { (char *)"RawPacket_swigregister", RawPacket_swigregister, METH_VARARGS, NULL}, + { (char *)"MetaPacket_SID_set", _wrap_MetaPacket_SID_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_SID_get", _wrap_MetaPacket_SID_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_packetDataHeader_set", _wrap_MetaPacket_packetDataHeader_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_packetDataHeader_get", _wrap_MetaPacket_packetDataHeader_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_record_set", _wrap_MetaPacket_record_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_record_get", _wrap_MetaPacket_record_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_recordHeader_set", _wrap_MetaPacket_recordHeader_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_recordHeader_get", _wrap_MetaPacket_recordHeader_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_startTime_set", _wrap_MetaPacket_startTime_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_startTime_get", _wrap_MetaPacket_startTime_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_endTime_set", _wrap_MetaPacket_endTime_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_endTime_get", _wrap_MetaPacket_endTime_get, METH_VARARGS, NULL}, + { (char *)"MetaPacket_timestamp_set", _wrap_MetaPacket_timestamp_set, METH_VARARGS, NULL}, + { (char *)"MetaPacket_timestamp_get", _wrap_MetaPacket_timestamp_get, METH_VARARGS, NULL}, + { (char *)"new_MetaPacket", _wrap_new_MetaPacket, METH_VARARGS, NULL}, + { (char *)"delete_MetaPacket", _wrap_delete_MetaPacket, METH_VARARGS, NULL}, + { (char *)"MetaPacket_swigregister", MetaPacket_swigregister, METH_VARARGS, NULL}, + { (char *)"new_Packet", _wrap_new_Packet, METH_VARARGS, NULL}, + { (char *)"Packet_clone", _wrap_Packet_clone, METH_VARARGS, NULL}, + { (char *)"Packet_buffer_set", _wrap_Packet_buffer_set, METH_VARARGS, NULL}, + { (char *)"Packet_buffer_get", _wrap_Packet_buffer_get, METH_VARARGS, NULL}, + { (char *)"Packet_record_set", _wrap_Packet_record_set, METH_VARARGS, NULL}, + { (char *)"Packet_record_get", _wrap_Packet_record_get, METH_VARARGS, NULL}, + { (char *)"Packet_networkCode_set", _wrap_Packet_networkCode_set, METH_VARARGS, NULL}, + { (char *)"Packet_networkCode_get", _wrap_Packet_networkCode_get, METH_VARARGS, NULL}, + { (char *)"Packet_stationCode_set", _wrap_Packet_stationCode_set, METH_VARARGS, NULL}, + { (char *)"Packet_stationCode_get", _wrap_Packet_stationCode_get, METH_VARARGS, NULL}, + { (char *)"Packet_locationCode_set", _wrap_Packet_locationCode_set, METH_VARARGS, NULL}, + { (char *)"Packet_locationCode_get", _wrap_Packet_locationCode_get, METH_VARARGS, NULL}, + { (char *)"Packet_channelCode_set", _wrap_Packet_channelCode_set, METH_VARARGS, NULL}, + { (char *)"Packet_channelCode_get", _wrap_Packet_channelCode_get, METH_VARARGS, NULL}, + { (char *)"Packet_streamID_set", _wrap_Packet_streamID_set, METH_VARARGS, NULL}, + { (char *)"Packet_streamID_get", _wrap_Packet_streamID_get, METH_VARARGS, NULL}, + { (char *)"Packet_dataType_set", _wrap_Packet_dataType_set, METH_VARARGS, NULL}, + { (char *)"Packet_dataType_get", _wrap_Packet_dataType_get, METH_VARARGS, NULL}, + { (char *)"Packet_dt_us_set", _wrap_Packet_dt_us_set, METH_VARARGS, NULL}, + { (char *)"Packet_dt_us_get", _wrap_Packet_dt_us_get, METH_VARARGS, NULL}, + { (char *)"Packet_uom_set", _wrap_Packet_uom_set, METH_VARARGS, NULL}, + { (char *)"Packet_uom_get", _wrap_Packet_uom_get, METH_VARARGS, NULL}, + { (char *)"Packet_timingQuality_set", _wrap_Packet_timingQuality_set, METH_VARARGS, NULL}, + { (char *)"Packet_timingQuality_get", _wrap_Packet_timingQuality_get, METH_VARARGS, NULL}, + { (char *)"Packet_size", _wrap_Packet_size, METH_VARARGS, NULL}, + { (char *)"delete_Packet", _wrap_delete_Packet, METH_VARARGS, NULL}, + { (char *)"Packet_swigregister", Packet_swigregister, METH_VARARGS, NULL}, + { (char *)"new_AnyDataRecord", _wrap_new_AnyDataRecord, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_setType", _wrap_AnyDataRecord_setType, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_type", _wrap_AnyDataRecord_type, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_formatName", _wrap_AnyDataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_readMetaData", _wrap_AnyDataRecord_readMetaData, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_header", _wrap_AnyDataRecord_header, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_startTime", _wrap_AnyDataRecord_startTime, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_endTime", _wrap_AnyDataRecord_endTime, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_canTrim", _wrap_AnyDataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_canMerge", _wrap_AnyDataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_trim", _wrap_AnyDataRecord_trim, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_dataSize", _wrap_AnyDataRecord_dataSize, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_get", _wrap_AnyDataRecord_get, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_put", _wrap_AnyDataRecord_put, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_packetType", _wrap_AnyDataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_setStartTime", _wrap_AnyDataRecord_setStartTime, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_setEndTime", _wrap_AnyDataRecord_setEndTime, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_setSamplingFrequency", _wrap_AnyDataRecord_setSamplingFrequency, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_data", _wrap_AnyDataRecord_data, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_setData", _wrap_AnyDataRecord_setData, METH_VARARGS, NULL}, + { (char *)"delete_AnyDataRecord", _wrap_delete_AnyDataRecord, METH_VARARGS, NULL}, + { (char *)"AnyDataRecord_swigregister", AnyDataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"SetLogHandler", _wrap_SetLogHandler, METH_VARARGS, NULL}, + { (char *)"SPClock_freqn_get", _wrap_SPClock_freqn_get, METH_VARARGS, NULL}, + { (char *)"SPClock_freqd_get", _wrap_SPClock_freqd_get, METH_VARARGS, NULL}, + { (char *)"new_SPClock", _wrap_new_SPClock, METH_VARARGS, NULL}, + { (char *)"SPClock_sync_time", _wrap_SPClock_sync_time, METH_VARARGS, NULL}, + { (char *)"SPClock_tick", _wrap_SPClock_tick, METH_VARARGS, NULL}, + { (char *)"SPClock_get_time", _wrap_SPClock_get_time, METH_VARARGS, NULL}, + { (char *)"SPClock_correction", _wrap_SPClock_correction, METH_VARARGS, NULL}, + { (char *)"delete_SPClock", _wrap_delete_SPClock, METH_VARARGS, NULL}, + { (char *)"SPClock_swigregister", SPClock_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_Encoder", _wrap_delete_Encoder, METH_VARARGS, NULL}, + { (char *)"Encoder_push", _wrap_Encoder_push, METH_VARARGS, NULL}, + { (char *)"Encoder_flush", _wrap_Encoder_flush, METH_VARARGS, NULL}, + { (char *)"Encoder_reset", _wrap_Encoder_reset, METH_VARARGS, NULL}, + { (char *)"Encoder_type", _wrap_Encoder_type, METH_VARARGS, NULL}, + { (char *)"Encoder_clk", _wrap_Encoder_clk, METH_VARARGS, NULL}, + { (char *)"Encoder_setStartTime", _wrap_Encoder_setStartTime, METH_VARARGS, NULL}, + { (char *)"Encoder_currentTime", _wrap_Encoder_currentTime, METH_VARARGS, NULL}, + { (char *)"Encoder_timingQuality", _wrap_Encoder_timingQuality, METH_VARARGS, NULL}, + { (char *)"Encoder_setTimingQuality", _wrap_Encoder_setTimingQuality, METH_VARARGS, NULL}, + { (char *)"Encoder_pop", _wrap_Encoder_pop, METH_VARARGS, NULL}, + { (char *)"Encoder_swigregister", Encoder_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_EncoderFactory", _wrap_delete_EncoderFactory, METH_VARARGS, NULL}, + { (char *)"EncoderFactory_create", _wrap_EncoderFactory_create, METH_VARARGS, NULL}, + { (char *)"EncoderFactory_supportsRecord", _wrap_EncoderFactory_supportsRecord, METH_VARARGS, NULL}, + { (char *)"EncoderFactory_errorString", _wrap_EncoderFactory_errorString, METH_VARARGS, NULL}, + { (char *)"EncoderFactory_swigregister", EncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"MSEEDEncoderFactory_setRecordLength", _wrap_MSEEDEncoderFactory_setRecordLength, METH_VARARGS, NULL}, + { (char *)"delete_MSEEDEncoderFactory", _wrap_delete_MSEEDEncoderFactory, METH_VARARGS, NULL}, + { (char *)"MSEEDEncoderFactory_swigregister", MSEEDEncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"SteimEncoderFactory_supportsRecord", _wrap_SteimEncoderFactory_supportsRecord, METH_VARARGS, NULL}, + { (char *)"delete_SteimEncoderFactory", _wrap_delete_SteimEncoderFactory, METH_VARARGS, NULL}, + { (char *)"SteimEncoderFactory_swigregister", SteimEncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"IdentityEncoderFactory_create", _wrap_IdentityEncoderFactory_create, METH_VARARGS, NULL}, + { (char *)"IdentityEncoderFactory_supportsRecord", _wrap_IdentityEncoderFactory_supportsRecord, METH_VARARGS, NULL}, + { (char *)"new_IdentityEncoderFactory", _wrap_new_IdentityEncoderFactory, METH_VARARGS, NULL}, + { (char *)"delete_IdentityEncoderFactory", _wrap_delete_IdentityEncoderFactory, METH_VARARGS, NULL}, + { (char *)"IdentityEncoderFactory_swigregister", IdentityEncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"Steim1EncoderFactory_create", _wrap_Steim1EncoderFactory_create, METH_VARARGS, NULL}, + { (char *)"new_Steim1EncoderFactory", _wrap_new_Steim1EncoderFactory, METH_VARARGS, NULL}, + { (char *)"delete_Steim1EncoderFactory", _wrap_delete_Steim1EncoderFactory, METH_VARARGS, NULL}, + { (char *)"Steim1EncoderFactory_swigregister", Steim1EncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"Steim2EncoderFactory_create", _wrap_Steim2EncoderFactory_create, METH_VARARGS, NULL}, + { (char *)"new_Steim2EncoderFactory", _wrap_new_Steim2EncoderFactory, METH_VARARGS, NULL}, + { (char *)"delete_Steim2EncoderFactory", _wrap_delete_Steim2EncoderFactory, METH_VARARGS, NULL}, + { (char *)"Steim2EncoderFactory_swigregister", Steim2EncoderFactory_swigregister, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_formatName", _wrap_MSEEDDataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_readMetaData", _wrap_MSEEDDataRecord_readMetaData, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_header", _wrap_MSEEDDataRecord_header, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_startTime", _wrap_MSEEDDataRecord_startTime, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_endTime", _wrap_MSEEDDataRecord_endTime, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_canTrim", _wrap_MSEEDDataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_canMerge", _wrap_MSEEDDataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_trim", _wrap_MSEEDDataRecord_trim, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_dataSize", _wrap_MSEEDDataRecord_dataSize, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_get", _wrap_MSEEDDataRecord_get, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_put", _wrap_MSEEDDataRecord_put, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_packetType", _wrap_MSEEDDataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_setData", _wrap_MSEEDDataRecord_setData, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_unpackHeader", _wrap_MSEEDDataRecord_unpackHeader, METH_VARARGS, NULL}, + { (char *)"delete_MSEEDDataRecord", _wrap_delete_MSEEDDataRecord, METH_VARARGS, NULL}, + { (char *)"MSEEDDataRecord_swigregister", MSEEDDataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"new_Plugin", _wrap_new_Plugin, METH_VARARGS, NULL}, + { (char *)"delete_Plugin", _wrap_delete_Plugin, METH_VARARGS, NULL}, + { (char *)"Plugin_close", _wrap_Plugin_close, METH_VARARGS, NULL}, + { (char *)"Plugin_quit", _wrap_Plugin_quit, METH_VARARGS, NULL}, + { (char *)"Plugin_enableLogging", _wrap_Plugin_enableLogging, METH_VARARGS, NULL}, + { (char *)"Plugin_setBackfillingBufferSize", _wrap_Plugin_setBackfillingBufferSize, METH_VARARGS, NULL}, + { (char *)"Plugin_backfillingBufferSize", _wrap_Plugin_backfillingBufferSize, METH_VARARGS, NULL}, + { (char *)"Plugin_isExitRequested", _wrap_Plugin_isExitRequested, METH_VARARGS, NULL}, + { (char *)"Plugin_stats", _wrap_Plugin_stats, METH_VARARGS, NULL}, + { (char *)"Plugin_resetMaxBytesBuffered", _wrap_Plugin_resetMaxBytesBuffered, METH_VARARGS, NULL}, + { (char *)"Plugin_setEncoderFactory", _wrap_Plugin_setEncoderFactory, METH_VARARGS, NULL}, + { (char *)"Plugin_setHost", _wrap_Plugin_setHost, METH_VARARGS, NULL}, + { (char *)"Plugin_host", _wrap_Plugin_host, METH_VARARGS, NULL}, + { (char *)"Plugin_setPort", _wrap_Plugin_setPort, METH_VARARGS, NULL}, + { (char *)"Plugin_port", _wrap_Plugin_port, METH_VARARGS, NULL}, + { (char *)"Plugin_setBufferSize", _wrap_Plugin_setBufferSize, METH_VARARGS, NULL}, + { (char *)"Plugin_bufferSize", _wrap_Plugin_bufferSize, METH_VARARGS, NULL}, + { (char *)"Plugin_setSSLEnabled", _wrap_Plugin_setSSLEnabled, METH_VARARGS, NULL}, + { (char *)"Plugin_setCredentials", _wrap_Plugin_setCredentials, METH_VARARGS, NULL}, + { (char *)"Plugin_setMaxFutureEndTime", _wrap_Plugin_setMaxFutureEndTime, METH_VARARGS, NULL}, + { (char *)"Plugin_setPacketAckFunc", _wrap_Plugin_setPacketAckFunc, METH_VARARGS, NULL}, + { (char *)"Plugin_setSendTimeout", _wrap_Plugin_setSendTimeout, METH_VARARGS, NULL}, + { (char *)"Plugin_setTimeouts", _wrap_Plugin_setTimeouts, METH_VARARGS, NULL}, + { (char *)"Plugin_readJournal", _wrap_Plugin_readJournal, METH_VARARGS, NULL}, + { (char *)"Plugin_setJournal", _wrap_Plugin_setJournal, METH_VARARGS, NULL}, + { (char *)"Plugin_setFlushInterval", _wrap_Plugin_setFlushInterval, METH_VARARGS, NULL}, + { (char *)"Plugin_streamStates", _wrap_Plugin_streamStates, METH_VARARGS, NULL}, + { (char *)"Plugin_writeJournal", _wrap_Plugin_writeJournal, METH_VARARGS, NULL}, + { (char *)"Plugin_version", _wrap_Plugin_version, METH_VARARGS, NULL}, + { (char *)"Plugin_push", _wrap_Plugin_push, METH_VARARGS, NULL}, + { (char *)"Plugin_swigregister", Plugin_swigregister, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_timeSeconds_set", _wrap_RawResponseHeader_timeSeconds_set, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_timeSeconds_get", _wrap_RawResponseHeader_timeSeconds_get, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_timeMicroSeconds_set", _wrap_RawResponseHeader_timeMicroSeconds_set, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_timeMicroSeconds_get", _wrap_RawResponseHeader_timeMicroSeconds_get, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_get", _wrap_RawResponseHeader_get, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_dataSize", _wrap_RawResponseHeader_dataSize, METH_VARARGS, NULL}, + { (char *)"new_RawResponseHeader", _wrap_new_RawResponseHeader, METH_VARARGS, NULL}, + { (char *)"delete_RawResponseHeader", _wrap_delete_RawResponseHeader, METH_VARARGS, NULL}, + { (char *)"RawResponseHeader_swigregister", RawResponseHeader_swigregister, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_formatName", _wrap_RawDataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_readMetaData", _wrap_RawDataRecord_readMetaData, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_setHeader", _wrap_RawDataRecord_setHeader, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_header", _wrap_RawDataRecord_header, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_startTime", _wrap_RawDataRecord_startTime, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_endTime", _wrap_RawDataRecord_endTime, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_canTrim", _wrap_RawDataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_canMerge", _wrap_RawDataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_trim", _wrap_RawDataRecord_trim, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_dataSize", _wrap_RawDataRecord_dataSize, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_get", _wrap_RawDataRecord_get, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_getData", _wrap_RawDataRecord_getData, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_put", _wrap_RawDataRecord_put, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_packetType", _wrap_RawDataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_setStartTime", _wrap_RawDataRecord_setStartTime, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_setSamplingFrequency", _wrap_RawDataRecord_setSamplingFrequency, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_setDataType", _wrap_RawDataRecord_setDataType, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_setBuffer", _wrap_RawDataRecord_setBuffer, METH_VARARGS, NULL}, + { (char *)"delete_RawDataRecord", _wrap_delete_RawDataRecord, METH_VARARGS, NULL}, + { (char *)"RawDataRecord_swigregister", RawDataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_canTrim", _wrap_FixedRawDataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_canMerge", _wrap_FixedRawDataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_trim", _wrap_FixedRawDataRecord_trim, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_formatName", _wrap_FixedRawDataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_get", _wrap_FixedRawDataRecord_get, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_packetType", _wrap_FixedRawDataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"delete_FixedRawDataRecord", _wrap_delete_FixedRawDataRecord, METH_VARARGS, NULL}, + { (char *)"FixedRawDataRecord_swigregister", FixedRawDataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_chunkSize_set", _wrap_ChunkHeader_chunkSize_set, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_chunkSize_get", _wrap_ChunkHeader_chunkSize_get, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_setChunkType", _wrap_ChunkHeader_setChunkType, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_isChunkType", _wrap_ChunkHeader_isChunkType, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_validChunkType", _wrap_ChunkHeader_validChunkType, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_dataSize", _wrap_ChunkHeader_dataSize, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_read", _wrap_ChunkHeader_read, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_write", _wrap_ChunkHeader_write, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_get", _wrap_ChunkHeader_get, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_put", _wrap_ChunkHeader_put, METH_VARARGS, NULL}, + { (char *)"new_ChunkHeader", _wrap_new_ChunkHeader, METH_VARARGS, NULL}, + { (char *)"delete_ChunkHeader", _wrap_delete_ChunkHeader, METH_VARARGS, NULL}, + { (char *)"ChunkHeader_swigregister", ChunkHeader_swigregister, METH_VARARGS, NULL}, + { (char *)"new_ChunkIterator", _wrap_new_ChunkIterator, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_begin", _wrap_ChunkIterator_begin, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_next", _wrap_ChunkIterator_next, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_header", _wrap_ChunkIterator_header, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_headerPos", _wrap_ChunkIterator_headerPos, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_contentPos", _wrap_ChunkIterator_contentPos, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_istream", _wrap_ChunkIterator_istream, METH_VARARGS, NULL}, + { (char *)"delete_ChunkIterator", _wrap_delete_ChunkIterator, METH_VARARGS, NULL}, + { (char *)"ChunkIterator_swigregister", ChunkIterator_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_Chunk", _wrap_delete_Chunk, METH_VARARGS, NULL}, + { (char *)"Chunk_read", _wrap_Chunk_read, METH_VARARGS, NULL}, + { (char *)"Chunk_write", _wrap_Chunk_write, METH_VARARGS, NULL}, + { (char *)"Chunk_get", _wrap_Chunk_get, METH_VARARGS, NULL}, + { (char *)"Chunk_put", _wrap_Chunk_put, METH_VARARGS, NULL}, + { (char *)"Chunk_chunkSize", _wrap_Chunk_chunkSize, METH_VARARGS, NULL}, + { (char *)"Chunk_swigregister", Chunk_swigregister, METH_VARARGS, NULL}, + { (char *)"HeadChunk_data_set", _wrap_HeadChunk_data_set, METH_VARARGS, NULL}, + { (char *)"HeadChunk_data_get", _wrap_HeadChunk_data_get, METH_VARARGS, NULL}, + { (char *)"HeadChunk_chunkSize", _wrap_HeadChunk_chunkSize, METH_VARARGS, NULL}, + { (char *)"HeadChunk_get", _wrap_HeadChunk_get, METH_VARARGS, NULL}, + { (char *)"HeadChunk_put", _wrap_HeadChunk_put, METH_VARARGS, NULL}, + { (char *)"new_HeadChunk", _wrap_new_HeadChunk, METH_VARARGS, NULL}, + { (char *)"delete_HeadChunk", _wrap_delete_HeadChunk, METH_VARARGS, NULL}, + { (char *)"HeadChunk_swigregister", HeadChunk_swigregister, METH_VARARGS, NULL}, + { (char *)"SID_networkCode_set", _wrap_SID_networkCode_set, METH_VARARGS, NULL}, + { (char *)"SID_networkCode_get", _wrap_SID_networkCode_get, METH_VARARGS, NULL}, + { (char *)"SID_stationCode_set", _wrap_SID_stationCode_set, METH_VARARGS, NULL}, + { (char *)"SID_stationCode_get", _wrap_SID_stationCode_get, METH_VARARGS, NULL}, + { (char *)"SID_locationCode_set", _wrap_SID_locationCode_set, METH_VARARGS, NULL}, + { (char *)"SID_locationCode_get", _wrap_SID_locationCode_get, METH_VARARGS, NULL}, + { (char *)"SID_channelCode_set", _wrap_SID_channelCode_set, METH_VARARGS, NULL}, + { (char *)"SID_channelCode_get", _wrap_SID_channelCode_get, METH_VARARGS, NULL}, + { (char *)"SID___eq__", _wrap_SID___eq__, METH_VARARGS, NULL}, + { (char *)"SID___ne__", _wrap_SID___ne__, METH_VARARGS, NULL}, + { (char *)"SID_toString", _wrap_SID_toString, METH_VARARGS, NULL}, + { (char *)"new_SID", _wrap_new_SID, METH_VARARGS, NULL}, + { (char *)"delete_SID", _wrap_delete_SID, METH_VARARGS, NULL}, + { (char *)"SID_swigregister", SID_swigregister, METH_VARARGS, NULL}, + { (char *)"SIDChunk_chunkSize", _wrap_SIDChunk_chunkSize, METH_VARARGS, NULL}, + { (char *)"SIDChunk_get", _wrap_SIDChunk_get, METH_VARARGS, NULL}, + { (char *)"SIDChunk_put", _wrap_SIDChunk_put, METH_VARARGS, NULL}, + { (char *)"new_SIDChunk", _wrap_new_SIDChunk, METH_VARARGS, NULL}, + { (char *)"delete_SIDChunk", _wrap_delete_SIDChunk, METH_VARARGS, NULL}, + { (char *)"SIDChunk_swigregister", SIDChunk_swigregister, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_formatName", _wrap_RTCM2DataRecord_formatName, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_setTimeStamp", _wrap_RTCM2DataRecord_setTimeStamp, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_setSamplingFrequency", _wrap_RTCM2DataRecord_setSamplingFrequency, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_readMetaData", _wrap_RTCM2DataRecord_readMetaData, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_header", _wrap_RTCM2DataRecord_header, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_startTime", _wrap_RTCM2DataRecord_startTime, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_endTime", _wrap_RTCM2DataRecord_endTime, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_canTrim", _wrap_RTCM2DataRecord_canTrim, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_canMerge", _wrap_RTCM2DataRecord_canMerge, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_trim", _wrap_RTCM2DataRecord_trim, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_dataSize", _wrap_RTCM2DataRecord_dataSize, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_get", _wrap_RTCM2DataRecord_get, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_put", _wrap_RTCM2DataRecord_put, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_packetType", _wrap_RTCM2DataRecord_packetType, METH_VARARGS, NULL}, + { (char *)"delete_RTCM2DataRecord", _wrap_delete_RTCM2DataRecord, METH_VARARGS, NULL}, + { (char *)"RTCM2DataRecord_swigregister", RTCM2DataRecord_swigregister, METH_VARARGS, NULL}, + { (char *)"new_Socket", _wrap_new_Socket, METH_VARARGS, NULL}, + { (char *)"delete_Socket", _wrap_delete_Socket, METH_VARARGS, NULL}, + { (char *)"Socket_toString", _wrap_Socket_toString, METH_VARARGS, NULL}, + { (char *)"Socket_fd", _wrap_Socket_fd, METH_VARARGS, NULL}, + { (char *)"Socket_isValid", _wrap_Socket_isValid, METH_VARARGS, NULL}, + { (char *)"Socket_shutdown", _wrap_Socket_shutdown, METH_VARARGS, NULL}, + { (char *)"Socket_close", _wrap_Socket_close, METH_VARARGS, NULL}, + { (char *)"Socket_send", _wrap_Socket_send, METH_VARARGS, NULL}, + { (char *)"Socket_write", _wrap_Socket_write, METH_VARARGS, NULL}, + { (char *)"Socket_read", _wrap_Socket_read, METH_VARARGS, NULL}, + { (char *)"Socket_flush", _wrap_Socket_flush, METH_VARARGS, NULL}, + { (char *)"Socket_setSocketTimeout", _wrap_Socket_setSocketTimeout, METH_VARARGS, NULL}, + { (char *)"Socket_setNonBlocking", _wrap_Socket_setNonBlocking, METH_VARARGS, NULL}, + { (char *)"Socket_connect", _wrap_Socket_connect, METH_VARARGS, NULL}, + { (char *)"Socket_rx", _wrap_Socket_rx, METH_VARARGS, NULL}, + { (char *)"Socket_tx", _wrap_Socket_tx, METH_VARARGS, NULL}, + { (char *)"Socket_swigregister", Socket_swigregister, METH_VARARGS, NULL}, + { (char *)"new_SSLSocket", _wrap_new_SSLSocket, METH_VARARGS, NULL}, + { (char *)"delete_SSLSocket", _wrap_delete_SSLSocket, METH_VARARGS, NULL}, + { (char *)"SSLSocket_write", _wrap_SSLSocket_write, METH_VARARGS, NULL}, + { (char *)"SSLSocket_read", _wrap_SSLSocket_read, METH_VARARGS, NULL}, + { (char *)"SSLSocket_connect", _wrap_SSLSocket_connect, METH_VARARGS, NULL}, + { (char *)"SSLSocket_sessionID", _wrap_SSLSocket_sessionID, METH_VARARGS, NULL}, + { (char *)"SSLSocket_sessionIDLength", _wrap_SSLSocket_sessionIDLength, METH_VARARGS, NULL}, + { (char *)"SSLSocket_peerCertificate", _wrap_SSLSocket_peerCertificate, METH_VARARGS, NULL}, + { (char *)"SSLSocket_swigregister", SSLSocket_swigregister, METH_VARARGS, NULL}, + { (char *)"new_charArray", _wrap_new_charArray, METH_VARARGS, NULL}, + { (char *)"delete_charArray", _wrap_delete_charArray, METH_VARARGS, NULL}, + { (char *)"charArray___getitem__", _wrap_charArray___getitem__, METH_VARARGS, NULL}, + { (char *)"charArray___setitem__", _wrap_charArray___setitem__, METH_VARARGS, NULL}, + { (char *)"charArray_cast", _wrap_charArray_cast, METH_VARARGS, NULL}, + { (char *)"charArray_frompointer", _wrap_charArray_frompointer, METH_VARARGS, NULL}, + { (char *)"charArray_swigregister", charArray_swigregister, METH_VARARGS, NULL}, + { (char *)"new_arraybuf", _wrap_new_arraybuf, METH_VARARGS, NULL}, + { (char *)"arraybuf_reset", _wrap_arraybuf_reset, METH_VARARGS, NULL}, + { (char *)"arraybuf_seekoff", _wrap_arraybuf_seekoff, METH_VARARGS, NULL}, + { (char *)"arraybuf_seekpos", _wrap_arraybuf_seekpos, METH_VARARGS, NULL}, + { (char *)"arraybuf_xsgetn", _wrap_arraybuf_xsgetn, METH_VARARGS, NULL}, + { (char *)"arraybuf_tellg", _wrap_arraybuf_tellg, METH_VARARGS, NULL}, + { (char *)"arraybuf_tellp", _wrap_arraybuf_tellp, METH_VARARGS, NULL}, + { (char *)"delete_arraybuf", _wrap_delete_arraybuf, METH_VARARGS, NULL}, + { (char *)"arraybuf_swigregister", arraybuf_swigregister, METH_VARARGS, NULL}, + { (char *)"splitAddress", _wrap_splitAddress, METH_VARARGS, NULL}, + { (char *)"tokenize", _wrap_tokenize, METH_VARARGS, NULL}, + { (char *)"trim", _wrap_trim, METH_VARARGS, NULL}, + { (char *)"timeToTimestamp", _wrap_timeToTimestamp, METH_VARARGS, NULL}, + { (char *)"str2int", _wrap_str2int, METH_VARARGS, NULL}, + { (char *)"timestampToTime", _wrap_timestampToTime, METH_VARARGS, NULL}, + { (char *)"samplesToTimeSpan", _wrap_samplesToTimeSpan, METH_VARARGS, NULL}, + { (char *)"timeSpanToSamples", _wrap_timeSpanToSamples, METH_VARARGS, NULL}, + { (char *)"timeSpanToSamplesCeil", _wrap_timeSpanToSamplesCeil, METH_VARARGS, NULL}, + { (char *)"timeSpanToSamplesFloor", _wrap_timeSpanToSamplesFloor, METH_VARARGS, NULL}, + { (char *)"dataTypeSize", _wrap_dataTypeSize, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static void *_p_Gempa__CAPS__PacketDataHeaderV2To_p_Gempa__CAPS__PacketDataHeader(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::PacketDataHeader *) ((Gempa::CAPS::PacketDataHeaderV2 *) x)); +} +static void *_p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__SteimEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim1EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__SteimEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim2EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__SteimEncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::MSEEDEncoderFactory *) ((Gempa::CAPS::SteimEncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__IdentityEncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::MSEEDEncoderFactory *) ((Gempa::CAPS::IdentityEncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::MSEEDEncoderFactory *) (Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim1EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::MSEEDEncoderFactory *) (Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim2EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__MSEEDEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::EncoderFactory *) ((Gempa::CAPS::MSEEDEncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__SteimEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::EncoderFactory *) (Gempa::CAPS::MSEEDEncoderFactory *) ((Gempa::CAPS::SteimEncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__IdentityEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::EncoderFactory *) (Gempa::CAPS::MSEEDEncoderFactory *) ((Gempa::CAPS::IdentityEncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__EncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::EncoderFactory *) (Gempa::CAPS::MSEEDEncoderFactory *)(Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim1EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__EncoderFactory(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::EncoderFactory *) (Gempa::CAPS::MSEEDEncoderFactory *)(Gempa::CAPS::SteimEncoderFactory *) ((Gempa::CAPS::Steim2EncoderFactory *) x)); +} +static void *_p_Gempa__CAPS__RIFF__SIDChunkTo_p_Gempa__CAPS__RIFF__Chunk(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::RIFF::Chunk *) ((Gempa::CAPS::RIFF::SIDChunk *) x)); +} +static void *_p_Gempa__CAPS__RIFF__HeadChunkTo_p_Gempa__CAPS__RIFF__Chunk(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::RIFF::Chunk *) ((Gempa::CAPS::RIFF::HeadChunk *) x)); +} +static void *_p_Gempa__CAPS__RIFF__SIDChunkTo_p_Gempa__CAPS__RIFF__SID(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::RIFF::SID *) ((Gempa::CAPS::RIFF::SIDChunk *) x)); +} +static void *_p_Gempa__CAPS__arraybufTo_p_std__streambuf(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((std::streambuf *) ((Gempa::CAPS::arraybuf *) x)); +} +static void *_p_Gempa__CAPS__TimeTo_p_Gempa__CAPS__TimeSpan(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::TimeSpan *) ((Gempa::CAPS::Time *) x)); +} +static void *_p_Gempa__CAPS__FixedRawDataRecordTo_p_Gempa__CAPS__RawDataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::RawDataRecord *) ((Gempa::CAPS::FixedRawDataRecord *) x)); +} +static void *_p_Gempa__CAPS__AnyDataRecordTo_p_Gempa__CAPS__DataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::DataRecord *) ((Gempa::CAPS::AnyDataRecord *) x)); +} +static void *_p_Gempa__CAPS__MSEEDDataRecordTo_p_Gempa__CAPS__DataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::DataRecord *) ((Gempa::CAPS::MSEEDDataRecord *) x)); +} +static void *_p_Gempa__CAPS__RawDataRecordTo_p_Gempa__CAPS__DataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::DataRecord *) ((Gempa::CAPS::RawDataRecord *) x)); +} +static void *_p_Gempa__CAPS__FixedRawDataRecordTo_p_Gempa__CAPS__DataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::DataRecord *) (Gempa::CAPS::RawDataRecord *) ((Gempa::CAPS::FixedRawDataRecord *) x)); +} +static void *_p_Gempa__CAPS__RTCM2DataRecordTo_p_Gempa__CAPS__DataRecord(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::DataRecord *) ((Gempa::CAPS::RTCM2DataRecord *) x)); +} +static void *_p_charArrayTo_p_char(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((char *) ((charArray *) x)); +} +static void *_p_Gempa__CAPS__SSLSocketTo_p_Gempa__CAPS__Socket(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((Gempa::CAPS::Socket *) ((Gempa::CAPS::SSLSocket *) x)); +} +static swig_type_info _swigt__p_BackfillingBuffer = {"_p_BackfillingBuffer", "BackfillingBuffer *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BufferPtr = {"_p_BufferPtr", "BufferPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__AnyDataRecord = {"_p_Gempa__CAPS__AnyDataRecord", "Gempa::CAPS::AnyDataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__DataRecord = {"_p_Gempa__CAPS__DataRecord", "Gempa::CAPS::DataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__DataRecord__Header = {"_p_Gempa__CAPS__DataRecord__Header", "Gempa::CAPS::DataRecord::Header *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__DataRecord__ReadStatus = {"_p_Gempa__CAPS__DataRecord__ReadStatus", "Gempa::CAPS::DataRecord::ReadStatus *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Encoder = {"_p_Gempa__CAPS__Encoder", "Gempa::CAPS::Encoder *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__EncoderFactory = {"_p_Gempa__CAPS__EncoderFactory", "Gempa::CAPS::EncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__FixedRawDataRecord = {"_p_Gempa__CAPS__FixedRawDataRecord", "Gempa::CAPS::FixedRawDataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__IdentityEncoderFactory = {"_p_Gempa__CAPS__IdentityEncoderFactory", "Gempa::CAPS::IdentityEncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__MSEEDDataRecord = {"_p_Gempa__CAPS__MSEEDDataRecord", "Gempa::CAPS::MSEEDDataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__MSEEDEncoderFactory = {"_p_Gempa__CAPS__MSEEDEncoderFactory", "Gempa::CAPS::MSEEDEncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__MetaPacket = {"_p_Gempa__CAPS__MetaPacket", "Gempa::CAPS::MetaPacket *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Packet = {"_p_Gempa__CAPS__Packet", "Gempa::CAPS::Packet *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__PacketDataHeader = {"_p_Gempa__CAPS__PacketDataHeader", "Gempa::CAPS::PacketDataHeader *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__PacketDataHeaderV2 = {"_p_Gempa__CAPS__PacketDataHeaderV2", "Gempa::CAPS::PacketDataHeaderV2 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__PacketHeaderV1 = {"_p_Gempa__CAPS__PacketHeaderV1", "Gempa::CAPS::PacketHeaderV1 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__PacketHeaderV2 = {"_p_Gempa__CAPS__PacketHeaderV2", "Gempa::CAPS::PacketHeaderV2 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Plugin = {"_p_Gempa__CAPS__Plugin", "Gempa::CAPS::Plugin *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Plugin__Stats = {"_p_Gempa__CAPS__Plugin__Stats", "Gempa::CAPS::Plugin::Stats *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Quality = {"_p_Gempa__CAPS__Quality", "Gempa::CAPS::Quality *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__Chunk = {"_p_Gempa__CAPS__RIFF__Chunk", "Gempa::CAPS::RIFF::Chunk *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__ChunkHeader = {"_p_Gempa__CAPS__RIFF__ChunkHeader", "Gempa::CAPS::RIFF::ChunkHeader *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__ChunkIterator = {"_p_Gempa__CAPS__RIFF__ChunkIterator", "Gempa::CAPS::RIFF::ChunkIterator *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__HeadChunk = {"_p_Gempa__CAPS__RIFF__HeadChunk", "Gempa::CAPS::RIFF::HeadChunk *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__SID = {"_p_Gempa__CAPS__RIFF__SID", "Gempa::CAPS::RIFF::SID *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RIFF__SIDChunk = {"_p_Gempa__CAPS__RIFF__SIDChunk", "Gempa::CAPS::RIFF::SIDChunk *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RTCM2DataRecord = {"_p_Gempa__CAPS__RTCM2DataRecord", "Gempa::CAPS::RTCM2DataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RawDataRecord = {"_p_Gempa__CAPS__RawDataRecord", "Gempa::CAPS::RawDataRecord *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RawPacket = {"_p_Gempa__CAPS__RawPacket", "Gempa::CAPS::RawPacket *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__RawResponseHeader = {"_p_Gempa__CAPS__RawResponseHeader", "Gempa::CAPS::RawResponseHeader *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__ResponseHeader = {"_p_Gempa__CAPS__ResponseHeader", "Gempa::CAPS::ResponseHeader *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__SPClock = {"_p_Gempa__CAPS__SPClock", "Gempa::CAPS::SPClock *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__SSLSocket = {"_p_Gempa__CAPS__SSLSocket", "Gempa::CAPS::SSLSocket *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Socket = {"_p_Gempa__CAPS__Socket", "Gempa::CAPS::Socket *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Socket__Device__Status = {"_p_Gempa__CAPS__Socket__Device__Status", "Gempa::CAPS::Socket::Device::Status *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Steim1EncoderFactory = {"_p_Gempa__CAPS__Steim1EncoderFactory", "Gempa::CAPS::Steim1EncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Steim2EncoderFactory = {"_p_Gempa__CAPS__Steim2EncoderFactory", "Gempa::CAPS::Steim2EncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__SteimEncoderFactory = {"_p_Gempa__CAPS__SteimEncoderFactory", "Gempa::CAPS::SteimEncoderFactory *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__Time = {"_p_Gempa__CAPS__Time", "Gempa::CAPS::Time *|Gempa::CAPS::SPClock::INT_TIME *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__TimeSpan = {"_p_Gempa__CAPS__TimeSpan", "Gempa::CAPS::TimeSpan *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__TimeStamp = {"_p_Gempa__CAPS__TimeStamp", "Gempa::CAPS::TimeStamp *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__UOM = {"_p_Gempa__CAPS__UOM", "Gempa::CAPS::UOM *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Gempa__CAPS__arraybuf = {"_p_Gempa__CAPS__arraybuf", "Gempa::CAPS::arraybuf *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_INT_TIME = {"_p_INT_TIME", "INT_TIME *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_PacketAckFunc = {"_p_PacketAckFunc", "PacketAckFunc *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL_CTX = {"_p_SSL_CTX", "SSL_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_StreamStates = {"_p_StreamStates", "StreamStates *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509 = {"_p_X509", "X509 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t = {"_p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t", "Gempa::CAPS::Plugin::PacketAckFunc *|boost::function< void (std::string const &,Gempa::CAPS::Time const &,Gempa::CAPS::Time const &) > *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t = {"_p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t", "Gempa::CAPS::DataRecordPtr *|boost::shared_ptr< Gempa::CAPS::DataRecord > *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t = {"_p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t", "boost::shared_ptr< Gempa::CAPS::Packet::Buffer > *|Gempa::CAPS::Packet::BufferPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet_t = {"_p_boost__shared_ptrT_Gempa__CAPS__Packet_t", "boost::shared_ptr< Gempa::CAPS::Packet > *|Gempa::CAPS::PacketPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__Plugin_t = {"_p_boost__shared_ptrT_Gempa__CAPS__Plugin_t", "boost::shared_ptr< Gempa::CAPS::Plugin > *|Gempa::CAPS::PluginPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t = {"_p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t", "boost::shared_ptr< Gempa::CAPS::SSLSocket > *|Gempa::CAPS::SSLSocketPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_boost__shared_ptrT_Gempa__CAPS__Socket_t = {"_p_boost__shared_ptrT_Gempa__CAPS__Socket_t", "boost::shared_ptr< Gempa::CAPS::Socket > *|Gempa::CAPS::SocketPtr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_charArray = {"_p_charArray", "charArray *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_count_t = {"_p_count_t", "count_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__char_v_______void = {"_p_f_p_q_const__char_v_______void", "void (*)(char const *,...)|Gempa::CAPS::LogOutput", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_off_type = {"_p_off_type", "off_type *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_f_p_q_const__char_v_______void = {"_p_p_f_p_q_const__char_v_______void", "void (**)(char const *,...)|Gempa::CAPS::LogOutput *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_pos_type = {"_p_pos_type", "pos_type *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__ios_base__openmode = {"_p_std__ios_base__openmode", "std::ios_base::openmode *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__ios_base__seekdir = {"_p_std__ios_base__seekdir", "std::ios_base::seekdir *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__istream = {"_p_std__istream", "std::istream *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t = {"_p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t", "std::map< std::string,Gempa::CAPS::Plugin::StreamState > *|Gempa::CAPS::Plugin::StreamStates *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__ostream = {"_p_std__ostream", "std::ostream *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__streambuf = {"_p_std__streambuf", "std::streambuf *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__streambuf__off_type = {"_p_std__streambuf__off_type", "std::streambuf::off_type *|Gempa::CAPS::arraybuf::off_type *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__streambuf__pos_type = {"_p_std__streambuf__pos_type", "std::streambuf::pos_type *|Gempa::CAPS::arraybuf::pos_type *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__streampos = {"_p_std__streampos", "std::streampos *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__streamsize = {"_p_std__streamsize", "std::streamsize *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorT_char_t = {"_p_std__vectorT_char_t", "std::vector< char > *|Buffer *|Gempa::CAPS::DataRecord::Buffer *|Gempa::CAPS::AnyDataRecord::Buffer *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_timeval = {"_p_timeval", "timeval *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_uint = {"_p_uint", "uint *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_BackfillingBuffer, + &_swigt__p_BufferPtr, + &_swigt__p_Gempa__CAPS__AnyDataRecord, + &_swigt__p_Gempa__CAPS__DataRecord, + &_swigt__p_Gempa__CAPS__DataRecord__Header, + &_swigt__p_Gempa__CAPS__DataRecord__ReadStatus, + &_swigt__p_Gempa__CAPS__Encoder, + &_swigt__p_Gempa__CAPS__EncoderFactory, + &_swigt__p_Gempa__CAPS__FixedRawDataRecord, + &_swigt__p_Gempa__CAPS__IdentityEncoderFactory, + &_swigt__p_Gempa__CAPS__MSEEDDataRecord, + &_swigt__p_Gempa__CAPS__MSEEDEncoderFactory, + &_swigt__p_Gempa__CAPS__MetaPacket, + &_swigt__p_Gempa__CAPS__Packet, + &_swigt__p_Gempa__CAPS__PacketDataHeader, + &_swigt__p_Gempa__CAPS__PacketDataHeaderV2, + &_swigt__p_Gempa__CAPS__PacketHeaderV1, + &_swigt__p_Gempa__CAPS__PacketHeaderV2, + &_swigt__p_Gempa__CAPS__Plugin, + &_swigt__p_Gempa__CAPS__Plugin__Stats, + &_swigt__p_Gempa__CAPS__Quality, + &_swigt__p_Gempa__CAPS__RIFF__Chunk, + &_swigt__p_Gempa__CAPS__RIFF__ChunkHeader, + &_swigt__p_Gempa__CAPS__RIFF__ChunkIterator, + &_swigt__p_Gempa__CAPS__RIFF__HeadChunk, + &_swigt__p_Gempa__CAPS__RIFF__SID, + &_swigt__p_Gempa__CAPS__RIFF__SIDChunk, + &_swigt__p_Gempa__CAPS__RTCM2DataRecord, + &_swigt__p_Gempa__CAPS__RawDataRecord, + &_swigt__p_Gempa__CAPS__RawPacket, + &_swigt__p_Gempa__CAPS__RawResponseHeader, + &_swigt__p_Gempa__CAPS__ResponseHeader, + &_swigt__p_Gempa__CAPS__SPClock, + &_swigt__p_Gempa__CAPS__SSLSocket, + &_swigt__p_Gempa__CAPS__Socket, + &_swigt__p_Gempa__CAPS__Socket__Device__Status, + &_swigt__p_Gempa__CAPS__Steim1EncoderFactory, + &_swigt__p_Gempa__CAPS__Steim2EncoderFactory, + &_swigt__p_Gempa__CAPS__SteimEncoderFactory, + &_swigt__p_Gempa__CAPS__Time, + &_swigt__p_Gempa__CAPS__TimeSpan, + &_swigt__p_Gempa__CAPS__TimeStamp, + &_swigt__p_Gempa__CAPS__UOM, + &_swigt__p_Gempa__CAPS__arraybuf, + &_swigt__p_INT_TIME, + &_swigt__p_PacketAckFunc, + &_swigt__p_SSL_CTX, + &_swigt__p_StreamStates, + &_swigt__p_X509, + &_swigt__p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__Plugin_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t, + &_swigt__p_boost__shared_ptrT_Gempa__CAPS__Socket_t, + &_swigt__p_char, + &_swigt__p_charArray, + &_swigt__p_count_t, + &_swigt__p_f_p_q_const__char_v_______void, + &_swigt__p_int, + &_swigt__p_long_long, + &_swigt__p_off_type, + &_swigt__p_p_f_p_q_const__char_v_______void, + &_swigt__p_pos_type, + &_swigt__p_short, + &_swigt__p_signed_char, + &_swigt__p_std__ios_base__openmode, + &_swigt__p_std__ios_base__seekdir, + &_swigt__p_std__istream, + &_swigt__p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t, + &_swigt__p_std__ostream, + &_swigt__p_std__streambuf, + &_swigt__p_std__streambuf__off_type, + &_swigt__p_std__streambuf__pos_type, + &_swigt__p_std__streampos, + &_swigt__p_std__streamsize, + &_swigt__p_std__string, + &_swigt__p_std__vectorT_char_t, + &_swigt__p_timeval, + &_swigt__p_uint, + &_swigt__p_unsigned_char, + &_swigt__p_unsigned_int, + &_swigt__p_unsigned_long_long, + &_swigt__p_unsigned_short, +}; + +static swig_cast_info _swigc__p_BackfillingBuffer[] = { {&_swigt__p_BackfillingBuffer, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BufferPtr[] = { {&_swigt__p_BufferPtr, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__AnyDataRecord[] = { {&_swigt__p_Gempa__CAPS__AnyDataRecord, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__DataRecord[] = { {&_swigt__p_Gempa__CAPS__DataRecord, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__AnyDataRecord, _p_Gempa__CAPS__AnyDataRecordTo_p_Gempa__CAPS__DataRecord, 0, 0}, {&_swigt__p_Gempa__CAPS__MSEEDDataRecord, _p_Gempa__CAPS__MSEEDDataRecordTo_p_Gempa__CAPS__DataRecord, 0, 0}, {&_swigt__p_Gempa__CAPS__RawDataRecord, _p_Gempa__CAPS__RawDataRecordTo_p_Gempa__CAPS__DataRecord, 0, 0}, {&_swigt__p_Gempa__CAPS__FixedRawDataRecord, _p_Gempa__CAPS__FixedRawDataRecordTo_p_Gempa__CAPS__DataRecord, 0, 0}, {&_swigt__p_Gempa__CAPS__RTCM2DataRecord, _p_Gempa__CAPS__RTCM2DataRecordTo_p_Gempa__CAPS__DataRecord, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__DataRecord__Header[] = { {&_swigt__p_Gempa__CAPS__DataRecord__Header, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__DataRecord__ReadStatus[] = { {&_swigt__p_Gempa__CAPS__DataRecord__ReadStatus, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Encoder[] = { {&_swigt__p_Gempa__CAPS__Encoder, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__EncoderFactory[] = { {&_swigt__p_Gempa__CAPS__EncoderFactory, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__MSEEDEncoderFactory, _p_Gempa__CAPS__MSEEDEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__SteimEncoderFactory, _p_Gempa__CAPS__SteimEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim1EncoderFactory, _p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__EncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim2EncoderFactory, _p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__EncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__IdentityEncoderFactory, _p_Gempa__CAPS__IdentityEncoderFactoryTo_p_Gempa__CAPS__EncoderFactory, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__FixedRawDataRecord[] = { {&_swigt__p_Gempa__CAPS__FixedRawDataRecord, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__IdentityEncoderFactory[] = { {&_swigt__p_Gempa__CAPS__IdentityEncoderFactory, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__MSEEDDataRecord[] = { {&_swigt__p_Gempa__CAPS__MSEEDDataRecord, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__MSEEDEncoderFactory[] = { {&_swigt__p_Gempa__CAPS__MSEEDEncoderFactory, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__SteimEncoderFactory, _p_Gempa__CAPS__SteimEncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim1EncoderFactory, _p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim2EncoderFactory, _p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__IdentityEncoderFactory, _p_Gempa__CAPS__IdentityEncoderFactoryTo_p_Gempa__CAPS__MSEEDEncoderFactory, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__MetaPacket[] = { {&_swigt__p_Gempa__CAPS__MetaPacket, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Packet[] = { {&_swigt__p_Gempa__CAPS__Packet, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__PacketDataHeader[] = { {&_swigt__p_Gempa__CAPS__PacketDataHeader, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__PacketDataHeaderV2, _p_Gempa__CAPS__PacketDataHeaderV2To_p_Gempa__CAPS__PacketDataHeader, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__PacketDataHeaderV2[] = { {&_swigt__p_Gempa__CAPS__PacketDataHeaderV2, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__PacketHeaderV1[] = { {&_swigt__p_Gempa__CAPS__PacketHeaderV1, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__PacketHeaderV2[] = { {&_swigt__p_Gempa__CAPS__PacketHeaderV2, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Plugin[] = { {&_swigt__p_Gempa__CAPS__Plugin, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Plugin__Stats[] = { {&_swigt__p_Gempa__CAPS__Plugin__Stats, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Quality[] = { {&_swigt__p_Gempa__CAPS__Quality, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__Chunk[] = { {&_swigt__p_Gempa__CAPS__RIFF__SIDChunk, _p_Gempa__CAPS__RIFF__SIDChunkTo_p_Gempa__CAPS__RIFF__Chunk, 0, 0}, {&_swigt__p_Gempa__CAPS__RIFF__Chunk, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__RIFF__HeadChunk, _p_Gempa__CAPS__RIFF__HeadChunkTo_p_Gempa__CAPS__RIFF__Chunk, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__ChunkHeader[] = { {&_swigt__p_Gempa__CAPS__RIFF__ChunkHeader, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__ChunkIterator[] = { {&_swigt__p_Gempa__CAPS__RIFF__ChunkIterator, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__HeadChunk[] = { {&_swigt__p_Gempa__CAPS__RIFF__HeadChunk, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__SID[] = { {&_swigt__p_Gempa__CAPS__RIFF__SIDChunk, _p_Gempa__CAPS__RIFF__SIDChunkTo_p_Gempa__CAPS__RIFF__SID, 0, 0}, {&_swigt__p_Gempa__CAPS__RIFF__SID, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RIFF__SIDChunk[] = { {&_swigt__p_Gempa__CAPS__RIFF__SIDChunk, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RTCM2DataRecord[] = { {&_swigt__p_Gempa__CAPS__RTCM2DataRecord, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RawDataRecord[] = { {&_swigt__p_Gempa__CAPS__RawDataRecord, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__FixedRawDataRecord, _p_Gempa__CAPS__FixedRawDataRecordTo_p_Gempa__CAPS__RawDataRecord, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RawPacket[] = { {&_swigt__p_Gempa__CAPS__RawPacket, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__RawResponseHeader[] = { {&_swigt__p_Gempa__CAPS__RawResponseHeader, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__ResponseHeader[] = { {&_swigt__p_Gempa__CAPS__ResponseHeader, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__SPClock[] = { {&_swigt__p_Gempa__CAPS__SPClock, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__SSLSocket[] = { {&_swigt__p_Gempa__CAPS__SSLSocket, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Socket[] = { {&_swigt__p_Gempa__CAPS__Socket, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__SSLSocket, _p_Gempa__CAPS__SSLSocketTo_p_Gempa__CAPS__Socket, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Socket__Device__Status[] = { {&_swigt__p_Gempa__CAPS__Socket__Device__Status, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Steim1EncoderFactory[] = { {&_swigt__p_Gempa__CAPS__Steim1EncoderFactory, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Steim2EncoderFactory[] = { {&_swigt__p_Gempa__CAPS__Steim2EncoderFactory, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__SteimEncoderFactory[] = { {&_swigt__p_Gempa__CAPS__SteimEncoderFactory, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim1EncoderFactory, _p_Gempa__CAPS__Steim1EncoderFactoryTo_p_Gempa__CAPS__SteimEncoderFactory, 0, 0}, {&_swigt__p_Gempa__CAPS__Steim2EncoderFactory, _p_Gempa__CAPS__Steim2EncoderFactoryTo_p_Gempa__CAPS__SteimEncoderFactory, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__Time[] = { {&_swigt__p_Gempa__CAPS__Time, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__TimeSpan[] = { {&_swigt__p_Gempa__CAPS__TimeSpan, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__Time, _p_Gempa__CAPS__TimeTo_p_Gempa__CAPS__TimeSpan, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__TimeStamp[] = { {&_swigt__p_Gempa__CAPS__TimeStamp, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__UOM[] = { {&_swigt__p_Gempa__CAPS__UOM, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Gempa__CAPS__arraybuf[] = { {&_swigt__p_Gempa__CAPS__arraybuf, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_INT_TIME[] = { {&_swigt__p_INT_TIME, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_PacketAckFunc[] = { {&_swigt__p_PacketAckFunc, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL_CTX[] = { {&_swigt__p_SSL_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_StreamStates[] = { {&_swigt__p_StreamStates, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509[] = { {&_swigt__p_X509, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t[] = { {&_swigt__p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__Packet_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__Packet_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__Plugin_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__Plugin_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_boost__shared_ptrT_Gempa__CAPS__Socket_t[] = { {&_swigt__p_boost__shared_ptrT_Gempa__CAPS__Socket_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0}, {&_swigt__p_charArray, _p_charArrayTo_p_char, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_charArray[] = { {&_swigt__p_charArray, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_count_t[] = { {&_swigt__p_count_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__char_v_______void[] = { {&_swigt__p_f_p_q_const__char_v_______void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_off_type[] = { {&_swigt__p_off_type, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_f_p_q_const__char_v_______void[] = { {&_swigt__p_p_f_p_q_const__char_v_______void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_pos_type[] = { {&_swigt__p_pos_type, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__ios_base__openmode[] = { {&_swigt__p_std__ios_base__openmode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__ios_base__seekdir[] = { {&_swigt__p_std__ios_base__seekdir, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__istream[] = { {&_swigt__p_std__istream, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t[] = { {&_swigt__p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__ostream[] = { {&_swigt__p_std__ostream, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__streambuf[] = { {&_swigt__p_std__streambuf, 0, 0, 0}, {&_swigt__p_Gempa__CAPS__arraybuf, _p_Gempa__CAPS__arraybufTo_p_std__streambuf, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__streambuf__off_type[] = { {&_swigt__p_std__streambuf__off_type, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__streambuf__pos_type[] = { {&_swigt__p_std__streambuf__pos_type, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__streampos[] = { {&_swigt__p_std__streampos, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__streamsize[] = { {&_swigt__p_std__streamsize, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorT_char_t[] = { {&_swigt__p_std__vectorT_char_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_timeval[] = { {&_swigt__p_timeval, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_uint[] = { {&_swigt__p_uint, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_BackfillingBuffer, + _swigc__p_BufferPtr, + _swigc__p_Gempa__CAPS__AnyDataRecord, + _swigc__p_Gempa__CAPS__DataRecord, + _swigc__p_Gempa__CAPS__DataRecord__Header, + _swigc__p_Gempa__CAPS__DataRecord__ReadStatus, + _swigc__p_Gempa__CAPS__Encoder, + _swigc__p_Gempa__CAPS__EncoderFactory, + _swigc__p_Gempa__CAPS__FixedRawDataRecord, + _swigc__p_Gempa__CAPS__IdentityEncoderFactory, + _swigc__p_Gempa__CAPS__MSEEDDataRecord, + _swigc__p_Gempa__CAPS__MSEEDEncoderFactory, + _swigc__p_Gempa__CAPS__MetaPacket, + _swigc__p_Gempa__CAPS__Packet, + _swigc__p_Gempa__CAPS__PacketDataHeader, + _swigc__p_Gempa__CAPS__PacketDataHeaderV2, + _swigc__p_Gempa__CAPS__PacketHeaderV1, + _swigc__p_Gempa__CAPS__PacketHeaderV2, + _swigc__p_Gempa__CAPS__Plugin, + _swigc__p_Gempa__CAPS__Plugin__Stats, + _swigc__p_Gempa__CAPS__Quality, + _swigc__p_Gempa__CAPS__RIFF__Chunk, + _swigc__p_Gempa__CAPS__RIFF__ChunkHeader, + _swigc__p_Gempa__CAPS__RIFF__ChunkIterator, + _swigc__p_Gempa__CAPS__RIFF__HeadChunk, + _swigc__p_Gempa__CAPS__RIFF__SID, + _swigc__p_Gempa__CAPS__RIFF__SIDChunk, + _swigc__p_Gempa__CAPS__RTCM2DataRecord, + _swigc__p_Gempa__CAPS__RawDataRecord, + _swigc__p_Gempa__CAPS__RawPacket, + _swigc__p_Gempa__CAPS__RawResponseHeader, + _swigc__p_Gempa__CAPS__ResponseHeader, + _swigc__p_Gempa__CAPS__SPClock, + _swigc__p_Gempa__CAPS__SSLSocket, + _swigc__p_Gempa__CAPS__Socket, + _swigc__p_Gempa__CAPS__Socket__Device__Status, + _swigc__p_Gempa__CAPS__Steim1EncoderFactory, + _swigc__p_Gempa__CAPS__Steim2EncoderFactory, + _swigc__p_Gempa__CAPS__SteimEncoderFactory, + _swigc__p_Gempa__CAPS__Time, + _swigc__p_Gempa__CAPS__TimeSpan, + _swigc__p_Gempa__CAPS__TimeStamp, + _swigc__p_Gempa__CAPS__UOM, + _swigc__p_Gempa__CAPS__arraybuf, + _swigc__p_INT_TIME, + _swigc__p_PacketAckFunc, + _swigc__p_SSL_CTX, + _swigc__p_StreamStates, + _swigc__p_X509, + _swigc__p_boost__functionT_void_fstd__string_const_R_Gempa__CAPS__Time_const_R_Gempa__CAPS__Time_const_RF_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__DataRecord_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__Packet__Buffer_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__Packet_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__Plugin_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__SSLSocket_t, + _swigc__p_boost__shared_ptrT_Gempa__CAPS__Socket_t, + _swigc__p_char, + _swigc__p_charArray, + _swigc__p_count_t, + _swigc__p_f_p_q_const__char_v_______void, + _swigc__p_int, + _swigc__p_long_long, + _swigc__p_off_type, + _swigc__p_p_f_p_q_const__char_v_______void, + _swigc__p_pos_type, + _swigc__p_short, + _swigc__p_signed_char, + _swigc__p_std__ios_base__openmode, + _swigc__p_std__ios_base__seekdir, + _swigc__p_std__istream, + _swigc__p_std__mapT_std__string_Gempa__CAPS__Plugin__StreamState_t, + _swigc__p_std__ostream, + _swigc__p_std__streambuf, + _swigc__p_std__streambuf__off_type, + _swigc__p_std__streambuf__pos_type, + _swigc__p_std__streampos, + _swigc__p_std__streamsize, + _swigc__p_std__string, + _swigc__p_std__vectorT_char_t, + _swigc__p_timeval, + _swigc__p_uint, + _swigc__p_unsigned_char, + _swigc__p_unsigned_int, + _swigc__p_unsigned_long_long, + _swigc__p_unsigned_short, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString(""); +#else + return PyString_FromString(""); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(str); + return 0; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + (printfunc) swig_varlink_print, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + varlink_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&varlink_type) < 0) + return NULL; +#endif + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md; +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { +# if PY_VERSION_HEX >= 0x03020000 + PyModuleDef_HEAD_INIT, +# else + { + PyObject_HEAD_INIT(NULL) + NULL, /* m_init */ + 0, /* m_index */ + NULL, /* m_copy */ + }, +# endif + (char *) SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + (PyCFunction) SwigPyObject_own, + (PyCFunction) SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule((char *) SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + + import_array(); + + PyDict_SetItemString(md,(char *)"cvar", SWIG_globals()); + SWIG_addvarlink(SWIG_globals(),(char *)"Time_Null",Swig_var_Time_Null_get, Swig_var_Time_Null_set); + SWIG_Python_SetConstant(d, "UnknownPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::UnknownPacket))); + SWIG_Python_SetConstant(d, "RawDataPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::RawDataPacket))); + SWIG_Python_SetConstant(d, "MSEEDPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::MSEEDPacket))); + SWIG_Python_SetConstant(d, "ANYPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::ANYPacket))); + SWIG_Python_SetConstant(d, "RTCM2Packet",SWIG_From_int(static_cast< int >(Gempa::CAPS::RTCM2Packet))); + SWIG_Python_SetConstant(d, "MetaDataPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::MetaDataPacket))); + SWIG_Python_SetConstant(d, "FixedRawDataPacket",SWIG_From_int(static_cast< int >(Gempa::CAPS::FixedRawDataPacket))); + SWIG_Python_SetConstant(d, "PacketTypeCount",SWIG_From_int(static_cast< int >(Gempa::CAPS::PacketTypeCount))); + SWIG_Python_SetConstant(d, "DT_Unknown",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_Unknown))); + SWIG_Python_SetConstant(d, "DT_DOUBLE",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_DOUBLE))); + SWIG_Python_SetConstant(d, "DT_FLOAT",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_FLOAT))); + SWIG_Python_SetConstant(d, "DT_INT64",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_INT64))); + SWIG_Python_SetConstant(d, "DT_INT32",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_INT32))); + SWIG_Python_SetConstant(d, "DT_INT16",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_INT16))); + SWIG_Python_SetConstant(d, "DT_INT8",SWIG_From_int(static_cast< int >(Gempa::CAPS::DT_INT8))); + SWIG_Python_SetConstant(d, "NetworkCode",SWIG_From_int(static_cast< int >(Gempa::CAPS::NetworkCode))); + SWIG_Python_SetConstant(d, "StationCode",SWIG_From_int(static_cast< int >(Gempa::CAPS::StationCode))); + SWIG_Python_SetConstant(d, "LocationCode",SWIG_From_int(static_cast< int >(Gempa::CAPS::LocationCode))); + SWIG_Python_SetConstant(d, "ChannelCode",SWIG_From_int(static_cast< int >(Gempa::CAPS::ChannelCode))); + SWIG_Python_SetConstant(d, "StreamIDComponentSize",SWIG_From_int(static_cast< int >(Gempa::CAPS::StreamIDComponentSize))); + SWIG_Python_SetConstant(d, "DataRecord_RS_Error",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_Error))); + SWIG_Python_SetConstant(d, "DataRecord_RS_Complete",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_Complete))); + SWIG_Python_SetConstant(d, "DataRecord_RS_Partial",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_Partial))); + SWIG_Python_SetConstant(d, "DataRecord_RS_BeforeTimeWindow",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_BeforeTimeWindow))); + SWIG_Python_SetConstant(d, "DataRecord_RS_AfterTimeWindow",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_AfterTimeWindow))); + SWIG_Python_SetConstant(d, "DataRecord_RS_Max",SWIG_From_int(static_cast< int >(Gempa::CAPS::DataRecord::RS_Max))); + SWIG_Python_SetConstant(d, "LL_UNDEFINED",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_UNDEFINED))); + SWIG_Python_SetConstant(d, "LL_ERROR",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_ERROR))); + SWIG_Python_SetConstant(d, "LL_WARNING",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_WARNING))); + SWIG_Python_SetConstant(d, "LL_NOTICE",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_NOTICE))); + SWIG_Python_SetConstant(d, "LL_INFO",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_INFO))); + SWIG_Python_SetConstant(d, "LL_DEBUG",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_DEBUG))); + SWIG_Python_SetConstant(d, "LL_QUANTITY",SWIG_From_int(static_cast< int >(Gempa::CAPS::LL_QUANTITY))); + SWIG_addvarlink(SWIG_globals(),(char *)"LogHandler",Swig_var_LogHandler_get, Swig_var_LogHandler_set); + SWIG_Python_SetConstant(d, "Plugin_Success",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::Success))); + SWIG_Python_SetConstant(d, "Plugin_PacketSize",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::PacketSize))); + SWIG_Python_SetConstant(d, "Plugin_PacketLoss",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::PacketLoss))); + SWIG_Python_SetConstant(d, "Plugin_PacketNotValid",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::PacketNotValid))); + SWIG_Python_SetConstant(d, "Plugin_PacketNotSupported",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::PacketNotSupported))); + SWIG_Python_SetConstant(d, "Plugin_MaxFutureEndTimeExceeded",SWIG_From_int(static_cast< int >(Gempa::CAPS::Plugin::MaxFutureEndTimeExceeded))); + SWIG_addvarlink(SWIG_globals(),(char *)"ChunkHeaderSize",Swig_var_ChunkHeaderSize_get, Swig_var_ChunkHeaderSize_set); + SWIG_Python_SetConstant(d, "Socket_Success",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::Success))); + SWIG_Python_SetConstant(d, "Socket_Error",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::Error))); + SWIG_Python_SetConstant(d, "Socket_AllocationError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::AllocationError))); + SWIG_Python_SetConstant(d, "Socket_ReuseAdressError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::ReuseAdressError))); + SWIG_Python_SetConstant(d, "Socket_BindError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::BindError))); + SWIG_Python_SetConstant(d, "Socket_ListenError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::ListenError))); + SWIG_Python_SetConstant(d, "Socket_AcceptError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::AcceptError))); + SWIG_Python_SetConstant(d, "Socket_ConnectError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::ConnectError))); + SWIG_Python_SetConstant(d, "Socket_AddrInfoError",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::AddrInfoError))); + SWIG_Python_SetConstant(d, "Socket_Timeout",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::Timeout))); + SWIG_Python_SetConstant(d, "Socket_InvalidSocket",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::InvalidSocket))); + SWIG_Python_SetConstant(d, "Socket_InvalidPort",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::InvalidPort))); + SWIG_Python_SetConstant(d, "Socket_InvalidAddressFamily",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::InvalidAddressFamily))); + SWIG_Python_SetConstant(d, "Socket_InvalidAddress",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::InvalidAddress))); + SWIG_Python_SetConstant(d, "Socket_InvalidHostname",SWIG_From_int(static_cast< int >(Gempa::CAPS::Socket::InvalidHostname))); +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/libs/swig/gempa/CMakeLists.txt b/libs/swig/gempa/CMakeLists.txt new file mode 100644 index 0000000..b043aba --- /dev/null +++ b/libs/swig/gempa/CMakeLists.txt @@ -0,0 +1,79 @@ +FIND_PACKAGE(PythonLibs REQUIRED) +FIND_PACKAGE(PythonInterp REQUIRED) +SET(PYTHON_LIBRARY_SUFFIX /python) +SET(PYTHON_LIBRARY_PATH lib${PYTHON_LIBRARY_SUFFIX}) + +FIND_PACKAGE(Numpy) + +INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${PYTHON_NUMPY_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(../../../system/libs/swig) + +FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem) + +IF (CMAKE_COMPILER_IS_GNUCC) + # Important for O2 compilation + ADD_DEFINITIONS("-fno-strict-aliasing") +ENDIF (CMAKE_COMPILER_IS_GNUCC) + +SET( + WRAPPER_MODULES + CAPS +) + +FIND_PACKAGE(OpenSSL REQUIRED) + +SET(WRAPPER_MODULE_CAPS_EXTRA_LIBS capsclient ${Boost_filesystem_LIBRARY} ${OPENSSL_LIBRARIES}) + +FOREACH (wrapper_module ${WRAPPER_MODULES}) + SET( + ${wrapper_module}_SOURCES + ${wrapper_module}PYTHON_wrap.cxx + ${WRAPPER_MODULE_${wrapper_module}_EXTRA_FILES} + ) + ADD_LIBRARY(_${wrapper_module} MODULE ${${wrapper_module}_SOURCES}) + SET_TARGET_PROPERTIES(_${wrapper_module} PROPERTIES PREFIX "") + TARGET_LINK_LIBRARIES(_${wrapper_module} ${PYTHON_LIBRARIES}) + TARGET_LINK_LIBRARIES(_${wrapper_module} ${WRAPPER_MODULE_${wrapper_module}_EXTRA_LIBS}) +ENDFOREACH (wrapper_module) + +#SC_SWIG_GET_MODULE_PATH(_module_path) +SET(_module_path ${CMAKE_INSTALL_PREFIX}/lib/python/gempa) + +FOREACH (wrapper_module ${WRAPPER_MODULES}) + INSTALL( + TARGETS _${wrapper_module} + LIBRARY DESTINATION ${_module_path} + ) + + INSTALL( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py + DESTINATION ${_module_path} + ) + + + INSTALL( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/${wrapper_module}.py + DESTINATION ${_module_path} + ) + + INSTALL( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${wrapper_module}.pyc + DESTINATION ${_module_path} + OPTIONAL + ) + + INSTALL( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${wrapper_module}.pyo + DESTINATION ${_module_path} + OPTIONAL + ) + + ADD_CUSTOM_COMMAND( + TARGET _${wrapper_module} + POST_BUILD + COMMAND ${CMAKE_SOURCE_DIR}/py-compile ARGS --python \"${PYTHON_EXECUTABLE}\" --destdir ${CMAKE_CURRENT_BINARY_DIR} ${wrapper_module}.py + ) +ENDFOREACH (wrapper_module) + diff --git a/libs/swig/gempa/__init__.py b/libs/swig/gempa/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/libs/swig/gempa/codegen.sh b/libs/swig/gempa/codegen.sh new file mode 100755 index 0000000..26462dd --- /dev/null +++ b/libs/swig/gempa/codegen.sh @@ -0,0 +1,2 @@ +#!/bin/bash +swig -c++ -I../../ -o CAPSPYTHON_wrap.cxx -python CAPS.i diff --git a/libs/swig/gempa/numpy.i b/libs/swig/gempa/numpy.i new file mode 100644 index 0000000..67a519e --- /dev/null +++ b/libs/swig/gempa/numpy.i @@ -0,0 +1,3161 @@ +/* -*- C -*- (not really, but good for syntax highlighting) */ + +/* + * Copyright (c) 2005-2015, NumPy Developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of the NumPy Developers nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef SWIGPYTHON + +%{ +#ifndef SWIG_FILE_WITH_INIT +#define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include +%} + +/**********************************************************************/ + +%fragment("NumPy_Backward_Compatibility", "header") +{ +%#if NPY_API_VERSION < 0x00000007 +%#define NPY_ARRAY_DEFAULT NPY_DEFAULT +%#define NPY_ARRAY_FARRAY NPY_FARRAY +%#define NPY_FORTRANORDER NPY_FORTRAN +%#endif +} + +/**********************************************************************/ + +/* The following code originally appeared in + * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was + * translated from C++ to C by John Hunter. Bill Spotz has modified + * it to fix some minor bugs, upgrade from Numeric to numpy (all + * versions), add some comments and functionality, and convert from + * direct code insertion to SWIG fragments. + */ + +%fragment("NumPy_Macros", "header") +{ +/* Macros to extract array attributes. + */ +%#if NPY_API_VERSION < 0x00000007 +%#define is_array(a) ((a) && PyArray_Check((PyArrayObject*)a)) +%#define array_type(a) (int)(PyArray_TYPE((PyArrayObject*)a)) +%#define array_numdims(a) (((PyArrayObject*)a)->nd) +%#define array_dimensions(a) (((PyArrayObject*)a)->dimensions) +%#define array_size(a,i) (((PyArrayObject*)a)->dimensions[i]) +%#define array_strides(a) (((PyArrayObject*)a)->strides) +%#define array_stride(a,i) (((PyArrayObject*)a)->strides[i]) +%#define array_data(a) (((PyArrayObject*)a)->data) +%#define array_descr(a) (((PyArrayObject*)a)->descr) +%#define array_flags(a) (((PyArrayObject*)a)->flags) +%#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f +%#else +%#define is_array(a) ((a) && PyArray_Check(a)) +%#define array_type(a) PyArray_TYPE((PyArrayObject*)a) +%#define array_numdims(a) PyArray_NDIM((PyArrayObject*)a) +%#define array_dimensions(a) PyArray_DIMS((PyArrayObject*)a) +%#define array_strides(a) PyArray_STRIDES((PyArrayObject*)a) +%#define array_stride(a,i) PyArray_STRIDE((PyArrayObject*)a,i) +%#define array_size(a,i) PyArray_DIM((PyArrayObject*)a,i) +%#define array_data(a) PyArray_DATA((PyArrayObject*)a) +%#define array_descr(a) PyArray_DESCR((PyArrayObject*)a) +%#define array_flags(a) PyArray_FLAGS((PyArrayObject*)a) +%#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f) +%#endif +%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a)) +%#define array_is_native(a) (PyArray_ISNOTSWAPPED((PyArrayObject*)a)) +%#define array_is_fortran(a) (PyArray_IS_F_CONTIGUOUS((PyArrayObject*)a)) +} + +/**********************************************************************/ + +%fragment("NumPy_Utilities", + "header") +{ + /* Given a PyObject, return a string describing its type. + */ + const char* pytype_string(PyObject* py_obj) + { + if (py_obj == NULL ) return "C NULL value"; + if (py_obj == Py_None ) return "Python None" ; + if (PyCallable_Check(py_obj)) return "callable" ; + if (PyString_Check( py_obj)) return "string" ; + if (PyInt_Check( py_obj)) return "int" ; + if (PyFloat_Check( py_obj)) return "float" ; + if (PyDict_Check( py_obj)) return "dict" ; + if (PyList_Check( py_obj)) return "list" ; + if (PyTuple_Check( py_obj)) return "tuple" ; +%#if PY_MAJOR_VERSION < 3 + if (PyFile_Check( py_obj)) return "file" ; + if (PyModule_Check( py_obj)) return "module" ; + if (PyInstance_Check(py_obj)) return "instance" ; +%#endif + + return "unknown type"; + } + + /* Given a NumPy typecode, return a string describing the type. + */ + const char* typecode_string(int typecode) + { + static const char* type_names[25] = {"bool", + "byte", + "unsigned byte", + "short", + "unsigned short", + "int", + "unsigned int", + "long", + "unsigned long", + "long long", + "unsigned long long", + "float", + "double", + "long double", + "complex float", + "complex double", + "complex long double", + "object", + "string", + "unicode", + "void", + "ntypes", + "notype", + "char", + "unknown"}; + return typecode < 24 ? type_names[typecode] : type_names[24]; + } + + /* Make sure input has correct numpy type. This now just calls + PyArray_EquivTypenums(). + */ + int type_match(int actual_type, + int desired_type) + { + return PyArray_EquivTypenums(actual_type, desired_type); + } + +%#ifdef SWIGPY_USE_CAPSULE + void free_cap(PyObject * cap) + { + void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME); + if (array != NULL) free(array); + } +%#endif + + +} + +/**********************************************************************/ + +%fragment("NumPy_Object_to_Array", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities") +{ + /* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL. + */ + PyArrayObject* obj_to_array_no_conversion(PyObject* input, + int typecode) + { + PyArrayObject* ary = NULL; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input), typecode))) + { + ary = (PyArrayObject*) input; + } + else if is_array(input) + { + const char* desired_type = typecode_string(typecode); + const char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else + { + const char* desired_type = typecode_string(typecode); + const char* actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A '%s' was given", + desired_type, + actual_type); + ary = NULL; + } + return ary; + } + + /* Convert the given PyObject to a NumPy array with the given + * typecode. On success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ + PyArrayObject* obj_to_array_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + PyArrayObject* ary = NULL; + PyObject* py_obj; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input),typecode))) + { + ary = (PyArrayObject*) input; + *is_new_object = 0; + } + else + { + py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT); + /* If NULL, PyArray_FromObject will have set python error value.*/ + ary = (PyArrayObject*) py_obj; + *is_new_object = 1; + } + return ary; + } + + /* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ + PyArrayObject* make_contiguous(PyArrayObject* ary, + int* is_new_object, + int min_dims, + int max_dims) + { + PyArrayObject* result; + if (array_is_contiguous(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, + array_type(ary), + min_dims, + max_dims); + *is_new_object = 1; + } + return result; + } + + /* Given a PyArrayObject, check to see if it is Fortran-contiguous. + * If so, return the input pointer, but do not flag it as not a new + * object. If it is not Fortran-contiguous, create a new + * PyArrayObject using the original data, flag it as a new object + * and return the pointer. + */ + PyArrayObject* make_fortran(PyArrayObject* ary, + int* is_new_object) + { + PyArrayObject* result; + if (array_is_fortran(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + Py_INCREF(array_descr(ary)); + result = (PyArrayObject*) PyArray_FromArray(ary, + array_descr(ary), + NPY_ARRAY_F_CONTIGUOUS); + *is_new_object = 1; + } + return result; + } + + /* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, + typecode, + &is_new1); + if (ary1) + { + ary2 = make_contiguous(ary1, &is_new2, 0, 0); + if ( is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } + + /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the + * specified type. If the input object is not a Fortran-ordered + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, + typecode, + &is_new1); + if (ary1) + { + ary2 = make_fortran(ary1, &is_new2); + if (is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } +} /* end fragment */ + +/**********************************************************************/ + +%fragment("NumPy_Array_Requirements", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros") +{ + /* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ + int require_contiguous(PyArrayObject* ary) + { + int contiguous = 1; + if (!array_is_contiguous(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous. A non-contiguous array was given"); + contiguous = 0; + } + return contiguous; + } + + /* Test whether a python object is (C_ or F_) contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ + int require_c_or_f_contiguous(PyArrayObject* ary) + { + int contiguous = 1; + if (!(array_is_contiguous(ary) || array_is_fortran(ary))) + { + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous (C_ or F_). A non-contiguous array was given"); + contiguous = 0; + } + return contiguous; + } + + /* Require that a numpy array is not byte-swapped. If the array is + * not byte-swapped, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_native(PyArrayObject* ary) + { + int native = 1; + if (!array_is_native(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must have native byteorder. " + "A byte-swapped array was given"); + native = 0; + } + return native; + } + + /* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ + int require_dimensions(PyArrayObject* ary, + int exact_dimensions) + { + int success = 1; + if (array_numdims(ary) != exact_dimensions) + { + PyErr_Format(PyExc_TypeError, + "Array must have %d dimensions. Given array has %d dimensions", + exact_dimensions, + array_numdims(ary)); + success = 0; + } + return success; + } + + /* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_dimensions_n(PyArrayObject* ary, + int* exact_dimensions, + int n) + { + int success = 0; + int i; + char dims_str[255] = ""; + char s[255]; + for (i = 0; i < n && !success; i++) + { + if (array_numdims(ary) == exact_dimensions[i]) + { + success = 1; + } + } + if (!success) + { + for (i = 0; i < n-1; i++) + { + sprintf(s, "%d, ", exact_dimensions[i]); + strcat(dims_str,s); + } + sprintf(s, " or %d", exact_dimensions[n-1]); + strcat(dims_str,s); + PyErr_Format(PyExc_TypeError, + "Array must have %s dimensions. Given array has %d dimensions", + dims_str, + array_numdims(ary)); + } + return success; + } + + /* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ + int require_size(PyArrayObject* ary, + npy_intp* size, + int n) + { + int i; + int success = 1; + int len; + char desired_dims[255] = "["; + char s[255]; + char actual_dims[255] = "["; + for(i=0; i < n;i++) + { + if (size[i] != -1 && size[i] != array_size(ary,i)) + { + success = 0; + } + } + if (!success) + { + for (i = 0; i < n; i++) + { + if (size[i] == -1) + { + sprintf(s, "*,"); + } + else + { + sprintf(s, "%ld,", (long int)size[i]); + } + strcat(desired_dims,s); + } + len = strlen(desired_dims); + desired_dims[len-1] = ']'; + for (i = 0; i < n; i++) + { + sprintf(s, "%ld,", (long int)array_size(ary,i)); + strcat(actual_dims,s); + } + len = strlen(actual_dims); + actual_dims[len-1] = ']'; + PyErr_Format(PyExc_TypeError, + "Array must have shape of %s. Given array has shape of %s", + desired_dims, + actual_dims); + } + return success; + } + + /* Require the given PyArrayObject to to be Fortran ordered. If the + * the PyArrayObject is already Fortran ordered, do nothing. Else, + * set the Fortran ordering flag and recompute the strides. + */ + int require_fortran(PyArrayObject* ary) + { + int success = 1; + int nd = array_numdims(ary); + int i; + npy_intp * strides = array_strides(ary); + if (array_is_fortran(ary)) return success; + /* Set the Fortran ordered flag */ + array_enableflags(ary,NPY_ARRAY_FARRAY); + /* Recompute the strides */ + strides[0] = strides[nd-1]; + for (i=1; i < nd; ++i) + strides[i] = strides[i-1] * array_size(ary,i-1); + return success; + } +} + +/* Combine all NumPy fragments into one for convenience */ +%fragment("NumPy_Fragments", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities", + fragment="NumPy_Object_to_Array", + fragment="NumPy_Array_Requirements") +{ +} + +/* End John Hunter translation (with modifications by Bill Spotz) + */ + +/* %numpy_typemaps() macro + * + * This macro defines a family of 75 typemaps that allow C arguments + * of the form + * + * 1. (DATA_TYPE IN_ARRAY1[ANY]) + * 2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + * 3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + * + * 4. (DATA_TYPE IN_ARRAY2[ANY][ANY]) + * 5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + * 7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + * + * 9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + * 10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 11. (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 12. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + * 13. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 14. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + * + * 15. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + * 16. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 17. (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) + * 19. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 20. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) + * + * 21. (DATA_TYPE INPLACE_ARRAY1[ANY]) + * 22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + * 23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + * + * 24. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + * 25. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + * 27. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 28. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + * + * 29. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + * 30. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 31. (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 32. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + * 33. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + * + * 35. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + * 36. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 37. (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 38. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) + * 39. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 40. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) + * + * 41. (DATA_TYPE ARGOUT_ARRAY1[ANY]) + * 42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + * 43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + * + * 44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + * + * 45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + * + * 46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + * + * 47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + * 48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + * + * 49. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + * 51. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + * + * 53. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + * 55. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) + * + * 57. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 58. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4) + * 59. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4) + * + * 61. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) + * 62. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) + * + * 63. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) + * 65. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) + * + * 67. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3) + * 69. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3) + * + * 71. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 72. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) + * 73. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 74. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) + * + * 75. (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + * + * where "DATA_TYPE" is any type supported by the NumPy module, and + * "DIM_TYPE" is any int-like type suitable for specifying dimensions. + * The difference between "ARRAY" typemaps and "FARRAY" typemaps is + * that the "FARRAY" typemaps expect Fortran ordering of + * multidimensional arrays. In python, the dimensions will not need + * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1" + * typemaps). The IN_ARRAYs can be a numpy array or any sequence that + * can be converted to a numpy array of the specified type. The + * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The + * ARGOUT_ARRAYs will be returned as new numpy arrays of the + * appropriate type. + * + * These typemaps can be applied to existing functions using the + * %apply directive. For example: + * + * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)}; + * double prod(double* series, int length); + * + * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2) + * {(int rows, int cols, double* matrix )}; + * void floor(int rows, int cols, double* matrix, double f); + * + * %apply (double IN_ARRAY3[ANY][ANY][ANY]) + * {(double tensor[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double low[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double upp[2][2][2] )}; + * void luSplit(double tensor[2][2][2], + * double low[2][2][2], + * double upp[2][2][2] ); + * + * or directly with + * + * double prod(double* IN_ARRAY1, int DIM1); + * + * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f); + * + * void luSplit(double IN_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY]); + */ + +%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE) + +/************************/ +/* Input Array Typemaps */ +/************************/ + +/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY1[ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY1[ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY1[ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { -1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = {-1}; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + /* for now, only concerned with lists */ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL) +{ + npy_intp size[2] = { -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + int is_new_object; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + is_new_object_array = (int *)calloc($2,sizeof(int)); + + if (array == NULL || object_array == NULL || is_new_object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + is_new_object_array[i] = is_new_object; + + if (!temp_array || !require_dimensions(temp_array, 2)) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + } + + if (!require_size(temp_array, size, 2)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; +} +%typemap(freearg) + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + Py_ssize_t i; + + if (array$argnum!=NULL) free(array$argnum); + + /*freeing the individual arrays if needed */ + if (object_array$argnum!=NULL) + { + if (is_new_object_array$argnum!=NULL) + { + for (i=0; i<$2; i++) + { + if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i]) + { Py_DECREF(object_array$argnum[i]); } + } + free(is_new_object_array$argnum); + } + free(object_array$argnum); + } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3}; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + /* for now, only concerned with lists */ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL) +{ + npy_intp size[3] = { -1, -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + int is_new_object; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + is_new_object_array = (int *)calloc($2,sizeof(int)); + + if (array == NULL || object_array == NULL || is_new_object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + is_new_object_array[i] = is_new_object; + + if (!temp_array || !require_dimensions(temp_array, 3)) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + size[2] = array_size(temp_array,2); + } + + if (!require_size(temp_array, size, 3)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; + $5 = (DIM_TYPE) size[2]; +} +%typemap(freearg) + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + Py_ssize_t i; + + if (array$argnum!=NULL) free(array$argnum); + + /*freeing the individual arrays if needed */ + if (object_array$argnum!=NULL) + { + if (is_new_object_array$argnum!=NULL) + { + for (i=0; i<$2; i++) + { + if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i]) + { Py_DECREF(object_array$argnum[i]); } + } + free(is_new_object_array$argnum); + } + free(object_array$argnum); + } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* IN_ARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1 , -1}; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* IN_FARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1 , -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/***************************/ +/* In-Place Array Typemaps */ +/***************************/ + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY1[ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY1[ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int i=1) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = 1; + for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + (PyArrayObject* array=NULL, int i=0) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = 1; + for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i); + $2 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL) +{ + npy_intp size[2] = { -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + + if (array == NULL || object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + + if ( !temp_array || !require_dimensions(temp_array, 2) || + !require_contiguous(temp_array) || + !require_native(temp_array) || + !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE) + ) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + } + + if (!require_size(temp_array, size, 2)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; +} +%typemap(freearg) + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (array$argnum!=NULL) free(array$argnum); + if (object_array$argnum!=NULL) free(object_array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} + +/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL) +{ + npy_intp size[3] = { -1, -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + + if (array == NULL || object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + + if ( !temp_array || !require_dimensions(temp_array, 3) || + !require_contiguous(temp_array) || + !require_native(temp_array) || + !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE) + ) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + size[2] = array_size(temp_array,2); + } + + if (!require_size(temp_array, size, 3)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; + $5 = (DIM_TYPE) size[2]; +} +%typemap(freearg) + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (array$argnum!=NULL) free(array$argnum); + if (object_array$argnum!=NULL) free(object_array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* INPLACE_ARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_FARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} + +/*************************/ +/* Argout Array Typemaps */ +/*************************/ + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY1[ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[1] = { $1_dim0 }; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY1[ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + (PyObject* array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + const char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $2 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $2; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + (PyObject* array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + const char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $1 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $1; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[2] = { $1_dim0, $1_dim1 }; + array = PyArray_SimpleNew(2, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = PyArray_SimpleNew(3, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 }; + array = PyArray_SimpleNew(4, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/*****************************/ +/* Argoutview Array Typemaps */ +/*****************************/ + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp) +{ + $1 = &data_temp; + $2 = &dim_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) +{ + npy_intp dims[1] = { *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1) + (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim_temp; + $2 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) +{ + npy_intp dims[1] = { *$1 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_ARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_FARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEW_FARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEW_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEW_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/*************************************/ +/* Managed Argoutview Array Typemaps */ +/*************************************/ + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp) +{ + $1 = &data_temp; + $2 = &dim_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) +{ + npy_intp dims[1] = { *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEWM_ARRAY1) + (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim_temp; + $2 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) +{ + npy_intp dims[1] = { *$1 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEWM_ARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEWM_FARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEWM_ARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEWM_ARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj= PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEWM_FARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEWM_FARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/**************************************/ +/* In-Place Array Typemap - flattened */ +/**************************************/ + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + (PyArrayObject* array=NULL, int i=1) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_c_or_f_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = 1; + for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i); +} + +%enddef /* %numpy_typemaps() macro */ +/* *************************************************************** */ + +/* Concrete instances of the %numpy_typemaps() macro: Each invocation + * below applies all of the typemaps above to the specified data type. + */ +%numpy_typemaps(signed char , NPY_BYTE , int) +%numpy_typemaps(unsigned char , NPY_UBYTE , int) +%numpy_typemaps(short , NPY_SHORT , int) +%numpy_typemaps(unsigned short , NPY_USHORT , int) +%numpy_typemaps(int , NPY_INT , int) +%numpy_typemaps(unsigned int , NPY_UINT , int) +%numpy_typemaps(long , NPY_LONG , int) +%numpy_typemaps(unsigned long , NPY_ULONG , int) +%numpy_typemaps(long long , NPY_LONGLONG , int) +%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int) +%numpy_typemaps(float , NPY_FLOAT , int) +%numpy_typemaps(double , NPY_DOUBLE , int) + +/* *************************************************************** + * The follow macro expansion does not work, because C++ bool is 4 + * bytes and NPY_BOOL is 1 byte + * + * %numpy_typemaps(bool, NPY_BOOL, int) + */ + +/* *************************************************************** + * On my Mac, I get the following warning for this macro expansion: + * 'swig/python detected a memory leak of type 'long double *', no destructor found.' + * + * %numpy_typemaps(long double, NPY_LONGDOUBLE, int) + */ + +#ifdef __cplusplus + +%include + +%numpy_typemaps(std::complex, NPY_CFLOAT , int) +%numpy_typemaps(std::complex, NPY_CDOUBLE, int) + +#endif + +#endif /* SWIGPYTHON */ diff --git a/py-compile b/py-compile new file mode 100755 index 0000000..64b361c --- /dev/null +++ b/py-compile @@ -0,0 +1,175 @@ +#!/bin/sh +# py-compile - Compile a Python program + +scriptversion=2005-05-14.22 + +# Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +if [ -z "$PYTHON" ]; then + PYTHON=python +fi + +basedir= +destdir= +files= +while test $# -ne 0; do + case "$1" in + --basedir) + basedir=$2 + if test -z "$basedir"; then + echo "$0: Missing argument to --basedir." 1>&2 + exit 1 + fi + shift + ;; + --destdir) + destdir=$2 + if test -z "$destdir"; then + echo "$0: Missing argument to --destdir." 1>&2 + exit 1 + fi + shift + ;; + --outputdir) + outputdir=$2 + if test -z "$outputdir"; then + echo "$0: Missing argument to --outputdir." 1>&2 + exit 1 + fi + shift + ;; + --python) + PYTHON=$2 + if test -z "$PYTHON"; then + echo "$0: Missing argument to --python." 1>&2 + exit 1 + fi + shift + ;; + -h|--h*) + cat <<\EOF +Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] [--outputdir DIR] FILES..." + +Byte compile some python scripts FILES. Use --destdir to specify any +leading directory path to the FILES that you don't want to include in the +byte compiled file. Specify --basedir for any additional path information you +do want to be shown in the byte compiled file. Specify --outputdir for any additional +path information you do want to be prepended to the byte compiled file. + +Example: + py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py + +Report bugs to . +EOF + exit $? + ;; + -v|--v*) + echo "py-compile $scriptversion" + exit $? + ;; + *) + files="$files $1" + ;; + esac + shift +done + +if test -z "$files"; then + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 +fi + +# if basedir was given, then it should be prepended to filenames before +# byte compilation. +if [ -z "$basedir" ]; then + pathtrans="path = file" +else + pathtrans="path = os.path.join('$basedir', file)" +fi + +# if destdir was given, then it needs to be prepended to the filename to +# byte compile but not go into the compiled file. +if [ -z "$destdir" ]; then + filetrans="filepath = path" +else + filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" +fi + +# if outputdir was given, then it needs to be prepended to the filename to +# byte compile but not go into the compiled file. +if [ -z "$outputdir" ]; then + outputtrans="outputpath = filepath" +else + outputtrans="outputpath = os.path.normpath('$outputdir' + os.sep + path)" +fi + +$PYTHON -c " +from __future__ import print_function +import sys, os, py_compile + +files = '''$files''' + +print('Byte-compiling python modules...') +for file in files.split(): + $pathtrans + $filetrans + $outputtrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + print(file, end=' ') + sys.stdout.flush() + py_compile.compile(filepath, outputpath + 'c', path) +print()" || exit $? + +# this will fail for python < 1.5, but that doesn't matter ... +$PYTHON -O -c " +from __future__ import print_function +import sys, os, py_compile + +files = '''$files''' +print('Byte-compiling python modules (optimized versions) ...') +for file in files.split(): + $pathtrans + $filetrans + $outputtrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + print(file, end=' ') + sys.stdout.flush() + py_compile.compile(filepath, outputpath + 'o', path) +print()" 2>/dev/null || : + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: